From 8a0d4e53327b5a68930635abad60791cc6808386 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:14:09 +0300 Subject: [PATCH 01/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- index.php | 4 +- pub/cron.php | 2 +- pub/errors/processorFactory.php | 2 +- pub/get.php | 2 +- pub/index.php | 2 +- pub/static.php | 2 +- setup/config/application.config.php | 4 +- setup/config/di.config.php | 81 +-- setup/config/router.config.php | 2 +- .../Command/AbstractDependenciesCommand.php | 6 +- .../Console/Command/AbstractModuleCommand.php | 4 +- .../Command/AbstractModuleManageCommand.php | 4 +- .../Setup/Console/Command/BackupCommand.php | 6 +- .../Setup/Console/Command/DbStatusCommand.php | 2 +- .../Console/Command/DiCompileCommand.php | 37 +- .../Command/DiCompileMultiTenantCommand.php | 493 ++++++++++++++++++ .../Command/GenerateFixturesCommand.php | 5 +- .../InstallStoreConfigurationCommand.php | 10 +- .../Console/Command/ModuleStatusCommand.php | 4 +- .../Command/ModuleUninstallCommand.php | 12 +- .../Setup/Console/Command/RollbackCommand.php | 6 +- .../src/Magento/Setup/Console/CommandList.php | 66 +-- .../Setup/Controller/BackupActionItems.php | 5 +- .../Setup/Controller/ComponentGrid.php | 6 +- .../Setup/Controller/CustomizeYourStore.php | 2 +- .../src/Magento/Setup/Controller/Modules.php | 4 +- .../src/Magento/Setup/Controller/Session.php | 10 +- .../src/Magento/Setup/Controller/Success.php | 2 +- .../Setup/Fixtures/CartPriceRulesFixture.php | 34 +- .../Fixtures/CatalogPriceRulesFixture.php | 15 +- .../Setup/Fixtures/CategoriesFixture.php | 4 +- .../Setup/Fixtures/ConfigsApplyFixture.php | 4 +- .../Fixtures/ConfigurableProductsFixture.php | 6 +- .../Setup/Fixtures/CustomersFixture.php | 4 +- .../Setup/Fixtures/EavVariationsFixture.php | 9 +- .../Magento/Setup/Fixtures/FixtureModel.php | 10 +- .../Fixtures/IndexersStatesApplyFixture.php | 2 +- .../Magento/Setup/Fixtures/OrdersFixture.php | 43 +- .../Setup/Fixtures/SimpleProductsFixture.php | 6 +- .../Magento/Setup/Fixtures/StoresFixture.php | 4 +- .../Setup/Fixtures/TaxRatesFixture.php | 6 +- .../Setup/Model/AdminAccountFactory.php | 2 +- .../Model/ConfigOptionsListCollector.php | 2 +- .../Magento/Setup/Model/Cron/AbstractJob.php | 5 +- .../Setup/Model/Cron/JobDbRollback.php | 4 +- .../Magento/Setup/Model/Cron/JobFactory.php | 32 +- .../Setup/Model/Cron/JobStaticRegenerate.php | 8 +- .../Setup/Model/DateTime/DateTimeProvider.php | 2 +- .../Setup/Model/DateTime/TimezoneProvider.php | 2 +- setup/src/Magento/Setup/Model/Installer.php | 16 +- .../Magento/Setup/Model/InstallerFactory.php | 45 +- .../src/Magento/Setup/Model/ModuleStatus.php | 3 +- .../Setup/Model/ModuleStatusFactory.php | 2 +- .../Magento/Setup/Model/ModuleUninstaller.php | 4 +- .../Model/ThemeDependencyCheckerFactory.php | 2 +- .../Setup/Model/UninstallCollector.php | 2 +- .../Setup/Model/UpdatePackagesCache.php | 3 +- setup/src/Magento/Setup/Module.php | 2 +- .../Magento/Setup/Module/DataSetupFactory.php | 2 +- .../Di/App/Task/Operation/Interception.php | 2 +- .../Module/Di/App/Task/OperationFactory.php | 15 +- .../Setup/Module/Di/Code/GeneratorFactory.php | 2 +- .../Module/Di/Code/Reader/ClassesScanner.php | 3 + .../Module/Di/Code/Reader/FileScanner.php | 2 +- .../Dictionary/Options/ResolverFactory.php | 2 +- .../Magento/Setup/Module/ResourceFactory.php | 2 +- .../src/Magento/Setup/Module/SetupFactory.php | 2 +- .../Setup/Mvc/Bootstrap/InitParamListener.php | 16 +- .../Command/AdminUserCreateCommandTest.php | 11 +- .../Console/Command/BackupCommandTest.php | 22 +- .../Console/Command/ConfigSetCommandTest.php | 12 +- .../Console/Command/CronRunCommandTest.php | 12 +- .../Command/DbDataUpgradeCommandTest.php | 6 +- .../Command/DbSchemaUpgradeCommandTest.php | 2 +- .../Console/Command/DbStatusCommandTest.php | 8 +- .../Console/Command/DiCompileCommandTest.php | 30 +- .../Command/GenerateFixturesCommandTest.php | 2 +- .../Command/InfoAdminUriCommandTest.php | 2 +- .../Command/InfoBackupsListCommandTest.php | 8 +- .../Command/InfoCurrencyListCommandTest.php | 6 +- .../Command/InfoLanguageListCommandTest.php | 6 +- .../Command/InfoTimezoneListCommandTest.php | 6 +- .../Console/Command/InstallCommandTest.php | 39 +- .../InstallStoreConfigurationCommandTest.php | 26 +- .../MaintenanceAllowIpsCommandTest.php | 4 +- .../Command/MaintenanceDisableCommandTest.php | 4 +- .../Command/MaintenanceEnableCommandTest.php | 4 +- .../Command/MaintenanceStatusCommandTest.php | 2 +- .../ModuleEnableDisableCommandTest.php | 20 +- .../Command/ModuleStatusCommandTest.php | 12 +- .../Command/ModuleUninstallCommandTest.php | 118 +++-- .../Console/Command/RollbackCommandTest.php | 26 +- .../Console/Command/UninstallCommandTest.php | 8 +- .../Console/Command/UpgradeCommandTest.php | 4 +- .../Test/Unit/Console/CommandListTest.php | 2 +- .../Unit/Console/CompilerPreparationTest.php | 8 +- .../Test/Unit/Controller/AddDatabaseTest.php | 2 +- .../Unit/Controller/BackupActionItemsTest.php | 33 +- .../Unit/Controller/CompleteBackupTest.php | 4 +- .../Unit/Controller/ComponentGridTest.php | 76 ++- .../Controller/CreateAdminAccountTest.php | 2 +- .../Test/Unit/Controller/CreateBackupTest.php | 2 +- .../Controller/CustomizeYourStoreTest.php | 14 +- .../Test/Unit/Controller/DataOptionTest.php | 13 +- .../Test/Unit/Controller/EnvironmentTest.php | 70 +-- .../Setup/Test/Unit/Controller/IndexTest.php | 2 +- .../Controller/InstallExtensionGridTest.php | 6 +- .../Test/Unit/Controller/InstallTest.php | 40 +- .../Unit/Controller/LandingInstallerTest.php | 4 +- .../Unit/Controller/LandingUpdaterTest.php | 4 +- .../Test/Unit/Controller/LicenseTest.php | 6 +- .../Test/Unit/Controller/MaintenanceTest.php | 14 +- .../Test/Unit/Controller/MarketplaceTest.php | 20 +- .../Test/Unit/Controller/ModulesTest.php | 12 +- .../Test/Unit/Controller/NavigationTest.php | 17 +- .../Controller/OtherComponentsGridTest.php | 12 +- .../ReadinessCheckInstallerTest.php | 4 +- .../Controller/ReadinessCheckUpdaterTest.php | 4 +- .../Unit/Controller/SelectVersionTest.php | 10 +- .../Test/Unit/Controller/SessionTest.php | 27 +- .../Test/Unit/Controller/StartUpdaterTest.php | 50 +- .../Test/Unit/Controller/SuccessTest.php | 11 +- .../Test/Unit/Controller/SystemConfigTest.php | 2 +- .../Unit/Controller/UpdaterSuccessTest.php | 4 +- .../Unit/Controller/WebConfigurationTest.php | 2 +- .../Fixtures/CartPriceRulesFixtureTest.php | 51 +- .../Fixtures/CatalogPriceRulesFixtureTest.php | 39 +- .../Unit/Fixtures/CategoriesFixtureTest.php | 20 +- .../Unit/Fixtures/ConfigsApplyFixtureTest.php | 12 +- .../ConfigurableProductsFixtureTest.php | 29 +- .../Unit/Fixtures/CustomersFixtureTest.php | 22 +- .../Fixtures/EavVariationsFixtureTest.php | 28 +- .../Test/Unit/Fixtures/FixtureModelTest.php | 10 +- .../IndexersStatesApplyFixtureTest.php | 10 +- .../Test/Unit/Fixtures/OrdersFixtureTest.php | 79 +-- .../Fixtures/SimpleProductsFixtureTest.php | 28 +- .../Test/Unit/Fixtures/StoresFixtureTest.php | 26 +- .../Unit/Fixtures/TaxRatesFixtureTest.php | 18 +- .../Unit/Model/AdminAccountFactoryTest.php | 11 +- .../Test/Unit/Model/AdminAccountTest.php | 6 +- .../Test/Unit/Model/ConfigGeneratorTest.php | 4 +- .../Setup/Test/Unit/Model/ConfigModelTest.php | 14 +- .../Test/Unit/Model/ConfigOptionsListTest.php | 38 +- .../Model/Cron/Helper/ModuleUninstallTest.php | 24 +- .../Model/Cron/Helper/ThemeUninstallTest.php | 7 +- .../Model/Cron/JobComponentUninstallTest.php | 26 +- .../Unit/Model/Cron/JobDbRollbackTest.php | 23 +- .../Test/Unit/Model/Cron/JobFactoryTest.php | 95 ++-- .../Test/Unit/Model/Cron/JobModuleTest.php | 44 +- .../Model/Cron/JobStaticRegenerateTest.php | 14 +- .../Test/Unit/Model/Cron/JobUpgradeTest.php | 15 +- .../Test/Unit/Model/Cron/Queue/ReaderTest.php | 4 +- .../Test/Unit/Model/Cron/Queue/WriterTest.php | 6 +- .../Setup/Test/Unit/Model/Cron/QueueTest.php | 10 +- .../Unit/Model/Cron/ReadinessCheckTest.php | 10 +- .../Setup/Test/Unit/Model/Cron/StatusTest.php | 4 +- .../Model/CronScriptReadinessCheckTest.php | 4 +- .../Model/DateTime/DateTimeProviderTest.php | 17 +- .../Model/DateTime/TimezoneProviderTest.php | 13 +- .../Model/DependencyReadinessCheckTest.php | 13 +- .../Model/Installer/ProgressFactoryTest.php | 2 +- .../Test/Unit/Model/InstallerFactoryTest.php | 132 +++-- .../Setup/Test/Unit/Model/InstallerTest.php | 90 ++-- .../Setup/Test/Unit/Model/LicenseTest.php | 10 +- .../Unit/Model/MarketplaceManagerTest.php | 12 +- .../Model/ModuleRegistryUninstallerTest.php | 12 +- .../Unit/Model/ModuleStatusFactoryTest.php | 12 +- .../Test/Unit/Model/ModuleStatusTest.php | 13 +- .../Test/Unit/Model/ModuleUninstallerTest.php | 33 +- .../Setup/Test/Unit/Model/NavigationTest.php | 4 +- .../Test/Unit/Model/PhpReadinessCheckTest.php | 22 +- .../Test/Unit/Model/SystemPackageTest.php | 29 +- .../ThemeDependencyCheckerFactoryTest.php | 12 +- .../Unit/Model/UninstallCollectorTest.php | 21 +- .../Model/UninstallDependencyCheckTest.php | 8 +- .../Setup/Test/Unit/Model/UpdaterTest.php | 4 +- .../Setup/Test/Unit/Model/WebLoggerTest.php | 22 +- .../Test/Unit/Module/ConfigGeneratorTest.php | 4 +- .../Unit/Module/ConnectionFactoryTest.php | 5 +- .../Test/Unit/Module/DataSetupFactoryTest.php | 19 +- .../Module/Dependency/Parser/CodeTest.php | 2 +- .../Dependency/Parser/Composer/JsonTest.php | 2 +- .../Dependency/Parser/Config/XmlTest.php | 2 +- .../Report/Builder/AbstractBuilderTest.php | 8 +- .../Report/Circular/Data/ChainTest.php | 2 +- .../Report/Circular/Data/ConfigTest.php | 6 +- .../Report/Circular/Data/ModuleTest.php | 2 +- .../Report/Data/Config/AbstractConfigTest.php | 2 +- .../Report/Dependency/Data/ConfigTest.php | 6 +- .../Report/Dependency/Data/DependencyTest.php | 2 +- .../Report/Dependency/Data/ModuleTest.php | 6 +- .../Report/Framework/BuilderTest.php | 4 +- .../Report/Framework/Data/ConfigTest.php | 6 +- .../Report/Framework/Data/DependencyTest.php | 2 +- .../Report/Framework/Data/ModuleTest.php | 2 +- .../Report/Writer/Csv/AbstractWriterTest.php | 8 +- .../App/Task/ApplicationCodeGeneratorTest.php | 9 +- .../Test/Unit/Module/Di/App/Task/AreaTest.php | 13 +- .../Di/App/Task/InterceptionCacheTest.php | 4 +- .../Di/App/Task/OperationFactoryTest.php | 14 +- .../Module/Di/App/Task/ProxyGeneratorTest.php | 6 +- .../Di/App/Task/RepositoryGeneratorTest.php | 10 +- .../ServiceDataAttributesGeneratorTest.php | 6 +- .../InterceptionConfigurationBuilderTest.php | 17 +- .../Code/Reader/ClassReaderDecoratorTest.php | 2 +- .../Reader/InstancesNamesList/AreaTest.php | 4 +- .../InstancesNamesList/DirectoryTest.php | 8 +- .../InstancesNamesList/InterceptionsTest.php | 8 +- .../Di/Code/Scanner/CompositeScannerTest.php | 4 +- .../Code/Scanner/ConfigurationScannerTest.php | 8 +- .../Module/Di/Code/Scanner/PhpScannerTest.php | 2 +- .../Di/Code/Scanner/PluginScannerTest.php | 2 +- .../ServiceDataAttributesScannerTest.php | 8 +- .../Scanner/XmlInterceptorScannerTest.php | 4 +- .../Module/Di/Code/Scanner/XmlScannerTest.php | 2 +- .../Di/Compiler/ArgumentsResolverTest.php | 4 +- .../Compiler/Config/ModificationChainTest.php | 24 +- .../Module/Di/Compiler/Config/ReaderTest.php | 15 +- .../Module/Di/Definition/CollectionTest.php | 2 +- .../Unit/Module/Di/_files/app/bootstrap.php | 2 +- .../code/Magento/SomeModule/Helper/Test.php | 2 +- .../code/Magento/SomeModule/Model/Test.php | 2 +- .../Test/Unit/Module/I18n/ContextTest.php | 8 +- .../Module/I18n/Dictionary/GeneratorTest.php | 42 +- .../Loader/File/AbstractFileTest.php | 14 +- .../Options/ResolverFactoryTest.php | 4 +- .../I18n/Dictionary/Options/ResolverTest.php | 12 +- .../Module/I18n/Dictionary/PhraseTest.php | 4 +- .../I18n/Dictionary/Writer/Csv/StdoTest.php | 2 +- .../Module/I18n/Dictionary/Writer/CsvTest.php | 10 +- .../Test/Unit/Module/I18n/DictionaryTest.php | 12 +- .../Test/Unit/Module/I18n/FactoryTest.php | 10 +- .../Unit/Module/I18n/FilesCollectorTest.php | 2 +- .../Unit/Module/I18n/Pack/GeneratorTest.php | 22 +- .../Module/I18n/Parser/AbstractParserTest.php | 7 +- .../Parser/Adapter/AbstractAdapterTest.php | 4 +- .../Module/I18n/Parser/Adapter/HtmlTest.php | 2 +- .../Module/I18n/Parser/Adapter/JsTest.php | 2 +- .../Php/Tokenizer/PhraseCollectorTest.php | 8 +- .../Adapter/Php/Tokenizer/TokenTest.php | 2 +- .../I18n/Parser/Adapter/Php/TokenizerTest.php | 2 +- .../Module/I18n/Parser/Adapter/PhpTest.php | 4 +- .../Module/I18n/Parser/Adapter/XmlTest.php | 2 +- .../Unit/Module/I18n/Parser/ParserTest.php | 20 +- .../Test/Unit/Module/ResourceFactoryTest.php | 11 +- .../Test/Unit/Module/SetupFactoryTest.php | 28 +- .../Setup/Test/Unit/Module/SetupTest.php | 4 +- .../Mvc/Bootstrap/InitParamListenerTest.php | 44 +- .../Test/Unit/Validator/DbValidatorTest.php | 12 +- 249 files changed, 2276 insertions(+), 1495 deletions(-) create mode 100644 setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php diff --git a/index.php b/index.php index c47a55e1e2550..e74879ad90e83 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 @@ $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 32d64e07e0f5f..ded37b7e0523c 100644 --- a/pub/cron.php +++ b/pub/cron.php @@ -29,7 +29,7 @@ $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 a0944c4f1fc61..f7f808d0c0a5c 100644 --- a/pub/errors/processorFactory.php +++ b/pub/errors/processorFactory.php @@ -22,7 +22,7 @@ public function createProcessor() { $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 760f922adb140..4be6159bb463e 100644 --- a/pub/get.php +++ b/pub/get.php @@ -74,7 +74,7 @@ $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 9d4682cdf685e..4f7735083241f 100644 --- a/pub/index.php +++ b/pub/index.php @@ -33,5 +33,5 @@ ]; $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 5626be1563781..2476bfb4a0e28 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 8d3f88d044e22..6984d2504e3ff 100644 --- a/setup/config/application.config.php +++ b/setup/config/application.config.php @@ -18,10 +18,10 @@ __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 9c73aae475358..0a58bf2022639 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 723cb300fc440..c612d04772c08 100644 --- a/setup/config/router.config.php +++ b/setup/config/router.config.php @@ -13,7 +13,7 @@ '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 0c1a4ede0ebff..a712c277af4f7 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php @@ -91,11 +91,11 @@ protected function execute(InputInterface $input, OutputInterface $output) { 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('Report successfully processed.'); diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php index 9a06568e1385f..0bfdd6d7cfe10 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php @@ -78,11 +78,11 @@ abstract protected function isModuleRequired(); 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('Cache cleared successfully.'); /** @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( "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 e207f114a69eb..b0ed5ddcd9383 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $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 protected function isEnable(); /** * 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 decb6c4a8cbf5..63f4aeffce99d 100644 --- a/setup/src/Magento/Setup/Console/Command/BackupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/BackupCommand.php @@ -71,7 +71,7 @@ public function __construct( ) { $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 @@ private function setAreaCode() { $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 e9e0ac0f819c3..cb114d24e96ed 100644 --- a/setup/src/Magento/Setup/Console/Command/DbStatusCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DbStatusCommand.php @@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** @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("The module code base doesn't match the DB schema and data."); diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index c4002f4043e1d..06c603faceb9e 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -133,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $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 @@ protected function execute(InputInterface $input, OutputInterface $output) /** @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 @@ private function configureObjectManager(OutputInterface $output) { $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 0000000000000..ac6a43189d7ab --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php @@ -0,0 +1,493 @@ +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, /var/generation by default' + ), + new InputOption( + self::INPUT_KEY_DI, + null, + InputOption::VALUE_REQUIRED, + 'Absolute path to DI definitions directory, /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( + '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 /var" where MAGENTO_ROOT is the Magento ' + . 'root directory).' + ); + } + } + + /** + * 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[] = 'Invalid value for command option \'' . self::INPUT_KEY_SERIALIZER + . '\'. Possible values (' . self::SERIALIZER_VALUE_SERIALIZE . '|' + . self::SERIALIZER_VALUE_IGBINARY . ').'; + } + break; + case self::INPUT_KEY_EXTRA_CLASSES_FILE: + if (!file_exists($value)) { + $errors[] = 'Path does not exist for the value of command option \'' + . self::INPUT_KEY_EXTRA_CLASSES_FILE . '\'.'; + } + 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[] = 'Invalid pattern for command option \'' . self::INPUT_KEY_EXCLUDE_PATTERN + . '\'.'; + } + 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 = 'Path does not exist for the value of command option \'' . $type . '\'.'; + } + if (file_exists($value) && !is_writeable($value)) { + $errorMsg .= 'Non-writable directory is provided by the value of command option \'' + . $type . '\'.'; + + } + return $errorMsg; + } +} diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php index 3e62ac0dba421..44d670f3a1abb 100644 --- a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -82,10 +82,11 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** @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 d48e5612fde9f..1549548f7355b 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php @@ -182,7 +182,7 @@ public function validate(InputInterface $input) 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[] = '' . 'Command option \'' . StoreConfigurationDataMapper::KEY_BASE_URL @@ -191,7 +191,7 @@ public function validate(InputInterface $input) 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 @@ public function validate(InputInterface $input) 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 @@ public function validate(InputInterface $input) 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 @@ public function validate(InputInterface $input) 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 08d057c70d644..a81ace272e68d 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php @@ -47,7 +47,7 @@ protected function configure() */ 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('List of enabled modules:'); $enabledModules = $moduleList->getNames(); if (count($enabledModules) === 0) { @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $output->writeln(''); - $fullModuleList = $this->objectManagerProvider->get()->create('Magento\Framework\Module\FullModuleList'); + $fullModuleList = $this->objectManagerProvider->get()->create(\Magento\Framework\Module\FullModuleList::class); $output->writeln("List of disabled modules:"); $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 7b1bcd19fe40f..f723ccaa2f86e 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php @@ -135,10 +135,10 @@ public function __construct( $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 @@ private function removeData(array $modules, OutputInterface $output, $dbBackupOp $this->moduleUninstaller->uninstallData($output, $modules); } - - /** * Validate list of modules against installed composer packages and return error messages * @@ -370,10 +368,10 @@ private function setAreaCode() { $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 a31d805de5953..f68decfaaf57f 100644 --- a/setup/src/Magento/Setup/Console/Command/RollbackCommand.php +++ b/setup/src/Magento/Setup/Console/Command/RollbackCommand.php @@ -68,7 +68,7 @@ public function __construct( ) { $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 @@ private function setAreaCode() { $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 c416ca04f25ac..4bb5ac0181a79 100644 --- a/setup/src/Magento/Setup/Console/CommandList.php +++ b/setup/src/Magento/Setup/Console/CommandList.php @@ -10,6 +10,8 @@ /** * Class CommandList contains predefined list of commands for Setup + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CommandList { @@ -38,38 +40,38 @@ public function __construct(ServiceManager $serviceManager) 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 b5cf25bae675f..0b8d239104102 100644 --- a/setup/src/Magento/Setup/Controller/BackupActionItems.php +++ b/setup/src/Magento/Setup/Controller/BackupActionItems.php @@ -52,7 +52,10 @@ public function __construct( \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 2d7e11bb8b2fc..885ed556ff7ba 100644 --- a/setup/src/Magento/Setup/Controller/ComponentGrid.php +++ b/setup/src/Magento/Setup/Controller/ComponentGrid.php @@ -69,9 +69,9 @@ public function __construct( ) { $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 8d999964bd248..c02e1515ad005 100644 --- a/setup/src/Magento/Setup/Controller/CustomizeYourStore.php +++ b/setup/src/Magento/Setup/Controller/CustomizeYourStore.php @@ -50,7 +50,7 @@ public function indexAction() $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 9c88e90a49f07..aba4306aca49e 100644 --- a/setup/src/Magento/Setup/Controller/Modules.php +++ b/setup/src/Magento/Setup/Controller/Modules.php @@ -85,7 +85,7 @@ public function allModulesValidAction() */ 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 @@ private function checkGraph(array $toBeEnabledModules, $prettyFormat = false) 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 5003e422e7b64..371365d11b62f 100644 --- a/setup/src/Magento/Setup/Controller/Session.php +++ b/setup/src/Magento/Setup/Controller/Session.php @@ -54,20 +54,20 @@ public function indexAction() 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 f3eab45eeefed..336380f1d8764 100644 --- a/setup/src/Magento/Setup/Controller/Success.php +++ b/setup/src/Magento/Setup/Controller/Success.php @@ -39,7 +39,7 @@ public function indexAction() { 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 aa21ef70b1cae..5e6a36d2f1d03 100755 --- a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php @@ -50,11 +50,11 @@ public function execute() ); /** @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 @@ public function generateCondition($ruleId, $categoriesArray) 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 @@ public function generateCondition($ruleId, $categoriesArray) ], '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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) 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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) $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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) 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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) ], '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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) '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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) $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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) 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 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) ], '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 46cfbe5ae0a6e..2296d5e5ec34f 100644 --- a/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php @@ -29,14 +29,15 @@ public function execute() $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 @@ public function execute() '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 01f550c58e3b5..16d7fde937880 100644 --- a/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php @@ -29,9 +29,9 @@ public function execute() $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 3efcf395b0716..bc8362890b638 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php @@ -30,7 +30,7 @@ public function execute() 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 @@ public function execute() ->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 0cdc3bd9a202e..09704f3274e65 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php @@ -581,9 +581,9 @@ public function execute() $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 @@ public function execute() /** @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 fab712f336803..ca29b4cf70447 100644 --- a/setup/src/Magento/Setup/Fixtures/CustomersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php @@ -30,7 +30,7 @@ public function execute() $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 @@ public function execute() $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 4799840afd86b..cff0548c2d104 100644 --- a/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php @@ -30,9 +30,10 @@ public function execute() $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 @@ public function execute() * 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 @@ public function execute() $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 0bbb4167854d1..118b29cb4306b 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\Output\OutputInterface; use Magento\Framework\Xml\Parser; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class FixtureModel { /** @@ -155,7 +158,7 @@ public function getObjectManager() $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 @@ public function initObjectManager() $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 471ed28e38dc6..9a80889e9c232 100644 --- a/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php @@ -29,7 +29,7 @@ public function execute() 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 5e8b20da54430..8210e4c941e01 100644 --- a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php @@ -10,6 +10,8 @@ /** * Class OrdersFixture + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrdersFixture extends Fixture { @@ -34,66 +36,66 @@ public function execute() $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 @@ public function execute() //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 @@ public function getTableName($tableName, $resourceName) 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 39d20b67095d7..6de4eaf91529f 100644 --- a/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php @@ -30,9 +30,9 @@ public function execute() $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 @@ public function execute() ); /** @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 162482d75c154..dcd7dd5b6f50c 100644 --- a/setup/src/Magento/Setup/Fixtures/StoresFixture.php +++ b/setup/src/Magento/Setup/Fixtures/StoresFixture.php @@ -31,7 +31,7 @@ public function execute() $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 @@ public function execute() //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 ae6ec34133c80..e024b47bc568a 100644 --- a/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php @@ -29,11 +29,11 @@ public function execute() /** 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 @@ public function execute() '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 bbc48f7c93232..36f997e980dee 100644 --- a/setup/src/Magento/Setup/Model/AdminAccountFactory.php +++ b/setup/src/Magento/Setup/Model/AdminAccountFactory.php @@ -33,7 +33,7 @@ public function create(Setup $setup, $data) { 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 da6029ce5bb04..524888c6c3571 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php @@ -96,7 +96,7 @@ public function collectOptionsLists() } // 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 a687e06156235..fdfb57757b901 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 @@ public function __construct( $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 2151cbb842322..3ce4511c1ed94 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php +++ b/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php @@ -81,10 +81,10 @@ private function setAreaCode() { $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 10d1d4f346c26..14bb75197fc4b 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php +++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php @@ -9,6 +9,8 @@ /** * Factory class to create jobs + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class JobFactory { @@ -47,20 +49,20 @@ public function __construct(ServiceLocatorInterface $serviceLocator) */ 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 @@ public function create($name, array $params = []) 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 @@ public function create($name, array $params = []) 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 @@ public function create($name, array $params = []) 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 01cb1dcc2e27f..f592b151cf287 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobStaticRegenerate.php +++ b/setup/src/Magento/Setup/Model/Cron/JobStaticRegenerate.php @@ -53,8 +53,8 @@ public function __construct( $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 @@ public function getOutputObject() */ public function getFilesystem() { - return $this->objectManager->create('Magento\Deploy\Model\Filesystem'); + return $this->objectManager->create(\Magento\Deploy\Model\Filesystem::class); } /** @@ -146,7 +146,7 @@ public function getFilesystem() 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 073b6ee027bea..72679d0c4a5a7 100644 --- a/setup/src/Magento/Setup/Model/DateTime/DateTimeProvider.php +++ b/setup/src/Magento/Setup/Model/DateTime/DateTimeProvider.php @@ -54,7 +54,7 @@ public function get() { 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 dfff802bc793c..2b1c3ac864431 100644 --- a/setup/src/Magento/Setup/Model/DateTime/TimezoneProvider.php +++ b/setup/src/Magento/Setup/Model/DateTime/TimezoneProvider.php @@ -46,7 +46,7 @@ public function get() { 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 39d80861878d0..74a08e2795c5d 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 @@ public function installUserConfig($data) { $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 @@ public function installUserConfig($data) } /** @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 @@ public function uninstall() 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 @@ private function enableCaches() 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 9e0eba3eb1d6c..8a7c2143f0ebc 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\State\CleanupFiles; use Magento\Framework\Setup\LoggerInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class InstallerFactory { /** @@ -50,31 +53,31 @@ public function __construct(ServiceLocatorInterface $serviceLocator, ResourceFac 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 @@ public function create(LoggerInterface $log) */ 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 b0d875b4db987..08683ef8f85c3 100644 --- a/setup/src/Magento/Setup/Model/ModuleStatus.php +++ b/setup/src/Magento/Setup/Model/ModuleStatus.php @@ -53,7 +53,8 @@ public function __construct( $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 44645dde61412..fe3ff4471fedb 100644 --- a/setup/src/Magento/Setup/Model/ModuleStatusFactory.php +++ b/setup/src/Magento/Setup/Model/ModuleStatusFactory.php @@ -35,6 +35,6 @@ public function __construct(ObjectManagerProvider $objectManagerProvider) */ 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 3e41f1b2da0e1..146a54f949425 100644 --- a/setup/src/Magento/Setup/Model/ModuleUninstaller.php +++ b/setup/src/Magento/Setup/Model/ModuleUninstaller.php @@ -63,7 +63,7 @@ public function uninstallData(OutputInterface $output, array $modules) { $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("Removing data of $module"); @@ -89,7 +89,7 @@ public function uninstallCode(OutputInterface $output, array $modules) $output->writeln('Removing code from Magento codebase:'); $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 7c7af94520c66..305574c6b72e7 100644 --- a/setup/src/Magento/Setup/Model/ThemeDependencyCheckerFactory.php +++ b/setup/src/Magento/Setup/Model/ThemeDependencyCheckerFactory.php @@ -35,6 +35,6 @@ public function __construct(ObjectManagerProvider $objectManagerProvider) */ 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 37aa3f6c41503..07a07a03c9237 100644 --- a/setup/src/Magento/Setup/Model/UninstallCollector.php +++ b/setup/src/Magento/Setup/Model/UninstallCollector.php @@ -63,7 +63,7 @@ public function collectUninstall($filterModules = []) $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 b63c10f770b41..c1238ef7cefbb 100644 --- a/setup/src/Magento/Setup/Model/UpdatePackagesCache.php +++ b/setup/src/Magento/Setup/Model/UpdatePackagesCache.php @@ -12,6 +12,7 @@ /** * Class UpdatePackagesCache manages information about available for update packages though the cache file. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpdatePackagesCache { @@ -76,7 +77,7 @@ public function __construct( 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 987d623bfa6b3..f6696ed9d3b6d 100644 --- a/setup/src/Magento/Setup/Module.php +++ b/setup/src/Magento/Setup/Module.php @@ -38,7 +38,7 @@ public function onBootstrap(EventInterface $e) // 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 5fa79d7fb4611..95afab3dbddcd 100644 --- a/setup/src/Magento/Setup/Module/DataSetupFactory.php +++ b/setup/src/Magento/Setup/Module/DataSetupFactory.php @@ -35,6 +35,6 @@ public function __construct(ObjectManagerProvider $objectManagerProvider) 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 b880bc3d8829d..49fac893b39d4 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 @@ public function doOperation() [ '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 9490fc9f6100e..95ae7abac31f6 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 95392321920e2..944b7ea744205 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 @@ public function __construct(ObjectManagerInterface $objectManager) */ 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 ee5a42069fb0c..568e1eae693f8 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 @@ public function getList($path) $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 5293b78206424..da4839f494f6a 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 @@ protected function scan() // 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 eef6b300bed4d..a0a0e3f09e0e6 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 b40c37faaf53a..31d72ed42705b 100644 --- a/setup/src/Magento/Setup/Module/ResourceFactory.php +++ b/setup/src/Magento/Setup/Module/ResourceFactory.php @@ -34,7 +34,7 @@ public function __construct(ServiceLocatorInterface $serviceLocator) */ 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 999e2fc357681..f0404bf70032b 100644 --- a/setup/src/Magento/Setup/Module/SetupFactory.php +++ b/setup/src/Magento/Setup/Module/SetupFactory.php @@ -38,7 +38,7 @@ public function create(ResourceConnection $appResource = null) { $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 777f87515d665..149cfe61a55a2 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 @@ public function attach(EventManagerInterface $events) { $sharedEvents = $events->getSharedManager(); $this->listeners[] = $sharedEvents->attach( - 'Zend\Mvc\Application', + \Zend\Mvc\Application::class, MvcEvent::EVENT_BOOTSTRAP, [$this, 'onBootstrap'] ); @@ -89,8 +89,8 @@ public function onBootstrap(MvcEvent $e) $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 @@ public function authPreDispatch($event) /** @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 f648dda8877d7..f274d354ba43f 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 @@ public function testExecute() 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 @@ public function testGetOptionsList() */ 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 f356713a444fa..38329a897775e 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 @@ public function setUp() $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 @@ public function setUp() ->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 0877d057d31d1..9d611d080ffc1 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 @@ public function testExecuteInteractiveWithNo() */ 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 3a29130017af5..c9a060bb070c7 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 @@ public function testExecuteJobFailed() $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 @@ public function testExecute() $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 eba21e10ea1b0..d31ca01b0f8f6 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 c4ea7712f086d..ac453cb450c6d 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 943d3a4cb5b24..0d3a19e803d3c 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 31b86e7cec70c..22df0b92a3984 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\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 @@ public function testExecute() $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 @@ public function testExecute() ->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 @@ public function testExecute() $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 cb7828c7dcb71..64b857cf9b300 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 3d3eda0a815e2..f63c8cc8fcf59 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 78bccd796e521..5b59e141c4fdb 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 9d5be0908acb0..52255274428f1 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 @@ public function testExecute() '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 94c47e8ba7b4b..a00aac14e4f9f 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 @@ public function testExecute() '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 0cdb2bb3a1f89..56f4e8230aa91 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 @@ public function testExecute() '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 9ef538662ff20..754913f4d627e 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\Framework\Config\ConfigOptionsListConstants as SetupConfigOptionsList; use Magento\Setup\Model\StoreConfigurationDataMapper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class InstallCommandTest extends \PHPUnit_Framework_TestCase { /** @@ -53,7 +56,7 @@ public function setUp() '--' . 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 @@ public function setUp() ->will($this->returnValue([])); $userConfig = $this->getMock( - 'Magento\Setup\Console\Command\InstallStoreConfigurationCommand', + \Magento\Setup\Console\Command\InstallStoreConfigurationCommand::class, [], [], '', @@ -79,7 +82,7 @@ public function setUp() ->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 @@ public function setUp() ->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 @@ public function testExecute() */ 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 @@ private function getOptionsListDeployConfig() */ 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 @@ private function getOptionsListUserConfig() */ 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 e8de226815e79..6f5ab3a5a64c5 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 @@ public function testExecuteNotInstalled() */ 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 f60df4064d918..126cbadb6a53b 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 e7f9f7ddb2921..9d23b225845c5 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 7e8c0028f652c..e9ad6384a05e1 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 00a12b078feda..740f41bdfd3bd 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 41b05cc302b19..8ef2151817b2c 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 b8403cb5329a5..5aefd51578f17 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 7a992ec868a5e..47e4251fe6d7c 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 @@ public function setUp() $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 @@ public function setUp() $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 @@ public function setUp() $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 @@ public function testExecute() $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 @@ public function testExecuteClearStaticContent() $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 @@ public function testExecuteRemoveData() $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 @@ public function testExecuteAll() $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 @@ public function testExecuteCodeBackup() $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 @@ public function testExecuteMediaBackup() $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 @@ public function testExecuteDBBackup() $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 @@ public function testInteraction() $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 ce36008d66afa..571c21d7c3055 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 @@ public function setUp() ->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 @@ public function setUp() $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 a3183950c8e59..fb9ba2ce7c647 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 @@ public function testExecuteInteractionNo() 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 46ebded67b6ec..aea98290aa898 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 ba41ea73d77c4..ce13e6977e773 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 ebf84062ee980..9351010dbd00b 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 512f882a0b8c5..64c431d946ea2 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 @@ public function testIndexAction() /** @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 62b7a64ba0dff..a082542fb66ad 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 @@ 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 @@ public function setUp() $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 @@ public function testCheckAction() $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 @@ public function testCheckActionWithError() $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 @@ public function testCreateAction() { $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 @@ public function testCreateAction() 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 4adf3fe1579f0..7101629502cb2 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 @@ public function setUp() 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 @@ public function testIndexAction() 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 9d56a19426e05..380a0615dae07 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\Stdlib\DateTime\TimezoneInterface; use Magento\Setup\Model\MarketplaceManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ComponentGridTest extends \PHPUnit_Framework_TestCase { /** @@ -100,7 +103,6 @@ public function setUp() 'time' => self::FORMATTED_TIME, ], ]; - $this->lastSyncData = [ "lastSyncDate" => "1447271496", "packages" => [ @@ -129,42 +131,60 @@ public function setUp() ]; $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 @@ public function setUp() 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 @@ public function testComponentsAction() ->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 @@ public function testSyncAction() ->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 cc7a78514cd54..5fcd7038fc6b5 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 @@ public function testIndexAction() { $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 8cbc237ccebe1..fae0ea32637ea 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 @@ public function testIndexAction() /** @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 098ab491a2e66..4fd150af9cbce 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 @@ public function testIndexAction($expected, $withSampleData) $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 @@ public function indexActionDataProvider() 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 08d2f435edb8d..22176845d79a7 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 @@ public function setUp() 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 @@ public function testNoHasUninstallAction() $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 5509808523dbb..693ad27f17081 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\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 @@ public function setUp() 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 @@ public function testPhpVersionActionInstaller() 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 @@ public function testPhpVersionActionUpdater() 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 @@ public function testPhpSettingsActionInstaller() 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 @@ public function testPhpSettingsActionUpdater() 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 @@ public function testPhpExtensionsActionInstaller() 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 @@ public function testCronScriptActionBothNotice() 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 0aa0daa6576fa..21ff33c26b23b 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 @@ public function testIndexAction() /** @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 b640a5db7c7d3..4e422f6f576b1 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 @@ public function setUp() 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 @@ public function testExtensionsAction($extensions) ->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 b2ec9a6f86300..d0771b0cebaef 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 @@ 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 @@ public function setUp() 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 @@ public function testStartAction() $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 @@ public function testStartActionWithSampleDataError() $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 @@ public function testProgressAction() $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 @@ public function testProgressActionWithError() $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 @@ public function testProgressActionWithSampleDataError() { $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 @@ public function testProgressActionNoInstallLogFile() { $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 @@ public function testProgressActionNoInstallLogFile() 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 ac14f325fe59b..ad6a65c0c8233 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 @@ public function testIndexAction() $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 7960ecf8c6af1..303f0a363a381 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 @@ public function testIndexAction() $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 9c59ec957b969..73c0680342af6 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 @@ public function testIndexActionWithLicense() { $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 @@ public function testIndexActionNoLicense() { $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 955734accde23..864e84e1a949e 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 @@ public function testIndexAction() { $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 @@ public function testIndexActionWithExceptions() $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 9b9d49cd392e0..d0219fe7420a9 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 @@ public function testSaveAuthJsonAction() ->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 @@ public function testSaveAuthJsonActionWithError() ->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 @@ public function testCheckAuthAction() ->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 @@ public function testCheckAuthActionWithError() ->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 @@ public function testRemoveCredetinalsAction() ->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 @@ public function testRemoveCredentialsWithError() ->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 @@ public function testRemoveCredentialsWithError() 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 3b7260f1717f7..efde9686db353 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 @@ public function testIndexAction(array $expected) $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 @@ public function testIndexActionWithError(array $expected) ->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 39ce3c81711b8..c50e27c74af6c 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 @@ public function testIndexAction() $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 @@ public function testMenuActionUpdater() 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 @@ public function testHeaderBarInstaller() { $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 @@ public function testHeaderBarUpdater() { $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 0c10405da45bb..bc5af72b0cb23 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 @@ public function testComponentsAction() ] ]); $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 @@ public function testComponentsActionWithError() ->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 @@ public function testComponentsActionWithError() 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 c2e019d6d7423..e60c494077318 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 @@ public function setUp() 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 @@ public function testIndexAction() 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 3dbf892128b9e..0a67407aad619 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 @@ public function setUp() 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 @@ public function testIndexAction() 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 3127dd297e488..50aebec46e3b2 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 @@ public function setUp() 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 @@ public function testSystemPackageAction() ] ]); $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 @@ public function testSystemPackageActionActionWithError() ->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 @@ public function testInstalledSystemPackageAction() ] ]); $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 bb826dda5e123..a58c9edbd44d3 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 @@ public function testUnloginAction() $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 @@ public function testUnloginAction() ->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 @@ public function testIndexAction() /** @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 c07ebd79e53e9..4399dd4a0c21c 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 @@ 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 @@ public function setUp() ['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 @@ public function setUp() 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 @@ public function testUpdateActionSuccessUpdate() $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 @@ public function testUpdateActionSuccessUpgrade() $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 @@ public function testUpdateActionSuccessEnable() . '"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 @@ public function testUpdateActionSuccessDisable() . '"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 3375e88245c44..205931cbd129d 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 94404e2e70fed..6ac823aad68ad 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 @@ public function testIndexAction() /** @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 3c7edf00e79f0..9b4db8c5c81e0 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 8aaca73901575..829c64651e346 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 @@ public function testIndexAction() $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 51e78d0560c7c..9a871cbd196d2 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 @@ 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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() 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 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo $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 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo $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 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo ], '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 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo '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 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo $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 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo ], '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 2d0aa2297b99a..a3ed44dcf3d7a 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 @@ 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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() 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 a0b617954bf47..4c44fb1cb059f 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 @@ public function testExecute() ->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 @@ public function testExecute() 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 5daffed15806b..aed093dad90c5 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 @@ public function testExecute() 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 f84a59359f1b9..9d72aaee102ed 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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ], $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 @@ public function testExecute() 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 26eccf735e72b..2ec140b4412ed 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 @@ public function testExecute() $valueMap = [ [ - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'customer_composite', @@ -61,10 +61,10 @@ public function testExecute() ], $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 @@ public function testExecute() 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 ed41b7d7863bc..9ed90b34dd6a4 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 @@ public function setUp() 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 @@ public function testExecute() ->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 @@ public function testExecute() 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 1db8a46a1eeeb..ee1369bd15d5a 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 @@ public function testLoadConfigException() 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 d2a9ffcb36f1f..56fa29d6d4b8c 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 @@ public function testExecute() 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 40ea93805f290..4b0e6d7a648ac 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 @@ 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 @@ public function setUp() 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 @@ public function testExecute() $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 @@ public function testExecute() } $connectionInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', true, @@ -80,12 +83,12 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() 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 @@ public function testExecute() public function testNoFixtureConfigValue() { $connectionMock = $this->getMockForAbstractClass( - '\Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', true, @@ -224,16 +229,16 @@ public function testNoFixtureConfigValue() $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 2a4edd81bf5c4..913b2a1e3f020 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 @@ public function testExecute() ->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 @@ public function testExecute() ->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 @@ public function testExecute() $valueMap = [ [ - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'catalog_product', @@ -89,10 +89,10 @@ public function testExecute() ], $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 @@ public function testExecute() 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 474f9b6840620..7c1c37cc81a5e 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 @@ public function setUp() */ 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 @@ public function testExecute() $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 @@ public function testExecute() ->willReturn($storeMock); $categoryMock = $this->getMock( - 'Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'setName', 'setPath', @@ -112,11 +112,11 @@ public function testExecute() ->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 @@ public function testExecute() 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 e8bd29cb9bb50..f7a4cc777b334 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 @@ public function testExecute() ); $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 @@ public function testExecute() public function testNoFixtureConfigValue() { $csvImportHandlerMock = $this->getMock( - 'Magento\TaxImportExport\Model\Rate\CsvImportHandler', + \Magento\TaxImportExport\Model\Rate\CsvImportHandler::class, [], [], '', @@ -82,7 +82,7 @@ public function testNoFixtureConfigValue() ); $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 cc234ddae9872..79f393ff6cc1a 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 ee44afcfcf534..fc7a79260d1f8 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 @@ function ($table) { } )); - $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 21f0bbb651676..033ab78c69cd0 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 @@ public function setUp() { $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 53ce6bfd204f5..22dd0581864ae 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 @@ public function setUp() 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 4f09d2751f6b7..1e37d351d8f03 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 @@ public function testCreateOptions() 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 @@ public function testValidateInvalidSessionHandler() 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 ef3f8653ab30f..4fe96a37c724a 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 @@ public function testUninstallRemoveData() 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 acb098b14db6a..923a4c16d2f13 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 e08760a140412..a3a1f6d9e9bc4 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\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 13c01c0e7d5a1..d1b084d3d853f 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 5048b8ad9091e..31e241c408dba 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 @@ 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 @@ public function setUp() 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 @@ public function testRollback() ->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 @@ public function testComponentUninstall() { $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 @@ public function testModuleDisable() { $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 @@ public function testModuleDisable() ->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 @@ public function testModuleEnable() { $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 @@ public function testModuleEnable() ->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 3d4536510ab8a..c881e26e708e9 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 @@ public function testExecuteModuleDisable() 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 8cf915b325f40..23027d4973d96 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 @@ public function testExecuteWithException() */ 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 @@ protected function getJobStaticRegenerateMock($methods = null) */ 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 @@ protected function getFilesystemObjectMock($methods = null) */ 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 @@ protected function getStatucObjectMock($methods = null) */ 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 @@ protected function getCleanFilesObjectMock($methods = null) */ 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 @@ protected function getCacheObjectMock($methods = null) */ protected function getOutputObjectMock() { - return $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface'); + return $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class); } /** @@ -203,6 +203,6 @@ protected function getOutputObjectMock() */ 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 106e5adc0d367..e21e344f7500b 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 21f99bc57a761..e081f85e0717a 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 4054acbed346b..7cc4b195cf70c 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 fd7bbee50d782..3f45652400601 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 @@ public function testPopQueuedJob() $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 @@ public function testPopQueuedJobEmptyAfter() $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 8501299c5f221..3dbfe334c54c9 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 @@ public function setUp() 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 b39ebaf0b68b2..4b88c0e56724d 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 45ecfe94cb454..52ad6b5e86f12 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 4d24e73a02e26..9103124d268f1 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 63c4df875e280..7ffcfcd4fbada 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 0b4107f2a0876..78e7a1f9ee52f 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 94e78039a31fe..095074b6af722 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 @@ public function testCreateFromLog() '[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 b8319fb158ba8..b683f536f2cf9 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 @@ 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 760340f3cfb01..c40ef99d4e914 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 @@ protected function setUp() 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 @@ public function testInstall() ); $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 @@ public function testUpdateModulesSequenceKeepGenerated() 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 @@ public function testUninstall() ->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 @@ private function prepareForUpdateModulesTests() '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 e85ddba28ee44..ed8f3efccb7a1 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 ec708eb613259..26b3d4d7447d3 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 @@ public function testLoadPackagesForInstallFromCache() */ protected function _getServiceLocatorMock() { - return $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface'); + return $this->getMockForAbstractClass(\Zend\ServiceManager\ServiceLocatorInterface::class); } /** @@ -732,7 +732,7 @@ protected function _getServiceLocatorMock() */ 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 @@ protected function _getComposerInformationMock($methods = null) */ 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 @@ protected function _getCurlClientMock($methods = null) */ 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 @@ protected function _getFilesystemMock($methods = null) */ protected function _getDirectoryMock() { - return $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + return $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); } /** @@ -775,6 +775,6 @@ protected function _getDirectoryMock() */ 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 2cc88c0358f40..f5054ce24f1c4 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 deac722a17cd8..c756a5362e24f 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 @@ public function testCreate() $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 15e5c49f84bd1..83930eb039dfb 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 bc802385368ee..e9248f7bb68ee 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 @@ 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 @@ public function setUp() $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 @@ public function testUninstallRemoveCode() { $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 8e81e498daf7a..eea8d68ae943a 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 @@ public function setUp() ] ])); $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 256f7b25921c0..971ba13bade7f 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 @@ public function testCheckPhpVersionPrettyVersion() { $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 @@ public function testCheckPhpVersionPrettyVersion() ->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 @@ public function testCheckPhpVersionPrettyVersionFailed() { $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 @@ public function testCheckPhpVersionPrettyVersionFailed() ->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 @@ public function testCheckPhpVersionPrettyVersionFailed() private function setUpNoPrettyVersionParser() { $multipleConstraints = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -128,7 +128,7 @@ private function setUpNoPrettyVersionParser() $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 @@ public function testCheckPhpVersionFailed() { $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 @@ public function testCheckPhpVersionFailed() $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 b9dde9b9176ab..e0ef3ae579664 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 @@ public function setUp() ); $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 @@ public function setUp() 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 @@ public function testGetPackageVersions() */ 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 @@ public function testGetPackageVersionGitCloned() */ 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 @@ public function testGetAllowedEnterpriseVersions($ceCurrentVersion, $expectedRes ->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 7074b8d0645b3..a26d5eb0f8867 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 @@ public function testCreate() $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 d4272da88fb95..3cb04351f0438 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 @@ public function setUp() ['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 @@ public function testUninstallCollectorWithInput() */ 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 2b643bd4eb2ca..3599fd549ef61 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 df144e2c7d527..6446c9959e496 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 @@ public function testCreateUpdaterTaskUpdate() 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 38f262bf2a93a..dd1cc93314cd6 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 @@ public function setUp() { 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 @@ public function setUp() 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 @@ public function testClear() $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('Message1
', 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 1344810b9a476..caca5509d1e14 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 69be0030e5740..8b887ab7ba002 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 43678da1dec8d..5688d7d63090e 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 25fd09230ec31..2c71f24109f54 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 62141b71885cd..3554359933449 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 1da1efc2c26e1..eb4b0adc63591 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 9f9f620f479f2..b24ab45df69f9 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 @@ public function testBuild() ]; $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 73e397a4a95af..0bb3795b8ad91 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 @@ public function testGetModules() $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 450f98add160d..c87f10af7eb59 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 @@ public function setUp() $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 88d72673b2270..ec0e3abed1e24 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 @@ protected function createModule($name, $chains = []) { $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 e28eb3e0f56a8..7a1f419a0fb1d 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 @@ public function testGetModules() /** @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 7b1dc8ff231cc..f785861a29fd5 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 @@ public function setUp() $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 ff1d8b733dcfb..293872644b38c 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 @@ protected function createDependency($module, $type = null) { $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 642f0b812c08f..e79e6df92ebdd 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 @@ public function setUp() $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 5b2dff5a4ab91..db1d0a0d4f481 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 2c2adf143d22f..8d97ea4cdf0f5 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 @@ public function setUp() $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 10832714c567d..0e525c9370dc9 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 @@ protected function createDependency($lib, $count) { $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 3d9714dfdb678..a25911a1e6c1f 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 @@ protected function createModule($name, $dependencies = []) { $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 27c75a95970ae..46eb07d7d91f1 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 @@ protected function setUp() 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 @@ public function testWrite() */ 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 37235614c075b..442efad67e344 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 72b1974dab23a..3f95082473208 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 @@ public function testDoOperationGlobalArea() $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 1bdcb5f8e904b..d283d2ff1a3f0 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 90c066d3c9261..cf00a7314ef59 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 @@ protected function setUp() */ 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 @@ public function testCreateException() { $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 @@ public function testCreateException() 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 e97a238106d18..bd19c2e055213 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 9c43f5f270887..b23f8844fea51 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 a53a6e5621cea..2c35efa1f2458 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 00ba3b25ec24e..deae552a514e8 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 406fa090d902c..5dcdc875a0d5e 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 d3bc6dc5dfb3e..234c647ca12d0 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 78ff6a6966dac..7e6c2f1ff1b03 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 7c120f799bd85..212575e644d7c 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 5b6759b6e3739..073bb18b379de 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 @@ public function testScan() $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 f36a120d819d1..53e48abfdb2ca 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 @@ protected function setUp() 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 e0a85322e6720..4534c532792fc 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 844959dd501e9..e77e98dff1c8f 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 @@ protected function tearDown() 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 3409f073f3156..1023f6b41b077 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 @@ public function testCollectEntities() { $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 0e58ef50f698c..fa8cf85a20867 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 @@ public function testCollectEntities() { $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 61c9cb7c9ccbe..02e603e4a2632 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 8ba9e8120c876..34bbcf118b19a 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 @@ public function testGetResolvedArgumentsConstructorConfiguredFormat() 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 7f2ffcb032ef1..5fb8f164cee89 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 @@ public function testConstructorException() { $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 @@ public function testModify() '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 4fb827bc67012..929f3100efde5 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 @@ protected function setUp() ->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 2d1c9ac0a9b6e..578f3a82dbca3 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 @@ private function getExpectedDefinition() 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 1eed8db71cb09..654c282d88c07 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 619819e48b360..7631f8a6bfb50 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 @@ public function __construct( */ 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 e20df8dcb21b1..df87a2b270c48 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 @@ public function __construct() */ 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 42825a947fd46..fa9f915de9e8c 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 37fabc7d2b8d6..9c182d31f7bae 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 @@ protected function setUp() $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 @@ public function testCreatingDictionaryWriter() { $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 @@ public function testUsingRightParserWhileWithoutContextParsing() $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 @@ public function testUsingRightParserWhileWithoutContextParsing() ->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 @@ public function testUsingRightParserWhileWithContextParsing() $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 @@ public function testUsingRightParserWhileWithContextParsing() ->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 @@ public function testWritingPhrases() { $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 @@ public function testWritingPhrases() ->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 @@ public function testGenerateWithNoPhrases() $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 bcdabf456185b..b0a04f6c6c813 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 @@ protected function setUp() 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 @@ public function testLoadWrongFile() 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 @@ public function testLoad() $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 @@ public function testLoad() 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 e3ab85b7cf7ec..e065a717697a6 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 @@ public function testCreate() $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 @@ public function testCreateException() $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 c5dc4f7c249be..c7731e3225db6 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 @@ public function testGetOptions($directory, $withContext, $result) [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 @@ public function getOptionsDataProvider() */ 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 b04d02b5084b7..39a852fb5e7fb 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 @@ public function testWrongParametersWhilePhraseCreation($constructArguments, $mes { $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 1765ea37d0a77..37fb24afe97a8 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 @@ public function testThatHandlerIsRight() { $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 dd8a2575799b9..53c0355403c67 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 @@ protected function setUp() $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 @@ public function testWrongOutputFile() { $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 @@ public function testWrite() $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 @@ public function testWriteWithoutContext() $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 fc43163461ca2..36975cc69c9be 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 @@ public function testPhraseCollecting() 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 720ccfa08735b..48085cb0da7fd 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 @@ public function createDictionaryWriterDataProvider() { 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 a69044cdcf3b1..130e7d2461db8 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 @@ protected function setUp() $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 c4afa08f18c77..0ec524c9ab25b 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 @@ public function testGenerate() $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 @@ public function testGenerateEmptyFile() $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 @@ public function testGenerateWithNotAllowedDuplicatesAndDuplicatesExist() $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 7957577ac732f..a9325196d1005 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 @@ public function testValidateOptions($options, $message) { $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 02776c900ab5e..0bad94e6e9a17 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 @@ protected function setUp() ['_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 96b1a11f7e774..841b4650cd09d 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 @@ protected function setUp() $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 ce31d68100635..87182185f6277 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 @@ protected function setUp() $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 c9718cbacd927..724a42d26495a 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 @@ protected function createToken( $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 @@ public function testCollectPhrases() $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 bf6300a153ef7..01e02b5fdf49a 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 @@ protected function createToken($name, $value) { $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 70e8a9faa33fb..5b454ec37dccd 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 @@ protected function setUp() { $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 07269a4b1cfeb..27729ae204b9c 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 @@ protected function setUp() $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 de0f776419ece..3ca9d6c37a1d0 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 @@ protected function setUp() $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 ff7d3525586a8..162264c39514a 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 @@ public function testAddPhrase($options, $phpFiles, $jsFiles, $phpMap, $jsMap, $p */ 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 a3f6fe3390b60..baf7eb3d01a1a 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 @@ protected function setUp() 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 1cf29b1510960..5055a7fb26c75 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 43c6fc0297ff0..231adb9ab695b 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 6f397a9c880a9..558533afe9242 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 @@ /** * Tests Magento\Setup\Mvc\Bootstrap\InitParamListener + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InitParamListenerTest extends \PHPUnit_Framework_TestCase { @@ -46,22 +48,27 @@ public function testDetach() 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 @@ public function testCreateServiceNotConsole() /** * @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 @@ public function testCreateService($zfAppConfig, $env, $cliParam, $expectedArray) /** * @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 @@ public function testCreateFilesystem() * @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 @@ public function testCreateFilesystem() */ 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 5b076e122a6e1..c2353bd03d13b 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 @@ public function testCheckDatabaseConnection() ->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 @@ public function testCheckDatabaseConnectionNotEnoughPrivileges() ->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 @@ public function testCheckDatabaseConnectionDbNotAccessible() ->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 @@ public function testCheckDatabaseTablePrefixWrongLength() */ 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'); From 982e0f260cee486ccf680ae61d9f48055d82bd6e Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:15:04 +0300 Subject: [PATCH 02/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../AclResource/Config/Reader/Filesystem.php | 2 +- .../Framework/Acl/AclResourceFactory.php | 2 +- .../AclResource/Config/SchemaLocatorTest.php | 2 +- .../Test/Unit/AclResource/ProviderTest.php | 4 +- .../Framework/Acl/Test/Unit/BuilderTest.php | 10 +-- .../Framework/Acl/Test/Unit/CacheTest.php | 4 +- .../Acl/Test/Unit/Loader/DefaultTest.php | 2 +- .../Test/Unit/Loader/ResourceLoaderTest.php | 16 ++-- .../Acl/Test/Unit/ResourceFactoryTest.php | 8 +- .../Acl/Test/Unit/Role/RegistryTest.php | 4 +- .../Framework/Api/AttributeValueFactory.php | 2 +- .../ExtensionAttributesGenerator.php | 2 +- .../ExtensionAttributesInterfaceGenerator.php | 2 +- .../Framework/Api/Code/Generator/Mapper.php | 2 +- .../Api/Code/Generator/SearchResults.php | 7 +- .../Framework/Api/DataObjectHelper.php | 4 +- .../Api/ExtensionAttribute/Config/Reader.php | 2 +- .../JoinDataInterfaceFactory.php | 2 +- .../Api/ExtensionAttributesFactory.php | 2 +- .../Magento/Framework/Api/ImageProcessor.php | 2 +- .../Framework/Api/Search/DocumentFactory.php | 2 +- .../Api/Search/SearchCriteriaFactory.php | 2 +- .../Api/Search/SearchResultFactory.php | 2 +- .../Unit/Api/ImageContentValidatorTest.php | 14 ++-- .../Api/Test/Unit/Api/ImageProcessorTest.php | 49 ++++++------ .../Generator/EntityChildTestAbstract.php | 6 +- .../ExtensionAttributesGeneratorTest.php | 20 ++--- ...ensionAttributesInterfaceGeneratorTest.php | 18 ++--- .../Code/Generator/GenerateMapperTest.php | 11 ++- .../Generator/GenerateSearchResultsTest.php | 11 ++- .../Api/Test/Unit/DataObjectHelperTest.php | 74 +++++++++---------- .../ExtensibleDataObjectConverterTest.php | 6 +- .../Config/ConverterTest.php | 25 +++---- .../ExtensionAttribute/Config/ReaderTest.php | 10 +-- .../Config/SchemaLocatorTest.php | 2 +- .../ExtensionAttribute/Config/XsdTest.php | 8 +- .../Magento/Framework/App/ActionFactory.php | 2 +- lib/internal/Magento/Framework/App/Area.php | 4 +- .../Magento/Framework/App/AreaList.php | 2 +- .../Magento/Framework/App/AreaList/Proxy.php | 2 +- .../Magento/Framework/App/Bootstrap.php | 10 +-- .../Framework/App/Cache/Frontend/Factory.php | 17 +++-- .../Magento/Framework/App/Cache/Proxy.php | 2 +- .../Framework/App/Cache/Type/FrontendPool.php | 2 +- .../Magento/Framework/App/Config/Base.php | 2 +- .../Framework/App/Config/BaseFactory.php | 2 +- .../Framework/App/Config/DataFactory.php | 2 +- .../Framework/App/Config/ValueFactory.php | 2 +- lib/internal/Magento/Framework/App/Cron.php | 4 +- lib/internal/Magento/Framework/App/Http.php | 2 +- .../Framework/App/Language/ConfigFactory.php | 2 +- .../Environment/AbstractEnvironment.php | 2 +- .../ObjectManager/Environment/Compiled.php | 19 +++-- .../ObjectManager/Environment/Developer.php | 18 ++--- .../Framework/App/ObjectManagerFactory.php | 40 +++++----- .../Framework/App/PageCache/Kernel.php | 2 +- .../Magento/Framework/App/Request/Http.php | 2 +- .../Magento/Framework/App/RequestFactory.php | 2 +- .../App/ResourceConnection/Config/Reader.php | 2 +- .../Magento/Framework/App/Response/Http.php | 8 +- .../Magento/Framework/App/ResponseFactory.php | 2 +- .../App/Route/ConfigInterface/Proxy.php | 2 +- .../Framework/App/Router/ActionList.php | 2 +- .../Magento/Framework/App/Router/Base.php | 2 +- .../Framework/App/Router/DefaultRouter.php | 2 +- .../App/Test/Unit/AclResourceTest.php | 6 +- .../Test/Unit/Action/AbstractActionTest.php | 15 ++-- .../App/Test/Unit/Action/ActionTest.php | 30 +++++--- .../App/Test/Unit/Action/ForwardTest.php | 12 +-- .../Test/Unit/Action/Plugin/DesignTest.php | 8 +- .../App/Test/Unit/ActionFlagTest.php | 2 +- .../Framework/App/Test/Unit/AreaListTest.php | 12 +-- .../Framework/App/Test/Unit/AreaTest.php | 52 ++++++------- .../Arguments/ArgumentInterpreterTest.php | 2 +- .../Arguments/FileResolver/PrimaryTest.php | 6 +- .../Framework/App/Test/Unit/BootstrapTest.php | 54 +++++++++----- .../Test/Unit/Cache/Frontend/FactoryTest.php | 20 ++--- .../App/Test/Unit/Cache/Frontend/PoolTest.php | 18 ++--- .../App/Test/Unit/Cache/ManagerTest.php | 18 ++--- .../App/Test/Unit/Cache/StateTest.php | 4 +- .../Test/Unit/Cache/Type/AccessProxyTest.php | 4 +- .../App/Test/Unit/Cache/Type/ConfigTest.php | 10 +-- .../Test/Unit/Cache/Type/FrontendPoolTest.php | 12 +-- .../App/Test/Unit/Cache/Type/GenericTest.php | 16 ++-- .../App/Test/Unit/Cache/TypeListTest.php | 12 +-- .../Framework/App/Test/Unit/CacheTest.php | 10 +-- .../App/Test/Unit/Config/BaseFactoryTest.php | 4 +- .../Unit/Config/Data/ProcessorFactoryTest.php | 24 +++--- .../App/Test/Unit/Config/DataFactoryTest.php | 4 +- .../App/Test/Unit/Config/DataTest.php | 2 +- .../App/Test/Unit/Config/ElementTest.php | 4 +- .../App/Test/Unit/Config/FileResolverTest.php | 8 +- .../Test/Unit/Config/Initial/ReaderTest.php | 12 +-- .../Unit/Config/Initial/SchemaLocatorTest.php | 4 +- .../App/Test/Unit/Config/InitialTest.php | 4 +- .../Unit/Config/MetadataProcessorTest.php | 6 +- .../App/Test/Unit/Config/ScopePoolTest.php | 20 ++--- .../Test/Unit/Config/Storage/WriterTest.php | 4 +- .../App/Test/Unit/Config/ValueFactoryTest.php | 4 +- .../App/Test/Unit/Config/ValueTest.php | 8 +- .../Framework/App/Test/Unit/CronTest.php | 16 ++-- .../Test/Unit/DeploymentConfig/ReaderTest.php | 14 ++-- .../Test/Unit/DeploymentConfig/WriterTest.php | 14 ++-- .../App/Test/Unit/DeploymentConfigTest.php | 2 +- .../Unit/Filesystem/DirectoryListTest.php | 2 +- .../App/Test/Unit/FrontControllerTest.php | 16 ++-- .../App/Test/Unit/Http/ContextTest.php | 2 +- .../Framework/App/Test/Unit/HttpTest.php | 39 +++++----- .../App/Test/Unit/Language/ConfigTest.php | 12 ++- .../App/Test/Unit/Language/DictionaryTest.php | 24 ++++-- .../App/Test/Unit/MaintenanceModeTest.php | 4 +- .../Unit/ObjectManager/ConfigCacheTest.php | 2 +- .../Unit/ObjectManager/ConfigLoaderTest.php | 10 +-- .../Environment/CompiledTest.php | 4 +- .../Environment/DeveloperTest.php | 28 +++---- .../App/Test/Unit/PageCache/FormKeyTest.php | 10 +-- .../Test/Unit/PageCache/IdentifierTest.php | 6 +- .../App/Test/Unit/PageCache/KernelTest.php | 12 +-- .../App/Test/Unit/PageCache/PageCacheTest.php | 4 +- .../App/Test/Unit/PageCache/VersionTest.php | 10 +-- .../App/Test/Unit/ProductMetadataTest.php | 4 +- .../App/Test/Unit/ReinitableConfigTest.php | 6 +- .../App/Test/Unit/Request/HttpTest.php | 16 ++-- .../App/Test/Unit/RequestFactoryTest.php | 6 +- .../ResourceConnection/Config/ReaderTest.php | 10 +-- .../Config/SchemaLocatorTest.php | 2 +- .../Unit/ResourceConnection/ConfigTest.php | 10 +-- .../ConnectionFactoryTest.php | 18 ++--- .../HeaderProvider/XFrameOptionsTest.php | 2 +- .../HeaderProvider/XssProtectionTest.php | 4 +- .../Unit/Response/Http/FileFactoryTest.php | 16 ++-- .../App/Test/Unit/Response/HttpTest.php | 31 ++++---- .../App/Test/Unit/ResponseFactoryTest.php | 6 +- .../Unit/Route/Config/SchemaLocatorTest.php | 2 +- .../Unit/Route/ConfigInterface/ProxyTest.php | 8 +- .../App/Test/Unit/Route/ConfigTest.php | 8 +- .../App/Test/Unit/Router/ActionListTest.php | 12 +-- .../App/Test/Unit/Router/BaseTest.php | 26 +++---- .../Test/Unit/Router/DefaultRouterTest.php | 22 ++++-- .../Unit/Router/NoRouteHandlerListTest.php | 14 ++-- .../Test/Unit/Router/NoRouteHandlerTest.php | 7 +- .../App/Test/Unit/RouterListTest.php | 2 +- .../App/Test/Unit/ScopeResolverPoolTest.php | 20 ++--- .../Framework/App/Test/Unit/ShellTest.php | 4 +- .../App/Test/Unit/State/CleanupFilesTest.php | 4 +- .../Framework/App/Test/Unit/StateTest.php | 10 +-- .../App/Test/Unit/StaticResourceTest.php | 25 ++++--- .../Unit/Utility/AggregateInvokerTest.php | 2 +- .../App/Test/Unit/Utility/FilesTest.php | 10 ++- .../MaterializationStrategy/CopyTest.php | 6 +- .../MaterializationStrategy/FactoryTest.php | 12 +-- .../MaterializationStrategy/SymlinkTest.php | 6 +- .../Test/Unit/View/Asset/PublisherTest.php | 28 +++++-- .../Deployment/Version/Storage/FileTest.php | 4 +- .../Test/Unit/View/Deployment/VersionTest.php | 4 +- .../Framework/App/Test/Unit/ViewTest.php | 32 ++++---- .../Magento/Framework/App/Utility/Classes.php | 5 +- .../Magento/Framework/App/Utility/Files.php | 7 ++ .../Asset/MaterializationStrategy/Factory.php | 2 +- .../Framework/Archive/Test/Unit/ZipTest.php | 4 +- .../Framework/Authorization/Factory.php | 2 +- .../Test/Unit/Policy/AclTest.php | 4 +- .../Test/Unit/ClassLoaderWrapperTest.php | 4 +- .../Autoload/Test/Unit/PopulatorTest.php | 4 +- .../Backup/Test/Unit/FactoryTest.php | 2 +- .../Framework/Backup/Test/Unit/MediaTest.php | 8 +- .../Backup/Test/Unit/NomediaTest.php | 8 +- .../Backup/Test/Unit/SnapshotTest.php | 6 +- .../Framework/Cache/Backend/Eaccelerator.php | 6 +- .../Magento/Framework/Cache/Config/Reader.php | 2 +- .../Cache/Test/Unit/Backend/DatabaseTest.php | 72 +++++++++--------- .../Backend/Decorator/CompressionTest.php | 17 +++-- .../Decorator/DecoratorAbstractTest.php | 14 ++-- .../Cache/Test/Unit/Backend/MongoDbTest.php | 4 +- .../Test/Unit/Config/SchemaLocatorTest.php | 2 +- .../Test/Unit/Config/_files/cache_config.php | 4 +- .../Framework/Cache/Test/Unit/ConfigTest.php | 2 +- .../Framework/Cache/Test/Unit/CoreTest.php | 23 +++--- .../Cache/Test/Unit/CoreTestMock.php | 10 +++ .../Test/Unit/Frontend/Adapter/ZendTest.php | 8 +- .../Test/Unit/Frontend/Decorator/BareTest.php | 6 +- .../Unit/Frontend/Decorator/ProfilerTest.php | 16 ++-- .../Unit/Frontend/Decorator/TagScopeTest.php | 2 +- .../Cache/Test/Unit/InvalidateLoggerTest.php | 4 +- .../Code/Generator/EntityAbstract.php | 2 +- .../Code/Generator/InterfaceGenerator.php | 2 +- .../Unit/Generator/DefinedClassesTest.php | 2 +- .../Unit/Generator/EntityAbstractTest.php | 64 +++++++++------- .../Unit/Generator/InterfaceGeneratorTest.php | 8 +- .../Code/Test/Unit/Generator/IoTest.php | 4 +- .../Code/Test/Unit/GeneratorTest.php | 20 ++--- .../Validator/NotProtectedExtensionTest.php | 6 +- .../Code/Test/Unit/NameBuilderTest.php | 5 +- .../Unit/Validator/ArgumentSequenceTest.php | 2 +- .../ConstructorArgumentTypesTest.php | 8 +- .../Validator/ConstructorIntegrityTest.php | 22 +++--- .../Unit/Validator/ContextAggregationTest.php | 4 +- .../Unit/Validator/TypeDuplicationTest.php | 2 +- .../Code/Test/Unit/ValidatorTest.php | 4 +- .../Code/Validator/ArgumentSequence.php | 2 +- .../Code/Validator/ContextAggregation.php | 2 +- .../Communication/Config/Reader/XmlReader.php | 2 +- .../Component/Test/Unit/DirSearchTest.php | 16 +++- .../Test/Unit/DependencyCheckerTest.php | 8 +- .../Magento/Framework/Config/DomFactory.php | 2 +- .../Framework/Config/Reader/Filesystem.php | 2 +- .../Config/Test/Unit/Composer/PackageTest.php | 2 +- .../Config/Test/Unit/Data/ScopedTest.php | 6 +- .../Framework/Config/Test/Unit/DataTest.php | 4 +- .../Test/Unit/Dom/ArrayNodeConfigTest.php | 2 +- .../Test/Unit/Dom/NodeMergingConfigTest.php | 2 +- .../Config/Test/Unit/Dom/UrnResolverTest.php | 2 +- .../Framework/Config/Test/Unit/DomTest.php | 4 +- .../Config/Test/Unit/FileIteratorTest.php | 10 ++- .../Test/Unit/Reader/FilesystemTest.php | 8 +- .../Framework/Config/Test/Unit/ScopeTest.php | 2 +- .../Framework/Config/Test/Unit/ThemeTest.php | 2 +- .../Config/Test/Unit/ViewFactoryTest.php | 28 +++---- .../Magento/Framework/Config/View.php | 2 +- .../Magento/Framework/Config/ViewFactory.php | 6 +- .../Magento/Framework/Console/Cli.php | 8 +- .../Controller/Result/JsonFactory.php | 2 +- .../Controller/Result/RedirectFactory.php | 2 +- .../Test/Unit/Controller/Index/IndexTest.php | 2 +- .../Test/Unit/Controller/NorouteTest.php | 8 +- .../Test/Unit/Result/ForwardTest.php | 17 +++-- .../Controller/Test/Unit/Result/JsonTest.php | 6 +- .../Controller/Test/Unit/Result/RawTest.php | 6 +- .../Test/Unit/Result/RedirectFactoryTest.php | 9 ++- .../Test/Unit/Result/RedirectTest.php | 24 +++--- .../Test/Unit/Router/Route/FactoryTest.php | 8 +- .../Framework/Convert/ExcelFactory.php | 2 +- .../Convert/Test/Unit/ExcelFactoryTest.php | 8 +- .../Convert/Test/Unit/ObjectTest.php | 12 +-- .../File/Collector/Aggregated.php | 2 +- .../PreProcessor/File/Collector/Library.php | 2 +- .../Adapter/Less/ProcessorTest.php | 10 +-- .../File/Collector/AggregatedTest.php | 16 ++-- .../File/Collector/LibraryTest.php | 30 ++++---- .../File/FileList/CollatorTest.php | 2 +- .../PreProcessor/Instruction/ImportTest.php | 6 +- .../Instruction/MagentoImportTest.php | 23 +++--- .../Framework/DB/Adapter/Pdo/Mysql.php | 2 +- .../Framework/DB/Ddl/TriggerFactory.php | 2 +- .../Magento/Framework/DB/QueryBuilder.php | 2 +- .../Framework/DB/Select/RendererProxy.php | 2 +- .../DB/Test/Unit/AbstractMapperTest.php | 24 +++--- .../DB/Test/Unit/Adapter/Pdo/MysqlTest.php | 26 +++---- .../DB/Test/Unit/GenericMapperTest.php | 16 ++-- .../Test/Unit/Helper/AbstractHelperTest.php | 6 +- .../Test/Unit/Helper/Mysql/FulltextTest.php | 10 +-- .../DB/Test/Unit/Logger/FileTest.php | 8 +- .../DB/Test/Unit/Platform/QuoteTest.php | 6 +- .../Framework/DB/Test/Unit/QueryTest.php | 20 ++--- .../Test/Unit/Select/ColumnsRendererTest.php | 12 ++- .../Test/Unit/Select/DistinctRendererTest.php | 4 +- .../Unit/Select/ForUpdateRendererTest.php | 4 +- .../DB/Test/Unit/Select/FromRendererTest.php | 6 +- .../DB/Test/Unit/Select/GroupRendererTest.php | 12 ++- .../Test/Unit/Select/HavingRendererTest.php | 4 +- .../DB/Test/Unit/Select/LimitRendererTest.php | 4 +- .../DB/Test/Unit/Select/OrderRendererTest.php | 4 +- .../DB/Test/Unit/Select/RendererProxyTest.php | 8 +- .../Test/Unit/Select/SelectRendererTest.php | 4 +- .../DB/Test/Unit/Select/UnionRendererTest.php | 4 +- .../DB/Test/Unit/Select/WhereRendererTest.php | 4 +- .../DB/Test/Unit/SelectFactoryTest.php | 6 +- .../Framework/DB/Test/Unit/SelectTest.php | 2 +- .../DB/Test/Unit/Sql/UnionExpressionTest.php | 2 +- .../Framework/DB/Test/Unit/Tree/NodeTest.php | 9 +-- .../Framework/Data/AbstractSearchResult.php | 2 +- .../Magento/Framework/Data/Collection.php | 4 +- .../Data/Form/Element/CollectionFactory.php | 2 +- .../Framework/Data/Form/Element/Gallery.php | 4 +- .../Framework/Data/Form/FilterFactory.php | 2 +- .../Magento/Framework/Data/FormFactory.php | 2 +- .../Framework/Data/SearchResultProcessor.php | 2 +- .../Data/SearchResultProcessorFactory.php | 2 +- .../Data/Test/Unit/AbstractCriteriaTest.php | 4 +- .../Data/Test/Unit/AbstractDataObjectTest.php | 8 +- .../Test/Unit/AbstractSearchResultTest.php | 18 ++--- .../Argument/Interpreter/ArrayTypeTest.php | 2 +- .../Unit/Argument/Interpreter/BooleanTest.php | 2 +- .../Argument/Interpreter/CompositeTest.php | 12 +-- .../Collection/Db/FetchStrategy/CacheTest.php | 6 +- .../Collection/Db/FetchStrategy/QueryTest.php | 4 +- .../Data/Test/Unit/Collection/DbTest.php | 63 ++++++++-------- .../Test/Unit/Collection/FilesystemTest.php | 2 +- .../Data/Test/Unit/CollectionTest.php | 16 ++-- .../Data/Test/Unit/Form/AbstractFormTest.php | 11 +-- .../Unit/Form/Element/AbstractElementTest.php | 43 +++++------ .../Test/Unit/Form/Element/ButtonTest.php | 6 +- .../Test/Unit/Form/Element/CheckboxTest.php | 6 +- .../Form/Element/CollectionFactoryTest.php | 6 +- .../Test/Unit/Form/Element/ColumnTest.php | 6 +- .../Data/Test/Unit/Form/Element/DateTest.php | 10 +-- .../Form/Element/EditablemultiselectTest.php | 2 +- .../Test/Unit/Form/Element/EditorTest.php | 16 ++-- .../Test/Unit/Form/Element/FactoryTest.php | 10 ++- .../Data/Test/Unit/Form/Element/FileTest.php | 6 +- .../Test/Unit/Form/Element/HiddenTest.php | 6 +- .../Data/Test/Unit/Form/Element/ImageTest.php | 8 +- .../Test/Unit/Form/Element/ImagefileTest.php | 6 +- .../Data/Test/Unit/Form/Element/LabelTest.php | 6 +- .../Data/Test/Unit/Form/Element/LinkTest.php | 6 +- .../Test/Unit/Form/Element/MultilineTest.php | 6 +- .../Unit/Form/Element/MultiselectTest.php | 2 +- .../Data/Test/Unit/Form/Element/NoteTest.php | 6 +- .../Test/Unit/Form/Element/ObscureTest.php | 6 +- .../Test/Unit/Form/Element/PasswordTest.php | 6 +- .../Data/Test/Unit/Form/Element/RadioTest.php | 6 +- .../Data/Test/Unit/Form/Element/ResetTest.php | 6 +- .../Test/Unit/Form/Element/SubmitTest.php | 6 +- .../Data/Test/Unit/Form/Element/TextTest.php | 6 +- .../Test/Unit/Form/Element/TextareaTest.php | 6 +- .../Data/Test/Unit/Form/FilterFactoryTest.php | 6 +- .../Test/Unit/Form/FormKey/ValidatorTest.php | 4 +- .../Data/Test/Unit/Form/FormKeyTest.php | 6 +- .../Data/Test/Unit/FormFactoryTest.php | 4 +- .../Framework/Data/Test/Unit/FormTest.php | 18 ++--- .../Data/Test/Unit/Helper/PostHelperTest.php | 4 +- .../Test/Unit/SearchCriteriaBuilderTest.php | 6 +- .../Test/Unit/SearchResultProcessorTest.php | 4 +- .../Test/Unit/Stub/SearchCriteriaBuilder.php | 2 +- .../Test/Unit/Tree/Node/CollectionTest.php | 2 +- .../Framework/Data/Tree/NodeFactory.php | 2 +- .../Magento/Framework/Data/TreeFactory.php | 2 +- .../DataObject/Copy/Config/Data/Proxy.php | 2 +- .../DataObject/Copy/Config/Reader.php | 2 +- .../Unit/Copy/Config/SchemaLocatorTest.php | 2 +- .../DataObject/Test/Unit/Copy/ConfigTest.php | 2 +- .../DataObject/Test/Unit/CopyTest.php | 18 ++--- .../DataObject/Test/Unit/MapperTest.php | 4 +- .../Encryption/Test/Unit/EncryptorTest.php | 10 +-- .../Encryption/Test/Unit/UrlCoderTest.php | 2 +- .../Sequence/SequenceFactory.php | 2 +- .../Magento/Framework/Event/Config/Reader.php | 2 +- .../Event/Invoker/InvokerDefault.php | 3 +- .../Event/Test/Unit/CollectionTest.php | 6 +- .../Test/Unit/Config/SchemaLocatorTest.php | 2 +- .../Framework/Event/Test/Unit/ConfigTest.php | 9 ++- .../Test/Unit/Invoker/InvokerDefaultTest.php | 8 +- .../Test/Unit/Observer/CollectionTest.php | 4 +- .../Event/Test/Unit/Observer/CronTest.php | 2 +- .../Event/Test/Unit/Observer/RegexTest.php | 2 +- .../Event/Test/Unit/ObserverFactoryTest.php | 6 +- .../Event/Test/Unit/ObserverTest.php | 8 +- .../Event/Test/Unit/WrapperFactoryTest.php | 4 +- .../Framework/Event/WrapperFactory.php | 2 +- .../Test/Unit/LocalizedExceptionTest.php | 2 +- .../Test/Unit/NoSuchEntityExceptionTest.php | 2 +- .../Test/Unit/State/ExpiredExceptionTest.php | 2 +- .../Unit/State/InputMismatchExceptionTest.php | 2 +- .../State/InvalidTransitionExceptionTest.php | 2 +- .../Test/Unit/StateExceptionTest.php | 4 +- lib/internal/Magento/Framework/File/Size.php | 4 +- .../Framework/File/Test/Unit/CsvTest.php | 8 +- .../Test/Unit/Transfer/Adapter/HttpTest.php | 4 +- .../Framework/File/UploaderFactory.php | 2 +- .../Framework/Filesystem/DriverPool.php | 10 +-- .../Test/Unit/Directory/ReadTest.php | 4 +- .../Test/Unit/Directory/WriteTest.php | 9 +-- .../Filesystem/Test/Unit/DriverPoolTest.php | 12 +-- .../Test/Unit/File/ExcludeFilterTest.php | 4 +- .../Test/Unit/File/ReadFactoryTest.php | 12 +-- .../Filesystem/Test/Unit/File/ReadTest.php | 6 +- .../Test/Unit/File/WriteFactoryTest.php | 18 ++--- .../Filesystem/Test/Unit/File/WriteTest.php | 10 +-- .../Filesystem/Test/Unit/FileResolverTest.php | 2 +- .../Magento/Framework/Filter/Factory.php | 44 +++++------ .../Framework/Filter/FilterManager/Config.php | 2 +- .../Magento/Framework/Filter/Input.php | 2 +- .../Filter/Test/Unit/AbstractFactoryTest.php | 26 +++---- .../Filter/Test/Unit/ArrayFilterTest.php | 4 +- .../Filter/Test/Unit/DataObject/GridTest.php | 8 +- .../Test/Unit/FilterManager/ConfigTest.php | 4 +- .../Filter/Test/Unit/FilterManagerTest.php | 20 ++--- .../Framework/Filter/Test/Unit/InputTest.php | 6 +- .../Filter/Test/Unit/TemplateTest.php | 8 +- .../Filter/Test/Unit/TranslitTest.php | 6 +- .../Filter/Test/Unit/TranslitUrlTest.php | 2 +- 381 files changed, 1730 insertions(+), 1549 deletions(-) create mode 100644 lib/internal/Magento/Framework/Cache/Test/Unit/CoreTestMock.php diff --git a/lib/internal/Magento/Framework/Acl/AclResource/Config/Reader/Filesystem.php b/lib/internal/Magento/Framework/Acl/AclResource/Config/Reader/Filesystem.php index 5da74a6899458..483fa70114651 100644 --- a/lib/internal/Magento/Framework/Acl/AclResource/Config/Reader/Filesystem.php +++ b/lib/internal/Magento/Framework/Acl/AclResource/Config/Reader/Filesystem.php @@ -31,7 +31,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'acl.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Acl/AclResourceFactory.php b/lib/internal/Magento/Framework/Acl/AclResourceFactory.php index 4e523ab4c34ab..b1c4bf969a807 100644 --- a/lib/internal/Magento/Framework/Acl/AclResourceFactory.php +++ b/lib/internal/Magento/Framework/Acl/AclResourceFactory.php @@ -11,7 +11,7 @@ class AclResourceFactory { - const RESOURCE_CLASS_NAME = 'Magento\Framework\Acl\AclResource'; + const RESOURCE_CLASS_NAME = \Magento\Framework\Acl\AclResource::class; /** * @var ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/Config/SchemaLocatorTest.php index 5389797539957..195037003d898 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/Config/SchemaLocatorTest.php @@ -11,7 +11,7 @@ public function testGetSchema() { $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolverMock->expects($this->once()) ->method('getRealPath') ->with('urn:magento:framework:Acl/etc/acl.xsd') diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/ProviderTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/ProviderTest.php index 11e0369d98d95..1d46d4eac48aa 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/ProviderTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/AclResource/ProviderTest.php @@ -24,9 +24,9 @@ class ProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_configReaderMock = $this->getMock('Magento\Framework\Config\ReaderInterface'); + $this->_configReaderMock = $this->getMock(\Magento\Framework\Config\ReaderInterface::class); $this->_treeBuilderMock = $this->getMock( - 'Magento\Framework\Acl\AclResource\TreeBuilder', + \Magento\Framework\Acl\AclResource\TreeBuilder::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/BuilderTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/BuilderTest.php index 40ef911dd677f..d88d1d600f566 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/BuilderTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/BuilderTest.php @@ -45,12 +45,12 @@ class BuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_aclMock = new \Magento\Framework\Acl(); - $this->_aclCacheMock = $this->getMock('Magento\Framework\Acl\CacheInterface'); - $this->_aclFactoryMock = $this->getMock('Magento\Framework\AclFactory', [], [], '', false); + $this->_aclCacheMock = $this->getMock(\Magento\Framework\Acl\CacheInterface::class); + $this->_aclFactoryMock = $this->getMock(\Magento\Framework\AclFactory::class, [], [], '', false); $this->_aclFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_aclMock)); - $this->_roleLoader = $this->getMock('Magento\Framework\Acl\Loader\DefaultLoader'); - $this->_ruleLoader = $this->getMock('Magento\Framework\Acl\Loader\DefaultLoader'); - $this->_resourceLoader = $this->getMock('Magento\Framework\Acl\Loader\DefaultLoader'); + $this->_roleLoader = $this->getMock(\Magento\Framework\Acl\Loader\DefaultLoader::class); + $this->_ruleLoader = $this->getMock(\Magento\Framework\Acl\Loader\DefaultLoader::class); + $this->_resourceLoader = $this->getMock(\Magento\Framework\Acl\Loader\DefaultLoader::class); $this->_model = new \Magento\Framework\Acl\Builder( $this->_aclFactoryMock, $this->_aclCacheMock, diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php index d6af07a3e34d4..d0c6515b1ce79 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php @@ -27,7 +27,7 @@ class CacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cacheConfig = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->cacheConfig = $this->getMock(\Magento\Framework\Config\CacheInterface::class); $this->cacheKey = 'test_key'; $this->model = new Cache($this->cacheConfig, $this->cacheKey); @@ -98,7 +98,7 @@ protected function initAcl($aclData) public function testSave() { - $acl = $this->getMockBuilder('Magento\Framework\Acl')->disableOriginalConstructor()->getMock(); + $acl = $this->getMockBuilder(\Magento\Framework\Acl::class)->disableOriginalConstructor()->getMock(); $this->cacheConfig->expects($this->once())->method('save')->with(serialize($acl), $this->cacheKey); $this->model->save($acl); diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/DefaultTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/DefaultTest.php index 6da38392dac45..ca7504abe0710 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/DefaultTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/DefaultTest.php @@ -19,7 +19,7 @@ protected function setUp() public function testPopulateAclDoesntChangeAclObject() { - $aclMock = $this->getMock('Magento\Framework\Acl'); + $aclMock = $this->getMock(\Magento\Framework\Acl::class); $aclMock->expects($this->never())->method('addRole'); $aclMock->expects($this->never())->method('addResource'); $aclMock->expects($this->never())->method('allow'); diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/ResourceLoaderTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/ResourceLoaderTest.php index df881914e191e..50d0665bc64d8 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/ResourceLoaderTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/Loader/ResourceLoaderTest.php @@ -15,16 +15,16 @@ class ResourceLoaderTest extends \PHPUnit_Framework_TestCase public function testPopulateAclOnValidObjects() { /** @var $aclResource \Magento\Framework\Acl\AclResource */ - $aclResource = $this->getMock('Magento\Framework\Acl\AclResource', [], [], '', false); + $aclResource = $this->getMock(\Magento\Framework\Acl\AclResource::class, [], [], '', false); /** @var $acl \Magento\Framework\Acl */ - $acl = $this->getMock('Magento\Framework\Acl', ['addResource'], [], '', false); + $acl = $this->getMock(\Magento\Framework\Acl::class, ['addResource'], [], '', false); $acl->expects($this->exactly(2))->method('addResource'); $acl->expects($this->at(0))->method('addResource')->with($aclResource, null)->will($this->returnSelf()); $acl->expects($this->at(1))->method('addResource')->with($aclResource, $aclResource)->will($this->returnSelf()); $factoryObject = $this->getMock( - 'Magento\Framework\Acl\AclResourceFactory', + \Magento\Framework\Acl\AclResourceFactory::class, ['createResource'], [], '', @@ -33,7 +33,7 @@ public function testPopulateAclOnValidObjects() $factoryObject->expects($this->any())->method('createResource')->will($this->returnValue($aclResource)); /** @var $resourceProvider \Magento\Framework\Acl\AclResource\ProviderInterface */ - $resourceProvider = $this->getMock('Magento\Framework\Acl\AclResource\ProviderInterface'); + $resourceProvider = $this->getMock(\Magento\Framework\Acl\AclResource\ProviderInterface::class); $resourceProvider->expects($this->once()) ->method('getAclResources') ->will( @@ -71,9 +71,9 @@ public function testPopulateAclOnValidObjects() public function testPopulateAclWithException() { /** @var $aclResource \Magento\Framework\Acl\AclResource */ - $aclResource = $this->getMock('Magento\Framework\Acl\AclResource', [], [], '', false); + $aclResource = $this->getMock(\Magento\Framework\Acl\AclResource::class, [], [], '', false); - $factoryObject = $this->getMockBuilder('Magento\Framework\Acl\AclResourceFactory') + $factoryObject = $this->getMockBuilder(\Magento\Framework\Acl\AclResourceFactory::class) ->setMethods(['createResource']) ->disableOriginalConstructor() ->getMock(); @@ -81,7 +81,7 @@ public function testPopulateAclWithException() $factoryObject->expects($this->any())->method('createResource')->will($this->returnValue($aclResource)); /** @var $resourceProvider \Magento\Framework\Acl\AclResource\ProviderInterface */ - $resourceProvider = $this->getMock('Magento\Framework\Acl\AclResource\ProviderInterface'); + $resourceProvider = $this->getMock(\Magento\Framework\Acl\AclResource\ProviderInterface::class); $resourceProvider->expects($this->once()) ->method('getAclResources') ->will( @@ -104,7 +104,7 @@ public function testPopulateAclWithException() ); /** @var $acl \Magento\Framework\Acl */ - $acl = $this->getMock('Magento\Framework\Acl', ['addResource'], [], '', false); + $acl = $this->getMock(\Magento\Framework\Acl::class, ['addResource'], [], '', false); /** @var $loaderResource \Magento\Framework\Acl\Loader\ResourceLoader */ $loaderResource = new \Magento\Framework\Acl\Loader\ResourceLoader($resourceProvider, $factoryObject); diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/ResourceFactoryTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/ResourceFactoryTest.php index 01c670c782668..61758cb288b34 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/ResourceFactoryTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/ResourceFactoryTest.php @@ -28,12 +28,12 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->_expectedObject = $this->getMock('Magento\Framework\Acl\AclResource', [], [], '', false); + $this->_expectedObject = $this->getMock(\Magento\Framework\Acl\AclResource::class, [], [], '', false); $this->_model = $helper->getObject( - 'Magento\Framework\Acl\AclResourceFactory', + \Magento\Framework\Acl\AclResourceFactory::class, ['objectManager' => $this->_objectManager] ); } @@ -46,7 +46,7 @@ public function testCreateResource() )->method( 'create' )->with( - 'Magento\Framework\Acl\AclResource', + \Magento\Framework\Acl\AclResource::class, $arguments )->will( $this->returnValue($this->_expectedObject) diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php index 1a072923ea642..f6fc13b939903 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php @@ -22,10 +22,10 @@ protected function setUp() protected function initRoles($roleId, $parentRoleId) { - $parentRole = $this->getMock('Zend_Acl_Role_Interface'); + $parentRole = $this->getMock(\Zend_Acl_Role_Interface::class); $parentRole->expects($this->any())->method('getRoleId')->will($this->returnValue($parentRoleId)); - $role = $this->getMock('Zend_Acl_Role_Interface'); + $role = $this->getMock(\Zend_Acl_Role_Interface::class); $role->expects($this->any())->method('getRoleId')->will($this->returnValue($roleId)); $this->model->add($role); diff --git a/lib/internal/Magento/Framework/Api/AttributeValueFactory.php b/lib/internal/Magento/Framework/Api/AttributeValueFactory.php index 57489100603e4..c9b19b91fd0a4 100644 --- a/lib/internal/Magento/Framework/Api/AttributeValueFactory.php +++ b/lib/internal/Magento/Framework/Api/AttributeValueFactory.php @@ -14,7 +14,7 @@ class AttributeValueFactory /** * Entity class name */ - const CLASS_NAME = 'Magento\Framework\Api\AttributeValue'; + const CLASS_NAME = \Magento\Framework\Api\AttributeValue::class; /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php index bcc3344e2adac..39f0e3c3b78a8 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php @@ -137,7 +137,7 @@ protected function _generateCode() */ protected function getExtendedClass() { - return '\Magento\Framework\Api\AbstractSimpleObject'; + return '\\' . \Magento\Framework\Api\AbstractSimpleObject::class; } /** diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php index 3a658da307f88..32eecc8910ec1 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php @@ -53,7 +53,7 @@ public function __construct( */ protected function getExtendedClass() { - return '\Magento\Framework\Api\ExtensionAttributesInterface'; + return '\\' . \Magento\Framework\Api\ExtensionAttributesInterface::class; } /** diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php b/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php index 614b769f58c79..21886b66e145d 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php @@ -104,7 +104,7 @@ protected function _getClassMethods() 'parameters' => [ [ 'name' => 'object', - 'type' => '\\Magento\Framework\Model\AbstractModel', + 'type' => '\\' . \Magento\Framework\Model\AbstractModel::class, ], ], 'body' => $body, diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php index 75619a7c12b3b..4e8ad74019919 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php @@ -20,11 +20,6 @@ class SearchResults extends EntityAbstract */ const ENTITY_TYPE = 'searchResults'; - /** - * Search result default class - */ - const SEARCH_RESULT = '\\Magento\Framework\Api\SearchResults'; - /** * Retrieve class properties * @@ -77,7 +72,7 @@ protected function _getDefaultConstructorDefinition() protected function _generateCode() { $this->_classGenerator->setName($this->_getResultClassName()) - ->setExtendedClass(self::SEARCH_RESULT) + ->setExtendedClass('\\' . \Magento\Framework\Api\SearchResults::class) ->addMethods($this->_getClassMethods()); return $this->_getGeneratedCode(); } diff --git a/lib/internal/Magento/Framework/Api/DataObjectHelper.php b/lib/internal/Magento/Framework/Api/DataObjectHelper.php index d951bee3d36f8..ca9b04f97c0b7 100644 --- a/lib/internal/Magento/Framework/Api/DataObjectHelper.php +++ b/lib/internal/Magento/Framework/Api/DataObjectHelper.php @@ -172,10 +172,10 @@ protected function setComplexValue( return $this; } - if (is_subclass_of($returnType, '\Magento\Framework\Api\ExtensibleDataInterface')) { + if (is_subclass_of($returnType, \Magento\Framework\Api\ExtensibleDataInterface::class)) { $object = $this->objectFactory->create($returnType, []); $this->populateWithArray($object, $value, $returnType); - } else if (is_subclass_of($returnType, '\Magento\Framework\Api\ExtensionAttributesInterface')) { + } else if (is_subclass_of($returnType, \Magento\Framework\Api\ExtensionAttributesInterface::class)) { $object = $this->extensionFactory->create(get_class($dataObject), ['data' => $value]); } else { $object = $this->objectFactory->create($returnType, $value); diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttribute/Config/Reader.php b/lib/internal/Magento/Framework/Api/ExtensionAttribute/Config/Reader.php index 1d11771f787c8..75d98d2412970 100644 --- a/lib/internal/Magento/Framework/Api/ExtensionAttribute/Config/Reader.php +++ b/lib/internal/Magento/Framework/Api/ExtensionAttribute/Config/Reader.php @@ -34,7 +34,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'extension_attributes.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinDataInterfaceFactory.php b/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinDataInterfaceFactory.php index 63613f6f58c74..184abb9e06d1e 100644 --- a/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinDataInterfaceFactory.php +++ b/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinDataInterfaceFactory.php @@ -34,7 +34,7 @@ class JoinDataInterfaceFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = '\\Magento\\Framework\\Api\\ExtensionAttribute\\JoinDataInterface' + $instanceName = \Magento\Framework\Api\ExtensionAttribute\JoinDataInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php b/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php index 68fe446aeaaf8..c849858735754 100644 --- a/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php +++ b/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php @@ -11,7 +11,7 @@ */ class ExtensionAttributesFactory { - const EXTENSIBLE_INTERFACE_NAME = 'Magento\Framework\Api\ExtensibleDataInterface'; + const EXTENSIBLE_INTERFACE_NAME = \Magento\Framework\Api\ExtensibleDataInterface::class; /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/Api/ImageProcessor.php b/lib/internal/Magento/Framework/Api/ImageProcessor.php index 768c8d8bdd4cd..73ea0e657f6dd 100644 --- a/lib/internal/Magento/Framework/Api/ImageProcessor.php +++ b/lib/internal/Magento/Framework/Api/ImageProcessor.php @@ -93,7 +93,7 @@ public function save( //Get all Image related custom attributes $imageDataObjects = $this->dataObjectHelper->getCustomAttributeValueByType( $dataObjectWithCustomAttributes->getCustomAttributes(), - '\Magento\Framework\Api\Data\ImageContentInterface' + \Magento\Framework\Api\Data\ImageContentInterface::class ); // Return if no images to process diff --git a/lib/internal/Magento/Framework/Api/Search/DocumentFactory.php b/lib/internal/Magento/Framework/Api/Search/DocumentFactory.php index 83ddf2f598d57..8e63f477bf029 100644 --- a/lib/internal/Magento/Framework/Api/Search/DocumentFactory.php +++ b/lib/internal/Magento/Framework/Api/Search/DocumentFactory.php @@ -27,7 +27,7 @@ class DocumentFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Api\Search\Document' + $instanceName = \Magento\Framework\Api\Search\Document::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Api/Search/SearchCriteriaFactory.php b/lib/internal/Magento/Framework/Api/Search/SearchCriteriaFactory.php index fd6e5a0c5e7b7..7e3a6316fa6ba 100644 --- a/lib/internal/Magento/Framework/Api/Search/SearchCriteriaFactory.php +++ b/lib/internal/Magento/Framework/Api/Search/SearchCriteriaFactory.php @@ -27,7 +27,7 @@ class SearchCriteriaFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Api\Search\SearchCriteria' + $instanceName = \Magento\Framework\Api\Search\SearchCriteria::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Api/Search/SearchResultFactory.php b/lib/internal/Magento/Framework/Api/Search/SearchResultFactory.php index bc8b892c5de2d..6b6714af2fac4 100644 --- a/lib/internal/Magento/Framework/Api/Search/SearchResultFactory.php +++ b/lib/internal/Magento/Framework/Api/Search/SearchResultFactory.php @@ -27,7 +27,7 @@ class SearchResultFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Api\Search\SearchResult' + $instanceName = \Magento\Framework\Api\Search\SearchResult::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageContentValidatorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageContentValidatorTest.php index 4f139760c9838..e57635a2d9750 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageContentValidatorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageContentValidatorTest.php @@ -26,7 +26,9 @@ class ImageContentValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->imageContentValidator = $this->objectManager->getObject('Magento\Framework\Api\ImageContentValidator'); + $this->imageContentValidator = $this->objectManager->getObject( + \Magento\Framework\Api\ImageContentValidator::class + ); } /** @@ -35,7 +37,7 @@ protected function setUp() */ public function testIsValidEmptyContent() { - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) @@ -51,7 +53,7 @@ public function testIsValidEmptyContent() */ public function testIsValidEmptyProperties() { - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) @@ -70,7 +72,7 @@ public function testIsValidInvalidMIMEType() $pathToImageFile = __DIR__ . '/_files/image.jpg'; $encodedData = @base64_encode(file_get_contents($pathToImageFile)); - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) @@ -92,7 +94,7 @@ public function testIsValidInvalidName() $pathToImageFile = __DIR__ . '/_files/image.jpg'; $encodedData = @base64_encode(file_get_contents($pathToImageFile)); - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) @@ -113,7 +115,7 @@ public function testIsValid() $pathToImageFile = __DIR__ . '/_files/image.jpg'; $encodedData = @base64_encode(file_get_contents($pathToImageFile)); - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php index 1ecca9c54e099..83d1a9ece7c18 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php @@ -57,25 +57,26 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->directoryWriteMock = $this->getMockForAbstractClass( - 'Magento\Framework\Filesystem\Directory\WriteInterface' + $this->directoryWriteMock = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class ); - $this->fileSystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->fileSystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); $this->fileSystemMock->expects($this->any()) ->method('getDirectoryWrite') ->willReturn($this->directoryWriteMock); - $this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface') + $this->contentValidatorMock = $this->getMockBuilder( + \Magento\Framework\Api\ImageContentValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->uploaderMock = $this->getMockBuilder('Magento\Framework\Api\Uploader') + $this->uploaderMock = $this->getMockBuilder(\Magento\Framework\Api\Uploader::class) ->setMethods( [ 'processFileAttributes', @@ -89,8 +90,8 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->imageProcessor = $this->objectManager->getObject( - 'Magento\Framework\Api\ImageProcessor', + $this->imageProcessor = $this->objectManager->getObject( + \Magento\Framework\Api\ImageProcessor::class, [ 'fileSystem' => $this->fileSystemMock, 'contentValidator' => $this->contentValidatorMock, @@ -103,7 +104,7 @@ protected function setUp() public function testSaveWithNoImageData() { - $imageDataMock = $this->getMockBuilder('Magento\Framework\Api\CustomAttributesDataInterface') + $imageDataMock = $this->getMockBuilder(\Magento\Framework\Api\CustomAttributesDataInterface::class) ->disableOriginalConstructor() ->getMock(); $imageDataMock->expects($this->once()) @@ -123,17 +124,17 @@ public function testSaveWithNoImageData() */ public function testSaveInputException() { - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); - $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + $imageDataObject = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); $imageDataObject->expects($this->once()) ->method('getValue') ->willReturn($imageContent); - $imageDataMock = $this->getMockBuilder('Magento\Framework\Api\CustomAttributesDataInterface') + $imageDataMock = $this->getMockBuilder(\Magento\Framework\Api\CustomAttributesDataInterface::class) ->disableOriginalConstructor() ->getMock(); $imageDataMock->expects($this->once()) @@ -153,7 +154,7 @@ public function testSaveInputException() public function testSaveWithNoPreviousData() { - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) @@ -166,14 +167,14 @@ public function testSaveWithNoPreviousData() ->method('getType') ->willReturn('image/jpg'); - $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + $imageDataObject = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); $imageDataObject->expects($this->once()) ->method('getValue') ->willReturn($imageContent); - $imageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $imageData = $this->getMockForAbstractClass(\Magento\Framework\Api\CustomAttributesDataInterface::class); $imageData->expects($this->once()) ->method('getCustomAttributes') ->willReturn([]); @@ -195,7 +196,7 @@ public function testSaveWithNoPreviousData() public function testSaveWithPreviousData() { - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->any()) @@ -205,14 +206,14 @@ public function testSaveWithPreviousData() ->method('getName') ->willReturn('testFileName.png'); - $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + $imageDataObject = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); $imageDataObject->expects($this->once()) ->method('getValue') ->willReturn($imageContent); - $imageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $imageData = $this->getMockForAbstractClass(\Magento\Framework\Api\CustomAttributesDataInterface::class); $imageData->expects($this->once()) ->method('getCustomAttributes') ->willReturn([]); @@ -229,12 +230,12 @@ public function testSaveWithPreviousData() ->method('getAbsolutePath') ->willReturn('testPath'); - $prevImageAttribute = $this->getMockForAbstractClass('Magento\Framework\Api\AttributeInterface'); + $prevImageAttribute = $this->getMockForAbstractClass(\Magento\Framework\Api\AttributeInterface::class); $prevImageAttribute->expects($this->once()) ->method('getValue') ->willReturn('testImagePath'); - $prevImageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $prevImageData = $this->getMockForAbstractClass(\Magento\Framework\Api\CustomAttributesDataInterface::class); $prevImageData->expects($this->once()) ->method('getCustomAttribute') ->willReturn($prevImageAttribute); @@ -248,7 +249,7 @@ public function testSaveWithPreviousData() */ public function testSaveWithoutFileExtension() { - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $imageContent->expects($this->once()) @@ -258,14 +259,14 @@ public function testSaveWithoutFileExtension() ->method('getName') ->willReturn('testFileName'); - $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + $imageDataObject = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); $imageDataObject->expects($this->once()) ->method('getValue') ->willReturn($imageContent); - $imageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $imageData = $this->getMockForAbstractClass(\Magento\Framework\Api\CustomAttributesDataInterface::class); $imageData->expects($this->once()) ->method('getCustomAttributes') ->willReturn([]); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php index b69ecc0894d1f..87d99908cd2ef 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php @@ -44,20 +44,20 @@ protected function setUp() require_once __DIR__ . '/Sample.php'; $this->ioObjectMock = $this->getMock( - 'Magento\Framework\Code\Generator\Io', + \Magento\Framework\Code\Generator\Io::class, [], [], '', false ); $this->classGenerator = $this->getMock( - 'Magento\Framework\Code\Generator\ClassGenerator', + \Magento\Framework\Code\Generator\ClassGenerator::class, [], [], '', false ); - $this->definedClassesMock = $this->getMockBuilder('Magento\Framework\Code\Generator\DefinedClasses') + $this->definedClassesMock = $this->getMockBuilder(\Magento\Framework\Code\Generator\DefinedClasses::class) ->disableOriginalConstructor()->getMock(); $objectManager = new ObjectManager($this); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php index bfdb3a0a2e8ac..43d066669b9e6 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php @@ -22,17 +22,17 @@ class ExtensionAttributesGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\Config') + $this->configMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttribute\Config::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator', + \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator::class, [ 'config' => $this->configMock, - 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', - 'resultClassName' => '\Magento\Catalog\Api\Data\ProductExtension', + 'sourceClassName' => \Magento\Catalog\Api\Data\Product::class, + 'resultClassName' => \Magento\Catalog\Api\Data\ProductExtension::class, 'classGenerator' => null ] ); @@ -45,7 +45,7 @@ public function testGenerate() ->method('get') ->willReturn( [ - 'Magento\Catalog\Api\Data\ProductInterface' => [ + \Magento\Catalog\Api\Data\ProductInterface::class => [ 'string_attribute' => [ Converter::DATA_TYPE => 'string', Converter::RESOURCE_PERMISSIONS => [], @@ -56,7 +56,7 @@ public function testGenerate() Converter::RESOURCE_PERMISSIONS => [], ], ], - 'Magento\Catalog\Api\Data\Product' => [ + \Magento\Catalog\Api\Data\Product::class => [ 'should_not_include' => [ Converter::DATA_TYPE => 'string', Converter::RESOURCE_PERMISSIONS => [], @@ -72,7 +72,7 @@ public function testGenerateEmptyExtension() { $this->configMock->expects($this->any()) ->method('get') - ->willReturn(['Magento\Catalog\Api\Data\Product' => ['should_not_include' => 'string']]); + ->willReturn([\Magento\Catalog\Api\Data\Product::class => ['should_not_include' => 'string']]); $expectedResult = file_get_contents(__DIR__ . '/_files/SampleEmptyExtension.txt'); $this->validateGeneratedCode($expectedResult); } @@ -82,10 +82,10 @@ public function testValidateException() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator $model */ $model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator', + \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator::class, [ - 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', - 'resultClassName' => '\Magento\Catalog\Api\Data\ProductInterface' + 'sourceClassName' => \Magento\Catalog\Api\Data\Product::class, + 'resultClassName' => \Magento\Catalog\Api\Data\ProductInterface::class ] ); $reflectionObject = new \ReflectionObject($model); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php index e01121b13881c..7a5a80abe8cc5 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php @@ -13,14 +13,14 @@ class ExtensionAttributesInterfaceGeneratorTest extends \PHPUnit_Framework_TestC public function testGenerate() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $configMock = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\Config') + $configMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttribute\Config::class) ->disableOriginalConstructor() ->getMock(); $configMock->expects($this->any()) ->method('get') ->willReturn( [ - 'Magento\Catalog\Api\Data\ProductInterface' => [ + \Magento\Catalog\Api\Data\ProductInterface::class => [ 'string_attribute' => [ Converter::DATA_TYPE => 'string', Converter::RESOURCE_PERMISSIONS => [], @@ -30,7 +30,7 @@ public function testGenerate() Converter::RESOURCE_PERMISSIONS => [], ], ], - 'Magento\Catalog\Api\Data\Product' => [ + \Magento\Catalog\Api\Data\Product::class => [ 'should_not_include' => [ Converter::DATA_TYPE => 'string', Converter::RESOURCE_PERMISSIONS => [], @@ -41,11 +41,11 @@ public function testGenerate() /** @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator $model */ $model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator::class, [ 'config' => $configMock, - 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', - 'resultClassName' => '\Magento\Catalog\Api\Data\ProductExtensionInterface', + 'sourceClassName' => \Magento\Catalog\Api\Data\Product::class, + 'resultClassName' => \Magento\Catalog\Api\Data\ProductExtensionInterface::class, 'classGenerator' => null ] ); @@ -62,10 +62,10 @@ public function testValidateException() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator $model */ $model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator::class, [ - 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', - 'resultClassName' => '\Magento\Catalog\Api\Data\ProductInterface' + 'sourceClassName' => \Magento\Catalog\Api\Data\Product::class, + 'resultClassName' => \Magento\Catalog\Api\Data\ProductInterface::class ] ); $reflectionObject = new \ReflectionObject($model); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateMapperTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateMapperTest.php index 863f86126c589..02384eca24c47 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateMapperTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateMapperTest.php @@ -21,7 +21,7 @@ class GenerateMapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->ioObjectMock = $this->getMock( - '\Magento\Framework\Code\Generator\Io', + \Magento\Framework\Code\Generator\Io::class, [], [], '', @@ -36,23 +36,22 @@ public function testGenerate() { require_once __DIR__ . '/Sample.php'; $model = $this->getMock( - 'Magento\Framework\Api\Code\Generator\Mapper', + \Magento\Framework\Api\Code\Generator\Mapper::class, [ '_validateData' ], - [ - '\Magento\Framework\Api\Code\Generator\Sample', + [\Magento\Framework\Api\Code\Generator\Sample::class, null, $this->ioObjectMock, null, null, - $this->getMock('Magento\Framework\Filesystem\FileResolver') + $this->getMock(\Magento\Framework\Filesystem\FileResolver::class) ] ); $sampleMapperCode = file_get_contents(__DIR__ . '/_files/SampleMapper.txt'); $this->ioObjectMock->expects($this->once()) ->method('generateResultFileName') - ->with('\Magento\Framework\Api\Code\Generator\SampleMapper') + ->with('\\' . \Magento\Framework\Api\Code\Generator\SampleMapper::class) ->will($this->returnValue('SampleMapper.php')); $this->ioObjectMock->expects($this->once()) ->method('writeResultFile') diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsTest.php index bcc963511bd57..18d5195a46c6b 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsTest.php @@ -22,7 +22,7 @@ class GenerateSearchResultsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->ioObjectMock = $this->getMock( - '\Magento\Framework\Code\Generator\Io', + \Magento\Framework\Code\Generator\Io::class, [], [], '', @@ -37,23 +37,22 @@ public function testGenerate() { require_once __DIR__ . '/Sample.php'; $model = $this->getMock( - 'Magento\Framework\Api\Code\Generator\SearchResults', + \Magento\Framework\Api\Code\Generator\SearchResults::class, [ '_validateData' ], - [ - '\Magento\Framework\Api\Code\Generator\Sample', + [\Magento\Framework\Api\Code\Generator\Sample::class, null, $this->ioObjectMock, null, null, - $this->getMock('Magento\Framework\Filesystem\FileResolver') + $this->getMock(\Magento\Framework\Filesystem\FileResolver::class) ] ); $sampleSearchResultBuilderCode = file_get_contents(__DIR__ . '/_files/SampleSearchResults.txt'); $this->ioObjectMock->expects($this->once()) ->method('generateResultFileName') - ->with('\Magento\Framework\Api\Code\Generator\SampleSearchResults') + ->with('\\' . \Magento\Framework\Api\Code\Generator\SampleSearchResults::class) ->will($this->returnValue('SampleSearchResults.php')); $this->ioObjectMock->expects($this->once()) ->method('writeResultFile') diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php index e8eae69c77f22..95e46d99a8e45 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php @@ -11,6 +11,9 @@ use Magento\Framework\Api\CustomAttributesDataInterface; use Magento\Framework\Api\AttributeInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DataObjectHelperTest extends \PHPUnit_Framework_TestCase { /** @@ -57,29 +60,29 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectFactoryMock = $this->getMockBuilder('Magento\Framework\Api\ObjectFactory') + $this->objectFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\ObjectFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->objectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $this->objectProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->methodsMapProcessor = $this->getMockBuilder('Magento\Framework\Reflection\MethodsMap') + $this->methodsMapProcessor = $this->getMockBuilder(\Magento\Framework\Reflection\MethodsMap::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->joinProcessorMock = $this->getMockBuilder('\Magento\Framework\Api\ExtensionAttribute\JoinProcessor') + $this->joinProcessorMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttribute\JoinProcessor::class) ->setMethods(['extractExtensionAttributes']) ->disableOriginalConstructor() ->getMock(); $this->joinProcessorMock->expects($this->any()) ->method('extractExtensionAttributes') ->willReturnArgument(1); - $this->typeProcessor = $this->objectManager->getObject('Magento\Framework\Reflection\TypeProcessor'); + $this->typeProcessor = $this->objectManager->getObject(\Magento\Framework\Reflection\TypeProcessor::class); $this->dataObjectHelper = $this->objectManager->getObject( - 'Magento\Framework\Api\DataObjectHelper', + \Magento\Framework\Api\DataObjectHelper::class, [ 'objectFactory' => $this->objectFactoryMock, 'typeProcessor' => $this->typeProcessor, @@ -102,7 +105,7 @@ public function testPopulateWithArrayWithSimpleAttributes() /** @var \Magento\Customer\Model\Data\Address $addressDataObject */ $addressDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Address', + \Magento\Customer\Model\Data\Address::class, [ 'dataObjectHelper' => $this->dataObjectHelper, ] @@ -110,7 +113,7 @@ public function testPopulateWithArrayWithSimpleAttributes() /** @var \Magento\Customer\Model\Data\Region $regionDataObject */ $regionDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Region', + \Magento\Customer\Model\Data\Region::class, [ 'dataObjectHelper' => $this->dataObjectHelper, ] @@ -128,21 +131,20 @@ public function testPopulateWithArrayWithSimpleAttributes() $this->methodsMapProcessor->expects($this->at(0)) ->method('getMethodReturnType') - ->with('\Magento\Customer\Api\Data\AddressInterface', 'getStreet') + ->with(\Magento\Customer\Api\Data\AddressInterface::class, 'getStreet') ->willReturn('string[]'); $this->methodsMapProcessor->expects($this->at(1)) ->method('getMethodReturnType') - ->with('\Magento\Customer\Api\Data\AddressInterface', 'getRegion') - ->willReturn('\Magento\Customer\Api\Data\RegionInterface'); + ->with(\Magento\Customer\Api\Data\AddressInterface::class, 'getRegion') + ->willReturn(\Magento\Customer\Api\Data\RegionInterface::class); $this->objectFactoryMock->expects($this->once()) ->method('create') - ->with('\Magento\Customer\Api\Data\RegionInterface', []) + ->with(\Magento\Customer\Api\Data\RegionInterface::class, []) ->willReturn($regionDataObject); $this->dataObjectHelper->populateWithArray( $addressDataObject, - $data, - '\Magento\Customer\Api\Data\AddressInterface' + $data, \Magento\Customer\Api\Data\AddressInterface::class ); $this->assertEquals($id, $addressDataObject->getId()); @@ -160,24 +162,24 @@ public function testPopulateWithArrayWithCustomAttribute() $customAttributeCode = 'custom_attribute_code_1'; $customAttributeValue = 'custom_attribute_value_1'; - $attributeMetaDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMetaDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMock(); $attributeMetaDataMock->expects($this->once()) ->method('getAttributeCode') ->willReturn($customAttributeCode); - $metadataServiceMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\AddressMetadata') + $metadataServiceMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\AddressMetadata::class) ->disableOriginalConstructor() ->getMock(); $metadataServiceMock->expects($this->once()) ->method('getCustomAttributesMetadata') - ->with('Magento\Customer\Model\Data\Address') + ->with(\Magento\Customer\Model\Data\Address::class) ->willReturn( [$attributeMetaDataMock] ); /** @var \Magento\Customer\Model\Data\Address $addressDataObject */ $addressDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Address', + \Magento\Customer\Model\Data\Address::class, [ 'dataObjectHelper' => $this->dataObjectHelper, 'metadataService' => $metadataServiceMock, @@ -190,14 +192,13 @@ public function testPopulateWithArrayWithCustomAttribute() $customAttributeCode => $customAttributeValue, ]; - $customAttribute = $this->objectManager->getObject('Magento\Framework\Api\AttributeValue'); + $customAttribute = $this->objectManager->getObject(\Magento\Framework\Api\AttributeValue::class); $this->attributeValueFactoryMock->expects($this->once()) ->method('create') ->willReturn($customAttribute); $this->dataObjectHelper->populateWithArray( $addressDataObject, - $data, - '\Magento\Customer\Api\Data\AddressInterface' + $data, \Magento\Customer\Api\Data\AddressInterface::class ); $this->assertEquals($id, $addressDataObject->getId()); @@ -218,24 +219,24 @@ public function testPopulateWithArrayWithCustomAttributes() $customAttributeCode = 'custom_attribute_code_1'; $customAttributeValue = 'custom_attribute_value_1'; - $attributeMetaDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMetaDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMock(); $attributeMetaDataMock->expects($this->once()) ->method('getAttributeCode') ->willReturn($customAttributeCode); - $metadataServiceMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\AddressMetadata') + $metadataServiceMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\AddressMetadata::class) ->disableOriginalConstructor() ->getMock(); $metadataServiceMock->expects($this->once()) ->method('getCustomAttributesMetadata') - ->with('Magento\Customer\Model\Data\Address') + ->with(\Magento\Customer\Model\Data\Address::class) ->willReturn( [$attributeMetaDataMock] ); /** @var \Magento\Customer\Model\Data\Address $addressDataObject */ $addressDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Address', + \Magento\Customer\Model\Data\Address::class, [ 'dataObjectHelper' => $this->dataObjectHelper, 'metadataService' => $metadataServiceMock, @@ -253,14 +254,13 @@ public function testPopulateWithArrayWithCustomAttributes() ], ]; - $customAttribute = $this->objectManager->getObject('Magento\Framework\Api\AttributeValue'); + $customAttribute = $this->objectManager->getObject(\Magento\Framework\Api\AttributeValue::class); $this->attributeValueFactoryMock->expects($this->once()) ->method('create') ->willReturn($customAttribute); $this->dataObjectHelper->populateWithArray( $addressDataObject, - $data, - '\Magento\Customer\Api\Data\AddressInterface' + $data, \Magento\Customer\Api\Data\AddressInterface::class ); $this->assertEquals($id, $addressDataObject->getId()); @@ -283,7 +283,7 @@ public function testMergeDataObjects($data1, $data2) { /** @var \Magento\Customer\Model\Data\Address $addressDataObject */ $firstAddressDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Address', + \Magento\Customer\Model\Data\Address::class, [ 'dataObjectHelper' => $this->dataObjectHelper, ] @@ -291,7 +291,7 @@ public function testMergeDataObjects($data1, $data2) /** @var \Magento\Customer\Model\Data\Region $regionDataObject */ $firstRegionDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Region', + \Magento\Customer\Model\Data\Region::class, [ 'dataObjectHelper' => $this->dataObjectHelper, ] @@ -310,7 +310,7 @@ public function testMergeDataObjects($data1, $data2) $firstAddressDataObject->setRegion($firstRegionDataObject); $secondAddressDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Address', + \Magento\Customer\Model\Data\Address::class, [ 'dataObjectHelper' => $this->dataObjectHelper, ] @@ -318,7 +318,7 @@ public function testMergeDataObjects($data1, $data2) /** @var \Magento\Customer\Model\Data\Region $regionDataObject */ $secondRegionDataObject = $this->objectManager->getObject( - 'Magento\Customer\Model\Data\Region', + \Magento\Customer\Model\Data\Region::class, [ 'dataObjectHelper' => $this->dataObjectHelper, ] @@ -342,15 +342,15 @@ public function testMergeDataObjects($data1, $data2) ->willReturn($data2); $this->methodsMapProcessor->expects($this->at(0)) ->method('getMethodReturnType') - ->with('Magento\Customer\Model\Data\Address', 'getStreet') + ->with(\Magento\Customer\Model\Data\Address::class, 'getStreet') ->willReturn('string[]'); $this->methodsMapProcessor->expects($this->at(1)) ->method('getMethodReturnType') - ->with('Magento\Customer\Model\Data\Address', 'getRegion') - ->willReturn('\Magento\Customer\Api\Data\RegionInterface'); + ->with(\Magento\Customer\Model\Data\Address::class, 'getRegion') + ->willReturn(\Magento\Customer\Api\Data\RegionInterface::class); $this->objectFactoryMock->expects($this->once()) ->method('create') - ->with('\Magento\Customer\Api\Data\RegionInterface', []) + ->with(\Magento\Customer\Api\Data\RegionInterface::class, []) ->willReturn($secondRegionDataObject); $this->dataObjectHelper->mergeDataObjects( diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php index 9306c6aefa68c..5ad5d7bebee6a 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php @@ -23,16 +23,16 @@ class ExtensibleDataObjectConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->processor = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $this->processor = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObject = $this->getMockBuilder('Magento\Framework\Api\ExtensibleDataInterface') + $this->dataObject = $this->getMockBuilder(\Magento\Framework\Api\ExtensibleDataInterface::class) ->getMock(); $objectManager = new ObjectManager($this); $this->converter = $objectManager->getObject( - 'Magento\Framework\Api\ExtensibleDataObjectConverter', + \Magento\Framework\Api\ExtensibleDataObjectConverter::class, [ 'dataObjectProcessor' => $this->processor, ] diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ConverterTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ConverterTest.php index 95440bf81a370..e38d81d80b688 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ConverterTest.php @@ -45,38 +45,34 @@ public function testConvertNoElements() */ public function testConvert() { - $expected = [ - 'Magento\Tax\Api\Data\TaxRateInterface' => [ - ], - 'Magento\Catalog\Api\Data\ProductInterface' => [ + $expected = [\Magento\Tax\Api\Data\TaxRateInterface::class => [ + ], \Magento\Catalog\Api\Data\ProductInterface::class => [ 'stock_item' => [ - Converter::DATA_TYPE => 'Magento\CatalogInventory\Api\Data\StockItemInterface', + Converter::DATA_TYPE => \Magento\CatalogInventory\Api\Data\StockItemInterface::class, Converter::RESOURCE_PERMISSIONS => [], Converter::JOIN_DIRECTIVE => null, ], - ], - 'Magento\Customer\Api\Data\CustomerInterface' => [ + ], \Magento\Customer\Api\Data\CustomerInterface::class => [ 'custom_1' => [ - Converter::DATA_TYPE => 'Magento\Customer\Api\Data\CustomerCustom', + Converter::DATA_TYPE => \Magento\Customer\Api\Data\CustomerCustom::class, Converter::RESOURCE_PERMISSIONS => [], Converter::JOIN_DIRECTIVE => null, ], 'custom_2' => [ - Converter::DATA_TYPE => 'Magento\CustomerExtra\Api\Data\CustomerCustom2', + Converter::DATA_TYPE => \Magento\CustomerExtra\Api\Data\CustomerCustom2::class, Converter::RESOURCE_PERMISSIONS => [], Converter::JOIN_DIRECTIVE => null, ], - ], - 'Magento\Customer\Api\Data\CustomerInterface2' => [ + ], \Magento\Customer\Api\Data\CustomerInterface2::class => [ 'custom_with_permission' => [ - Converter::DATA_TYPE => 'Magento\Customer\Api\Data\CustomerCustom', + Converter::DATA_TYPE => \Magento\Customer\Api\Data\CustomerCustom::class, Converter::RESOURCE_PERMISSIONS => [ 'Magento_Customer::manage', ], Converter::JOIN_DIRECTIVE => null, ], 'custom_with_multiple_permissions' => [ - Converter::DATA_TYPE => 'Magento\CustomerExtra\Api\Data\CustomerCustom2', + Converter::DATA_TYPE => \Magento\CustomerExtra\Api\Data\CustomerCustom2::class, Converter::RESOURCE_PERMISSIONS => [ 'Magento_Customer::manage', 'Magento_Customer::manage2', @@ -98,8 +94,7 @@ public function testConvert() */ public function testConvertWithJoinDirectives() { - $expected = [ - 'Magento\Customer\Api\Data\CustomerInterface' => [ + $expected = [\Magento\Customer\Api\Data\CustomerInterface::class => [ 'library_card_id' => [ Converter::DATA_TYPE => 'string', Converter::RESOURCE_PERMISSIONS => [], diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ReaderTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ReaderTest.php index 8f72cb52894f6..7ff462070b347 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/ReaderTest.php @@ -17,16 +17,16 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $fileResolver = $this->getMockBuilder('Magento\Framework\App\Config\FileResolver') + $fileResolver = $this->getMockBuilder(\Magento\Framework\App\Config\FileResolver::class) ->disableOriginalConstructor() ->getMock(); - $converter = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\Config\Converter') + $converter = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttribute\Config\Converter::class) ->disableOriginalConstructor() ->getMock(); - $schema = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\Config\SchemaLocator') + $schema = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttribute\Config\SchemaLocator::class) ->disableOriginalConstructor() ->getMock(); - $validator = $this->getMockBuilder('\Magento\Framework\Config\ValidationStateInterface') + $validator = $this->getMockBuilder(\Magento\Framework\Config\ValidationStateInterface::class) ->disableOriginalConstructor() ->getMock(); $this->_reader = new \Magento\Framework\Api\ExtensionAttribute\Config\Reader( @@ -42,6 +42,6 @@ protected function setUp() */ public function testInstanceof() { - $this->assertInstanceOf('Magento\Framework\Api\ExtensionAttribute\Config\Reader', $this->_reader); + $this->assertInstanceOf(\Magento\Framework\Api\ExtensionAttribute\Config\Reader::class, $this->_reader); } } diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/SchemaLocatorTest.php index b970d7dceea4e..5a3fdd19aaec5 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/SchemaLocatorTest.php @@ -22,7 +22,7 @@ protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolverMock->expects($this->once()) ->method('getRealPath') ->with('urn:magento:framework:Api/etc/extension_attributes.xsd') diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php index fa325eeea8a24..84892a1e96d42 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php @@ -28,7 +28,13 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $messageFormat = '%message%'; diff --git a/lib/internal/Magento/Framework/App/ActionFactory.php b/lib/internal/Magento/Framework/App/ActionFactory.php index 52cdefc971f92..0711ce349a06c 100644 --- a/lib/internal/Magento/Framework/App/ActionFactory.php +++ b/lib/internal/Magento/Framework/App/ActionFactory.php @@ -31,7 +31,7 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create($actionName) { - if (!is_subclass_of($actionName, '\Magento\Framework\App\ActionInterface')) { + if (!is_subclass_of($actionName, \Magento\Framework\App\ActionInterface::class)) { throw new \InvalidArgumentException('Invalid action name provided'); } return $this->_objectManager->create($actionName); diff --git a/lib/internal/Magento/Framework/App/Area.php b/lib/internal/Magento/Framework/App/Area.php index d5a2b001a0d5d..20dbbe01d9f29 100644 --- a/lib/internal/Magento/Framework/App/Area.php +++ b/lib/internal/Magento/Framework/App/Area.php @@ -185,7 +185,7 @@ protected function _applyUserAgentDesignException($request) */ protected function _getDesign() { - return $this->_objectManager->get('Magento\Framework\View\DesignInterface'); + return $this->_objectManager->get(\Magento\Framework\View\DesignInterface::class); } /** @@ -240,7 +240,7 @@ protected function _initTranslate() $this->_translator->loadData(null, false); \Magento\Framework\Phrase::setRenderer( - $this->_objectManager->get('Magento\Framework\Phrase\RendererInterface') + $this->_objectManager->get(\Magento\Framework\Phrase\RendererInterface::class) ); return $this; diff --git a/lib/internal/Magento/Framework/App/AreaList.php b/lib/internal/Magento/Framework/App/AreaList.php index 62c30eaa28b6f..4de8f651728e8 100644 --- a/lib/internal/Magento/Framework/App/AreaList.php +++ b/lib/internal/Magento/Framework/App/AreaList.php @@ -124,7 +124,7 @@ public function getArea($code) { if (!isset($this->_areaInstances[$code])) { $this->_areaInstances[$code] = $this->objectManager->create( - 'Magento\Framework\App\AreaInterface', + \Magento\Framework\App\AreaInterface::class, ['areaCode' => $code] ); } diff --git a/lib/internal/Magento/Framework/App/AreaList/Proxy.php b/lib/internal/Magento/Framework/App/AreaList/Proxy.php index 64a5a8c682be3..a121a2aa59f68 100644 --- a/lib/internal/Magento/Framework/App/AreaList/Proxy.php +++ b/lib/internal/Magento/Framework/App/AreaList/Proxy.php @@ -47,7 +47,7 @@ class Proxy extends \Magento\Framework\App\AreaList implements */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\App\AreaList', + $instanceName = \Magento\Framework\App\AreaList::class, $shared = true ) { $this->_objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index 6658b099c1204..92a07b35a0531 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -283,7 +283,7 @@ protected function assertMaintenance() } $this->initObjectManager(); /** @var \Magento\Framework\App\MaintenanceMode $maintenance */ - $this->maintenance = $this->objectManager->get('Magento\Framework\App\MaintenanceMode'); + $this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class); $isOn = $this->maintenance->isOn(isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''); if ($isOn && !$isExpected) { $this->errorCode = self::ERR_MAINTENANCE; @@ -348,7 +348,7 @@ private function isInstalled() { $this->initObjectManager(); /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ - $deploymentConfig = $this->objectManager->get('Magento\Framework\App\DeploymentConfig'); + $deploymentConfig = $this->objectManager->get(\Magento\Framework\App\DeploymentConfig::class); return $deploymentConfig->isAvailable(); } @@ -383,7 +383,7 @@ private function initObjectManager() { if (!$this->objectManager) { $this->objectManager = $this->factory->create($this->server); - $this->maintenance = $this->objectManager->get('Magento\Framework\App\MaintenanceMode'); + $this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class); } } @@ -408,7 +408,7 @@ public function isDeveloperMode() return true; } /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ - $deploymentConfig = $this->getObjectManager()->get('Magento\Framework\App\DeploymentConfig'); + $deploymentConfig = $this->getObjectManager()->get(\Magento\Framework\App\DeploymentConfig::class); if ($deploymentConfig->get(State::PARAM_MODE) == State::MODE_DEVELOPER) { return true; } @@ -432,7 +432,7 @@ protected function terminate(\Exception $e) if (!$this->objectManager) { throw new \DomainException(); } - $this->objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } catch (\Exception $e) { $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; } diff --git a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php index c904a049e68cd..54c2ed5c1708b 100644 --- a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php +++ b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php @@ -14,6 +14,9 @@ use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\DriverInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Factory { /** @@ -143,7 +146,7 @@ public function create(array $options) /** @var $result \Magento\Framework\Cache\Frontend\Adapter\Zend */ $result = $this->_objectManager->create( - 'Magento\Framework\Cache\Frontend\Adapter\Zend', + \Magento\Framework\Cache\Frontend\Adapter\Zend::class, [ 'frontend' => \Zend_Cache::factory( $frontend['type'], @@ -241,7 +244,7 @@ protected function _getBackendOptions(array $cacheOptions) } break; case 'apc': - if (extension_loaded('apc') && ini_get('apc.enabled')) { + if (extension_loaded('apc') && ini_get(\apc.enabled::class)) { $enableTwoLevels = true; $backendType = 'Apc'; } @@ -254,13 +257,13 @@ protected function _getBackendOptions(array $cacheOptions) break; case 'eaccelerator': case 'varien_cache_backend_eaccelerator': - if (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) { + if (extension_loaded('eaccelerator') && ini_get(\eaccelerator.enable::class)) { $enableTwoLevels = true; - $backendType = 'Magento\Framework\Cache\Backend\Eaccelerator'; + $backendType = \Magento\Framework\Cache\Backend\Eaccelerator::class; } break; case 'database': - $backendType = 'Magento\Framework\Cache\Backend\Database'; + $backendType = \Magento\Framework\Cache\Backend\Database::class; $options = $this->_getDbAdapterOptions(); break; default: @@ -347,7 +350,7 @@ protected function _getTwoLevelsBackendOptions($fastOptions, $cacheOptions) $options['slow_backend_options'] = $this->_backendOptions; } if ($options['slow_backend'] == 'database') { - $options['slow_backend'] = 'Magento\Framework\Cache\Backend\Database'; + $options['slow_backend'] = \Magento\Framework\Cache\Backend\Database::class; $options['slow_backend_options'] = $this->_getDbAdapterOptions(); if (isset($cacheOptions['slow_backend_store_data'])) { $options['slow_backend_options']['store_data'] = (bool)$cacheOptions['slow_backend_store_data']; @@ -382,7 +385,7 @@ protected function _getFrontendOptions(array $cacheOptions) $options['automatic_cleaning_factor'] = 0; } $options['type'] = - isset($cacheOptions['frontend']) ? $cacheOptions['frontend'] : 'Magento\Framework\Cache\Core'; + isset($cacheOptions['frontend']) ? $cacheOptions['frontend'] : \Magento\Framework\Cache\Core::class; return $options; } } diff --git a/lib/internal/Magento/Framework/App/Cache/Proxy.php b/lib/internal/Magento/Framework/App/Cache/Proxy.php index 748eeb16b3615..961d8a8a19070 100644 --- a/lib/internal/Magento/Framework/App/Cache/Proxy.php +++ b/lib/internal/Magento/Framework/App/Cache/Proxy.php @@ -41,7 +41,7 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan protected function _getCache() { if (null == $this->_cache) { - $this->_cache = $this->_objectManager->get('Magento\Framework\App\Cache'); + $this->_cache = $this->_objectManager->get(\Magento\Framework\App\Cache::class); } return $this->_cache; } diff --git a/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php b/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php index 49813c631aca3..2124e0f7372aa 100644 --- a/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php +++ b/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php @@ -84,7 +84,7 @@ public function get($cacheType) $frontendInstance = $this->_frontendPool->get($frontendId); /** @var $frontendInstance AccessProxy */ $frontendInstance = $this->_objectManager->create( - 'Magento\Framework\App\Cache\Type\AccessProxy', + \Magento\Framework\App\Cache\Type\AccessProxy::class, ['frontend' => $frontendInstance, 'identifier' => $cacheType] ); $this->_instances[$cacheType] = $frontendInstance; diff --git a/lib/internal/Magento/Framework/App/Config/Base.php b/lib/internal/Magento/Framework/App/Config/Base.php index 3c5d493ca9d6e..3e2e1fdee7207 100644 --- a/lib/internal/Magento/Framework/App/Config/Base.php +++ b/lib/internal/Magento/Framework/App/Config/Base.php @@ -22,7 +22,7 @@ class Base extends \Magento\Framework\Simplexml\Config */ public function __construct($sourceData = null) { - $this->_elementClass = 'Magento\Framework\App\Config\Element'; + $this->_elementClass = \Magento\Framework\App\Config\Element::class; parent::__construct($sourceData); self::$instances[] = $this; } diff --git a/lib/internal/Magento/Framework/App/Config/BaseFactory.php b/lib/internal/Magento/Framework/App/Config/BaseFactory.php index 7799985ba800b..22d7af74f2bb1 100644 --- a/lib/internal/Magento/Framework/App/Config/BaseFactory.php +++ b/lib/internal/Magento/Framework/App/Config/BaseFactory.php @@ -30,6 +30,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create($sourceData = null) { - return $this->_objectManager->create('Magento\Framework\App\Config\Base', ['sourceData' => $sourceData]); + return $this->_objectManager->create(\Magento\Framework\App\Config\Base::class, ['sourceData' => $sourceData]); } } diff --git a/lib/internal/Magento/Framework/App/Config/DataFactory.php b/lib/internal/Magento/Framework/App/Config/DataFactory.php index 7a733c8504773..f6b8f795535c5 100644 --- a/lib/internal/Magento/Framework/App/Config/DataFactory.php +++ b/lib/internal/Magento/Framework/App/Config/DataFactory.php @@ -29,7 +29,7 @@ class DataFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\App\Config\Data' + $instanceName = \Magento\Framework\App\Config\Data::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/App/Config/ValueFactory.php b/lib/internal/Magento/Framework/App/Config/ValueFactory.php index 6f8ab39e71c17..70a2a1a9a8646 100644 --- a/lib/internal/Magento/Framework/App/Config/ValueFactory.php +++ b/lib/internal/Magento/Framework/App/Config/ValueFactory.php @@ -32,7 +32,7 @@ class ValueFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\App\Config\ValueInterface' + $instanceName = \Magento\Framework\App\Config\ValueInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/App/Cron.php b/lib/internal/Magento/Framework/App/Cron.php index ddf6e6fd3c316..5982aba284586 100644 --- a/lib/internal/Magento/Framework/App/Cron.php +++ b/lib/internal/Magento/Framework/App/Cron.php @@ -66,11 +66,11 @@ public function __construct( public function launch() { $this->_state->setAreaCode(Area::AREA_CRONTAB); - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load(Area::AREA_CRONTAB)); /** @var \Magento\Framework\Event\ManagerInterface $eventManager */ - $eventManager = $this->objectManager->get('Magento\Framework\Event\ManagerInterface'); + $eventManager = $this->objectManager->get(\Magento\Framework\Event\ManagerInterface::class); $eventManager->dispatch('default'); $this->_response->setCode(0); return $this->_response; diff --git a/lib/internal/Magento/Framework/App/Http.php b/lib/internal/Magento/Framework/App/Http.php index 7e8779dc9c65a..65eee3aecdf19 100644 --- a/lib/internal/Magento/Framework/App/Http.php +++ b/lib/internal/Magento/Framework/App/Http.php @@ -111,7 +111,7 @@ public function launch() $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_configLoader->load($areaCode)); /** @var \Magento\Framework\App\FrontControllerInterface $frontController */ - $frontController = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface'); + $frontController = $this->_objectManager->get(\Magento\Framework\App\FrontControllerInterface::class); $result = $frontController->dispatch($this->_request); // TODO: Temporary solution until all controllers return ResultInterface (MAGETWO-28359) if ($result instanceof ResultInterface) { diff --git a/lib/internal/Magento/Framework/App/Language/ConfigFactory.php b/lib/internal/Magento/Framework/App/Language/ConfigFactory.php index 66dd45f07a1ef..d837fc16172eb 100644 --- a/lib/internal/Magento/Framework/App/Language/ConfigFactory.php +++ b/lib/internal/Magento/Framework/App/Language/ConfigFactory.php @@ -33,6 +33,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $arguments = []) { - return $this->_objectManager->create('Magento\Framework\App\Language\Config', $arguments); + return $this->_objectManager->create(\Magento\Framework\App\Language\Config::class, $arguments); } } diff --git a/lib/internal/Magento/Framework/App/ObjectManager/Environment/AbstractEnvironment.php b/lib/internal/Magento/Framework/App/ObjectManager/Environment/AbstractEnvironment.php index 9e54394fae0f5..e43cce2723054 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/Environment/AbstractEnvironment.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/Environment/AbstractEnvironment.php @@ -28,7 +28,7 @@ abstract class AbstractEnvironment implements EnvironmentInterface /** * @var string */ - protected $configPreference = 'Magento\Framework\ObjectManager\Factory\Dynamic\Developer'; + protected $configPreference = \Magento\Framework\ObjectManager\Factory\Dynamic\Developer::class; /** * @var FactoryInterface diff --git a/lib/internal/Magento/Framework/App/ObjectManager/Environment/Compiled.php b/lib/internal/Magento/Framework/App/ObjectManager/Environment/Compiled.php index 9a596355fabb6..a1ffc98259947 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/Environment/Compiled.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/Environment/Compiled.php @@ -13,6 +13,9 @@ use Magento\Framework\Interception\ObjectManager\ConfigInterface; use Magento\Framework\App\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Compiled extends AbstractEnvironment implements EnvironmentInterface { /**#@+ @@ -26,7 +29,7 @@ class Compiled extends AbstractEnvironment implements EnvironmentInterface /** * @var string */ - protected $configPreference = 'Magento\Framework\ObjectManager\Factory\Compiled'; + protected $configPreference = \Magento\Framework\ObjectManager\Factory\Compiled::class; /** * @var \Magento\Framework\App\ObjectManager\ConfigLoader\Compiled @@ -100,20 +103,20 @@ public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstan $objectManager->configure( $objectManager - ->get('Magento\Framework\ObjectManager\ConfigLoaderInterface') + ->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class) ->load(Area::AREA_GLOBAL) ); - $objectManager->get('Magento\Framework\Config\ScopeInterface') + $objectManager->get(\Magento\Framework\Config\ScopeInterface::class) ->setCurrentScope('global'); $diConfig->setInterceptionConfig( - $objectManager->get('Magento\Framework\Interception\Config\Config') + $objectManager->get(\Magento\Framework\Interception\Config\Config::class) ); - $sharedInstances['Magento\Framework\Interception\PluginList\PluginList'] = $objectManager->create( - 'Magento\Framework\Interception\PluginListInterface', - ['cache' => $objectManager->get('Magento\Framework\App\Interception\Cache\CompiledConfig')] + $sharedInstances[\Magento\Framework\Interception\PluginList\PluginList::class] = $objectManager->create( + \Magento\Framework\Interception\PluginListInterface::class, + ['cache' => $objectManager->get(\Magento\Framework\App\Interception\Cache\CompiledConfig::class)] ); $objectManager - ->get('Magento\Framework\App\Cache\Manager') + ->get(\Magento\Framework\App\Cache\Manager::class) ->setEnabled([CompiledConfig::TYPE_IDENTIFIER], true); } } diff --git a/lib/internal/Magento/Framework/App/ObjectManager/Environment/Developer.php b/lib/internal/Magento/Framework/App/ObjectManager/Environment/Developer.php index 84665f2d3dc0a..4546caafaa2b1 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/Environment/Developer.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/Environment/Developer.php @@ -28,7 +28,7 @@ class Developer extends AbstractEnvironment implements EnvironmentInterface /** * @var string */ - protected $configPreference = 'Magento\Framework\ObjectManager\Factory\Dynamic\Developer'; + protected $configPreference = \Magento\Framework\ObjectManager\Factory\Dynamic\Developer::class; /** * Returns initialized di config entity @@ -64,26 +64,26 @@ public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstan { $originalSharedInstances = $sharedInstances; $objectManager = ObjectManager::getInstance(); - $sharedInstances['Magento\Framework\ObjectManager\ConfigLoaderInterface'] = $objectManager - ->get('Magento\Framework\App\ObjectManager\ConfigLoader'); + $sharedInstances[\Magento\Framework\ObjectManager\ConfigLoaderInterface::class] = $objectManager + ->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class); $diConfig->setCache( - $objectManager->get('Magento\Framework\App\ObjectManager\ConfigCache') + $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigCache::class) ); $objectManager->configure( $objectManager - ->get('Magento\Framework\App\ObjectManager\ConfigLoader') + ->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class) ->load(Area::AREA_GLOBAL) ); - $objectManager->get('Magento\Framework\Config\ScopeInterface') + $objectManager->get(\Magento\Framework\Config\ScopeInterface::class) ->setCurrentScope('global'); $diConfig->setInterceptionConfig( - $objectManager->get('Magento\Framework\Interception\Config\Config') + $objectManager->get(\Magento\Framework\Interception\Config\Config::class) ); /** Reset the shared instances once interception config is set so classes can be intercepted if necessary */ $sharedInstances = $originalSharedInstances; - $sharedInstances['Magento\Framework\ObjectManager\ConfigLoaderInterface'] = $objectManager - ->get('Magento\Framework\App\ObjectManager\ConfigLoader'); + $sharedInstances[\Magento\Framework\ObjectManager\ConfigLoaderInterface::class] = $objectManager + ->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class); } } diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index 86ba41cc08132..fdc5c1057c9ee 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -40,21 +40,21 @@ class ObjectManagerFactory * * @var string */ - protected $_locatorClassName = 'Magento\Framework\ObjectManager\ObjectManager'; + protected $_locatorClassName = \Magento\Framework\ObjectManager\ObjectManager::class; /** * Config class name * * @var string */ - protected $_configClassName = 'Magento\Framework\Interception\ObjectManager\ConfigInterface'; + protected $_configClassName = \Magento\Framework\Interception\ObjectManager\ConfigInterface::class; /** * Environment factory class name * * @var string */ - protected $envFactoryClassName = 'Magento\Framework\App\EnvironmentFactory'; + protected $envFactoryClassName = \Magento\Framework\App\EnvironmentFactory::class; /** * Filesystem directory list @@ -142,30 +142,30 @@ public function create(array $arguments) // set cache profiler decorator if enabled if (\Magento\Framework\Profiler::isEnabled()) { - $cacheFactoryArguments = $diConfig->getArguments('Magento\Framework\App\Cache\Frontend\Factory'); + $cacheFactoryArguments = $diConfig->getArguments(\Magento\Framework\App\Cache\Frontend\Factory::class); $cacheFactoryArguments['decorators'][] = [ - 'class' => 'Magento\Framework\Cache\Frontend\Decorator\Profiler', + 'class' => \Magento\Framework\Cache\Frontend\Decorator\Profiler::class, 'parameters' => ['backendPrefixes' => ['Zend_Cache_Backend_', 'Cm_Cache_Backend_']], ]; $cacheFactoryConfig = [ - 'Magento\Framework\App\Cache\Frontend\Factory' => ['arguments' => $cacheFactoryArguments] + \Magento\Framework\App\Cache\Frontend\Factory::class => ['arguments' => $cacheFactoryArguments] ]; $diConfig->extend($cacheFactoryConfig); } $sharedInstances = [ - 'Magento\Framework\App\DeploymentConfig' => $deploymentConfig, - 'Magento\Framework\App\Filesystem\DirectoryList' => $this->directoryList, - 'Magento\Framework\Filesystem\DirectoryList' => $this->directoryList, - 'Magento\Framework\Filesystem\DriverPool' => $this->driverPool, - 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, - 'Magento\Framework\Interception\DefinitionInterface' => $definitionFactory->createPluginDefinition(), - 'Magento\Framework\ObjectManager\ConfigInterface' => $diConfig, - 'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $diConfig, - 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, - 'Magento\Framework\Stdlib\BooleanUtils' => $booleanUtils, - 'Magento\Framework\ObjectManager\Config\Mapper\Dom' => $argumentMapper, - 'Magento\Framework\ObjectManager\ConfigLoaderInterface' => $env->getObjectManagerConfigLoader(), + \Magento\Framework\App\DeploymentConfig::class => $deploymentConfig, + \Magento\Framework\App\Filesystem\DirectoryList::class => $this->directoryList, + \Magento\Framework\Filesystem\DirectoryList::class => $this->directoryList, + \Magento\Framework\Filesystem\DriverPool::class => $this->driverPool, + \Magento\Framework\ObjectManager\RelationsInterface::class => $relations, + \Magento\Framework\Interception\DefinitionInterface::class => $definitionFactory->createPluginDefinition(), + \Magento\Framework\ObjectManager\ConfigInterface::class => $diConfig, + \Magento\Framework\Interception\ObjectManager\ConfigInterface::class => $diConfig, + \Magento\Framework\ObjectManager\DefinitionInterface::class => $definitions, + \Magento\Framework\Stdlib\BooleanUtils::class => $booleanUtils, + \Magento\Framework\ObjectManager\Config\Mapper\Dom::class => $argumentMapper, + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class => $env->getObjectManagerConfigLoader(), $this->_configClassName => $diConfig, ]; $arguments['shared_instances'] = &$sharedInstances; @@ -177,7 +177,7 @@ public function create(array $arguments) $this->factory->setObjectManager($objectManager); ObjectManager::setInstance($objectManager); - $generatorParams = $diConfig->getArguments('Magento\Framework\Code\Generator'); + $generatorParams = $diConfig->getArguments(\Magento\Framework\Code\Generator::class); /** Arguments are stored in different format when DI config is compiled, thus require custom processing */ $generatedEntities = isset($generatorParams['generatedEntities']['_v_']) ? $generatorParams['generatedEntities']['_v_'] @@ -302,7 +302,7 @@ protected function _createPluginList( \Magento\Framework\ObjectManager\DefinitionInterface $definitions ) { return $objectManager->create( - 'Magento\Framework\Interception\PluginList\PluginList', + \Magento\Framework\Interception\PluginList\PluginList::class, [ 'relations' => $relations, 'definitions' => $definitionFactory->createPluginDefinition(), diff --git a/lib/internal/Magento/Framework/App/PageCache/Kernel.php b/lib/internal/Magento/Framework/App/PageCache/Kernel.php index 58ec87b68212b..8a83592bc322e 100644 --- a/lib/internal/Magento/Framework/App/PageCache/Kernel.php +++ b/lib/internal/Magento/Framework/App/PageCache/Kernel.php @@ -97,7 +97,7 @@ public function process(\Magento\Framework\App\Response\Http $response) private function getCache() { if (!$this->fullPageCache) { - $this->fullPageCache = ObjectManager::getInstance()->get('\Magento\PageCache\Model\Cache\Type'); + $this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class); } return $this->fullPageCache; } diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php index 2bb5380be937a..449fbaea3e82a 100644 --- a/lib/internal/Magento/Framework/App/Request/Http.php +++ b/lib/internal/Magento/Framework/App/Request/Http.php @@ -416,7 +416,7 @@ public function isSecure() /* TODO: Untangle Config dependence on Scope, so that this class can be instantiated even if app is not installed MAGETWO-31756 */ // Check if a proxy sent a header indicating an initial secure request - $config = $this->objectManager->get('Magento\Framework\App\Config'); + $config = $this->objectManager->get(\Magento\Framework\App\Config::class); $offLoaderHeader = trim( (string)$config->getValue( self::XML_PATH_OFFLOADER_HEADER, diff --git a/lib/internal/Magento/Framework/App/RequestFactory.php b/lib/internal/Magento/Framework/App/RequestFactory.php index 0581663966e3b..ba07f6fd7ab25 100644 --- a/lib/internal/Magento/Framework/App/RequestFactory.php +++ b/lib/internal/Magento/Framework/App/RequestFactory.php @@ -30,6 +30,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $arguments = []) { - return $this->objectManager->create('Magento\Framework\App\RequestInterface', $arguments); + return $this->objectManager->create(\Magento\Framework\App\RequestInterface::class, $arguments); } } diff --git a/lib/internal/Magento/Framework/App/ResourceConnection/Config/Reader.php b/lib/internal/Magento/Framework/App/ResourceConnection/Config/Reader.php index d19b6716a896b..ef82032b15203 100644 --- a/lib/internal/Magento/Framework/App/ResourceConnection/Config/Reader.php +++ b/lib/internal/Magento/Framework/App/ResourceConnection/Config/Reader.php @@ -33,7 +33,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'resources.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index c96410d31bbf5..8deab7f0fa621 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -168,9 +168,11 @@ public function __sleep() public function __wakeup() { $objectManager = ObjectManager::getInstance(); - $this->cookieManager = $objectManager->create('Magento\Framework\Stdlib\CookieManagerInterface'); - $this->cookieMetadataFactory = $objectManager->get('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory'); - $this->request = $objectManager->get('Magento\Framework\App\Request\Http'); + $this->cookieManager = $objectManager->create(\Magento\Framework\Stdlib\CookieManagerInterface::class); + $this->cookieMetadataFactory = $objectManager->get( + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class + ); + $this->request = $objectManager->get(\Magento\Framework\App\Request\Http::class); } /** diff --git a/lib/internal/Magento/Framework/App/ResponseFactory.php b/lib/internal/Magento/Framework/App/ResponseFactory.php index 7b7830b9123c2..de8a7642064ee 100644 --- a/lib/internal/Magento/Framework/App/ResponseFactory.php +++ b/lib/internal/Magento/Framework/App/ResponseFactory.php @@ -30,6 +30,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $arguments = []) { - return $this->_objectManager->create('Magento\Framework\App\ResponseInterface', $arguments); + return $this->_objectManager->create(\Magento\Framework\App\ResponseInterface::class, $arguments); } } diff --git a/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php b/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php index 3a1719ea39549..20bcc0de3cf60 100644 --- a/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php +++ b/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php @@ -51,7 +51,7 @@ class Proxy implements */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\App\Route\ConfigInterface', + $instanceName = \Magento\Framework\App\Route\ConfigInterface::class, $shared = true ) { $this->_objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/App/Router/ActionList.php b/lib/internal/Magento/Framework/App/Router/ActionList.php index 1268ff8b9fac6..11ee22a5f375e 100644 --- a/lib/internal/Magento/Framework/App/Router/ActionList.php +++ b/lib/internal/Magento/Framework/App/Router/ActionList.php @@ -45,7 +45,7 @@ class ActionList public function __construct( \Magento\Framework\Config\CacheInterface $cache, ModuleReader $moduleReader, - $actionInterface = '\Magento\Framework\App\ActionInterface', + $actionInterface = \Magento\Framework\App\ActionInterface::class, $cacheKey = 'app_action_list', $reservedWords = [] ) { diff --git a/lib/internal/Magento/Framework/App/Router/Base.php b/lib/internal/Magento/Framework/App/Router/Base.php index 7a59c5be836f1..9be1788387323 100644 --- a/lib/internal/Magento/Framework/App/Router/Base.php +++ b/lib/internal/Magento/Framework/App/Router/Base.php @@ -24,7 +24,7 @@ class Base implements \Magento\Framework\App\RouterInterface /** * @var string */ - protected $actionInterface = '\Magento\Framework\App\ActionInterface'; + protected $actionInterface = \Magento\Framework\App\ActionInterface::class; /** * @var array diff --git a/lib/internal/Magento/Framework/App/Router/DefaultRouter.php b/lib/internal/Magento/Framework/App/Router/DefaultRouter.php index 376405aea7da0..9861d2042382d 100644 --- a/lib/internal/Magento/Framework/App/Router/DefaultRouter.php +++ b/lib/internal/Magento/Framework/App/Router/DefaultRouter.php @@ -47,6 +47,6 @@ public function match(RequestInterface $request) } } - return $this->actionFactory->create('Magento\Framework\App\Action\Forward'); + return $this->actionFactory->create(\Magento\Framework\App\Action\Forward::class); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php b/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php index c2883fb994056..ee12be79d8927 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php @@ -46,7 +46,7 @@ protected function setUp() $this->connectionFactory = $this->getMockBuilder(ConnectionFactoryInterface::class) ->setMethods(['create']) ->getMockForAbstractClass(); - $this->config = $this->getMockBuilder('Magento\Framework\App\ResourceConnection\ConfigInterface') + $this->config = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection\ConfigInterface::class) ->disableOriginalConstructor() ->setMethods(['getConnectionName']) ->getMock(); @@ -55,7 +55,7 @@ protected function setUp() ->with(self::RESOURCE_NAME) ->will($this->returnValue(self::CONNECTION_NAME)); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->deploymentConfig ->expects($this->any()) ->method('get') @@ -78,7 +78,7 @@ protected function setUp() ] ); - $this->connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); + $this->connection = $this->getMockForAbstractClass(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->connection->expects($this->any()) ->method('getTableName') ->will($this->returnArgument(0)); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Action/AbstractActionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Action/AbstractActionTest.php index 94839361478e6..af7f904418f26 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Action/AbstractActionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Action/AbstractActionTest.php @@ -28,15 +28,15 @@ class AbstractActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); - $this->redirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->redirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->setMethods(['setRefererOrBaseUrl']) ->disableOriginalConstructor() ->getMock(); - $this->redirectFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->redirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -44,7 +44,7 @@ protected function setUp() ->method('create') ->willReturn($this->redirect); - $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any()) @@ -57,7 +57,10 @@ protected function setUp() ->method('getResponse') ->willReturn($this->response); - $this->action = $this->getMockForAbstractClass('Magento\Framework\App\Action\AbstractAction', [$this->context]); + $this->action = $this->getMockForAbstractClass( + \Magento\Framework\App\Action\AbstractAction::class, + [$this->context] + ); } public function testGetRequest() diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Action/ActionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Action/ActionTest.php index ddee457d03758..cb9c427816d23 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Action/ActionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Action/ActionTest.php @@ -84,21 +84,33 @@ class ActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $this->_actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); - $this->_redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface', [], [], '', false); - $this->_requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->_actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); + $this->_redirectMock = $this->getMock( + \Magento\Framework\App\Response\RedirectInterface::class, + [], + [], + '', + false + ); + $this->_requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->_responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - - $this->pageConfigMock = $this->getMock('Magento\Framework\View\Page\Config', ['getConfig'], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); + $this->_responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + + $this->pageConfigMock = $this->getMock( + \Magento\Framework\View\Page\Config::class, + ['getConfig'], + [], + '', + false + ); + $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); $this->viewMock->expects($this->any())->method('getPage')->will($this->returnValue($this->pageConfigMock)); $this->pageConfigMock->expects($this->any())->method('getConfig')->will($this->returnValue(1)); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->action = $this->objectManagerHelper->getObject( - 'Magento\Framework\App\Test\Unit\Action\ActionFake', + \Magento\Framework\App\Test\Unit\Action\ActionFake::class, [ 'request' => $this->_requestMock, 'response' => $this->_responseMock, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Action/ForwardTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Action/ForwardTest.php index bb59490ca2915..90a0337ba4f30 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Action/ForwardTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Action/ForwardTest.php @@ -33,13 +33,13 @@ protected function setUp() { $objectManager = new ObjectManager($this); $cookieMetadataFactoryMock = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class )->disableOriginalConstructor()->getMock(); - $cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); - $contextMock = $this->getMockBuilder('Magento\Framework\App\Http\Context')->disableOriginalConstructor() + $cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); + $contextMock = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class)->disableOriginalConstructor() ->getMock(); $this->response = $objectManager->getObject( - 'Magento\Framework\App\Response\Http', + \Magento\Framework\App\Response\Http::class, [ 'cookieManager' => $cookieManagerMock, 'cookieMetadataFactory' => $cookieMetadataFactoryMock, @@ -47,11 +47,11 @@ protected function setUp() ] ); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->actionAbstract = $objectManager->getObject( - 'Magento\Framework\App\Action\Forward', + \Magento\Framework\App\Action\Forward::class, [ 'request' => $this->request, 'response' => $this->response diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Action/Plugin/DesignTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Action/Plugin/DesignTest.php index e9556fcbbef12..554fa0f3a8301 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Action/Plugin/DesignTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Action/Plugin/DesignTest.php @@ -9,10 +9,10 @@ class DesignTest extends \PHPUnit_Framework_TestCase { public function testAroundDispatch() { - $subjectMock = $this->getMock('Magento\Framework\App\Action\Action', [], [], '', false); - $designLoaderMock = $this->getMock('Magento\Framework\View\DesignLoader', [], [], '', false); - $messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface', [], [], '', false); - $requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $subjectMock = $this->getMock(\Magento\Framework\App\Action\Action::class, [], [], '', false); + $designLoaderMock = $this->getMock(\Magento\Framework\View\DesignLoader::class, [], [], '', false); + $messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class, [], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); $plugin = new \Magento\Framework\App\Action\Plugin\Design($designLoaderMock, $messageManagerMock); $designLoaderMock->expects($this->once())->method('load'); $plugin->beforeDispatch($subjectMock, $requestMock); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ActionFlagTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ActionFlagTest.php index 49428a59fd238..12966dd010b0b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ActionFlagTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ActionFlagTest.php @@ -19,7 +19,7 @@ class ActionFlagTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->_actionFlag = new \Magento\Framework\App\ActionFlag($this->_requestMock); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/AreaListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/AreaListTest.php index 6d5e9e8fab501..9886abf023216 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/AreaListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/AreaListTest.php @@ -29,9 +29,9 @@ class AreaListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_resolverFactory = $this - ->getMock('\Magento\Framework\App\Area\FrontNameResolverFactory', [], [], '', false); + ->getMock(\Magento\Framework\App\Area\FrontNameResolverFactory::class, [], [], '', false); } public function testGetCodeByFrontNameWhenAreaDoesNotContainFrontName() @@ -44,7 +44,7 @@ public function testGetCodeByFrontNameWhenAreaDoesNotContainFrontName() $expected ); - $resolverMock = $this->getMock('\Magento\Framework\App\Area\FrontNameResolverInterface'); + $resolverMock = $this->getMock(\Magento\Framework\App\Area\FrontNameResolverInterface::class); $this->_resolverFactory->expects( $this->any() )->method( @@ -97,7 +97,7 @@ public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet() $this->assertNull($model->getDefaultRouter($code)); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\App\AreaInterface', ['areaCode' => $code]) + ->with(\Magento\Framework\App\AreaInterface::class, ['areaCode' => $code]) ->willReturn('test'); $this->assertSame('test', $model->getArea($code)); } @@ -142,12 +142,12 @@ public function testGetArea() */ protected function getObjectManagerMockGetArea() { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock ->expects($this->any()) ->method('create') ->with( - $this->equalTo('Magento\Framework\App\AreaInterface'), + $this->equalTo(\Magento\Framework\App\AreaInterface::class), $this->equalTo(['areaCode' => 'testArea']) ) ->will($this->returnValue('ok')); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php b/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php index cab1a46e0e825..a280658ca2a89 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php @@ -77,28 +77,28 @@ protected function setUp() { $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->translatorMock = $this->getMockBuilder('Magento\Framework\TranslateInterface') + $this->translatorMock = $this->getMockBuilder(\Magento\Framework\TranslateInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->diConfigLoaderMock = $this->getMockBuilder('Magento\Framework\App\ObjectManager\ConfigLoader') + $this->diConfigLoaderMock = $this->getMockBuilder(\Magento\Framework\App\ObjectManager\ConfigLoader::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->designMock = $this->getMockBuilder('Magento\Framework\App\DesignInterface') + $this->designMock = $this->getMockBuilder(\Magento\Framework\App\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeResolverMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface') + $this->scopeResolverMock = $this->getMockBuilder(\Magento\Framework\App\ScopeResolverInterface::class) ->disableOriginalConstructor() ->getMock(); - $scopeMock = $this->getMockBuilder('Magento\Framework\App\ScopeInterface') + $scopeMock = $this->getMockBuilder(\Magento\Framework\App\ScopeInterface::class) ->disableOriginalConstructor() ->getMock(); $scopeMock->expects($this->any()) @@ -107,13 +107,13 @@ protected function setUp() $this->scopeResolverMock->expects($this->any()) ->method('getScope') ->will($this->returnValue($scopeMock)); - $this->designExceptionsMock = $this->getMockBuilder('Magento\Framework\View\DesignExceptions') + $this->designExceptionsMock = $this->getMockBuilder(\Magento\Framework\View\DesignExceptions::class) ->disableOriginalConstructor() ->getMock(); $this->areaCode = Area::AREA_FRONTEND; $this->object = $this->objectManager->getObject( - 'Magento\Framework\App\Area', + \Magento\Framework\App\Area::class, [ 'logger' => $this->loggerMock, 'objectManager' => $this->objectManagerMock, @@ -143,24 +143,24 @@ public function testLoadTranslate() { $this->translatorMock->expects($this->once()) ->method('loadData'); - $renderMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') + $renderMock = $this->getMockBuilder(\Magento\Framework\Phrase\RendererInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\Phrase\RendererInterface') + ->with(\Magento\Framework\Phrase\RendererInterface::class) ->will($this->returnValue($renderMock)); $this->object->load(Area::PART_TRANSLATE); } public function testLoadDesign() { - $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $designMock = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\View\DesignInterface') + ->with(\Magento\Framework\View\DesignInterface::class) ->will($this->returnValue($designMock)); $designMock->expects($this->once()) ->method('setArea') @@ -185,10 +185,10 @@ public function testLoad() $this->verifyLoadConfig(); $this->translatorMock->expects($this->once()) ->method('loadData'); - $renderMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') + $renderMock = $this->getMockBuilder(\Magento\Framework\Phrase\RendererInterface::class) ->disableOriginalConstructor() ->getMock(); - $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $designMock = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); $designMock->expects($this->once()) @@ -201,8 +201,8 @@ public function testLoad() ->method('get') ->will($this->returnValueMap( [ - ['Magento\Framework\Phrase\RendererInterface', $renderMock], - ['Magento\Framework\View\DesignInterface', $designMock], + [\Magento\Framework\Phrase\RendererInterface::class, $renderMock], + [\Magento\Framework\View\DesignInterface::class, $designMock], ] )); $this->object->load(); @@ -228,12 +228,12 @@ public function testDetectDesign() ->method('loadChange') ->with(self::SCOPE_ID) ->willReturnSelf(); - $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $designMock = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\View\DesignInterface') + ->with(\Magento\Framework\View\DesignInterface::class) ->will($this->returnValue($designMock)); $this->designMock->expects($this->once()) ->method('changeDesign') @@ -253,14 +253,14 @@ public function testDetectDesignByRequest($value, $callNum, $callNum2) $this->designExceptionsMock->expects($this->once()) ->method('getThemeByRequest') ->will($this->returnValue($value)); - $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $designMock = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); $designMock->expects($this->exactly($callNum)) ->method('setDesignTheme'); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\View\DesignInterface') + ->with(\Magento\Framework\View\DesignInterface::class) ->will($this->returnValue($designMock)); $this->designMock->expects($this->exactly($callNum2)) ->method('loadChange') @@ -270,7 +270,7 @@ public function testDetectDesignByRequest($value, $callNum, $callNum2) ->method('changeDesign') ->with($designMock) ->willReturnSelf(); - $requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $this->object->detectDesign($requestMock); @@ -290,14 +290,14 @@ public function testDetectDesignByRequestWithException() $this->designExceptionsMock->expects($this->once()) ->method('getThemeByRequest') ->will($this->throwException($exception)); - $designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $designMock = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); $designMock->expects($this->never()) ->method('setDesignTheme'); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\View\DesignInterface') + ->with(\Magento\Framework\View\DesignInterface::class) ->will($this->returnValue($designMock)); $this->designMock->expects($this->once()) ->method('loadChange') @@ -307,7 +307,7 @@ public function testDetectDesignByRequestWithException() ->method('changeDesign') ->with($designMock) ->willReturnSelf(); - $requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $this->loggerMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Arguments/ArgumentInterpreterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Arguments/ArgumentInterpreterTest.php index 103acb59f23e7..7f511a836aa9c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Arguments/ArgumentInterpreterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Arguments/ArgumentInterpreterTest.php @@ -17,7 +17,7 @@ class ArgumentInterpreterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $const = $this->getMock( - '\Magento\Framework\Data\Argument\Interpreter\Constant', + \Magento\Framework\Data\Argument\Interpreter\Constant::class, ['evaluate'], [], '', diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Arguments/FileResolver/PrimaryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Arguments/FileResolver/PrimaryTest.php index e5a4de0113037..ae6f5fb6476e3 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Arguments/FileResolver/PrimaryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Arguments/FileResolver/PrimaryTest.php @@ -17,10 +17,10 @@ class PrimaryTest extends \PHPUnit_Framework_TestCase */ public function testGet(array $fileList, $scope, $filename) { - $directory = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $directory = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $iteratorFactory = $this->getMock( - 'Magento\Framework\Config\FileIteratorFactory', + \Magento\Framework\Config\FileIteratorFactory::class, ['create'], [], '', diff --git a/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php b/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php index e4b5de3f74ee8..81a01006fa01b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php @@ -14,6 +14,9 @@ use Magento\Framework\App\Filesystem\DirectoryList; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class BootstrapTest extends \PHPUnit_Framework_TestCase { /** @@ -63,33 +66,45 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerFactory = $this->getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->dirs = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', ['getPath'], [], '', false); - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', ['isOn'], [], '', false); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->objectManagerFactory = $this->getMock( + \Magento\Framework\App\ObjectManagerFactory::class, + [], + [], + '', + false + ); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->dirs = $this->getMock( + \Magento\Framework\App\Filesystem\DirectoryList::class, + ['getPath'], + [], + '', + false + ); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, ['isOn'], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $mapObjectManager = [ - ['Magento\Framework\App\Filesystem\DirectoryList', $this->dirs], - ['Magento\Framework\App\MaintenanceMode', $this->maintenanceMode], - ['Magento\Framework\Filesystem', $filesystem], - ['Magento\Framework\App\DeploymentConfig', $this->deploymentConfig], + [\Magento\Framework\App\Filesystem\DirectoryList::class, $this->dirs], + [\Magento\Framework\App\MaintenanceMode::class, $this->maintenanceMode], + [\Magento\Framework\Filesystem::class, $filesystem], + [\Magento\Framework\App\DeploymentConfig::class, $this->deploymentConfig], ['Psr\Log\LoggerInterface', $this->logger], ]; $this->objectManager->expects($this->any())->method('get') ->will(($this->returnValueMap($mapObjectManager))); - $this->configDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); + $this->configDir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $filesystem->expects($this->any())->method('getDirectoryRead') ->will(($this->returnValue($this->configDir))); - $this->application = $this->getMockForAbstractClass('Magento\Framework\AppInterface'); + $this->application = $this->getMockForAbstractClass(\Magento\Framework\AppInterface::class); $this->objectManager->expects($this->any())->method('create') ->will(($this->returnValue($this->application))); @@ -97,7 +112,8 @@ protected function setUp() $this->objectManagerFactory->expects($this->any())->method('create') ->will(($this->returnValue($this->objectManager))); - $this->bootstrapMock = $this->getMock('Magento\Framework\App\Bootstrap', + $this->bootstrapMock = $this->getMock( + \Magento\Framework\App\Bootstrap::class, ['assertMaintenance', 'assertInstalled', 'getIsExpected', 'isInstalled', 'terminate'], [$this->objectManagerFactory, '', ['value1', 'value2']] ); @@ -106,7 +122,7 @@ protected function setUp() public function testCreateObjectManagerFactory() { $result = Bootstrap::createObjectManagerFactory('test', []); - $this->assertInstanceOf('Magento\Framework\App\ObjectManagerFactory', $result); + $this->assertInstanceOf(\Magento\Framework\App\ObjectManagerFactory::class, $result); } public function testCreateFilesystemDirectoryList() @@ -116,18 +132,18 @@ public function testCreateFilesystemDirectoryList() [Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [DirectoryList::APP => ['path' => '/custom/path']]] ); /** @var \Magento\Framework\App\Filesystem\DirectoryList $result */ - $this->assertInstanceOf('Magento\Framework\App\Filesystem\DirectoryList', $result); + $this->assertInstanceOf(\Magento\Framework\App\Filesystem\DirectoryList::class, $result); $this->assertEquals('/custom/path', $result->getPath(DirectoryList::APP)); } public function testCreateFilesystemDriverPool() { - $driverClass = get_class($this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface')); + $driverClass = get_class($this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class)); $result = Bootstrap::createFilesystemDriverPool( [Bootstrap::INIT_PARAM_FILESYSTEM_DRIVERS => ['custom' => $driverClass]] ); /** @var \Magento\Framework\Filesystem\DriverPool $result */ - $this->assertInstanceOf('Magento\Framework\Filesystem\DriverPool', $result); + $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverPool::class, $result); $this->assertInstanceof($driverClass, $result->getDriver('custom')); } @@ -186,7 +202,7 @@ public function testIsDeveloperModeСontradictoryValues() public function testRunNoErrors() { - $responseMock = $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface'); + $responseMock = $this->getMockForAbstractClass(\Magento\Framework\App\ResponseInterface::class); $this->bootstrapMock->expects($this->once())->method('assertMaintenance')->will($this->returnValue(null)); $this->bootstrapMock->expects($this->once())->method('assertInstalled')->will($this->returnValue(null)); $this->application->expects($this->once())->method('launch')->willReturn($responseMock); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/FactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/FactoryTest.php index bcbaa79745edf..77a0d7e664e91 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/FactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/FactoryTest.php @@ -19,12 +19,12 @@ public function testCreate() $result = $model->create(['backend' => 'Zend_Cache_Backend_BlackHole']); $this->assertInstanceOf( - 'Magento\Framework\Cache\FrontendInterface', + \Magento\Framework\Cache\FrontendInterface::class, $result, 'Created object must implement \Magento\Framework\Cache\FrontendInterface' ); $this->assertInstanceOf( - 'Magento\Framework\Cache\Core', + \Magento\Framework\Cache\Core::class, $result->getLowLevelFrontend(), 'Created object must have \Magento\Framework\Cache\Core frontend by default' ); @@ -100,7 +100,7 @@ public function testCreateDecorators() [], [ [ - 'class' => 'Magento\Framework\App\Test\Unit\Cache\Frontend\FactoryTest\CacheDecoratorDummy', + 'class' => \Magento\Framework\App\Test\Unit\Cache\Frontend\FactoryTest\CacheDecoratorDummy::class, 'parameters' => ['param' => 'value'], ] ] @@ -108,7 +108,7 @@ public function testCreateDecorators() $result = $model->create(['backend' => 'Zend_Cache_Backend_BlackHole']); $this->assertInstanceOf( - 'Magento\Framework\App\Test\Unit\Cache\Frontend\FactoryTest\CacheDecoratorDummy', + \Magento\Framework\App\Test\Unit\Cache\Frontend\FactoryTest\CacheDecoratorDummy::class, $result ); @@ -128,9 +128,9 @@ protected function _buildModelForCreate($enforcedOptions = [], $decorators = []) { $processFrontendFunc = function ($class, $params) { switch ($class) { - case 'Magento\Framework\Cache\Frontend\Adapter\Zend': + case \Magento\Framework\Cache\Frontend\Adapter\Zend::class: return new $class($params['frontend']); - case 'Magento\Framework\App\Test\Unit\Cache\Frontend\FactoryTest\CacheDecoratorDummy': + case \Magento\Framework\App\Test\Unit\Cache\Frontend\FactoryTest\CacheDecoratorDummy::class: $frontend = $params['frontend']; unset($params['frontend']); return new $class($frontend, $params); @@ -140,18 +140,18 @@ protected function _buildModelForCreate($enforcedOptions = [], $decorators = []) } }; /** @var $objectManager \PHPUnit_Framework_MockObject_MockObject */ - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager->expects($this->any())->method('create')->will($this->returnCallback($processFrontendFunc)); - $dirMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); + $dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $dirMock->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnValue('DIR')); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($dirMock)); $filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($dirMock)); - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $model = new \Magento\Framework\App\Cache\Frontend\Factory( $objectManager, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php index 72e2c244742c5..af13f96425a02 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php @@ -25,9 +25,9 @@ class PoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_frontendInstances = [ - Pool::DEFAULT_FRONTEND_ID => $this->getMock('Magento\Framework\Cache\FrontendInterface'), - 'resource1' => $this->getMock('Magento\Framework\Cache\FrontendInterface'), - 'resource2' => $this->getMock('Magento\Framework\Cache\FrontendInterface'), + Pool::DEFAULT_FRONTEND_ID => $this->getMock(\Magento\Framework\Cache\FrontendInterface::class), + 'resource1' => $this->getMock(\Magento\Framework\Cache\FrontendInterface::class), + 'resource2' => $this->getMock(\Magento\Framework\Cache\FrontendInterface::class), ]; $frontendFactoryMap = [ @@ -38,10 +38,10 @@ protected function setUp() [['r1d1' => 'value1', 'r1d2' => 'value2'], $this->_frontendInstances['resource1']], [['r2d1' => 'value1', 'r2d2' => 'value2'], $this->_frontendInstances['resource2']], ]; - $frontendFactory = $this->getMock('Magento\Framework\App\Cache\Frontend\Factory', [], [], '', false); + $frontendFactory = $this->getMock(\Magento\Framework\App\Cache\Frontend\Factory::class, [], [], '', false); $frontendFactory->expects($this->any())->method('create')->will($this->returnValueMap($frontendFactoryMap)); - $deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfig->expects( $this->any() )->method( @@ -69,8 +69,8 @@ protected function setUp() */ public function testConstructorNoInitialization() { - $deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $frontendFactory = $this->getMock('Magento\Framework\App\Cache\Frontend\Factory', [], [], '', false); + $deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $frontendFactory = $this->getMock(\Magento\Framework\App\Cache\Frontend\Factory::class, [], [], '', false); $frontendFactory->expects($this->never())->method('create'); new \Magento\Framework\App\Cache\Frontend\Pool($deploymentConfig, $frontendFactory); } @@ -87,7 +87,7 @@ public function testInitializationParams( array $frontendSettings, array $expectedFactoryArg ) { - $deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfig->expects( $this->once() )->method( @@ -98,7 +98,7 @@ public function testInitializationParams( $this->returnValue($fixtureCacheConfig) ); - $frontendFactory = $this->getMock('Magento\Framework\App\Cache\Frontend\Factory', [], [], '', false); + $frontendFactory = $this->getMock(\Magento\Framework\App\Cache\Frontend\Factory::class, [], [], '', false); $frontendFactory->expects($this->at(0))->method('create')->with($expectedFactoryArg); $model = new \Magento\Framework\App\Cache\Frontend\Pool($deploymentConfig, $frontendFactory, $frontendSettings); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/ManagerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/ManagerTest.php index d96d0b549d9f2..b960574331256 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/ManagerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/ManagerTest.php @@ -37,10 +37,10 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cacheTypeList = $this->getMockForAbstractClass('Magento\Framework\App\Cache\TypeListInterface'); - $this->cacheState = $this->getMockForAbstractClass('Magento\Framework\App\Cache\StateInterface'); - $this->response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); - $this->frontendPool = $this->getMock('Magento\Framework\App\Cache\Type\FrontendPool', [], [], '', false); + $this->cacheTypeList = $this->getMockForAbstractClass(\Magento\Framework\App\Cache\TypeListInterface::class); + $this->cacheState = $this->getMockForAbstractClass(\Magento\Framework\App\Cache\StateInterface::class); + $this->response = $this->getMock(\Magento\Framework\App\Console\Response::class, [], [], '', false); + $this->frontendPool = $this->getMock(\Magento\Framework\App\Cache\Type\FrontendPool::class, [], [], '', false); $this->model = new Manager($this->cacheTypeList, $this->cacheState, $this->frontendPool); } @@ -101,16 +101,16 @@ public function testSetEnabledFalseAll() public function testFlushAll() { $cacheTypes = ['foo', 'bar', 'baz']; - $frontendFoo = $this->getMockForAbstractClass('Magento\Framework\Cache\FrontendInterface'); - $frontendBar = $this->getMockForAbstractClass('Magento\Framework\Cache\FrontendInterface'); - $frontendBaz = $this->getMockForAbstractClass('Magento\Framework\Cache\FrontendInterface'); + $frontendFoo = $this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class); + $frontendBar = $this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class); + $frontendBaz = $this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class); $this->frontendPool->expects($this->exactly(3))->method('get')->will($this->returnValueMap([ ['foo', $frontendFoo], ['bar', $frontendBar], ['baz', $frontendBaz], ])); - $backendOne = $this->getMockForAbstractClass('Zend_Cache_Backend_Interface'); - $backendTwo = $this->getMockForAbstractClass('Zend_Cache_Backend_Interface'); + $backendOne = $this->getMockForAbstractClass(\Zend_Cache_Backend_Interface::class); + $backendTwo = $this->getMockForAbstractClass(\Zend_Cache_Backend_Interface::class); $frontendFoo->expects($this->once())->method('getBackend')->willReturn($backendOne); $frontendBar->expects($this->once())->method('getBackend')->willReturn($backendOne); $frontendBaz->expects($this->once())->method('getBackend')->willReturn($backendTwo); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php index 2bc97eca47099..804e8ca1fcacd 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php @@ -22,8 +22,8 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->writer = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->writer = $this->getMock(\Magento\Framework\App\DeploymentConfig\Writer::class, [], [], '', false); } /** diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/AccessProxyTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/AccessProxyTest.php index ded215d6f23fe..5461f510f6256 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/AccessProxyTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/AccessProxyTest.php @@ -18,9 +18,9 @@ public function testProxyMethod($method, $params, $disabledResult, $enabledResul { $identifier = 'cache_type_identifier'; - $frontendMock = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $frontendMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); - $cacheEnabler = $this->getMock('Magento\Framework\App\Cache\StateInterface'); + $cacheEnabler = $this->getMock(\Magento\Framework\App\Cache\StateInterface::class); $cacheEnabler->expects($this->at(0))->method('isEnabled')->with($identifier)->will($this->returnValue(false)); $cacheEnabler->expects($this->at(1))->method('isEnabled')->with($identifier)->will($this->returnValue(true)); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php index e011a6d56f576..385121012bbe5 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php @@ -22,14 +22,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $cacheFrontendPoolMock = $this->getMockBuilder('Magento\Framework\App\Cache\Type\FrontendPool') + $cacheFrontendPoolMock = $this->getMockBuilder(\Magento\Framework\App\Cache\Type\FrontendPool::class) ->disableOriginalConstructor() ->getMock(); $this->model = (new ObjectManager($this))->getObject( - 'Magento\Framework\App\Cache\Type\Config', + \Magento\Framework\App\Cache\Type\Config::class, ['cacheFrontendPool' => $cacheFrontendPoolMock] ); - $this->frontendMock = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $this->frontendMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $cacheFrontendPoolMock->expects($this->once()) ->method('get') ->with(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER) @@ -58,8 +58,8 @@ public function proxyMethodDataProvider() ['test', ['record_id'], 111], ['load', ['record_id'], '111'], ['remove', ['record_id'], true], - ['getBackend', [], $this->getMock('Zend_Cache_Backend')], - ['getLowLevelFrontend', [], $this->getMock('Zend_Cache_Core')], + ['getBackend', [], $this->getMock(\Zend_Cache_Backend::class)], + ['getLowLevelFrontend', [], $this->getMock(\Zend_Cache_Core::class)], ]; } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php index 7281d9883367a..eb8c9b3f98a87 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php @@ -31,9 +31,9 @@ class FrontendPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->_cachePool = $this->getMock('Magento\Framework\App\Cache\Frontend\Pool', [], [], '', false); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->_cachePool = $this->getMock(\Magento\Framework\App\Cache\Frontend\Pool::class, [], [], '', false); $this->_model = new FrontendPool( $this->_objectManager, $this->deploymentConfig, @@ -61,7 +61,7 @@ public function testGet($fixtureConfigData, $inputCacheType, $expectedFrontendId $this->returnValue($fixtureConfigData) ); - $cacheFrontend = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $cacheFrontend = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $this->_cachePool->expects( $this->once() )->method( @@ -72,13 +72,13 @@ public function testGet($fixtureConfigData, $inputCacheType, $expectedFrontendId $this->returnValue($cacheFrontend) ); - $accessProxy = $this->getMock('Magento\Framework\App\Cache\Type\AccessProxy', [], [], '', false); + $accessProxy = $this->getMock(\Magento\Framework\App\Cache\Type\AccessProxy::class, [], [], '', false); $this->_objectManager->expects( $this->once() )->method( 'create' )->with( - 'Magento\Framework\App\Cache\Type\AccessProxy', + \Magento\Framework\App\Cache\Type\AccessProxy::class, $this->identicalTo(['frontend' => $cacheFrontend, 'identifier' => $inputCacheType]) )->will( $this->returnValue($accessProxy) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/GenericTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/GenericTest.php index f4ef8641a46f5..c96ea0199c78c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/GenericTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/GenericTest.php @@ -17,9 +17,9 @@ class GenericTest extends \PHPUnit_Framework_TestCase */ public function testConstructor($className) { - $frontendMock = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $frontendMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); - $poolMock = $this->getMock('Magento\Framework\App\Cache\Type\FrontendPool', [], [], '', false); + $poolMock = $this->getMock(\Magento\Framework\App\Cache\Type\FrontendPool::class, [], [], '', false); $poolMock->expects( $this->atLeastOnce() )->method( @@ -46,12 +46,12 @@ public function testConstructor($className) public static function constructorDataProvider() { return [ - ['Magento\Framework\App\Cache\Type\Block'], - ['Magento\Framework\App\Cache\Type\Collection'], - ['Magento\Framework\App\Cache\Type\Config'], - ['Magento\Framework\App\Cache\Type\Layout'], - ['Magento\Framework\App\Cache\Type\Translate'], - ['Magento\Framework\App\Cache\Type\Block'] + [\Magento\Framework\App\Cache\Type\Block::class], + [\Magento\Framework\App\Cache\Type\Collection::class], + [\Magento\Framework\App\Cache\Type\Config::class], + [\Magento\Framework\App\Cache\Type\Layout::class], + [\Magento\Framework\App\Cache\Type\Translate::class], + [\Magento\Framework\App\Cache\Type\Block::class] ]; } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/TypeListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/TypeListTest.php index 6d6502db20c42..a6074f6c45740 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/TypeListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/TypeListTest.php @@ -46,7 +46,7 @@ class TypeListTest extends \PHPUnit_Framework_TestCase /** * Expected cache type */ - const CACHE_TYPE = 'Magento\Framework\Cache\FrontendInterface'; + const CACHE_TYPE = \Magento\Framework\Cache\FrontendInterface::class; protected function setUp() { @@ -57,7 +57,7 @@ protected function setUp() ], ]; $this->_config = $this->getMock( - 'Magento\Framework\Cache\ConfigInterface', + \Magento\Framework\Cache\ConfigInterface::class, ['getTypes', 'getType'], [], '', @@ -66,7 +66,7 @@ protected function setUp() $this->_config->expects($this->any())->method('getTypes')->will($this->returnValue($this->_typesArray)); $cacheState = $this->getMock( - 'Magento\Framework\App\Cache\StateInterface', + \Magento\Framework\App\Cache\StateInterface::class, ['isEnabled', 'setEnabled', 'persist'], [], '', @@ -74,12 +74,12 @@ protected function setUp() ); $cacheState->expects($this->any())->method('isEnabled')->will($this->returnValue(self::IS_CACHE_ENABLED)); $cacheBlockMock = $this->getMock(self::CACHE_TYPE, [], [], '', false); - $factory = $this->getMock('Magento\Framework\App\Cache\InstanceFactory', ['get'], [], '', false); + $factory = $this->getMock(\Magento\Framework\App\Cache\InstanceFactory::class, ['get'], [], '', false); $factory->expects($this->any())->method('get')->with(self::CACHE_TYPE)->will( $this->returnValue($cacheBlockMock) ); $this->_cache = $this->getMock( - 'Magento\Framework\App\CacheInterface', + \Magento\Framework\App\CacheInterface::class, ['load', 'getFrontend', 'save', 'remove', 'clean'], [], '', @@ -88,7 +88,7 @@ protected function setUp() $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_typeList = $objectHelper->getObject( - 'Magento\Framework\App\Cache\TypeList', + \Magento\Framework\App\Cache\TypeList::class, [ 'config' => $this->_config, 'cacheState' => $cacheState, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php b/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php index 2e659ce45db31..275d74efd9416 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php @@ -27,7 +27,7 @@ protected function setUp() $this->_initCacheTypeMocks(); $this->_cacheFrontendMock = $this->getMockForAbstractClass( - 'Magento\Framework\Cache\FrontendInterface', + \Magento\Framework\Cache\FrontendInterface::class, [], '', true, @@ -36,7 +36,7 @@ protected function setUp() ['clean'] ); - $frontendPoolMock = $this->getMock('Magento\Framework\App\Cache\Frontend\Pool', [], [], '', false); + $frontendPoolMock = $this->getMock(\Magento\Framework\App\Cache\Frontend\Pool::class, [], [], '', false); $frontendPoolMock->expects($this->any())->method('valid')->will($this->onConsecutiveCalls(true, false)); $frontendPoolMock->expects( @@ -65,14 +65,14 @@ protected function setUp() protected function _initCacheTypeMocks() { $cacheTypes = [ - 'Magento\Framework\Cache\Frontend\Decorator\TagScope', - 'Magento\Framework\Cache\Frontend\Decorator\Bare', + \Magento\Framework\Cache\Frontend\Decorator\TagScope::class, + \Magento\Framework\Cache\Frontend\Decorator\Bare::class, ]; foreach ($cacheTypes as $type) { $this->_cacheTypeMocks[$type] = $this->getMock( $type, ['clean'], - [$this->getMockForAbstractClass('Magento\Framework\Cache\FrontendInterface'), 'FIXTURE_TAG'] + [$this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class), 'FIXTURE_TAG'] ); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/BaseFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/BaseFactoryTest.php index 6436671b251e5..66fac1058ff34 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/BaseFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/BaseFactoryTest.php @@ -9,8 +9,8 @@ class BaseFactoryTest extends \Magento\Framework\TestFramework\Unit\AbstractFact { protected function setUp() { - $this->instanceClassName = 'Magento\Framework\App\Config\Base'; - $this->factoryClassName = 'Magento\Framework\App\Config\BaseFactory'; + $this->instanceClassName = \Magento\Framework\App\Config\Base::class; + $this->factoryClassName = \Magento\Framework\App\Config\BaseFactory::class; parent::setUp(); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Data/ProcessorFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Data/ProcessorFactoryTest.php index 1682004dbcadb..2de8206f2e1ab 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Data/ProcessorFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Data/ProcessorFactoryTest.php @@ -24,9 +24,11 @@ class ProcessorFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Framework\App\Config\Data\ProcessorFactory($this->_objectManager); - $this->_processorMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\Data\ProcessorInterface'); + $this->_processorMock = $this->getMockForAbstractClass( + \Magento\Framework\App\Config\Data\ProcessorInterface::class + ); } /** @@ -39,14 +41,14 @@ public function testGetModelWithCorrectInterface() )->method( 'create' )->with( - 'Magento\Framework\App\Config\Data\TestBackendModel' + \Magento\Framework\App\Config\Data\TestBackendModel::class )->will( $this->returnValue($this->_processorMock) ); $this->assertInstanceOf( - 'Magento\Framework\App\Config\Data\ProcessorInterface', - $this->_model->get('Magento\Framework\App\Config\Data\TestBackendModel') + \Magento\Framework\App\Config\Data\ProcessorInterface::class, + $this->_model->get(\Magento\Framework\App\Config\Data\TestBackendModel::class) ); } @@ -62,14 +64,14 @@ public function testGetModelWithWrongInterface() )->method( 'create' )->with( - 'Magento\Framework\App\Config\Data\WrongBackendModel' + \Magento\Framework\App\Config\Data\WrongBackendModel::class )->will( $this->returnValue( - $this->getMock('Magento\Framework\App\Config\Data\WrongBackendModel', [], [], '', false) + $this->getMock(\Magento\Framework\App\Config\Data\WrongBackendModel::class, [], [], '', false) ) ); - $this->_model->get('Magento\Framework\App\Config\Data\WrongBackendModel'); + $this->_model->get(\Magento\Framework\App\Config\Data\WrongBackendModel::class); } /** @@ -82,12 +84,12 @@ public function testGetMemoryCache() )->method( 'create' )->with( - 'Magento\Framework\App\Config\Data\TestBackendModel' + \Magento\Framework\App\Config\Data\TestBackendModel::class )->will( $this->returnValue($this->_processorMock) ); - $this->_model->get('Magento\Framework\App\Config\Data\TestBackendModel'); - $this->_model->get('Magento\Framework\App\Config\Data\TestBackendModel'); + $this->_model->get(\Magento\Framework\App\Config\Data\TestBackendModel::class); + $this->_model->get(\Magento\Framework\App\Config\Data\TestBackendModel::class); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/DataFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/DataFactoryTest.php index b8192bdc559f0..a47e2214c65db 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/DataFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/DataFactoryTest.php @@ -9,8 +9,8 @@ class DataFactoryTest extends \Magento\Framework\TestFramework\Unit\AbstractFact { protected function setUp() { - $this->instanceClassName = 'Magento\Framework\App\Config\Data'; - $this->factoryClassName = 'Magento\Framework\App\Config\DataFactory'; + $this->instanceClassName = \Magento\Framework\App\Config\Data::class; + $this->factoryClassName = \Magento\Framework\App\Config\DataFactory::class; parent::setUp(); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php index 8c216aadf4ac2..fcfffc4b99f11 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php @@ -20,7 +20,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_metaDataProcessor = $this->getMock( - 'Magento\Framework\App\Config\MetadataProcessor', + \Magento\Framework\App\Config\MetadataProcessor::class, [], [], '', diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ElementTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ElementTest.php index 7bab07526379b..e14d4422f1210 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ElementTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ElementTest.php @@ -33,8 +33,8 @@ public function testIs() public function testGetClassName() { - $this->assertEquals('Magento\ModuleName\Model\ClassName', $this->model->class_test->getClassName()); - $this->assertEquals('Magento\ModuleName\Model\ClassName', $this->model->model_test->getClassName()); + $this->assertEquals(\Magento\ModuleName\Model\ClassName::class, $this->model->class_test->getClassName()); + $this->assertEquals(\Magento\ModuleName\Model\ClassName::class, $this->model->model_test->getClassName()); $this->assertFalse($this->model->no_classname_test->getClassName()); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/FileResolverTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/FileResolverTest.php index 2b2b2e5aadf60..8ab612de69bd8 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/FileResolverTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/FileResolverTest.php @@ -38,21 +38,21 @@ class FileResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->iteratorFactory = $this->getMock( - 'Magento\Framework\Config\FileIteratorFactory', + \Magento\Framework\Config\FileIteratorFactory::class, [], ['getPath'], '', false ); $this->filesystem = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryRead'], [], '', false ); $this->moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, [], ['getConfigurationFiles'], '', @@ -76,7 +76,7 @@ protected function setUp() public function testGetPrimary($filename, $fileList) { $scope = 'primary'; - $directory = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $directory = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $directory->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php index 1f7178ec6ed11..8634427b1f666 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php @@ -56,20 +56,20 @@ protected function setUp() } $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->filePath = __DIR__ . '/_files/'; - $this->fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); - $this->converterMock = $this->getMock('Magento\Framework\App\Config\Initial\Converter'); + $this->fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); + $this->converterMock = $this->getMock(\Magento\Framework\App\Config\Initial\Converter::class); $this->schemaLocatorMock = $this->getMock( - 'Magento\Framework\App\Config\Initial\SchemaLocator', + \Magento\Framework\App\Config\Initial\SchemaLocator::class, [], [], '', false ); - $this->validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->validationStateMock = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->validationStateMock->expects($this->any()) ->method('isValidationRequired') ->will($this->returnValue(true)); - $this->domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $this->domFactoryMock = $this->getMock(\Magento\Framework\Config\DomFactory::class, [], [], '', false); } public function testConstructor() @@ -168,7 +168,7 @@ private function createModelAndVerifyConstructor() $schemaFile = $this->filePath . 'config.xsd'; $this->schemaLocatorMock->expects($this->once())->method('getSchema')->will($this->returnValue($schemaFile)); $this->model = $this->objectManager->getObject( - 'Magento\Framework\App\Config\Initial\Reader', + \Magento\Framework\App\Config\Initial\Reader::class, [ 'fileResolver' => $this->fileResolverMock, 'converter' => $this->converterMock, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/SchemaLocatorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/SchemaLocatorTest.php index 60369d0111cd8..1e5ec76702c14 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/SchemaLocatorTest.php @@ -25,13 +25,13 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_moduleReaderMock = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->_moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->_moduleReaderMock->expects($this->once()) ->method('getModuleDir') ->with('etc', 'moduleName') ->will($this->returnValue('schema_dir')); $this->_model = $this->objectManager->getObject( - 'Magento\Framework\App\Config\Initial\SchemaLocator', + \Magento\Framework\App\Config\Initial\SchemaLocator::class, [ 'moduleReader' => $this->_moduleReaderMock, 'moduleName' => 'moduleName', diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php index d214dc5488b2a..ce85753bedab5 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php @@ -25,9 +25,9 @@ class InitialTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_initialReaderMock = - $this->getMock('Magento\Framework\App\Config\Initial\Reader', [], [], '', false); + $this->getMock(\Magento\Framework\App\Config\Initial\Reader::class, [], [], '', false); $this->_configCacheMock = - $this->getMock('Magento\Framework\App\Cache\Type\Config', [], [], '', false); + $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false); $serializedData = serialize( [ 'data' => [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/MetadataProcessorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/MetadataProcessorTest.php index d74d68e21a5e3..7db4ae150ce3c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/MetadataProcessorTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/MetadataProcessorTest.php @@ -30,14 +30,14 @@ class MetadataProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_modelPoolMock = $this->getMock( - 'Magento\Framework\App\Config\Data\ProcessorFactory', + \Magento\Framework\App\Config\Data\ProcessorFactory::class, [], [], '', false ); - $this->_initialConfigMock = $this->getMock('Magento\Framework\App\Config\Initial', [], [], '', false); - $this->_backendModelMock = $this->getMock('Magento\Framework\App\Config\Data\ProcessorInterface'); + $this->_initialConfigMock = $this->getMock(\Magento\Framework\App\Config\Initial::class, [], [], '', false); + $this->_backendModelMock = $this->getMock(\Magento\Framework\App\Config\Data\ProcessorInterface::class); $this->_initialConfigMock->expects( $this->any() )->method( diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php index cf3be29ad8865..ac22e3e19ab7e 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php @@ -35,14 +35,16 @@ class ScopePoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_readerPool = $this->getMockForAbstractClass('\Magento\Framework\App\Config\Scope\ReaderPoolInterface'); - $this->_reader = $this->getMockForAbstractClass('\Magento\Framework\App\Config\Scope\ReaderInterface'); + $this->_readerPool = $this->getMockForAbstractClass( + \Magento\Framework\App\Config\Scope\ReaderPoolInterface::class + ); + $this->_reader = $this->getMockForAbstractClass(\Magento\Framework\App\Config\Scope\ReaderInterface::class); $this->_dataFactory = $this->getMockBuilder( - '\Magento\Framework\App\Config\DataFactory' + \Magento\Framework\App\Config\DataFactory::class )->disableOriginalConstructor()->getMock(); - $this->_cache = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); + $this->_cache = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $this->_object = $helper->getObject( - '\Magento\Framework\App\Config\ScopePool', + \Magento\Framework\App\Config\ScopePool::class, [ 'readerPool' => $this->_readerPool, 'dataFactory' => $this->_dataFactory, @@ -89,7 +91,7 @@ public function testGetScope($scopeType, $scope, array $data, $cachedData) ); } - $configData = $this->getMockBuilder('\Magento\Framework\App\Config\Data') + $configData = $this->getMockBuilder(\Magento\Framework\App\Config\Data::class) ->disableOriginalConstructor() ->getMock(); $this->_dataFactory->expects( @@ -102,20 +104,20 @@ public function testGetScope($scopeType, $scope, array $data, $cachedData) $this->returnValue($configData) ); $this->assertInstanceOf( - '\Magento\Framework\App\Config\DataInterface', + \Magento\Framework\App\Config\DataInterface::class, $this->_object->getScope($scopeType, $scope) ); // second call to check caching $this->assertInstanceOf( - '\Magento\Framework\App\Config\DataInterface', + \Magento\Framework\App\Config\DataInterface::class, $this->_object->getScope($scopeType, $scope) ); } public function getScopeDataProvider() { - $baseScope = $this->getMockForAbstractClass('Magento\Framework\App\ScopeInterface'); + $baseScope = $this->getMockForAbstractClass(\Magento\Framework\App\ScopeInterface::class); $baseScope->expects($this->any())->method('getCode')->will($this->returnValue('testScope')); return [ ['scopeType1', 'testScope', ['key' => 'value'], null], diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php index e79925399ccfb..16304bc304171 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Storage/WriterTest.php @@ -28,11 +28,11 @@ class WriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->resource = $this->getMockBuilder('Magento\Framework\App\Config\ConfigResource\ConfigInterface') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\Config\ConfigResource\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $this->model = $this->objectManager->getObject( - 'Magento\Framework\App\Config\Storage\Writer', + \Magento\Framework\App\Config\Storage\Writer::class, ['resource' => $this->resource] ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueFactoryTest.php index f5d732b0a1ab9..69853ef983079 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueFactoryTest.php @@ -9,8 +9,8 @@ class ValueFactoryTest extends \Magento\Framework\TestFramework\Unit\AbstractFac { protected function setUp() { - $this->instanceClassName = 'Magento\Framework\App\Config\ValueInterface'; - $this->factoryClassName = 'Magento\Framework\App\Config\ValueFactory'; + $this->instanceClassName = \Magento\Framework\App\Config\ValueInterface::class; + $this->factoryClassName = \Magento\Framework\App\Config\ValueFactory::class; parent::setUp(); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php index 375a30a9756e8..f69063ac41b73 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php @@ -32,15 +32,15 @@ class ValueTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->cacheTypeListMock = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeListInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Framework\App\Config\Value', + \Magento\Framework\App\Config\Value::class, [ 'config' => $this->configMock, 'eventDispatcher' => $this->eventManagerMock, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php b/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php index 81057a591d3bc..9104d1d40eb02 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php @@ -42,22 +42,22 @@ class CronTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->_request = $this->getMock('Magento\Framework\App\Console\Request', [], [], '', false); - $this->_responseMock = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->_stateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->_request = $this->getMock(\Magento\Framework\App\Console\Request::class, [], [], '', false); + $this->_responseMock = $this->getMock(\Magento\Framework\App\Console\Response::class, [], [], '', false); + $this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new Cron($this->_stateMock, $this->_request, $this->_responseMock, $this->objectManager); } public function testLaunchDispatchesCronEvent() { - $configLoader = $this->getMockForAbstractClass('Magento\Framework\ObjectManager\ConfigLoaderInterface'); - $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $configLoader = $this->getMockForAbstractClass(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], - ['Magento\Framework\Event\ManagerInterface', $eventManagerMock], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $configLoader], + [\Magento\Framework\Event\ManagerInterface::class, $eventManagerMock], ])); $crontabConfig = ['config']; $configLoader->expects($this->once()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php index cd65f5e60fafb..b78e5a536ac9d 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php @@ -33,12 +33,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dirList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $this->dirList = $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); $this->dirList->expects($this->any()) ->method('getPath') ->with(DirectoryList::CONFIG) ->willReturn(__DIR__ . '/_files'); - $this->fileDriver = $this->getMock('\Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $this->fileDriver = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class, [], [], '', false); $this->fileDriver ->expects($this->any()) ->method('isExists') @@ -51,12 +51,12 @@ protected function setUp() [__DIR__ . '/_files/mergeTwo.php', true], [__DIR__ . '/_files/nonexistent.php', false] ])); - $this->driverPool = $this->getMock('\Magento\Framework\Filesystem\DriverPool', [], [], '', false); + $this->driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, [], [], '', false); $this->driverPool ->expects($this->any()) ->method('getDriver') ->willReturn($this->fileDriver); - $this->configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $this->configFilePool = $this->getMock(\Magento\Framework\Config\File\ConfigFilePool::class, [], [], '', false); $this->configFilePool ->expects($this->any()) ->method('getPaths') @@ -100,7 +100,7 @@ public function testLoad() */ public function testCustomLoad($file, $expected) { - $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $configFilePool = $this->getMock(\Magento\Framework\Config\File\ConfigFilePool::class, [], [], '', false); $configFilePool->expects($this->any())->method('getPaths')->willReturn([$file]); $configFilePool->expects($this->any())->method('getPath')->willReturn($file); $object = new Reader($this->dirList, $this->driverPool, $configFilePool, $file); @@ -124,7 +124,7 @@ public function loadCustomDataProvider() */ public function testMerging() { - $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $configFilePool = $this->getMock(\Magento\Framework\Config\File\ConfigFilePool::class, [], [], '', false); $files = [['configKeyOne', 'mergeOne.php'], ['configKeyTwo','mergeTwo.php']]; $configFilePool ->expects($this->any()) @@ -144,7 +144,7 @@ public function testMerging() */ public function testMergingWithDuplicateEndValues() { - $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $configFilePool = $this->getMock(\Magento\Framework\Config\File\ConfigFilePool::class, [], [], '', false); $files = [['configKeyOne', 'config.php'], ['configKeyTwo','duplicateConfig.php']]; $configFilePool ->expects($this->any()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php index 9382dc42be6bb..1cf64d60f6c2a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php @@ -50,13 +50,13 @@ class WriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->reader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->reader = $this->getMock(\Magento\Framework\App\DeploymentConfig\Reader::class, [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->formatter = $this->getMockForAbstractClass( - 'Magento\Framework\App\DeploymentConfig\Writer\FormatterInterface' + \Magento\Framework\App\DeploymentConfig\Writer\FormatterInterface::class ); - $this->configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->configFilePool = $this->getMock(\Magento\Framework\Config\File\ConfigFilePool::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->object = new Writer( $this->reader, $filesystem, @@ -65,8 +65,8 @@ protected function setUp() $this->formatter ); $this->reader->expects($this->any())->method('getFiles')->willReturn('test.php'); - $this->dirWrite = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); - $this->dirRead = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); + $this->dirWrite = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); + $this->dirRead = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->dirRead->expects($this->any()) ->method('getAbsolutePath'); $filesystem->expects($this->any()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php index 5e8a823fb0a50..0101c7902f127 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php @@ -69,7 +69,7 @@ public static function setUpBeforeClass() protected function setUp() { - $this->reader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); + $this->reader = $this->getMock(\Magento\Framework\App\DeploymentConfig\Reader::class, [], [], '', false); $this->_deploymentConfig = new \Magento\Framework\App\DeploymentConfig($this->reader, []); $this->_deploymentConfigMerged = new \Magento\Framework\App\DeploymentConfig( $this->reader, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php index 4e0cc085197e2..12cbaab59bfb1 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php @@ -24,7 +24,7 @@ public function testDirectoriesCustomization() $this->assertEquals('/root/dir/foo', $object->getPath(DirectoryList::APP)); $this->assertEquals('bar', $object->getUrlPath(DirectoryList::APP)); $this->setExpectedException( - '\Magento\Framework\Exception\FileSystemException', + \Magento\Framework\Exception\FileSystemException::class, "Unknown directory type: 'unknown'" ); $object->getPath('unknown'); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/FrontControllerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/FrontControllerTest.php index 702690211f1d9..5d77cbb8df0f2 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/FrontControllerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/FrontControllerTest.php @@ -36,14 +36,14 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods(['isDispatched', 'setDispatched', 'initForward', 'setActionName']) ->getMock(); - $this->router = $this->getMock('Magento\Framework\App\RouterInterface'); - $this->routerList = $this->getMock('Magento\Framework\App\RouterList', [], [], '', false); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->router = $this->getMock(\Magento\Framework\App\RouterInterface::class); + $this->routerList = $this->getMock(\Magento\Framework\App\RouterList::class, [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $this->model = new \Magento\Framework\App\FrontController($this->routerList, $this->response); } @@ -79,8 +79,8 @@ public function testDispatched() ->method('valid') ->will($this->returnValue(true)); - $response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $controllerInstance = $this->getMockBuilder('Magento\Framework\App\Action\Action') + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $controllerInstance = $this->getMockBuilder(\Magento\Framework\App\Action\Action::class) ->disableOriginalConstructor() ->getMock(); $controllerInstance->expects($this->any()) @@ -113,8 +113,8 @@ public function testDispatchedNotFoundException() ->method('valid') ->will($this->returnValue(true)); - $response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $controllerInstance = $this->getMockBuilder('Magento\Framework\App\Action\Action') + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $controllerInstance = $this->getMockBuilder(\Magento\Framework\App\Action\Action::class) ->disableOriginalConstructor() ->getMock(); $controllerInstance->expects($this->any()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Http/ContextTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Http/ContextTest.php index f853f9a8c49ad..05f589e0dc61a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Http/ContextTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Http/ContextTest.php @@ -23,7 +23,7 @@ class ContextTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->object = $this->objectManager->getObject('Magento\Framework\App\Http\Context'); + $this->object = $this->objectManager->getObject(\Magento\Framework\App\Http\Context::class); } public function testGetValue() diff --git a/lib/internal/Magento/Framework/App/Test/Unit/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/HttpTest.php index 3f931ac8c48d9..618dd5e8dde06 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/HttpTest.php @@ -10,6 +10,9 @@ use Magento\Framework\App\SetupInfo; use Magento\Framework\App\Bootstrap; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class HttpTest extends \PHPUnit_Framework_TestCase { /** @@ -65,23 +68,23 @@ class HttpTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $cookieReaderMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieReaderInterface') + $cookieReaderMock = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieReaderInterface::class) ->disableOriginalConstructor() ->getMock(); - $routeConfigMock = $this->getMockBuilder('Magento\Framework\App\Route\ConfigInterface\Proxy') + $routeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Route\ConfigInterface\Proxy::class) ->disableOriginalConstructor() ->getMock(); - $pathInfoProcessorMock = $this->getMockBuilder('Magento\Framework\App\Request\PathInfoProcessorInterface') + $pathInfoProcessorMock = $this->getMockBuilder(\Magento\Framework\App\Request\PathInfoProcessorInterface::class) ->disableOriginalConstructor() ->getMock(); - $converterMock = $this->getMockBuilder('Magento\Framework\Stdlib\StringUtils') + $converterMock = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class) ->disableOriginalConstructor() ->setMethods(['cleanString']) ->getMock(); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->setConstructorArgs([ 'cookieReader' => $cookieReaderMock, 'converter' => $converterMock, @@ -91,28 +94,28 @@ protected function setUp() ]) ->setMethods(['getFrontName']) ->getMock(); - $this->areaListMock = $this->getMockBuilder('Magento\Framework\App\AreaList') + $this->areaListMock = $this->getMockBuilder(\Magento\Framework\App\AreaList::class) ->disableOriginalConstructor() ->setMethods(['getCodeByFrontName']) ->getMock(); - $this->configLoaderMock = $this->getMockBuilder('Magento\Framework\App\ObjectManager\ConfigLoader') + $this->configLoaderMock = $this->getMockBuilder(\Magento\Framework\App\ObjectManager\ConfigLoader::class) ->disableOriginalConstructor() ->setMethods(['load']) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->frontControllerMock = $this->getMockBuilder('Magento\Framework\App\FrontControllerInterface') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->frontControllerMock = $this->getMockBuilder(\Magento\Framework\App\FrontControllerInterface::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); - $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->http = $this->objectManager->getObject( - 'Magento\Framework\App\Http', + \Magento\Framework\App\Http::class, [ 'objectManager' => $this->objectManagerMock, 'eventManager' => $this->eventManagerMock, @@ -141,7 +144,7 @@ private function setUpLaunch() $this->objectManagerMock->expects($this->once())->method('configure')->with([]); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\App\FrontControllerInterface') + ->with(\Magento\Framework\App\FrontControllerInterface::class) ->will($this->returnValue($this->frontControllerMock)); $this->frontControllerMock->expects($this->once()) ->method('dispatch') @@ -180,7 +183,7 @@ function () { public function testHandleDeveloperModeNotInstalled() { - $dir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); + $dir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $dir->expects($this->once())->method('getAbsolutePath')->willReturn(__DIR__); $this->filesystemMock->expects($this->once()) ->method('getDirectoryRead') @@ -219,7 +222,7 @@ public function testCatchExceptionSessionException() { $this->responseMock->expects($this->once())->method('setRedirect'); $this->responseMock->expects($this->once())->method('sendHeaders'); - $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $bootstrap = $this->getMock(\Magento\Framework\App\Bootstrap::class, [], [], '', false); $bootstrap->expects($this->once())->method('isDeveloperMode')->willReturn(false); $this->assertTrue($this->http->catchException( $bootstrap, @@ -234,7 +237,7 @@ public function testCatchExceptionSessionException() */ private function getBootstrapNotInstalled() { - $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $bootstrap = $this->getMock(\Magento\Framework\App\Bootstrap::class, [], [], '', false); $bootstrap->expects($this->once())->method('isDeveloperMode')->willReturn(true); $bootstrap->expects($this->once())->method('getErrorCode')->willReturn(Bootstrap::ERR_IS_INSTALLED); return $bootstrap; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php index 57484dca900a9..97a6d7ea2d097 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php @@ -25,15 +25,21 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->urnResolverMock->expects($this->any()) ->method('getRealPath') ->with('urn:magento:framework:App/Language/package.xsd') ->willReturn($this->urnResolver->getRealPath('urn:magento:framework:App/Language/package.xsd')); - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); - $domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $domFactoryMock = $this->getMock(\Magento\Framework\Config\DomFactory::class, [], [], '', false); $domFactoryMock->expects($this->once()) ->method('createDom') ->willReturnCallback( diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php index f29da5f624784..b73c282f9d15c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php @@ -33,9 +33,21 @@ class DictionaryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->readFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); - $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); - $this->configFactory = $this->getMockBuilder('\Magento\Framework\App\Language\ConfigFactory') + $this->readFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); + $this->componentRegistrar = $this->getMock( + \Magento\Framework\Component\ComponentRegistrar::class, + [], + [], + '', + false + ); + $this->configFactory = $this->getMockBuilder(\Magento\Framework\App\Language\ConfigFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -51,13 +63,13 @@ public function testDictionaryGetter() $expected[$item[0]] = $item[1]; } - $file = $this->getMockForAbstractClass('Magento\Framework\Filesystem\File\ReadInterface'); + $file = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\File\ReadInterface::class); for ($i = 0; $i < count($data); $i++) { $file->expects($this->at($i))->method('readCsv')->will($this->returnValue($data[$i])); } $file->expects($this->at($i))->method('readCsv')->will($this->returnValue(false)); - $readMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $readMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $readMock->expects($this->any())->method('readFile')->willReturnMap([ ['language.xml', $readMock], [$csvFileName, $file], @@ -71,7 +83,7 @@ public function testDictionaryGetter() $this->readFactory->expects($this->any())->method("create")->willReturn($readMock); - $languageConfig = $this->getMock('\Magento\Framework\App\Language\Config', [], [], '', false); + $languageConfig = $this->getMock(\Magento\Framework\App\Language\Config::class, [], [], '', false); $languageConfig->expects($this->any())->method('getCode')->will($this->returnValue('en_US')); $languageConfig->expects($this->any())->method('getVendor')->will($this->returnValue('foo')); $languageConfig->expects($this->any())->method('getPackage')->will($this->returnValue('en_us')); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/MaintenanceModeTest.php b/lib/internal/Magento/Framework/App/Test/Unit/MaintenanceModeTest.php index 726786afafd73..3311e4d48e77f 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/MaintenanceModeTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/MaintenanceModeTest.php @@ -22,8 +22,8 @@ class MaintenanceModeTest extends \PHPUnit_Framework_TestCase protected function setup() { - $this->flagDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->flagDir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValue($this->flagDir)); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php index 40e01b102dbef..336e958403f91 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php @@ -19,7 +19,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_cacheFrontendMock = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); + $this->_cacheFrontendMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $this->_configCache = new \Magento\Framework\App\ObjectManager\ConfigCache($this->_cacheFrontendMock); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php index 93707f2ef9a40..5a0b4ae96f26c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php @@ -32,16 +32,16 @@ class ConfigLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_readerMock = $this->getMock( - 'Magento\Framework\ObjectManager\Config\Reader\Dom', + $this->_readerMock = $this->getMock( + \Magento\Framework\ObjectManager\Config\Reader\Dom::class, [], [], '', false ); - $this->_readerFactoryMock = $this->getMock( - 'Magento\Framework\ObjectManager\Config\Reader\DomFactory', + $this->_readerFactoryMock = $this->getMock( + \Magento\Framework\ObjectManager\Config\Reader\DomFactory::class, ['create'], [], '', @@ -56,7 +56,7 @@ protected function setUp() $this->returnValue($this->_readerMock) ); - $this->_cacheMock = $this->getMock('Magento\Framework\App\Cache\Type\Config', [], [], '', false); + $this->_cacheMock = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false); $this->_model = new \Magento\Framework\App\ObjectManager\ConfigLoader( $this->_cacheMock, $this->_readerFactoryMock ); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/CompiledTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/CompiledTest.php index add099e6f395e..26ed18521ab48 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/CompiledTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/CompiledTest.php @@ -16,7 +16,7 @@ class CompiledTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $envFactoryMock = $this->getMock('Magento\Framework\App\EnvironmentFactory', [], [], '', false); + $envFactoryMock = $this->getMock(\Magento\Framework\App\EnvironmentFactory::class, [], [], '', false); $this->_compiled = new CompiledTesting($envFactoryMock); } @@ -28,7 +28,7 @@ public function testGetMode() public function testGetObjectManagerFactory() { $this->assertInstanceOf( - 'Magento\Framework\ObjectManager\Factory\Compiled', + \Magento\Framework\ObjectManager\Factory\Compiled::class, $this->_compiled->getObjectManagerFactory(['shared_instances' => []]) ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/DeveloperTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/DeveloperTest.php index f1edd110c2ede..88257c195980b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/DeveloperTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/Environment/DeveloperTest.php @@ -17,7 +17,7 @@ class DeveloperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $envFactoryMock = $this->getMock('Magento\Framework\App\EnvironmentFactory', [], [], '', false); + $envFactoryMock = $this->getMock(\Magento\Framework\App\EnvironmentFactory::class, [], [], '', false); $this->_developer = new Developer($envFactoryMock); } @@ -39,36 +39,32 @@ public function testConfigureObjectManager() $origObjectManager = null; } - - $objectManagerMock = $this->getMockBuilder('Magento\Framework\App\ObjectManager') + $objectManagerMock = $this->getMockBuilder(\Magento\Framework\App\ObjectManager::class) ->disableOriginalConstructor() ->getMock(); ObjectManager::setInstance($objectManagerMock); - $diConfigMock = $this->getMockBuilder('\Magento\Framework\Interception\ObjectManager\ConfigInterface') + $diConfigMock = $this->getMockBuilder(\Magento\Framework\Interception\ObjectManager\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $configLoaderMock = $this->getMockBuilder('Magento\Framework\App\ObjectManager\ConfigLoader') + $configLoaderMock = $this->getMockBuilder(\Magento\Framework\App\ObjectManager\ConfigLoader::class) ->disableOriginalConstructor() ->getMock(); $configLoaderMock->expects($this->any())->method('load')->willReturn([]); $omReturnMap = [ - ['Magento\Framework\App\ObjectManager\ConfigLoader', $configLoaderMock], - [ - 'Magento\Framework\Config\ScopeInterface', - $this->getMockBuilder('Magento\Framework\Config\ScopeInterface') + [\Magento\Framework\App\ObjectManager\ConfigLoader::class, $configLoaderMock], + [\Magento\Framework\Config\ScopeInterface::class, + $this->getMockBuilder(\Magento\Framework\Config\ScopeInterface::class) ->disableOriginalConstructor() ->getMock() ], - [ - 'Magento\Framework\App\ObjectManager\ConfigCache', - $this->getMockBuilder('Magento\Framework\App\ObjectManager\ConfigCache') + [\Magento\Framework\App\ObjectManager\ConfigCache::class, + $this->getMockBuilder(\Magento\Framework\App\ObjectManager\ConfigCache::class) ->disableOriginalConstructor() ->getMock() ], - [ - 'Magento\Framework\Interception\Config\Config', - $this->getMockBuilder('Magento\Framework\Interception\Config\Config') + [\Magento\Framework\Interception\Config\Config::class, + $this->getMockBuilder(\Magento\Framework\Interception\Config\Config::class) ->disableOriginalConstructor() ->getMock() ] @@ -80,7 +76,7 @@ public function testConfigureObjectManager() $expectedSharedInstances = [ 'class_name' => 'shared_object', - 'Magento\Framework\ObjectManager\ConfigLoaderInterface' => $configLoaderMock + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class => $configLoaderMock ]; $this->assertSame($expectedSharedInstances, $sharedInstances); if (isset($origObjectManager)) { diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/FormKeyTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/FormKeyTest.php index 82e7306b8b2e5..a67b37c440bef 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/FormKeyTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/FormKeyTest.php @@ -46,13 +46,13 @@ class FormKeyTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); + $this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); $this->cookieMetadataFactory = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class ) ->disableOriginalConstructor() ->getMock(); - $this->sessionManager = $this->getMock('Magento\Framework\Session\SessionManagerInterface'); + $this->sessionManager = $this->getMock(\Magento\Framework\Session\SessionManagerInterface::class); $this->formKey = new FormKey( $this->cookieManagerMock, $this->cookieMetadataFactory, @@ -79,7 +79,7 @@ public function testSet() $formKeyValue = 'form_key'; /** @var PublicCookieMetadata|\PHPUnit_Framework_MockObject_MockObject $metadata */ $metadata = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class ) ->disableOriginalConstructor() ->getMock(); @@ -101,7 +101,7 @@ public function testDelete() $cookieDomain = 'example.com'; /** @var PublicCookieMetadata|\PHPUnit_Framework_MockObject_MockObject $metadata */ $metadata = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php index f54747dc0cfcf..2484f3172ca8d 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php @@ -24,7 +24,7 @@ protected function setUp() */ protected function getRequestMock($uri, $vary = null) { - $requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $requestMock->expects($this->once()) ->method('getUriString') ->willReturn($uri); @@ -42,7 +42,7 @@ protected function getRequestMock($uri, $vary = null) */ protected function getContextMock($getVeryStringCalledTimes, $vary) { - $contextMock = $this->getMock('\Magento\Framework\App\Http\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false); $contextMock->expects($this->exactly($getVeryStringCalledTimes)) ->method('getVaryString') ->willReturn($vary); @@ -62,7 +62,7 @@ public function testGetValue($uri, $varyStringCookie, $varyStringContext, $expec $context = $this->getContextMock($varyStringCookie ? 0 : 1, $varyStringContext); $model = $this->objectManager->getObject( - '\Magento\Framework\App\PageCache\Identifier', + \Magento\Framework\App\PageCache\Identifier::class, [ 'request' => $request, 'context' => $context, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php index d309fa79f4ab6..81b828b3f938c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php @@ -32,20 +32,20 @@ class KernelTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->cacheMock = $this->getMock('Magento\Framework\App\PageCache\Cache', [], [], '', false); - $this->fullPageCacheMock = $this->getMock('\Magento\PageCache\Model\Cache\Type', [], [], '', false); + $this->cacheMock = $this->getMock(\Magento\Framework\App\PageCache\Cache::class, [], [], '', false); + $this->fullPageCacheMock = $this->getMock(\Magento\PageCache\Model\Cache\Type::class, [], [], '', false); $this->identifierMock = - $this->getMock('Magento\Framework\App\PageCache\Identifier', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->getMock(\Magento\Framework\App\PageCache\Identifier::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->kernel = new Kernel($this->cacheMock, $this->identifierMock, $this->requestMock); - $reflection = new \ReflectionClass('\Magento\Framework\App\PageCache\Kernel'); + $reflection = new \ReflectionClass(\Magento\Framework\App\PageCache\Kernel::class); $reflectionProperty = $reflection->getProperty('fullPageCache'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->kernel, $this->fullPageCacheMock); $this->responseMock = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' + \Magento\Framework\App\Response\Http::class )->setMethods( ['getHeader', 'getHttpResponseCode', 'setNoCacheHeaders', 'clearHeader', '__wakeup'] )->disableOriginalConstructor()->getMock(); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/PageCacheTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/PageCacheTest.php index b7908963bcfaf..9b52a8ddc525c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/PageCacheTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/PageCacheTest.php @@ -11,7 +11,7 @@ public function testIdentifierProperty() { $identifier = 'page_cache'; - $poolMock = $this->getMockBuilder('\Magento\Framework\App\Cache\Frontend\Pool') + $poolMock = $this->getMockBuilder(\Magento\Framework\App\Cache\Frontend\Pool::class) ->disableOriginalConstructor() ->getMock(); $poolMock->expects( @@ -24,6 +24,6 @@ public function testIdentifierProperty() $this->returnArgument(0) ); $model = new \Magento\Framework\App\PageCache\Cache($poolMock); - $this->assertInstanceOf('Magento\Framework\App\PageCache\Cache', $model); + $this->assertInstanceOf(\Magento\Framework\App\PageCache\Cache::class, $model); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/VersionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/VersionTest.php index 22d6f910b8287..1ed8b7d173f30 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/VersionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/VersionTest.php @@ -45,15 +45,15 @@ class VersionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->cookieMetadataFactoryMock = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class ) ->disableOriginalConstructor()->getMock(); $this->version = $objectManager->getObject( - 'Magento\Framework\App\PageCache\Version', + \Magento\Framework\App\PageCache\Version::class, [ 'cookieManager' => $this->cookieManagerMock, 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, @@ -77,7 +77,7 @@ public function testProcess($isPost) { $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue($isPost)); if ($isPost) { - $publicCookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata'); + $publicCookieMetadataMock = $this->getMock(\Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class); $publicCookieMetadataMock->expects($this->once()) ->method('setPath') ->with('/') diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php index ac98764ea953f..4d218a94276b3 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php @@ -16,14 +16,14 @@ class ProductMetadataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $composerJsonFinder = $this->getMockBuilder('Magento\Framework\Composer\ComposerJsonFinder') + $composerJsonFinder = $this->getMockBuilder(\Magento\Framework\Composer\ComposerJsonFinder::class) ->disableOriginalConstructor()->setMethods(['findComposerJson'])->getMock(); $composerJsonFinder->expects($this->any())->method('findComposerJson') ->willReturn(realpath(__DIR__ . '/_files/test.composer.json')); $objectManager = new ObjectManager($this); $this->productMetadata = $objectManager->getObject( - 'Magento\Framework\App\ProductMetadata', + \Magento\Framework\App\ProductMetadata::class, ['composerJsonFinder' => $composerJsonFinder] ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php index 4767b94a3e4b5..9a35aa9104e80 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php @@ -13,10 +13,10 @@ class ReinitableConfigTest extends \PHPUnit_Framework_TestCase public function testReinit() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $scopePool = $this->getMock('\Magento\Framework\App\Config\ScopePool', ['clean'], [], '', false); + $scopePool = $this->getMock(\Magento\Framework\App\Config\ScopePool::class, ['clean'], [], '', false); $scopePool->expects($this->once())->method('clean'); /** @var \Magento\Framework\App\ReinitableConfig $config */ - $config = $helper->getObject('Magento\Framework\App\ReinitableConfig', ['scopePool' => $scopePool]); - $this->assertInstanceOf('\Magento\Framework\App\Config\ReinitableConfigInterface', $config->reinit()); + $config = $helper->getObject(\Magento\Framework\App\ReinitableConfig::class, ['scopePool' => $scopePool]); + $this->assertInstanceOf(\Magento\Framework\App\Config\ReinitableConfigInterface::class, $config->reinit()); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php index 1dd2e50fd8334..9e88ad6b632ec 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php @@ -50,16 +50,16 @@ protected function setUp() { $this->_routerListMock = $this->getMock( - 'Magento\Framework\App\Route\ConfigInterface\Proxy', + \Magento\Framework\App\Route\ConfigInterface\Proxy::class, ['getRouteFrontName', 'getRouteByFrontName', '__wakeup'], [], '', false ); - $this->_infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); + $this->_infoProcessorMock = $this->getMock(\Magento\Framework\App\Request\PathInfoProcessorInterface::class); $this->_infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1)); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->converterMock = $this->getMockBuilder('Magento\Framework\Stdlib\StringUtils') + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->converterMock = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class) ->disableOriginalConstructor() ->setMethods(['cleanString']) ->getMock(); @@ -81,7 +81,7 @@ private function getModel($uri = null) { $testFrameworkObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager ($this); return $testFrameworkObjectManager->getObject( - 'Magento\Framework\App\Request\Http', + \Magento\Framework\App\Request\Http::class, [ 'routeConfig' => $this->_routerListMock, 'pathInfoProcessor' => $this->_infoProcessorMock, @@ -121,7 +121,7 @@ public function testGetBasePathWithoutPath() public function testSetRouteNameWithRouter() { - $router = $this->getMock('Magento\Framework\App\Router\AbstractRouter', [], [], '', false); + $router = $this->getMock(\Magento\Framework\App\Route\ConfigInterface::class, [], [], '', false); $this->_routerListMock->expects($this->any())->method('getRouteFrontName')->will($this->returnValue($router)); $this->_model = $this->getModel(); $this->_model->setRouteName('RouterName'); @@ -331,7 +331,7 @@ public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $header { $this->_model = $this->getModel(); $configOffloadHeader = 'Header-From-Proxy'; - $configMock = $this->getMockBuilder('Magento\Framework\App\Config') + $configMock = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -341,7 +341,7 @@ public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $header ->willReturn($configOffloadHeader); $this->objectManager->expects($this->exactly($configCall)) ->method('get') - ->with('Magento\Framework\App\Config') + ->with(\Magento\Framework\App\Config::class) ->will($this->returnValue($configMock)); $this->_model->getServer()->set($headerOffloadKey, $headerOffloadValue); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/RequestFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/RequestFactoryTest.php index 4d9bc6703b73d..72ba81168c05a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/RequestFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/RequestFactoryTest.php @@ -21,7 +21,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new RequestFactory($this->objectManagerMock); } @@ -33,11 +33,11 @@ public function testCreate() { $arguments = ['some_key' => 'same_value']; - $appRequest = $this->getMock('Magento\Framework\App\RequestInterface'); + $appRequest = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\App\RequestInterface', $arguments) + ->with(\Magento\Framework\App\RequestInterface::class, $arguments) ->will($this->returnValue($appRequest)); $this->assertEquals($appRequest, $this->model->create($arguments)); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/ReaderTest.php index 5a67221f41c0e..775dfa8070486 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/ReaderTest.php @@ -46,10 +46,10 @@ protected function setUp() { $this->_filePath = __DIR__ . '/_files/'; - $this->_fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); - $this->_validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->_fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); + $this->_validationStateMock = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->_schemaLocatorMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection\Config\SchemaLocator', + \Magento\Framework\App\ResourceConnection\Config\SchemaLocator::class, [], [], '', @@ -57,9 +57,9 @@ protected function setUp() ); $this->_converterMock = - $this->getMock('Magento\Framework\App\ResourceConnection\Config\Converter', [], [], '', false); + $this->getMock(\Magento\Framework\App\ResourceConnection\Config\Converter::class, [], [], '', false); - $this->_configLocalMock = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->_configLocalMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->_model = new \Magento\Framework\App\ResourceConnection\Config\Reader( $this->_fileResolverMock, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/SchemaLocatorTest.php index 0fa53c388c0e2..ffbb05d5b3674 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/Config/SchemaLocatorTest.php @@ -20,7 +20,7 @@ protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolverMock->expects($this->once()) ->method('getRealPath') ->with('urn:magento:framework:App/etc/resources.xsd') diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php index d601547660fd6..936a806432419 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php @@ -39,11 +39,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_scopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->_scopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); + $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); $this->_readerMock = - $this->getMock('Magento\Framework\App\ResourceConnection\Config\Reader', [], [], '', false); + $this->getMock(\Magento\Framework\App\ResourceConnection\Config\Reader::class, [], [], '', false); $this->_resourcesConfig = [ 'mainResourceName' => ['name' => 'mainResourceName', 'extends' => 'anotherResourceName'], @@ -65,7 +65,7 @@ protected function setUp() $this->returnValue(serialize($this->_resourcesConfig)) ); - $deploymentConfig = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfig->expects($this->once()) ->method('getConfigData') ->with('resource') @@ -95,7 +95,7 @@ public function testGetConnectionName($resourceName, $connectionName) */ public function testExceptionConstructor() { - $deploymentConfig = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfig->expects($this->once()) ->method('getConfigData') ->with('resource') diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConnectionFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConnectionFactoryTest.php index 5426b03694808..cab6d784275e9 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConnectionFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConnectionFactoryTest.php @@ -25,28 +25,28 @@ class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->model = $this->objectManager->getObject( - 'Magento\Framework\App\ResourceConnection\ConnectionFactory', + \Magento\Framework\App\ResourceConnection\ConnectionFactory::class, ['objectManager' => $this->objectManagerMock] ); } public function testCreate() { - $cacheAdapterMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\DdlCache') + $cacheAdapterMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\DdlCache::class) ->disableOriginalConstructor() ->getMock(); - $loggerMock = $this->getMockBuilder('Magento\Framework\DB\LoggerInterface') + $loggerMock = $this->getMockBuilder(\Magento\Framework\DB\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $adapterClass = 'Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface'; + $adapterClass = \Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface::class; $connectionAdapterMock = $this->getMockBuilder($adapterClass) ->disableOriginalConstructor() ->getMock(); - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMock(); $connectionMock->expects($this->once()) @@ -59,14 +59,14 @@ public function testCreate() ->will($this->returnValue($connectionMock)); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface') + ->with(\Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface::class) ->will($this->returnValue($connectionAdapterMock)); $this->objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap( [ - ['Magento\Framework\DB\LoggerInterface', $loggerMock], - ['Magento\Framework\DB\Adapter\DdlCache', $cacheAdapterMock], + [\Magento\Framework\DB\LoggerInterface::class, $loggerMock], + [\Magento\Framework\DB\Adapter\DdlCache::class, $cacheAdapterMock], ] )); $this->assertSame($connectionMock, $this->model->create(['active' => true])); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XFrameOptionsTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XFrameOptionsTest.php index ce0f02376bf9b..fff7d6ef2e33b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XFrameOptionsTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XFrameOptionsTest.php @@ -28,7 +28,7 @@ protected function setUp() { $objectManager = new ObjectManagerHelper($this); $this->object = $objectManager->getObject( - '\Magento\Framework\App\Response\HeaderProvider\XFrameOptions', + \Magento\Framework\App\Response\HeaderProvider\XFrameOptions::class, ['xFrameOpt' => $this::HEADER_VALUE] ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XssProtectionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XssProtectionTest.php index 6477bb41914e7..6e861842416a7 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XssProtectionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/HeaderProvider/XssProtectionTest.php @@ -18,12 +18,12 @@ class XssProtectionTest extends \PHPUnit_Framework_TestCase */ public function testGetValue($userAgent, $expectedHeader) { - $headerServiceMock = $this->getMockBuilder('Magento\Framework\HTTP\Header') + $headerServiceMock = $this->getMockBuilder(\Magento\Framework\HTTP\Header::class) ->disableOriginalConstructor() ->getMock(); $headerServiceMock->expects($this->once())->method('getHttpUserAgent')->willReturn($userAgent); $model = (new ObjectManager($this))->getObject( - 'Magento\Framework\App\Response\HeaderProvider\XssProtection', + \Magento\Framework\App\Response\HeaderProvider\XssProtection::class, ['headerService' => $headerServiceMock] ); $this->assertSame($expectedHeader, $model->getValue()); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php index 23c6543060652..64350225e64ac 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php @@ -31,14 +31,14 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->fileSystemMock = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryWrite'], [], '', false ); $this->dirMock = $this->getMockBuilder( - '\Magento\Framework\Filesystem\Directory\Write' + \Magento\Framework\Filesystem\Directory\Write::class )->disableOriginalConstructor()->getMock(); $this->fileSystemMock->expects( @@ -57,7 +57,7 @@ protected function setUp() $this->returnValue(0) ); $this->responseMock = $this->getMock( - 'Magento\Framework\App\Response\Http', + \Magento\Framework\App\Response\Http::class, ['setHeader', 'sendHeaders', 'setHttpResponseCode', 'clearBody', 'setBody', '__wakeup'], [], '', @@ -121,7 +121,7 @@ public function testCreateArrayContent() ->method('sendHeaders') ->will($this->returnSelf()); - $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + $streamMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\WriteInterface::class) ->disableOriginalConstructor()->getMock(); $this->dirMock->expects($this->once()) ->method('openFile') @@ -164,7 +164,7 @@ public function testCreateArrayContentRm() ->method('sendHeaders') ->will($this->returnSelf()); - $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + $streamMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\WriteInterface::class) ->disableOriginalConstructor()->getMock(); $this->dirMock->expects($this->once()) ->method('openFile') @@ -206,7 +206,7 @@ public function testCreateStringContent() $this->dirMock->expects($this->once()) ->method('writeFile') ->with('fileName', 'content', 'w+'); - $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + $streamMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\WriteInterface::class) ->disableOriginalConstructor()->getMock(); $this->dirMock->expects($this->once()) ->method('openFile') @@ -227,7 +227,7 @@ public function testCreateStringContent() private function getModel() { return $this->objectManager->getObject( - 'Magento\Framework\App\Response\Http\FileFactory', + \Magento\Framework\App\Response\Http\FileFactory::class, [ 'response' => $this->responseMock, 'filesystem' => $this->fileSystemMock, @@ -243,7 +243,7 @@ private function getModel() private function getModelMock() { $modelMock = $this->getMock( - 'Magento\Framework\App\Response\Http\FileFactory', + \Magento\Framework\App\Response\Http\FileFactory::class, ['callExit'], [ 'response' => $this->responseMock, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php index a2153d639cd53..2045fc9bd17b4 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php @@ -11,6 +11,9 @@ use \Magento\Framework\App\Response\Http; use Magento\Framework\ObjectManagerInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class HttpTest extends \PHPUnit_Framework_TestCase { /** @@ -42,22 +45,23 @@ class HttpTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->requestMock = $this->getMockBuilder('\Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $this->cookieMetadataFactoryMock = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class )->disableOriginalConstructor()->getMock(); - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); - $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Http\Context')->disableOriginalConstructor() + $this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); + $this->contextMock = $this->getMockBuilder( + \Magento\Framework\App\Http\Context::class)->disableOriginalConstructor() ->getMock(); - $this->dateTimeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime') + $this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class) ->disableOriginalConstructor() ->getMock(); $this->model = $this->objectManager->getObject( - 'Magento\Framework\App\Response\Http', + \Magento\Framework\App\Response\Http::class, [ 'request' => $this->requestMock, 'cookieManager' => $this->cookieManagerMock, @@ -74,7 +78,7 @@ protected function tearDown() { unset($this->model); /** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManagerMock*/ - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); } @@ -83,7 +87,8 @@ public function testSendVary() $data = ['some-vary-key' => 'some-vary-value']; $expectedCookieName = Http::COOKIE_VARY_STRING; $expectedCookieValue = sha1(serialize($data)); - $sensitiveCookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata') + $sensitiveCookieMetadataMock = $this->getMockBuilder( + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class) ->disableOriginalConstructor() ->getMock(); $sensitiveCookieMetadataMock->expects($this->once()) @@ -108,7 +113,7 @@ public function testSendVary() public function testSendVaryEmptyDataDeleteCookie() { $expectedCookieName = Http::COOKIE_VARY_STRING; - $cookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadata'); + $cookieMetadataMock = $this->getMock(\Magento\Framework\Stdlib\Cookie\CookieMetadata::class); $cookieMetadataMock->expects($this->once()) ->method('setPath') ->with('/') @@ -261,7 +266,7 @@ public function testRepresentJson() public function testWakeUpWithException() { /* ensure that the test preconditions are met */ - $objectManagerClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $objectManagerClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $instanceProperty = $objectManagerClass->getProperty('_instance'); $instanceProperty->setAccessible(true); $instanceProperty->setValue(null); @@ -278,14 +283,14 @@ public function testWakeUpWithException() */ public function testWakeUpWith() { - $objectManagerMock = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\App\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\Stdlib\CookieManagerInterface') + ->with(\Magento\Framework\Stdlib\CookieManagerInterface::class) ->will($this->returnValue($this->cookieManagerMock)); $objectManagerMock->expects($this->at(1)) ->method('get') - ->with('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory') + ->with(\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class) ->will($this->returnValue($this->cookieMetadataFactoryMock)); \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResponseFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResponseFactoryTest.php index a32a878565285..a8bd549276148 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResponseFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResponseFactoryTest.php @@ -24,20 +24,20 @@ class ResponseFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Framework\App\ResponseFactory($this->_objectManagerMock); } public function testCreate() { - $this->_expectedObject = $this->getMockBuilder('\Magento\Framework\App\ResponseInterface')->getMock(); + $this->_expectedObject = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class)->getMock(); $arguments = [['property' => 'value']]; $this->_objectManagerMock->expects( $this->once() )->method( 'create' )->with( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, $arguments )->will( $this->returnValue($this->_expectedObject) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Route/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Route/Config/SchemaLocatorTest.php index fe09c4570b346..26497e7ff6051 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Route/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Route/Config/SchemaLocatorTest.php @@ -22,7 +22,7 @@ protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->config = new \Magento\Framework\App\Route\Config\SchemaLocator($this->urnResolverMock); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigInterface/ProxyTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigInterface/ProxyTest.php index bea53642188e9..6d65e95d847c1 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigInterface/ProxyTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigInterface/ProxyTest.php @@ -21,22 +21,22 @@ class ProxyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_object = $this->getMock( - '\Magento\Framework\App\Route\ConfigInterface', + \Magento\Framework\App\Route\ConfigInterface::class, ['getRouteFrontName', 'getRouteByFrontName', 'getModulesByFrontName'], [], '', false ); - $objectManager = $this->getMock('\Magento\Framework\ObjectManager\ObjectManager', ['get'], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, ['get'], [], '', false); $objectManager->expects($this->once()) ->method('get') - ->with('Magento\Framework\App\Route\ConfigInterface') + ->with(\Magento\Framework\App\Route\ConfigInterface::class) ->will($this->returnValue($this->_object)); $this->_proxy = new \Magento\Framework\App\Route\ConfigInterface\Proxy( $objectManager, - 'Magento\Framework\App\Route\ConfigInterface' + \Magento\Framework\App\Route\ConfigInterface::class ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php index a2f0ba8da7467..949ed3f9953c9 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php @@ -34,10 +34,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_readerMock = $this->getMock('Magento\Framework\App\Route\Config\Reader', [], [], '', false); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); - $this->_configScopeMock = $this->getMock('\Magento\Framework\Config\ScopeInterface'); - $this->_areaList = $this->getMock('\Magento\Framework\App\AreaList', [], [], '', false); + $this->_readerMock = $this->getMock(\Magento\Framework\App\Route\Config\Reader::class, [], [], '', false); + $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); + $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); + $this->_areaList = $this->getMock(\Magento\Framework\App\AreaList::class, [], [], '', false); $this->_configScopeMock->expects( $this->any() )->method( diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php index 898ee146c29c8..c24c31e282c62 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php @@ -32,10 +32,10 @@ class ActionListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->cacheMock = $this->getMockBuilder('Magento\Framework\Config\CacheInterface') + $this->cacheMock = $this->getMockBuilder(\Magento\Framework\Config\CacheInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->moduleReaderMock = $this->getMockBuilder('Magento\Framework\Module\Dir\Reader') + $this->moduleReaderMock = $this->getMockBuilder(\Magento\Framework\Module\Dir\Reader::class) ->disableOriginalConstructor() ->getMock(); } @@ -50,7 +50,7 @@ public function testConstructorCachedData() $this->moduleReaderMock->expects($this->never()) ->method('getActionFiles'); $this->actionList = $this->objectManager->getObject( - 'Magento\Framework\App\Router\ActionList', + \Magento\Framework\App\Router\ActionList::class, [ 'cache' => $this->cacheMock, 'moduleReader' => $this->moduleReaderMock, @@ -69,7 +69,7 @@ public function testConstructorNoCachedData() ->method('getActionFiles') ->will($this->returnValue('data')); $this->actionList = $this->objectManager->getObject( - 'Magento\Framework\App\Router\ActionList', + \Magento\Framework\App\Router\ActionList::class, [ 'cache' => $this->cacheMock, 'moduleReader' => $this->moduleReaderMock, @@ -98,7 +98,7 @@ public function testGet($module, $area, $namespace, $action, $data, $expected) ->method('getActionFiles') ->will($this->returnValue($data)); $this->actionList = $this->objectManager->getObject( - 'Magento\Framework\App\Router\ActionList', + \Magento\Framework\App\Router\ActionList::class, [ 'cache' => $this->cacheMock, 'moduleReader' => $this->moduleReaderMock, @@ -111,7 +111,7 @@ public function getDataProvider() { $mockClassName = 'Mock_Action_Class'; $actionClass = $this->getMockClass( - 'Magento\Framework\App\ActionInterface', + \Magento\Framework\App\ActionInterface::class, ['execute', 'getResponse'], [], $mockClassName diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/BaseTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/BaseTest.php index 0576f120aa986..bf49959b67007 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/BaseTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/BaseTest.php @@ -53,13 +53,13 @@ protected function setUp() { parent::setUp(); // Create mocks - $this->requestMock = $this->basicMock('Magento\Framework\App\Request\Http'); - $this->routeConfigMock = $this->basicMock('Magento\Framework\App\Route\ConfigInterface'); - $this->appStateMock = $this->basicMock('Magento\Framework\App\State'); - $this->actionListMock = $this->basicMock('Magento\Framework\App\Router\ActionList'); - $this->actionFactoryMock = $this->basicMock('Magento\Framework\App\ActionFactory'); - $this->nameBuilderMock = $this->basicMock('Magento\Framework\Code\NameBuilder'); - $this->defaultPathMock = $this->basicMock('Magento\Framework\App\DefaultPathInterface'); + $this->requestMock = $this->basicMock(\Magento\Framework\App\Request\Http::class); + $this->routeConfigMock = $this->basicMock(\Magento\Framework\App\Route\ConfigInterface::class); + $this->appStateMock = $this->basicMock(\Magento\Framework\App\State::class); + $this->actionListMock = $this->basicMock(\Magento\Framework\App\Router\ActionList::class); + $this->actionFactoryMock = $this->basicMock(\Magento\Framework\App\ActionFactory::class); + $this->nameBuilderMock = $this->basicMock(\Magento\Framework\Code\NameBuilder::class); + $this->defaultPathMock = $this->basicMock(\Magento\Framework\App\DefaultPathInterface::class); // Prepare SUT $mocks = [ @@ -70,7 +70,7 @@ protected function setUp() 'nameBuilder' => $this->nameBuilderMock, 'defaultPath' => $this->defaultPathMock, ]; - $this->model = $this->objectManager->getObject('Magento\Framework\App\Router\Base', $mocks); + $this->model = $this->objectManager->getObject(\Magento\Framework\App\Router\Base::class, $mocks); } public function testMatch() @@ -80,7 +80,7 @@ public function testMatch() $moduleFrontName = 'module front name'; $actionPath = 'action path'; $actionName = 'action name'; - $actionClassName = 'Magento\Cms\Controller\Index\Index'; + $actionClassName = \Magento\Cms\Controller\Index\Index::class; $moduleName = 'module name'; $moduleList = [$moduleName]; @@ -109,7 +109,7 @@ public function testMatchUseParams() $moduleFrontName = 'module front name'; $actionPath = 'action path'; $actionName = 'action name'; - $actionClassName = 'Magento\Cms\Controller\Index\Index'; + $actionClassName = \Magento\Cms\Controller\Index\Index::class; $moduleName = 'module name'; $moduleList = [$moduleName]; $paramList = $moduleFrontName . '/' . $actionPath . '/' . $actionName . '/key/val/key2/val2/'; @@ -137,7 +137,7 @@ public function testMatchUseDefaultPath() $moduleFrontName = 'module front name'; $actionPath = 'action path'; $actionName = 'action name'; - $actionClassName = 'Magento\Cms\Controller\Index\Index'; + $actionClassName = \Magento\Cms\Controller\Index\Index::class; $moduleName = 'module name'; $moduleList = [$moduleName]; @@ -169,7 +169,7 @@ public function testMatchEmptyModuleList() $moduleFrontName = 'module front name'; $actionPath = 'action path'; $actionName = 'action name'; - $actionClassName = 'Magento\Cms\Controller\Index\Index'; + $actionClassName = \Magento\Cms\Controller\Index\Index::class; $emptyModuleList = []; // Stubs @@ -192,7 +192,7 @@ public function testMatchEmptyActionInstance() $moduleFrontName = 'module front name'; $actionPath = 'action path'; $actionName = 'action name'; - $actionClassName = 'Magento\Cms\Controller\Index\Index'; + $actionClassName = \Magento\Cms\Controller\Index\Index::class; $moduleName = 'module name'; $moduleList = [$moduleName]; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/DefaultRouterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/DefaultRouterTest.php index c32896b32a39e..fa25773fd0686 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/DefaultRouterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/DefaultRouterTest.php @@ -16,27 +16,33 @@ class DefaultRouterTest extends \PHPUnit_Framework_TestCase public function testMatch() { - $request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); + $request = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $actionFactory = $this->getMock('Magento\Framework\App\ActionFactory', [], [], '', false); + $actionFactory = $this->getMock(\Magento\Framework\App\ActionFactory::class, [], [], '', false); $actionFactory->expects($this->once())->method('create')->with( - 'Magento\Framework\App\Action\Forward' + \Magento\Framework\App\Action\Forward::class )->will( $this->returnValue( - $this->getMockForAbstractClass('Magento\Framework\App\Action\AbstractAction', [], '', false) + $this->getMockForAbstractClass(\Magento\Framework\App\Action\AbstractAction::class, [], '', false) ) ); - $noRouteHandler = $this->getMock('Magento\Framework\App\Router\NoRouteHandler', [], [], '', false); + $noRouteHandler = $this->getMock(\Magento\Framework\App\Router\NoRouteHandler::class, [], [], '', false); $noRouteHandler->expects($this->any())->method('process')->will($this->returnValue(true)); - $noRouteHandlerList = $this->getMock('Magento\Framework\App\Router\NoRouteHandlerList', [], [], '', false); + $noRouteHandlerList = $this->getMock( + \Magento\Framework\App\Router\NoRouteHandlerList::class, + [], + [], + '', + false + ); $noRouteHandlerList->expects($this->any())->method('getHandlers')->will($this->returnValue([$noRouteHandler])); $this->_model = $helper->getObject( - 'Magento\Framework\App\Router\DefaultRouter', + \Magento\Framework\App\Router\DefaultRouter::class, [ 'actionFactory' => $actionFactory, 'noRouteHandlerList' => $noRouteHandlerList ] ); - $this->assertInstanceOf('Magento\Framework\App\Action\AbstractAction', $this->_model->match($request)); + $this->assertInstanceOf(\Magento\Framework\App\Action\AbstractAction::class, $this->_model->match($request)); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php index cdff08abdc24f..1af3a0b86ee7e 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php @@ -22,10 +22,10 @@ class NoRouteHandlerListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $handlersList = [ - 'default_handler' => ['class' => 'Magento\Framework\App\Router\NoRouteHandler', 'sortOrder' => 100], - 'backend_handler' => ['class' => 'Magento\Backend\App\Router\NoRouteHandler', 'sortOrder' => 10], + 'default_handler' => ['class' => \Magento\Framework\App\Router\NoRouteHandler::class, 'sortOrder' => 100], + 'backend_handler' => ['class' => \Magento\Backend\App\Router\NoRouteHandler::class, 'sortOrder' => 10], ]; $this->_model = new \Magento\Framework\App\Router\NoRouteHandlerList($this->_objectManagerMock, $handlersList); @@ -33,15 +33,15 @@ protected function setUp() public function testGetHandlers() { - $backendHandlerMock = $this->getMock('Magento\Backend\App\Router\NoRouteHandler', [], [], '', false); - $defaultHandlerMock = $this->getMock('Magento\Framework\App\Router\NoRouteHandler', [], [], '', false); + $backendHandlerMock = $this->getMock(\Magento\Backend\App\Router\NoRouteHandler::class, [], [], '', false); + $defaultHandlerMock = $this->getMock(\Magento\Framework\App\Router\NoRouteHandler::class, [], [], '', false); $this->_objectManagerMock->expects( $this->at(0) )->method( 'create' )->with( - 'Magento\Backend\App\Router\NoRouteHandler' + \Magento\Backend\App\Router\NoRouteHandler::class )->will( $this->returnValue($backendHandlerMock) ); @@ -51,7 +51,7 @@ public function testGetHandlers() )->method( 'create' )->with( - 'Magento\Framework\App\Router\NoRouteHandler' + \Magento\Framework\App\Router\NoRouteHandler::class )->will( $this->returnValue($defaultHandlerMock) ); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerTest.php index 2341dddd64293..eaa6418348dba 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerTest.php @@ -30,9 +30,10 @@ class NoRouteHandlerTest extends \Magento\Framework\TestFramework\Unit\BaseTestC protected function setUp() { parent::setUp(); - $this->configMock = $this->basicMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->requestMock = $this->basicMock('Magento\Framework\App\Request\Http'); - $this->model = $this->objectManager->getObject('Magento\Framework\App\Router\NoRouteHandler', + $this->configMock = $this->basicMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->requestMock = $this->basicMock(\Magento\Framework\App\Request\Http::class); + $this->model = $this->objectManager->getObject( + \Magento\Framework\App\Router\NoRouteHandler::class, [ 'config' => $this->configMock, ] diff --git a/lib/internal/Magento/Framework/App/Test/Unit/RouterListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/RouterListTest.php index 9bc9d784a1b54..398d53ec0d451 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/RouterListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/RouterListTest.php @@ -34,7 +34,7 @@ protected function setUp() 'anotherRouter' => ['class' => 'AnotherClass', 'disable' => false, 'sortOrder' => 15], ]; - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Framework\App\RouterList($this->objectManagerMock, $this->routerList); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php index 5c174981ff5e7..5e9f9513d52ad 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php @@ -20,12 +20,13 @@ protected function setUp() public function testGet() { - $scope = $this->getMock('\Magento\Framework\App\ScopeResolverInterface'); - $scopeResolver = $this->_helper->getObject('Magento\Framework\App\ScopeResolverPool', [ - 'scopeResolvers' => [ - 'test' => $scope, + $scope = $this->getMock(\Magento\Framework\App\ScopeResolverInterface::class); + $scopeResolver = $this->_helper->getObject( + \Magento\Framework\App\ScopeResolverPool::class, + [ + 'scopeResolvers' => ['test' => $scope] ] - ]); + ); $this->assertSame($scope, $scopeResolver->get('test')); } @@ -39,11 +40,12 @@ public function testGet() */ public function testGetException($scope) { - $scopeResolver = $this->_helper->getObject('Magento\Framework\App\ScopeResolverPool', [ - 'scopeResolvers' => [ - 'test' => new \Magento\Framework\DataObject(), + $scopeResolver = $this->_helper->getObject( + \Magento\Framework\App\ScopeResolverPool::class, + [ + 'scopeResolvers' => ['test' => new \Magento\Framework\DataObject()] ] - ]); + ); $scopeResolver->get($scope); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php index 9f1cc05345281..bb15ca757fc54 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php @@ -22,10 +22,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->loggerMock = $this->getMockBuilder('\Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->driverMock = $this->getMockBuilder('\Magento\Framework\Shell\Driver') + $this->driverMock = $this->getMockBuilder(\Magento\Framework\Shell\Driver::class) ->disableOriginalConstructor() ->getMock(); $this->model = new Shell( diff --git a/lib/internal/Magento/Framework/App/Test/Unit/State/CleanupFilesTest.php b/lib/internal/Magento/Framework/App/Test/Unit/State/CleanupFilesTest.php index 3c88b7ca291d7..3c7c6b2a2256f 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/State/CleanupFilesTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/State/CleanupFilesTest.php @@ -25,7 +25,7 @@ class CleanupFilesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->object = new CleanupFiles($this->filesystem); } @@ -65,7 +65,7 @@ public function testClearMaterializedViewFiles() */ private function getDirectoryCleanMock($subPath = null) { - $dir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $dir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $dir->expects($this->once())->method('search')->with('*', $subPath)->willReturn(['one', 'two']); $dir->expects($this->exactly(2))->method('delete'); $dir->expects($this->once())->method('isExist')->will($this->returnValue(true)); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php b/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php index 657f2f2821c50..c68d8eb30aed0 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php @@ -23,7 +23,7 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeMock = $this->getMockForAbstractClass( - 'Magento\Framework\Config\ScopeInterface', + \Magento\Framework\Config\ScopeInterface::class, ['setCurrentScope'], '', false @@ -36,14 +36,14 @@ public function testSetAreaCode() $areaCode = 'some code'; $this->scopeMock->expects($this->once())->method('setCurrentScope')->with($areaCode); $this->model->setAreaCode($areaCode); - $this->setExpectedException('Magento\Framework\Exception\LocalizedException'); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); $this->model->setAreaCode('any code'); } public function testGetAreaCodeException() { $this->scopeMock->expects($this->never())->method('setCurrentScope'); - $this->setExpectedException('Magento\Framework\Exception\LocalizedException'); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); $this->model->getAreaCode(); } @@ -129,7 +129,7 @@ public function emulateAreaCodeCallbackException() public function testConstructor($mode) { $model = new \Magento\Framework\App\State( - $this->getMockForAbstractClass('Magento\Framework\Config\ScopeInterface', [], '', false), + $this->getMockForAbstractClass(\Magento\Framework\Config\ScopeInterface::class, [], '', false), $mode ); $this->assertEquals($mode, $model->getMode()); @@ -154,7 +154,7 @@ public static function constructorDataProvider() public function testConstructorException() { new \Magento\Framework\App\State( - $this->getMockForAbstractClass('Magento\Framework\Config\ScopeInterface', [], '', false), + $this->getMockForAbstractClass(\Magento\Framework\Config\ScopeInterface::class, [], '', false), "unknown mode" ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php b/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php index 78d5cc7f5acc9..52c3edc38e340 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php @@ -8,6 +8,9 @@ namespace Magento\Framework\App\Test\Unit; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class StaticResourceTest extends \PHPUnit_Framework_TestCase { /** @@ -57,15 +60,15 @@ class StaticResourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->state = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->response = $this->getMock('Magento\MediaStorage\Model\File\Storage\Response', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->publisher = $this->getMock('Magento\Framework\App\View\Asset\Publisher', [], [], '', false); - $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->moduleList = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->state = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->response = $this->getMock(\Magento\MediaStorage\Model\File\Storage\Response::class, [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->publisher = $this->getMock(\Magento\Framework\App\View\Asset\Publisher::class, [], [], '', false); + $this->assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->moduleList = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $this->configLoader = $this->getMock( - 'Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false + \Magento\Framework\App\ObjectManager\ConfigLoader::class, [], [], '', false ); $this->object = new \Magento\Framework\App\StaticResource( $this->state, @@ -76,7 +79,7 @@ protected function setUp() $this->moduleList, $this->objectManager, $this->configLoader, - $this->getMockForAbstractClass('\Magento\Framework\View\DesignInterface') + $this->getMockForAbstractClass(\Magento\Framework\View\DesignInterface::class) ); } @@ -132,7 +135,7 @@ public function testLaunch( ->method('has') ->with($requestedModule) ->will($this->returnValue($moduleExists)); - $asset = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\LocalInterface'); + $asset = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\LocalInterface::class); $asset->expects($this->once())->method('getSourceFile')->will($this->returnValue('resource/file.css')); $this->assetRepo->expects($this->once()) ->method('createAsset') @@ -190,7 +193,7 @@ public function testLaunchWrongPath() public function testCatchException() { - $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $bootstrap = $this->getMock(\Magento\Framework\App\Bootstrap::class, [], [], '', false); $bootstrap->expects($this->at(0))->method('isDeveloperMode')->willReturn(false); $bootstrap->expects($this->at(1))->method('isDeveloperMode')->willReturn(true); $exception = new \Exception('message'); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Utility/AggregateInvokerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Utility/AggregateInvokerTest.php index f5149445574ea..ac0e44f3e522a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Utility/AggregateInvokerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Utility/AggregateInvokerTest.php @@ -22,7 +22,7 @@ class AggregateInvokerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_testCase = $this->getMock( - 'PHPUnit_Framework_Test', + \PHPUnit_Framework_Test::class, ['run', 'count', 'fail', 'markTestIncomplete', 'markTestSkipped'] ); $this->_invoker = new AggregateInvoker($this->_testCase, []); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Utility/FilesTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Utility/FilesTest.php index ee92507a5b2fd..ecb3cc78258ba 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Utility/FilesTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Utility/FilesTest.php @@ -23,8 +23,14 @@ class FilesTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->componentRegistrar = new ComponentRegistrar(); - $this->dirSearch = $this->getMock('Magento\Framework\Component\DirSearch', [], [], '', false); - $themePackageList = $this->getMock('Magento\Framework\View\Design\Theme\ThemePackageList', [], [], '', false); + $this->dirSearch = $this->getMock(\Magento\Framework\Component\DirSearch::class, [], [], '', false); + $themePackageList = $this->getMock( + \Magento\Framework\View\Design\Theme\ThemePackageList::class, + [], + [], + '', + false + ); Files::setInstance(new Files($this->componentRegistrar, $this->dirSearch, $themePackageList)); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/CopyTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/CopyTest.php index 101481cd674b2..107dee6567aac 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/CopyTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/CopyTest.php @@ -22,9 +22,9 @@ protected function setUp() public function testPublishFile() { - $rootDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $rootDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMock(); - $targetDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $targetDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMock(); $sourcePath = 'source/path/file'; $destinationPath = 'destination/path/file'; @@ -42,7 +42,7 @@ public function testPublishFile() public function testIsSupported() { - $asset = $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface') + $asset = $this->getMockBuilder(\Magento\Framework\View\Asset\LocalInterface::class) ->getMock(); $this->assertTrue($this->copyPublisher->isSupported($asset)); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php index 2dd0bd5306766..c478d15c902b2 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php @@ -19,7 +19,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->setMethods([]) ->getMock(); } @@ -27,7 +27,7 @@ protected function setUp() public function testCreateEmptyStrategies() { $asset = $this->getAsset(); - $copyStrategy = $this->getMockBuilder('Magento\Framework\App\View\Asset\MaterializationStrategy\Copy') + $copyStrategy = $this->getMockBuilder(\Magento\Framework\App\View\Asset\MaterializationStrategy\Copy::class) ->setMethods([]) ->getMock(); $copyStrategy->expects($this->once()) @@ -47,7 +47,7 @@ public function testCreateEmptyStrategies() public function testCreateSupported() { $asset = $this->getAsset(); - $copyStrategy = $this->getMockBuilder('Magento\Framework\App\View\Asset\MaterializationStrategy\Copy') + $copyStrategy = $this->getMockBuilder(\Magento\Framework\App\View\Asset\MaterializationStrategy\Copy::class) ->setMethods([]) ->getMock(); $copyStrategy->expects($this->once()) @@ -56,7 +56,7 @@ public function testCreateSupported() ->willReturn(false); $supportedStrategy = $this->getMockBuilder( - 'Magento\Framework\App\View\Asset\MaterializationStrategy\StrategyInterface' + \Magento\Framework\App\View\Asset\MaterializationStrategy\StrategyInterface::class ) ->setMethods([]) ->getMock(); @@ -72,7 +72,7 @@ public function testCreateSupported() public function testCreateException() { $asset = $this->getAsset(); - $copyStrategy = $this->getMockBuilder('Magento\Framework\App\View\Asset\MaterializationStrategy\Copy') + $copyStrategy = $this->getMockBuilder(\Magento\Framework\App\View\Asset\MaterializationStrategy\Copy::class) ->setMethods([]) ->getMock(); $copyStrategy->expects($this->once()) @@ -96,7 +96,7 @@ public function testCreateException() */ private function getAsset() { - return $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface') + return $this->getMockBuilder(\Magento\Framework\View\Asset\LocalInterface::class) ->setMethods([]) ->getMock(); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/SymlinkTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/SymlinkTest.php index b160e121efbfc..868a3ee51f70a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/SymlinkTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/SymlinkTest.php @@ -25,9 +25,9 @@ protected function setUp() public function testPublishFile() { - $rootDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $rootDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMock(); - $targetDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $targetDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMock(); $sourcePath = 'source/path/file'; $destinationPath = 'destination/path/file'; @@ -48,7 +48,7 @@ public function testPublishFile() */ public function testIsSupported($path, $expectation) { - $asset = $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface') + $asset = $this->getMockBuilder(\Magento\Framework\View\Asset\LocalInterface::class) ->setMethods([]) ->getMock(); $asset->expects($this->once()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/PublisherTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/PublisherTest.php index 9e73c0e148c54..6af3f3ffda12f 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/PublisherTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/PublisherTest.php @@ -51,20 +51,32 @@ class PublisherTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->materializationStrategyFactory = $this->getMock( - 'Magento\Framework\App\View\Asset\MaterializationStrategy\Factory', + \Magento\Framework\App\View\Asset\MaterializationStrategy\Factory::class, + [], + [], + '', + false + ); + $this->writeFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\WriteFactory::class, [], [], '', false ); - $this->writeFactory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false); $this->object = new Publisher($this->filesystem, $this->materializationStrategyFactory, $this->writeFactory); - $this->sourceDirWrite = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); - $this->staticDirRead = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->staticDirWrite = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->sourceDirWrite = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class + ); + $this->staticDirRead = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\ReadInterface::class + ); + $this->staticDirWrite = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class + ); $this->filesystem->expects($this->any()) ->method('getDirectoryRead') ->with(DirectoryList::STATIC_VIEW) @@ -91,7 +103,7 @@ public function testPublish() ->with('some/file.ext') ->will($this->returnValue(false)); $materializationStrategy = $this->getMock( - 'Magento\Framework\App\View\Asset\MaterializationStrategy\StrategyInterface', + \Magento\Framework\App\View\Asset\MaterializationStrategy\StrategyInterface::class, [], [], '', @@ -117,7 +129,7 @@ public function testPublish() */ protected function getAsset() { - $asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); + $asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $asset->expects($this->any()) ->method('getPath') ->will($this->returnValue('some/file.ext')); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php index 34ea3db2c987d..3981511ad4701 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php @@ -22,8 +22,8 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface'); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->directory = $this->getMock(\Magento\Framework\Filesystem\Directory\WriteInterface::class); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem ->expects($this->once()) ->method('getDirectoryWrite') diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php index 5caa3275e1d54..30f398b4f6000 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php @@ -29,8 +29,8 @@ class VersionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->versionStorage = $this->getMock('Magento\Framework\App\View\Deployment\Version\StorageInterface'); + $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->versionStorage = $this->getMock(\Magento\Framework\App\View\Deployment\Version\StorageInterface::class); $this->object = new Version($this->appState, $this->versionStorage); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ViewTest.php index 527e3981ef60e..e03b86ffd1001 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ViewTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ViewTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Framework\App\Test\Unit; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ViewTest extends \PHPUnit_Framework_TestCase { /** @@ -55,28 +58,29 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_layoutProcessor = $this->getMock('Magento\Framework\View\Model\Layout\Merge', [], [], '', false); + $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); + $this->_layoutProcessor = $this->getMock(\Magento\Framework\View\Model\Layout\Merge::class, [], [], '', false); $this->_layoutMock->expects($this->any())->method('getUpdate') ->will($this->returnValue($this->_layoutProcessor)); - $this->_actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); - $this->_eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $pageConfigMock = $this->getMockBuilder('\Magento\Framework\View\Page\Config')->disableOriginalConstructor() - ->getMock(); + $this->_actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); + $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $pageConfigMock = $this->getMockBuilder( + \Magento\Framework\View\Page\Config::class + )->disableOriginalConstructor()->getMock(); $pageConfigMock->expects($this->any()) ->method('publicBuild') ->willReturnSelf(); - $pageConfigRendererFactory = $this->getMockBuilder('Magento\Framework\View\Page\Config\RendererFactory') + $pageConfigRendererFactory = $this->getMockBuilder(\Magento\Framework\View\Page\Config\RendererFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPage = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPage = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->setConstructorArgs( - $helper->getConstructArguments('Magento\Framework\View\Result\Page', [ + $helper->getConstructArguments(\Magento\Framework\View\Result\Page::class, [ 'request' => $this->_requestMock, 'pageConfigRendererFactory' => $pageConfigRendererFactory, 'layout' => $this->_layoutMock @@ -87,7 +91,7 @@ protected function setUp() $this->resultPage->expects($this->any()) ->method('getConfig') ->will($this->returnValue($pageConfigMock)); - $pageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $pageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -95,10 +99,10 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->resultPage)); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $this->_view = $helper->getObject( - 'Magento\Framework\App\View', + \Magento\Framework\App\View::class, [ 'layout' => $this->_layoutMock, 'request' => $this->_requestMock, diff --git a/lib/internal/Magento/Framework/App/Utility/Classes.php b/lib/internal/Magento/Framework/App/Utility/Classes.php index bcdd606461876..5deac4a06e556 100644 --- a/lib/internal/Magento/Framework/App/Utility/Classes.php +++ b/lib/internal/Magento/Framework/App/Utility/Classes.php @@ -138,7 +138,7 @@ public static function collectClassesInConfig(\SimpleXMLElement $xml) ) ); - $classes = array_map(['Magento\Framework\App\Utility\Classes', 'getCallbackClass'], $classes); + $classes = array_map([\Magento\Framework\App\Utility\Classes::class, 'getCallbackClass'], $classes); $classes = array_map('trim', $classes); $classes = array_unique($classes); $classes = array_filter( @@ -273,10 +273,11 @@ public static function isAutogenerated($className) { if ( preg_match( - '/.*\\\\[a-zA-Z0-9]{1,}(Factory|Proxy|SearchResults|DataBuilder|Extension|ExtensionInterface)$/', + '/.*\\\\[a-zA-Z0-9]{1,}(Factory|SearchResults|DataBuilder|Extension|ExtensionInterface)$/', $className ) || preg_match('/Magento\\\\[\w]+\\\\(Test\\\\(Page|Fixture))\\\\/', $className) + || preg_match('/.*\\\\[a-zA-Z0-9]{1,}\\\\Proxy$/', $className) ) { return true; } diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index cf5a8aae3b501..722b29172d8f9 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -1257,6 +1257,7 @@ private function getPaths() * @param string $class * @param string &$path * @return bool + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function classFileExists($class, &$path = '') { @@ -1277,6 +1278,8 @@ public function classFileExists($class, &$path = '') '/dev/tests/static/framework', '/dev/tests/static/testsuite', '/dev/tests/functional/tests/app', + '/dev/tests/functional/lib', + '/dev/tests/functional/vendor/magento/mtf', '/setup/src' ]; foreach ($directories as $key => $dir) { @@ -1305,6 +1308,10 @@ public function classFileExists($class, &$path = '') if ($this->classFileExistsCheckContent($trimmedFullPath, $namespace, $className)) { return true; } + $trimmedFullPath = $dir . '/' . $classParts[2] . '/' . $classParts[3]; + if ($this->classFileExistsCheckContent($trimmedFullPath, $namespace, $className)) { + return true; + } } } return false; diff --git a/lib/internal/Magento/Framework/App/View/Asset/MaterializationStrategy/Factory.php b/lib/internal/Magento/Framework/App/View/Asset/MaterializationStrategy/Factory.php index b864e20329bb1..d74da78fd9b98 100644 --- a/lib/internal/Magento/Framework/App/View/Asset/MaterializationStrategy/Factory.php +++ b/lib/internal/Magento/Framework/App/View/Asset/MaterializationStrategy/Factory.php @@ -28,7 +28,7 @@ class Factory /** * Default strategy key */ - const DEFAULT_STRATEGY = 'Magento\Framework\App\View\Asset\MaterializationStrategy\Copy'; + const DEFAULT_STRATEGY = \Magento\Framework\App\View\Asset\MaterializationStrategy\Copy::class; /** * @param ObjectManagerInterface $objectManager diff --git a/lib/internal/Magento/Framework/Archive/Test/Unit/ZipTest.php b/lib/internal/Magento/Framework/Archive/Test/Unit/ZipTest.php index b2ced298d3894..e7fbff77de190 100644 --- a/lib/internal/Magento/Framework/Archive/Test/Unit/ZipTest.php +++ b/lib/internal/Magento/Framework/Archive/Test/Unit/ZipTest.php @@ -19,7 +19,7 @@ class ZipTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->zip = $this->getMockBuilder('\Magento\Framework\Archive\Zip') + $this->zip = $this->getMockBuilder(\Magento\Framework\Archive\Zip::class) ->disableOriginalConstructor() ->getMock(); } @@ -30,7 +30,7 @@ protected function setUp() public function testConstructorNoExceptions() { try { - $reflectedClass = new \ReflectionClass('\Magento\Framework\Archive\Zip'); + $reflectedClass = new \ReflectionClass(\Magento\Framework\Archive\Zip::class); $constructor = $reflectedClass->getConstructor(); $constructor->invoke($this->zip, []); } catch (\Exception $e) { diff --git a/lib/internal/Magento/Framework/Authorization/Factory.php b/lib/internal/Magento/Framework/Authorization/Factory.php index c27ec10cfeb8b..e019b96a93925 100644 --- a/lib/internal/Magento/Framework/Authorization/Factory.php +++ b/lib/internal/Magento/Framework/Authorization/Factory.php @@ -15,7 +15,7 @@ class Factory /** * Entity class name */ - const CLASS_NAME = 'Magento\Framework\Authorization'; + const CLASS_NAME = \Magento\Framework\Authorization::class; /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/Authorization/Test/Unit/Policy/AclTest.php b/lib/internal/Magento/Framework/Authorization/Test/Unit/Policy/AclTest.php index 43eba7a103ad1..b6a381e777241 100644 --- a/lib/internal/Magento/Framework/Authorization/Test/Unit/Policy/AclTest.php +++ b/lib/internal/Magento/Framework/Authorization/Test/Unit/Policy/AclTest.php @@ -24,8 +24,8 @@ class AclTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_aclMock = $this->getMock('Magento\Framework\Acl'); - $this->_aclBuilderMock = $this->getMock('Magento\Framework\Acl\Builder', [], [], '', false); + $this->_aclMock = $this->getMock(\Magento\Framework\Acl::class); + $this->_aclBuilderMock = $this->getMock(\Magento\Framework\Acl\Builder::class, [], [], '', false); $this->_aclBuilderMock->expects($this->any())->method('getAcl')->will($this->returnValue($this->_aclMock)); $this->_model = new \Magento\Framework\Authorization\Policy\Acl($this->_aclBuilderMock); } diff --git a/lib/internal/Magento/Framework/Autoload/Test/Unit/ClassLoaderWrapperTest.php b/lib/internal/Magento/Framework/Autoload/Test/Unit/ClassLoaderWrapperTest.php index d3d1429548bde..be40adcdc0edc 100644 --- a/lib/internal/Magento/Framework/Autoload/Test/Unit/ClassLoaderWrapperTest.php +++ b/lib/internal/Magento/Framework/Autoload/Test/Unit/ClassLoaderWrapperTest.php @@ -31,8 +31,8 @@ class ClassLoaderWrapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->autoloaderMock = $this->getMock('Composer\Autoload\ClassLoader'); - $this->model = (new ObjectManager($this))->getObject('Magento\Framework\Autoload\ClassLoaderWrapper', + $this->autoloaderMock = $this->getMock(\Composer\Autoload\ClassLoader::class); + $this->model = (new ObjectManager($this))->getObject(\Magento\Framework\Autoload\ClassLoaderWrapper::class, [ 'autoloader' => $this->autoloaderMock ] diff --git a/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php b/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php index f53bc7e7bf1fb..e54abe380b1d0 100644 --- a/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php +++ b/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php @@ -16,7 +16,7 @@ class PopulatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mockDirectoryList = $this->getMockBuilder('\Magento\Framework\App\Filesystem\DirectoryList') + $this->mockDirectoryList = $this->getMockBuilder(\Magento\Framework\App\Filesystem\DirectoryList::class) ->disableOriginalConstructor() ->getMock(); @@ -27,7 +27,7 @@ protected function setUp() public function testPopulateMappings() { - $mockAutoloader = $this->getMockBuilder('\Magento\Framework\Autoload\AutoloaderInterface') + $mockAutoloader = $this->getMockBuilder(\Magento\Framework\Autoload\AutoloaderInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Backup/Test/Unit/FactoryTest.php b/lib/internal/Magento/Framework/Backup/Test/Unit/FactoryTest.php index b4afde13f7de7..f6f65921a4b84 100644 --- a/lib/internal/Magento/Framework/Backup/Test/Unit/FactoryTest.php +++ b/lib/internal/Magento/Framework/Backup/Test/Unit/FactoryTest.php @@ -19,7 +19,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Framework\Backup\Factory($this->_objectManager); } diff --git a/lib/internal/Magento/Framework/Backup/Test/Unit/MediaTest.php b/lib/internal/Magento/Framework/Backup/Test/Unit/MediaTest.php index c58cb128895f9..ef382be2d4b52 100644 --- a/lib/internal/Magento/Framework/Backup/Test/Unit/MediaTest.php +++ b/lib/internal/Magento/Framework/Backup/Test/Unit/MediaTest.php @@ -36,7 +36,7 @@ public static function tearDownAfterClass() protected function setUp() { - $this->_backupDbMock = $this->getMock('Magento\Framework\Backup\Db', [], [], '', false); + $this->_backupDbMock = $this->getMock(\Magento\Framework\Backup\Db::class, [], [], '', false); $this->_backupDbMock->expects($this->any())->method('setBackupExtension')->will($this->returnSelf()); $this->_backupDbMock->expects($this->any())->method('setTime')->will($this->returnSelf()); @@ -55,13 +55,13 @@ protected function setUp() $this->_backupDbMock->expects($this->any())->method('create')->will($this->returnValue(true)); - $this->_filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $dirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->_filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->_filesystemMock->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValue($dirMock)); - $this->_backupFactoryMock = $this->getMock('Magento\Framework\Backup\Factory', [], [], '', false); + $this->_backupFactoryMock = $this->getMock(\Magento\Framework\Backup\Factory::class, [], [], '', false); $this->_backupFactoryMock->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/Backup/Test/Unit/NomediaTest.php b/lib/internal/Magento/Framework/Backup/Test/Unit/NomediaTest.php index 53829a16d82e5..6a045a9974f84 100644 --- a/lib/internal/Magento/Framework/Backup/Test/Unit/NomediaTest.php +++ b/lib/internal/Magento/Framework/Backup/Test/Unit/NomediaTest.php @@ -36,7 +36,7 @@ public static function tearDownAfterClass() protected function setUp() { - $this->_backupDbMock = $this->getMock('Magento\Framework\Backup\Db', [], [], '', false); + $this->_backupDbMock = $this->getMock(\Magento\Framework\Backup\Db::class, [], [], '', false); $this->_backupDbMock->expects($this->any())->method('setBackupExtension')->will($this->returnSelf()); $this->_backupDbMock->expects($this->any())->method('setTime')->will($this->returnSelf()); @@ -55,13 +55,13 @@ protected function setUp() $this->_backupDbMock->expects($this->any())->method('create')->will($this->returnValue(true)); - $this->_filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $dirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->_filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->_filesystemMock->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValue($dirMock)); - $this->_backupFactoryMock = $this->getMock('Magento\Framework\Backup\Factory', [], [], '', false); + $this->_backupFactoryMock = $this->getMock(\Magento\Framework\Backup\Factory::class, [], [], '', false); $this->_backupFactoryMock->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php b/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php index ad11d32945f01..ced4a43321083 100644 --- a/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php +++ b/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php @@ -9,10 +9,10 @@ class SnapshotTest extends \PHPUnit_Framework_TestCase { public function testGetDbBackupFilename() { - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $backupFactory = $this->getMock('Magento\Framework\Backup\Factory', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $backupFactory = $this->getMock(\Magento\Framework\Backup\Factory::class, [], [], '', false); $manager = $this->getMock( - 'Magento\Framework\Backup\Snapshot', + \Magento\Framework\Backup\Snapshot::class, ['getBackupFilename'], [$filesystem, $backupFactory] ); diff --git a/lib/internal/Magento/Framework/Cache/Backend/Eaccelerator.php b/lib/internal/Magento/Framework/Cache/Backend/Eaccelerator.php index 80d48a7c2d597..c8b96659a6b40 100644 --- a/lib/internal/Magento/Framework/Cache/Backend/Eaccelerator.php +++ b/lib/internal/Magento/Framework/Cache/Backend/Eaccelerator.php @@ -13,9 +13,11 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex /** * Log message */ - const TAGS_UNSUPPORTED_BY_CLEAN_OF_EACCELERATOR_BACKEND = 'Magento\Framework\Cache\Backend\Eaccelerator::clean() : tags are unsupported by the Eaccelerator backend'; + const TAGS_UNSUPPORTED_BY_CLEAN_OF_EACCELERATOR_BACKEND = + 'Magento\Framework\Cache\Backend\Eaccelerator::clean() : tags are unsupported by the Eaccelerator backend'; - const TAGS_UNSUPPORTED_BY_SAVE_OF_EACCELERATOR_BACKEND = 'Magento\Framework\Cache\Backend\Eaccelerator::save() : tags are unsupported by the Eaccelerator backend'; + const TAGS_UNSUPPORTED_BY_SAVE_OF_EACCELERATOR_BACKEND = + 'Magento\Framework\Cache\Backend\Eaccelerator::save() : tags are unsupported by the Eaccelerator backend'; /** * Constructor diff --git a/lib/internal/Magento/Framework/Cache/Config/Reader.php b/lib/internal/Magento/Framework/Cache/Config/Reader.php index a3e3f66dfd71b..fb4c2f1ade533 100644 --- a/lib/internal/Magento/Framework/Cache/Config/Reader.php +++ b/lib/internal/Magento/Framework/Cache/Config/Reader.php @@ -31,7 +31,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'cache.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/DatabaseTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/DatabaseTest.php index 691c7b0c57736..28cb5176b9b77 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/DatabaseTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/DatabaseTest.php @@ -26,7 +26,7 @@ protected function setUp() public function testInitializeWithException($options) { $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, [ 'options' => $options, ] @@ -56,7 +56,7 @@ public function initializeWithExceptionDataProvider() 'data_table_callback' => '', 'tags_table' => 'tags_table', 'tags_table_callback' => 'tags_table_callback', - 'adapter' => $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false), + 'adapter' => $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false), ], ], 'empty_tags_table' => [ @@ -66,7 +66,7 @@ public function initializeWithExceptionDataProvider() 'data_table_callback' => 'data_table_callback', 'tags_table' => '', 'tags_table_callback' => '', - 'adapter' => $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false), + 'adapter' => $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false), ], ], ]; @@ -82,7 +82,7 @@ public function testLoad($options, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -95,12 +95,12 @@ public function testLoad($options, $expected) */ public function loadDataProvider() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchOne']) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMock('Magento\Framework\DB\Select', ['where', 'from'], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['where', 'from'], [], '', false); $selectMock->expects($this->any()) ->method('where') @@ -155,7 +155,7 @@ public function getOptionsWithStoreData($connectionMock) public function getOptionsWithoutStoreData($connectionMock = null) { if (null === $connectionMock) { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); } @@ -181,7 +181,7 @@ public function testTest($options, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -199,7 +199,7 @@ public function testSave($options, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -233,12 +233,12 @@ public function saveDataProvider() */ protected function getSaveAdapterMock($result) { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['quoteIdentifier', 'query']) ->disableOriginalConstructor() ->getMock(); - $dbStatementMock = $this->getMockBuilder('Zend_Db_Statement_Interface') + $dbStatementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class) ->setMethods(['rowCount']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -268,7 +268,7 @@ public function testRemove($options, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -280,7 +280,7 @@ public function testRemove($options, $expected) */ public function removeDataProvider() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['delete']) ->disableOriginalConstructor() ->getMock(); @@ -313,7 +313,7 @@ public function testClean($options, $mode, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -325,7 +325,7 @@ public function testClean($options, $mode, $expected) */ public function cleanDataProvider() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['query', 'delete']) ->disableOriginalConstructor() ->getMock(); @@ -386,7 +386,7 @@ public function testCleanException() { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $this->getOptionsWithoutStoreData()] ); @@ -403,7 +403,7 @@ public function testGetIds($options, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -415,12 +415,12 @@ public function testGetIds($options, $expected) */ public function getIdsDataProvider() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchCol']) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMock('Magento\Framework\DB\Select', ['from'], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['from'], [], '', false); $selectMock->expects($this->any()) ->method('from') @@ -449,12 +449,12 @@ public function getIdsDataProvider() public function testGetTags() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchCol']) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMock('Magento\Framework\DB\Select', ['from', 'distinct'], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['from', 'distinct'], [], '', false); $selectMock->expects($this->any()) ->method('from') @@ -474,7 +474,7 @@ public function testGetTags() /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $this->getOptionsWithStoreData($connectionMock)] ); @@ -483,13 +483,13 @@ public function testGetTags() public function testGetIdsMatchingTags() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchCol']) ->disableOriginalConstructor() ->getMock(); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['from', 'distinct', 'where', 'group', 'having'], [], '', @@ -526,7 +526,7 @@ public function testGetIdsMatchingTags() /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $this->getOptionsWithStoreData($connectionMock)] ); @@ -535,13 +535,13 @@ public function testGetIdsMatchingTags() public function testGetIdsNotMatchingTags() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchCol']) ->disableOriginalConstructor() ->getMock(); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['from', 'distinct', 'where', 'group', 'having'], [], '', @@ -582,7 +582,7 @@ public function testGetIdsNotMatchingTags() /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $this->getOptionsWithStoreData($connectionMock)] ); @@ -591,12 +591,12 @@ public function testGetIdsNotMatchingTags() public function testGetIdsMatchingAnyTags() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchCol']) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMock('Magento\Framework\DB\Select', ['from', 'distinct'], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['from', 'distinct'], [], '', false); $selectMock->expects($this->any()) ->method('from') @@ -616,7 +616,7 @@ public function testGetIdsMatchingAnyTags() /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $this->getOptionsWithStoreData($connectionMock)] ); @@ -625,12 +625,12 @@ public function testGetIdsMatchingAnyTags() public function testGetMetadatas() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'fetchCol', 'fetchRow']) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMock('Magento\Framework\DB\Select', ['from', 'where'], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['from', 'where'], [], '', false); $selectMock->expects($this->any()) ->method('from') @@ -654,7 +654,7 @@ public function testGetMetadatas() /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $this->getOptionsWithStoreData($connectionMock)] ); @@ -678,7 +678,7 @@ public function testTouch($options, $expected) { /** @var \Magento\Framework\Cache\Backend\Database $database */ $database = $this->objectManager->getObject( - 'Magento\Framework\Cache\Backend\Database', + \Magento\Framework\Cache\Backend\Database::class, ['options' => $options] ); @@ -690,7 +690,7 @@ public function testTouch($options, $expected) */ public function touchDataProvider() { - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['update']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php index f5fe81d1f511c..82ff4dc3b8d76 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php @@ -29,7 +29,7 @@ class CompressionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $options = [ - 'concrete_backend' => $this->getMock('Zend_Cache_Backend_File'), + 'concrete_backend' => $this->getMock(\Zend_Cache_Backend_File::class), 'compression_threshold' => strlen($this->_testString), ]; $this->_decorator = new \Magento\Framework\Cache\Backend\Decorator\Compression($options); @@ -43,7 +43,10 @@ protected function tearDown() public function testCompressData() { - $method = new \ReflectionMethod('Magento\Framework\Cache\Backend\Decorator\Compression', '_compressData'); + $method = new \ReflectionMethod( + \Magento\Framework\Cache\Backend\Decorator\Compression::class, + '_compressData' + ); $method->setAccessible(true); $this->assertStringStartsWith('CACHE_COMPRESSION', $method->invoke($this->_decorator, $this->_testString)); @@ -52,13 +55,13 @@ public function testCompressData() public function testDecompressData() { $methodCompress = new \ReflectionMethod( - 'Magento\Framework\Cache\Backend\Decorator\Compression', + \Magento\Framework\Cache\Backend\Decorator\Compression::class, '_compressData' ); $methodCompress->setAccessible(true); $methodDecompress = new \ReflectionMethod( - 'Magento\Framework\Cache\Backend\Decorator\Compression', + \Magento\Framework\Cache\Backend\Decorator\Compression::class, '_decompressData' ); $methodDecompress->setAccessible(true); @@ -75,7 +78,7 @@ public function testDecompressData() public function testIsCompressionNeeded() { $method = new \ReflectionMethod( - 'Magento\Framework\Cache\Backend\Decorator\Compression', + \Magento\Framework\Cache\Backend\Decorator\Compression::class, '_isCompressionNeeded' ); $method->setAccessible(true); @@ -90,7 +93,7 @@ public function testIsDecompressionNeeded() $prefix = 'CACHE_COMPRESSION'; $method = new \ReflectionMethod( - 'Magento\Framework\Cache\Backend\Decorator\Compression', + \Magento\Framework\Cache\Backend\Decorator\Compression::class, '_isDecompressionNeeded' ); $method->setAccessible(true); @@ -104,7 +107,7 @@ public function testSaveLoad() { $cacheId = 'cacheId' . rand(1, 100); - $backend = $this->getMock('Zend_Cache_Backend_File', ['save', 'load']); + $backend = $this->getMock(\Zend_Cache_Backend_File::class, ['save', 'load']); $backend->expects($this->once())->method('save')->will($this->returnCallback([__CLASS__, 'mockSave'])); $backend->expects($this->once())->method('load')->will($this->returnCallback([__CLASS__, 'mockLoad'])); diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php index 1a67951f3c453..9e9124164852f 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php @@ -18,7 +18,7 @@ class DecoratorAbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_mockBackend = $this->getMock('Zend_Cache_Backend_File'); + $this->_mockBackend = $this->getMock(\Zend_Cache_Backend_File::class); } protected function tearDown() @@ -31,18 +31,18 @@ public function testConstructor() $options = ['concrete_backend' => $this->_mockBackend, 'testOption' => 'testOption']; $decorator = $this->getMockForAbstractClass( - 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', + \Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, [$options] ); $backendProperty = new \ReflectionProperty( - 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', + \Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, '_backend' ); $backendProperty->setAccessible(true); $optionsProperty = new \ReflectionProperty( - 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', + \Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, '_decoratorOptions' ); $optionsProperty->setAccessible(true); @@ -60,14 +60,14 @@ public function testConstructor() */ public function testConstructorException($options) { - $this->getMockForAbstractClass('Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', [$options]); + $this->getMockForAbstractClass(\Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, [$options]); } public function constructorExceptionDataProvider() { return [ 'empty' => [[]], - 'wrong_class' => [['concrete_backend' => $this->getMock('Test_Class')]] + 'wrong_class' => [['concrete_backend' => $this->getMock(\Test_Class::class)]] ]; } @@ -79,7 +79,7 @@ public function testAllMethods($methodName) $this->_mockBackend->expects($this->once())->method($methodName); $decorator = $this->getMockForAbstractClass( - 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', + \Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, [['concrete_backend' => $this->_mockBackend]] ); diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php index bd2c6927c1291..f376fd6001b18 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php @@ -20,14 +20,14 @@ class MongoDbTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_collection = $this->getMock( - 'MongoCollection', + \MongoCollection::class, ['find', 'findOne', 'distinct', 'save', 'update', 'remove', 'drop'], [], '', false ); $this->_model = $this->getMock( - 'Magento\Framework\Cache\Backend\MongoDb', + \Magento\Framework\Cache\Backend\MongoDb::class, ['_getCollection'], [], '', diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/SchemaLocatorTest.php index 7a1efbabf52a7..9c00440172cf7 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/SchemaLocatorTest.php @@ -20,7 +20,7 @@ protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->schemaLocator = new \Magento\Framework\Cache\Config\SchemaLocator($this->urnResolverMock); } diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/_files/cache_config.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/_files/cache_config.php index e2603e971db94..ff739d0e59779 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/_files/cache_config.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/_files/cache_config.php @@ -8,14 +8,14 @@ 'config' => [ 'name' => 'config', 'translate' => 'label,description', - 'instance' => 'Magento\Framework\App\Cache\Type\Config', + 'instance' => \Magento\Framework\App\Cache\Type\Config::class, 'label' => 'Configuration', 'description' => 'Cache Description', ], 'layout' => [ 'name' => 'layout', 'translate' => 'label,description', - 'instance' => 'Magento\Framework\App\Cache\Type\Layout', + 'instance' => \Magento\Framework\App\Cache\Type\Layout::class, 'label' => 'Layouts', 'description' => 'Layout building instructions', ], diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/ConfigTest.php index 02fa1a5155d3a..a4e1a248a51d9 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/ConfigTest.php @@ -19,7 +19,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storage = $this->getMock('Magento\Framework\Cache\Config\Data', ['get'], [], '', false); + $this->_storage = $this->getMock(\Magento\Framework\Cache\Config\Data::class, ['get'], [], '', false); $this->_model = new \Magento\Framework\Cache\Config($this->_storage); } diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php index 8557eec07f7c2..cdbbc4baed695 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php @@ -33,7 +33,7 @@ class CoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_mockBackend = $this->getMock('Zend_Cache_Backend_File'); + $this->_mockBackend = $this->getMock(\Zend_Cache_Backend_File::class); } protected function tearDown() @@ -46,7 +46,10 @@ public function testSetBackendDefault() $core = new \Magento\Framework\Cache\Core(); $core->setBackend($this->_mockBackend); - $this->assertNotInstanceOf('Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', $core->getBackend()); + $this->assertNotInstanceOf( + \Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, + $core->getBackend() + ); $this->assertEquals($this->_mockBackend, $core->getBackend()); } @@ -73,7 +76,7 @@ public function setBackendExceptionProvider() public function testSaveDisabled() { - $backendMock = $this->getMock('Zend_Cache_Backend_BlackHole'); + $backendMock = $this->getMock(\Zend_Cache_Backend_BlackHole::class); $backendMock->expects($this->never())->method('save'); $frontend = new \Magento\Framework\Cache\Core(['disable_save' => true]); $frontend->setBackend($backendMock); @@ -83,7 +86,7 @@ public function testSaveDisabled() public function testSaveNoCaching() { - $backendMock = $this->getMock('Zend_Cache_Backend_BlackHole'); + $backendMock = $this->getMock(\Zend_Cache_Backend_BlackHole::class); $backendMock->expects($this->never())->method('save'); $frontend = new \Magento\Framework\Cache\Core(['disable_save' => false, 'caching' => false]); $frontend->setBackend($backendMock); @@ -98,7 +101,7 @@ public function testSave() $prefix = 'prefix_'; $prefixedTags = ['prefix_abc', 'prefix__def', 'prefix__ghi']; - $backendMock = $this->getMock('Zend_Cache_Backend_BlackHole'); + $backendMock = $this->getMock(\Zend_Cache_Backend_BlackHole::class); $backendMock->expects($this->once()) ->method('save') ->with($data, $this->anything(), $prefixedTags) @@ -123,7 +126,7 @@ public function testClean() $prefixedTags = ['prefix_abc', 'prefix__def', 'prefix__ghi']; $expectedResult = true; - $backendMock = $this->getMock('Zend_Cache_Backend_BlackHole'); + $backendMock = $this->getMock(\Zend_Cache_Backend_BlackHole::class); $backendMock->expects($this->once()) ->method('clean') ->with($mode, $prefixedTags) @@ -145,7 +148,7 @@ public function testGetIdsMatchingTags() $prefixedTags = ['prefix_abc', 'prefix__def', 'prefix__ghi']; $ids = ['id', 'id2', 'id3']; - $backendMock = $this->getMock('Magento\Framework\Cache\Test\Unit\CoreMock'); + $backendMock = $this->getMock(\Magento\Framework\Cache\Test\Unit\CoreTestMock::class); $backendMock->expects($this->once()) ->method('getIdsMatchingTags') ->with($prefixedTags) @@ -170,7 +173,7 @@ public function testGetIdsNotMatchingTags() $prefixedTags = ['prefix_abc', 'prefix__def', 'prefix__ghi']; $ids = ['id', 'id2', 'id3']; - $backendMock = $this->getMock('Magento\Framework\Cache\Test\Unit\CoreMock'); + $backendMock = $this->getMock(\Magento\Framework\Cache\Test\Unit\CoreTestMock::class); $backendMock->expects($this->once()) ->method('getIdsNotMatchingTags') ->with($prefixedTags) @@ -188,7 +191,3 @@ public function testGetIdsNotMatchingTags() $this->assertEquals($ids, $result); } } - -abstract class CoreMock extends \Zend_Cache_Backend implements \Zend_Cache_Backend_ExtendedInterface -{ -} diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTestMock.php b/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTestMock.php new file mode 100644 index 0000000000000..af4e157d444cc --- /dev/null +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTestMock.php @@ -0,0 +1,10 @@ +getMock('Zend_Cache_Core'); + $frontendMock = $this->getMock(\Zend_Cache_Core::class); $object = new \Magento\Framework\Cache\Frontend\Adapter\Zend($frontendMock); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ProxyTesting(); $result = $helper->invokeWithExpectations( @@ -68,7 +68,7 @@ public function proxyMethodDataProvider() 'getBackend', [], [], - $this->getMock('Zend_Cache_Backend'), + $this->getMock(\Zend_Cache_Backend::class), ] ]; } @@ -81,7 +81,7 @@ public function proxyMethodDataProvider() public function testCleanException($cleaningMode, $expectedErrorMessage) { $this->setExpectedException('InvalidArgumentException', $expectedErrorMessage); - $object = new \Magento\Framework\Cache\Frontend\Adapter\Zend($this->getMock('Zend_Cache_Core')); + $object = new \Magento\Framework\Cache\Frontend\Adapter\Zend($this->getMock(\Zend_Cache_Core::class)); $object->clean($cleaningMode); } @@ -105,7 +105,7 @@ public function cleanExceptionDataProvider() public function testGetLowLevelFrontend() { - $frontendMock = $this->getMock('Zend_Cache_Core'); + $frontendMock = $this->getMock(\Zend_Cache_Core::class); $object = new \Magento\Framework\Cache\Frontend\Adapter\Zend($frontendMock); $this->assertSame($frontendMock, $object->getLowLevelFrontend()); } diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/BareTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/BareTest.php index 6141ac3b850d6..3d3126f4ad6b4 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/BareTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/BareTest.php @@ -15,7 +15,7 @@ class BareTest extends \PHPUnit_Framework_TestCase */ public function testProxyMethod($method, $params, $expectedResult) { - $frontendMock = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $frontendMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $object = new \Magento\Framework\Cache\Frontend\Decorator\Bare($frontendMock); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ProxyTesting(); @@ -34,8 +34,8 @@ public function proxyMethodDataProvider() ['save', ['record_value', 'record_id', ['tag'], 555], true], ['remove', ['record_id'], true], ['clean', [\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, ['tag']], true], - ['getBackend', [], $this->getMock('Zend_Cache_Backend')], - ['getLowLevelFrontend', [], $this->getMock('Zend_Cache_Core')], + ['getBackend', [], $this->getMock(\Zend_Cache_Backend::class)], + ['getLowLevelFrontend', [], $this->getMock(\Zend_Cache_Core::class)], ]; } } diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/ProfilerTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/ProfilerTest.php index 13153c520e06f..0021fdd18e4d5 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/ProfilerTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/ProfilerTest.php @@ -37,14 +37,14 @@ public function testProxyMethod( $expectedResult ) { // Cache frontend setup - $frontendMock = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $frontendMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $frontendMock->expects($this->any())->method('getBackend')->will($this->returnValue($cacheBackend)); $frontendMock->expects($this->any())->method('getLowLevelFrontend')->will($this->returnValue($cacheFrontend)); // Profiler setup - $driver = $this->getMock('Magento\Framework\Profiler\DriverInterface'); + $driver = $this->getMock(\Magento\Framework\Profiler\DriverInterface::class); $driver->expects($this->once())->method('start')->with($expectedProfileId, $expectedProfilerTags); $driver->expects($this->once())->method('stop')->with($expectedProfileId); \Magento\Framework\Profiler::add($driver); @@ -62,7 +62,7 @@ public function testProxyMethod( public function proxyMethodDataProvider() { $backend = new \Zend_Cache_Backend_BlackHole(); - $adaptee = $this->getMock('Zend_Cache_Core', [], [], '', false); + $adaptee = $this->getMock(\Zend_Cache_Core::class, [], [], '', false); $lowLevelFrontend = new \Magento\Framework\Cache\Frontend\Adapter\Zend($adaptee); return [ @@ -75,7 +75,7 @@ public function proxyMethodDataProvider() [ 'group' => 'cache', 'operation' => 'cache:test', - 'frontend_type' => 'Magento\Framework\Cache\Frontend\Adapter\Zend', + 'frontend_type' => \Magento\Framework\Cache\Frontend\Adapter\Zend::class, 'backend_type' => 'BlackHole' ], 111, @@ -89,7 +89,7 @@ public function proxyMethodDataProvider() [ 'group' => 'cache', 'operation' => 'cache:load', - 'frontend_type' => 'Magento\Framework\Cache\Frontend\Adapter\Zend', + 'frontend_type' => \Magento\Framework\Cache\Frontend\Adapter\Zend::class, 'backend_type' => 'BlackHole' ], '111' @@ -103,7 +103,7 @@ public function proxyMethodDataProvider() [ 'group' => 'cache', 'operation' => 'cache:save', - 'frontend_type' => 'Magento\Framework\Cache\Frontend\Adapter\Zend', + 'frontend_type' => \Magento\Framework\Cache\Frontend\Adapter\Zend::class, 'backend_type' => 'BlackHole' ], true @@ -117,7 +117,7 @@ public function proxyMethodDataProvider() [ 'group' => 'cache', 'operation' => 'cache:remove', - 'frontend_type' => 'Magento\Framework\Cache\Frontend\Adapter\Zend', + 'frontend_type' => \Magento\Framework\Cache\Frontend\Adapter\Zend::class, 'backend_type' => 'BlackHole' ], true @@ -131,7 +131,7 @@ public function proxyMethodDataProvider() [ 'group' => 'cache', 'operation' => 'cache:clean', - 'frontend_type' => 'Magento\Framework\Cache\Frontend\Adapter\Zend', + 'frontend_type' => \Magento\Framework\Cache\Frontend\Adapter\Zend::class, 'backend_type' => 'BlackHole' ], true diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php index 31afb9efecd3f..1676d94ef10a0 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php @@ -19,7 +19,7 @@ class TagScopeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_frontend = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $this->_frontend = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $this->_object = new \Magento\Framework\Cache\Frontend\Decorator\TagScope($this->_frontend, 'enforced_tag'); } diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/InvalidateLoggerTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/InvalidateLoggerTest.php index 5f1f6a7dc527f..86a8dc056c0a2 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/InvalidateLoggerTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/InvalidateLoggerTest.php @@ -31,8 +31,8 @@ class InvalidateLoggerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); $this->invalidateLogger = new \Magento\Framework\Cache\InvalidateLogger( $this->requestMock, $this->loggerMock diff --git a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php index 2d7102525d90b..9e5dff03a919f 100644 --- a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php +++ b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php @@ -187,7 +187,7 @@ protected function _getClassProperties() 'visibility' => 'protected', 'docblock' => [ 'shortDescription' => 'Object Manager instance', - 'tags' => [['name' => 'var', 'description' => '\Magento\Framework\ObjectManagerInterface']], + 'tags' => [['name' => 'var', 'description' => '\\' . \Magento\Framework\ObjectManagerInterface::class]], ], ]; diff --git a/lib/internal/Magento/Framework/Code/Generator/InterfaceGenerator.php b/lib/internal/Magento/Framework/Code/Generator/InterfaceGenerator.php index a3f6fa450af20..13698393353f5 100644 --- a/lib/internal/Magento/Framework/Code/Generator/InterfaceGenerator.php +++ b/lib/internal/Magento/Framework/Code/Generator/InterfaceGenerator.php @@ -33,7 +33,7 @@ public function generate() } $output .= 'interface ' . $this->getName(); if (!empty($this->extendedClass)) { - $output .= ' extends ' . $this->extendedClass; + $output .= ' extends \\' . ltrim($this->extendedClass, '\\'); } $output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php index fe0dee10db4ea..075fd98ccc202 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php @@ -60,7 +60,7 @@ public function testClassLoadableFromDisc() /** * @var AutoloaderInterface | \PHPUnit_Framework_MockObject_MockObject $autoloaderMock */ - $autoloaderMock = $this->getMock('\Magento\Framework\Autoload\AutoloaderInterface'); + $autoloaderMock = $this->getMock(\Magento\Framework\Autoload\AutoloaderInterface::class); $autoloaderMock->expects($this->once())->method('findFile')->with($classOnDisc)->willReturn(true); AutoloaderRegistry::registerAutoloader($autoloaderMock); $this->assertTrue($this->model->isClassLoadable($classOnDisc)); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/EntityAbstractTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/EntityAbstractTest.php index 5b4264343ebe8..4193c66514feb 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/EntityAbstractTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/EntityAbstractTest.php @@ -10,10 +10,6 @@ class EntityAbstractTest extends \PHPUnit_Framework_TestCase /**#@+ * Source and result class parameters */ - const SOURCE_CLASS = '\Magento\Framework\DataObject'; - - const RESULT_CLASS = '\Magento\Framework\DataObject_MyResult'; - const RESULT_FILE = 'MyResult/MyResult.php'; const RESULT_DIRECTORY = 'MyResult'; @@ -41,9 +37,21 @@ class EntityAbstractTest extends \PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var string + */ + private $sourceClass; + + /** + * @var string + */ + private $resultClass; + protected function setUp() { - $this->_model = $this->getMockForAbstractClass('Magento\Framework\Code\Generator\EntityAbstract'); + $this->sourceClass = '\\' . \Magento\Framework\DataObject::class; + $this->resultClass = '\\' . \Magento\Framework\DataObject_MyResult::class; + $this->_model = $this->getMockForAbstractClass(\Magento\Framework\Code\Generator\EntityAbstract::class); } protected function tearDown() @@ -56,40 +64,40 @@ public function testConstruct() // without parameters $this->assertAttributeEmpty('_sourceClassName', $this->_model); $this->assertAttributeEmpty('_resultClassName', $this->_model); - $this->assertAttributeInstanceOf('Magento\Framework\Code\Generator\Io', '_ioObject', $this->_model); + $this->assertAttributeInstanceOf(\Magento\Framework\Code\Generator\Io::class, '_ioObject', $this->_model); $this->assertAttributeInstanceOf( - 'Magento\Framework\Code\Generator\ClassGenerator', + \Magento\Framework\Code\Generator\ClassGenerator::class, '_classGenerator', $this->_model ); $this->assertAttributeInstanceOf( - 'Magento\Framework\Code\Generator\DefinedClasses', + \Magento\Framework\Code\Generator\DefinedClasses::class, 'definedClasses', $this->_model ); // with source class name $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Code\Generator\EntityAbstract', - [self::SOURCE_CLASS] + \Magento\Framework\Code\Generator\EntityAbstract::class, + [$this->sourceClass] ); - $this->assertAttributeEquals(self::SOURCE_CLASS, '_sourceClassName', $this->_model); - $this->assertAttributeEquals(self::SOURCE_CLASS . 'Abstract', '_resultClassName', $this->_model); + $this->assertAttributeEquals($this->sourceClass, '_sourceClassName', $this->_model); + $this->assertAttributeEquals($this->sourceClass . 'Abstract', '_resultClassName', $this->_model); // with all arguments // Configure IoObject mock - $ioObject = $this->getMockBuilder('Magento\Framework\Code\Generator\Io') + $ioObject = $this->getMockBuilder(\Magento\Framework\Code\Generator\Io::class) ->disableOriginalConstructor() ->getMock(); - $codeGenerator = $this->getMockBuilder('Magento\Framework\Code\Generator\ClassGenerator') + $codeGenerator = $this->getMockBuilder(\Magento\Framework\Code\Generator\ClassGenerator::class) ->disableOriginalConstructor() ->getMock(); $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Code\Generator\EntityAbstract', - [self::SOURCE_CLASS, self::RESULT_CLASS, $ioObject, $codeGenerator] + \Magento\Framework\Code\Generator\EntityAbstract::class, + [$this->sourceClass, $this->resultClass, $ioObject, $codeGenerator] ); - $this->assertAttributeEquals(self::RESULT_CLASS, '_resultClassName', $this->_model); + $this->assertAttributeEquals($this->resultClass, '_resultClassName', $this->_model); $this->assertAttributeEquals($ioObject, '_ioObject', $this->_model); $this->assertAttributeEquals($codeGenerator, '_classGenerator', $this->_model); } @@ -103,7 +111,7 @@ public function generateDataProvider() { return [ 'no_source_class' => [ - 'errors' => ['Source class ' . self::SOURCE_CLASS . ' doesn\'t exist.'], + 'errors' => ['Source class \Magento\Framework\DataObject doesn\'t exist.'], 'validationSuccess' => false, 'sourceClassExists' => false, ], @@ -178,7 +186,7 @@ public function testGenerate( } $abstractGetters = ['_getClassProperties', '_getClassMethods']; $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Code\Generator\EntityAbstract', + \Magento\Framework\Code\Generator\EntityAbstract::class, $arguments, '', true, @@ -218,20 +226,20 @@ protected function _prepareMocksForValidateData( $resultFileExists = false ) { // Configure DefinedClasses mock - $definedClassesMock = $this->getMock('Magento\Framework\Code\Generator\DefinedClasses'); + $definedClassesMock = $this->getMock(\Magento\Framework\Code\Generator\DefinedClasses::class); $definedClassesMock->expects($this->once()) ->method('isClassLoadable') - ->with(self::SOURCE_CLASS) + ->with($this->sourceClass) ->willReturn($sourceClassExists); if ($resultClassExists) { $definedClassesMock->expects($this->once()) ->method('isClassLoadableFromDisc') - ->with(self::RESULT_CLASS) + ->with($this->resultClass) ->willReturn($resultClassExists); } // Configure IoObject mock - $ioObject = $this->getMockBuilder('Magento\Framework\Code\Generator\Io') + $ioObject = $this->getMockBuilder(\Magento\Framework\Code\Generator\Io::class) ->disableOriginalConstructor() ->getMock(); @@ -240,13 +248,13 @@ protected function _prepareMocksForValidateData( if ($sourceClassExists && !$resultClassExists) { $ioObject->expects($this->once()) ->method('makeResultFileDirectory') - ->with(self::RESULT_CLASS) + ->with($this->resultClass) ->willReturn($makeResultDirSuccess); } return [ - 'source_class' => self::SOURCE_CLASS, - 'result_class' => self::RESULT_CLASS, + 'source_class' => $this->sourceClass, + 'result_class' => $this->resultClass, 'io_object' => $ioObject, 'code_generator' => null, 'definedClasses' => $definedClassesMock, @@ -264,11 +272,11 @@ protected function _prepareMocksForGenerateCode($willWriteCode) // Configure mocks for the validation step $mocks = $this->_prepareMocksForValidateData(); - $codeGenerator = $this->getMockBuilder('Magento\Framework\Code\Generator\ClassGenerator') + $codeGenerator = $this->getMockBuilder(\Magento\Framework\Code\Generator\ClassGenerator::class) ->disableOriginalConstructor() ->getMock(); - $codeGenerator->expects($this->once())->method('setName')->with(self::RESULT_CLASS)->will($this->returnSelf()); + $codeGenerator->expects($this->once())->method('setName')->with($this->resultClass)->will($this->returnSelf()); $codeGenerator->expects($this->once())->method('addProperties')->will($this->returnSelf()); $codeGenerator->expects($this->once())->method('addMethods')->will($this->returnSelf()); $codeGenerator->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php index 494a4a2502be8..1b478f4eafd68 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php @@ -81,10 +81,10 @@ public function testGenerate($additionalMethodsData, $expectedException, $expect $this->interfaceGenerator->setClassDocBlock($this->interfaceDocBlock) ->addMethods($methodsData) ->setName('SevenInterface') - ->setNamespaceName('Magento\SomeModule\Model') - ->addUse('Magento\SomeModule\Model\Two\Test', 'TestTwo') - ->addUse('Magento\SomeModule\Model\Three\Test', 'TestThree') - ->setExtendedClass('\Magento\Framework\Code\Generator\CodeGeneratorInterface'); + ->setNamespaceName(\Magento\SomeModule\Model::class) + ->addUse(\Magento\SomeModule\Model\Two\Test::class, 'TestTwo') + ->addUse(\Magento\SomeModule\Model\Three\Test::class, 'TestThree') + ->setExtendedClass(\Magento\Framework\Code\Generator\CodeGeneratorInterface::class); $generatedInterface = $this->interfaceGenerator->generate(); $expectedInterface = file_get_contents( __DIR__ . '/../_files/app/code/Magento/SomeModule/Model/SevenInterface.php' diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php index f682ac924b71a..deb3175529d1b 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php @@ -47,7 +47,7 @@ protected function setUp() { $this->_generationDirectory = rtrim(self::GENERATION_DIRECTORY, '/') . '/'; - $this->_filesystemDriverMock = $this->getMock('Magento\Framework\Filesystem\Driver\File'); + $this->_filesystemDriverMock = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class); $this->_object = new \Magento\Framework\Code\Generator\Io( $this->_filesystemDriverMock, @@ -98,7 +98,7 @@ public function testWriteResultFileAlreadyExists($resultFileName, $fileExists, $ } else { $exceptionMessage = 'Some error renaming file'; $renameMockEvent = $this->throwException(new FileSystemException(new Phrase($exceptionMessage))); - $this->setExpectedException('\Magento\Framework\Exception\FileSystemException', $exceptionMessage); + $this->setExpectedException(\Magento\Framework\Exception\FileSystemException::class, $exceptionMessage); } $this->_filesystemDriverMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php index bc2bbc77f7738..9024d56e8a29a 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php @@ -45,16 +45,16 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->definedClassesMock = $this->getMock('\Magento\Framework\Code\Generator\DefinedClasses'); - $this->ioObjectMock = $this->getMockBuilder('\Magento\Framework\Code\Generator\Io') + $this->definedClassesMock = $this->getMock(\Magento\Framework\Code\Generator\DefinedClasses::class); + $this->ioObjectMock = $this->getMockBuilder(\Magento\Framework\Code\Generator\Io::class) ->disableOriginalConstructor() ->getMock(); $this->model = $this->buildModel( $this->ioObjectMock, [ - 'factory' => '\Magento\Framework\ObjectManager\Code\Generator\Factory', - 'proxy' => '\Magento\Framework\ObjectManager\Code\Generator\Proxy', - 'interceptor' => '\Magento\Framework\Interception\Code\Generator\Interceptor' + 'factory' => \Magento\Framework\ObjectManager\Code\Generator\Factory::class, + 'proxy' => \Magento\Framework\ObjectManager\Code\Generator\Proxy::class, + 'interceptor' => \Magento\Framework\Interception\Code\Generator\Interceptor::class ], $this->definedClassesMock ); @@ -76,9 +76,9 @@ public function testGetGeneratedEntities() */ public function testGenerateClass($className, $entityType) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $fullClassName = $className . $entityType; - $entityGeneratorMock = $this->getMockBuilder('\Magento\Framework\Code\Generator\EntityAbstract') + $entityGeneratorMock = $this->getMockBuilder(\Magento\Framework\Code\Generator\EntityAbstract::class) ->disableOriginalConstructor() ->getMock(); $objectManagerMock->expects($this->once())->method('create')->willReturn($entityGeneratorMock); @@ -101,8 +101,8 @@ public function testGenerateClassWithError() { $expectedEntities = array_values($this->expectedEntities); $resultClassName = self::SOURCE_CLASS . ucfirst(array_shift($expectedEntities)); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $entityGeneratorMock = $this->getMockBuilder('\Magento\Framework\Code\Generator\EntityAbstract') + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $entityGeneratorMock = $this->getMockBuilder(\Magento\Framework\Code\Generator\EntityAbstract::class) ->disableOriginalConstructor() ->getMock(); $objectManagerMock->expects($this->once())->method('create')->willReturn($entityGeneratorMock); @@ -127,7 +127,7 @@ public function testGenerateClassWithExistName($fileExists) $this->assertEquals( \Magento\Framework\Code\Generator::GENERATION_SKIP, - $this->model->generateClass('Magento\GeneratedClass\Factory') + $this->model->generateClass(\Magento\GeneratedClass\Factory::class) ); } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Model/File/Validator/NotProtectedExtensionTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Model/File/Validator/NotProtectedExtensionTest.php index 9c642a7b67d82..11781dc1b4407 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Model/File/Validator/NotProtectedExtensionTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Model/File/Validator/NotProtectedExtensionTest.php @@ -26,7 +26,7 @@ class NotProtectedExtensionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_scopeConfig = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->_scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_scopeConfig->expects( $this->atLeastOnce() )->method( @@ -51,7 +51,7 @@ public function testGetProtectedFileExtensions() public function testInitialization() { $property = new \ReflectionProperty( - '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension', + \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class, '_messageTemplates' ); $property->setAccessible(true); @@ -61,7 +61,7 @@ public function testInitialization() $this->assertEquals($defaultMess, $property->getValue($this->_model)); $property = new \ReflectionProperty( - '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension', + \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class, '_protectedFileExtensions' ); $property->setAccessible(true); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php index b1ebee69bab46..503ce7dea2a2c 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php @@ -15,7 +15,7 @@ class NameBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $nelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->nameBuilder = $nelper->getObject('Magento\Framework\Code\NameBuilder'); + $this->nameBuilder = $nelper->getObject(\Magento\Framework\Code\NameBuilder::class); } /** @@ -35,8 +35,7 @@ public function buildClassNameDataProvider() [['Checkout', 'Controller', 'Index'], 'Checkout\Controller\Index'], [['checkout', 'controller', 'index'], 'Checkout\Controller\Index'], [ - ['magento_backend', 'block', 'system', 'store', 'edit'], - 'Magento\Backend\Block\System\Store\Edit' + ['magento_backend', 'block', 'system', 'store', 'edit'], \Magento\Backend\Block\System\Store\Edit::class ], [['MyNamespace', 'MyModule'], 'MyNamespace\MyModule'], [['uc', 'words', 'test'], 'Uc\Words\Test'], diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php index 1de9fbdd186d7..e600721b91ac4 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php @@ -51,7 +51,7 @@ public function testInvalidSequence() 'Actual : %s' . PHP_EOL; $message = sprintf($message, '\ArgumentSequence\InvalidChildClass', $expectedSequence, $actualSequence); - $this->setExpectedException('Magento\Framework\Exception\ValidatorException', $message); + $this->setExpectedException(\Magento\Framework\Exception\ValidatorException::class, $message); $this->_validator->validate('\ArgumentSequence\InvalidChildClass'); } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorArgumentTypesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorArgumentTypesTest.php index b7e49c73d3a27..d03db534f1837 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorArgumentTypesTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorArgumentTypesTest.php @@ -28,15 +28,15 @@ class ConstructorArgumentTypesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->argumentsReaderMock = $this->getMock( - '\Magento\Framework\Code\Reader\ArgumentsReader', + $this->argumentsReaderMock = $this->getMock( + \Magento\Framework\Code\Reader\ArgumentsReader::class, [], [], '', false ); - $this->sourceArgumentsReaderMock = $this->getMock( - '\Magento\Framework\Code\Reader\SourceArgumentsReader', + $this->sourceArgumentsReaderMock = $this->getMock( + \Magento\Framework\Code\Reader\SourceArgumentsReader::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php index c711d5e267472..8a3b90769d677 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php @@ -26,17 +26,17 @@ protected function setUp() public function testValidateIfParentClassExist() { - $this->assertEquals(true, $this->_model->validate('Magento\SomeModule\Model\One\Test')); + $this->assertEquals(true, $this->_model->validate(\Magento\SomeModule\Model\One\Test::class)); } public function testValidateIfClassHasParentConstructCall() { - $this->assertEquals(true, $this->_model->validate('Magento\SomeModule\Model\Two\Test')); + $this->assertEquals(true, $this->_model->validate(\Magento\SomeModule\Model\Two\Test::class)); } public function testValidateIfClassHasArgumentsQtyEqualToParentClass() { - $this->assertEquals(true, $this->_model->validate('Magento\SomeModule\Model\Three\Test')); + $this->assertEquals(true, $this->_model->validate(\Magento\SomeModule\Model\Three\Test::class)); } public function testValidateIfClassHasExtraArgumentInTheParentConstructor() @@ -44,10 +44,10 @@ public function testValidateIfClassHasExtraArgumentInTheParentConstructor() $fileName = realpath(__DIR__ . '/../_files/app/code/Magento/SomeModule/Model/Four/Test.php'); $fileName = str_replace('\\', '/', $fileName); $this->setExpectedException( - '\Magento\Framework\Exception\ValidatorException', + \Magento\Framework\Exception\ValidatorException::class, 'Extra parameters passed to parent construct: $factory. File: ' . $fileName ); - $this->_model->validate('Magento\SomeModule\Model\Four\Test'); + $this->_model->validate(\Magento\SomeModule\Model\Four\Test::class); } public function testValidateIfClassHasMissingRequiredArguments() @@ -55,10 +55,10 @@ public function testValidateIfClassHasMissingRequiredArguments() $fileName = realpath(__DIR__ . '/../_files/app/code/Magento/SomeModule/Model/Five/Test.php'); $fileName = str_replace('\\', '/', $fileName); $this->setExpectedException( - '\Magento\Framework\Exception\ValidatorException', + \Magento\Framework\Exception\ValidatorException::class, 'Missed required argument factory in parent::__construct call. File: ' . $fileName ); - $this->_model->validate('Magento\SomeModule\Model\Five\Test'); + $this->_model->validate(\Magento\SomeModule\Model\Five\Test::class); } public function testValidateIfClassHasIncompatibleArguments() @@ -66,13 +66,13 @@ public function testValidateIfClassHasIncompatibleArguments() $fileName = realpath(__DIR__ . '/../_files/app/code/Magento/SomeModule/Model/Six/Test.php'); $fileName = str_replace('\\', '/', $fileName); $this->setExpectedException( - '\Magento\Framework\Exception\ValidatorException', + \Magento\Framework\Exception\ValidatorException::class, 'Incompatible argument type: Required type: \Magento\SomeModule\Model\Proxy. ' . 'Actual type: \Magento\SomeModule\Model\ElementFactory; File: ' . PHP_EOL . $fileName ); - $this->_model->validate('Magento\SomeModule\Model\Six\Test'); + $this->_model->validate(\Magento\SomeModule\Model\Six\Test::class); } public function testValidateWrongOrderForParentArguments() @@ -80,7 +80,7 @@ public function testValidateWrongOrderForParentArguments() $fileName = realpath(__DIR__) . '/_files/ClassesForConstructorIntegrity.php'; $fileName = str_replace('\\', '/', $fileName); $this->setExpectedException( - '\Magento\Framework\Exception\ValidatorException', + \Magento\Framework\Exception\ValidatorException::class, 'Incompatible argument type: Required type: \Context. ' . 'Actual type: \ClassA; File: ' . PHP_EOL . @@ -94,7 +94,7 @@ public function testValidateWrongOptionalParamsType() $fileName = realpath(__DIR__) . '/_files/ClassesForConstructorIntegrity.php'; $fileName = str_replace('\\', '/', $fileName); $this->setExpectedException( - '\Magento\Framework\Exception\ValidatorException', + \Magento\Framework\Exception\ValidatorException::class, 'Incompatible argument type: Required type: array. ' . 'Actual type: \ClassB; File: ' . PHP_EOL . $fileName ); $this->_model->validate('ClassArgumentWithWrongParentArgumentsType'); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ContextAggregationTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ContextAggregationTest.php index c86da1606248a..53ce41bdef761 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ContextAggregationTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ContextAggregationTest.php @@ -32,7 +32,7 @@ public function testClassArgumentAlreadyInjectedIntoContext() PHP_EOL . '\ClassFirst already exists in context object'; - $this->setExpectedException('\Magento\Framework\Exception\ValidatorException', $message); + $this->setExpectedException(\Magento\Framework\Exception\ValidatorException::class, $message); $this->_model->validate('ClassArgumentAlreadyInjectedInContext'); } @@ -53,7 +53,7 @@ public function testClassArgumentWithAlreadyInjectedInterface() PHP_EOL . '\\InterfaceFirst already exists in context object'; - $this->setExpectedException('\Magento\Framework\Exception\ValidatorException', $message); + $this->setExpectedException(\Magento\Framework\Exception\ValidatorException::class, $message); $this->_model->validate('ClassArgumentWithAlreadyInjectedInterface'); } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php index ea9de477bce29..fc2637436b185 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php @@ -49,7 +49,7 @@ public function testInvalidClass() $this->_fixturePath . PHP_EOL . 'Multiple type injection [\TypeDuplication\ArgumentBaseClass]'; - $this->setExpectedException('Magento\Framework\Exception\ValidatorException', $message); + $this->setExpectedException(\Magento\Framework\Exception\ValidatorException::class, $message); $this->_validator->validate('\TypeDuplication\InvalidClassWithDuplicatedTypes'); } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/ValidatorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/ValidatorTest.php index 0fb09da50ae8f..0ca1f1a54b226 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/ValidatorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/ValidatorTest.php @@ -22,9 +22,9 @@ protected function setUp() public function testValidate() { $className = 'Same\Class\Name'; - $validator1 = $this->getMock('Magento\Framework\Code\ValidatorInterface'); + $validator1 = $this->getMock(\Magento\Framework\Code\ValidatorInterface::class); $validator1->expects($this->once())->method('validate')->with($className); - $validator2 = $this->getMock('Magento\Framework\Code\ValidatorInterface'); + $validator2 = $this->getMock(\Magento\Framework\Code\ValidatorInterface::class); $validator2->expects($this->once())->method('validate')->with($className); $this->model->add($validator1); diff --git a/lib/internal/Magento/Framework/Code/Validator/ArgumentSequence.php b/lib/internal/Magento/Framework/Code/Validator/ArgumentSequence.php index 90b76604ab952..3ecd307d8763e 100644 --- a/lib/internal/Magento/Framework/Code/Validator/ArgumentSequence.php +++ b/lib/internal/Magento/Framework/Code/Validator/ArgumentSequence.php @@ -233,6 +233,6 @@ protected function _isContextOnly(array $arguments) */ protected function _isContextType($type) { - return is_subclass_of($type, '\Magento\Framework\ObjectManager\ContextInterface'); + return is_subclass_of($type, \Magento\Framework\ObjectManager\ContextInterface::class); } } diff --git a/lib/internal/Magento/Framework/Code/Validator/ContextAggregation.php b/lib/internal/Magento/Framework/Code/Validator/ContextAggregation.php index bc3de34964428..93c45643353aa 100644 --- a/lib/internal/Magento/Framework/Code/Validator/ContextAggregation.php +++ b/lib/internal/Magento/Framework/Code/Validator/ContextAggregation.php @@ -43,7 +43,7 @@ public function validate($className) foreach ($actualDependencies as $type) { /** Check if argument is context object */ - if (is_subclass_of($type, '\Magento\Framework\ObjectManager\ContextInterface')) { + if (is_subclass_of($type, \Magento\Framework\ObjectManager\ContextInterface::class)) { $contextDependencies = array_merge( $contextDependencies, $this->_argumentsReader->getConstructorArguments(new \ReflectionClass($type), false, true) diff --git a/lib/internal/Magento/Framework/Communication/Config/Reader/XmlReader.php b/lib/internal/Magento/Framework/Communication/Config/Reader/XmlReader.php index ffc3955bd1423..d27853f1411cb 100644 --- a/lib/internal/Magento/Framework/Communication/Config/Reader/XmlReader.php +++ b/lib/internal/Magento/Framework/Communication/Config/Reader/XmlReader.php @@ -36,7 +36,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'communication.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Component/Test/Unit/DirSearchTest.php b/lib/internal/Magento/Framework/Component/Test/Unit/DirSearchTest.php index bd1d3f84e49d1..62877ecf2ac44 100644 --- a/lib/internal/Magento/Framework/Component/Test/Unit/DirSearchTest.php +++ b/lib/internal/Magento/Framework/Component/Test/Unit/DirSearchTest.php @@ -32,9 +32,17 @@ class DirSearchTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registrar = $this->getMockForAbstractClass('\Magento\Framework\Component\ComponentRegistrarInterface'); - $this->readFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); - $this->dir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $this->registrar = $this->getMockForAbstractClass( + \Magento\Framework\Component\ComponentRegistrarInterface::class + ); + $this->readFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); + $this->dir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->dir->expects($this->any()) ->method('getAbsolutePath') ->willReturnArgument(0); @@ -98,7 +106,7 @@ public function testCollectFilesWithContext() $this->assertNotEmpty($actualFiles); /** @var \Magento\Framework\Component\ComponentFile $file */ foreach ($actualFiles as $file) { - $this->assertInstanceOf('\Magento\Framework\Component\ComponentFile', $file); + $this->assertInstanceOf(\Magento\Framework\Component\ComponentFile::class, $file); $this->assertSame($componentType, $file->getComponentType()); } $this->assertCount(2, $actualFiles); diff --git a/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php b/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php index 5994ca1795def..a71e955118092 100644 --- a/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php +++ b/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php @@ -12,13 +12,13 @@ class DependencyCheckerTest extends \PHPUnit_Framework_TestCase public function testCheckDependencies() { $composerApp = $this->getMock( - 'Composer\Console\Application', + \Composer\Console\Application::class, ['setAutoExit', 'resetComposer', 'run'], [], '', false ); - $directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $directoryList = $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); $directoryList->expects($this->exactly(2))->method('getRoot'); $composerApp->expects($this->once())->method('setAutoExit')->with(false); @@ -53,13 +53,13 @@ function ($input, $buffer) { public function testCheckDependenciesExcludeSelf() { $composerApp = $this->getMock( - 'Composer\Console\Application', + \Composer\Console\Application::class, ['setAutoExit', 'resetComposer', 'run'], [], '', false ); - $directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $directoryList = $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); $directoryList->expects($this->exactly(3))->method('getRoot'); $composerApp->expects($this->once())->method('setAutoExit')->with(false); diff --git a/lib/internal/Magento/Framework/Config/DomFactory.php b/lib/internal/Magento/Framework/Config/DomFactory.php index 49924b4a689a9..9d44dccb58ee4 100644 --- a/lib/internal/Magento/Framework/Config/DomFactory.php +++ b/lib/internal/Magento/Framework/Config/DomFactory.php @@ -10,7 +10,7 @@ */ class DomFactory { - const CLASS_NAME = 'Magento\Framework\Config\Dom'; + const CLASS_NAME = \Magento\Framework\Config\Dom::class; /** * Object manager diff --git a/lib/internal/Magento/Framework/Config/Reader/Filesystem.php b/lib/internal/Magento/Framework/Config/Reader/Filesystem.php index 5896999e980e3..eb456f787cd8e 100644 --- a/lib/internal/Magento/Framework/Config/Reader/Filesystem.php +++ b/lib/internal/Magento/Framework/Config/Reader/Filesystem.php @@ -96,7 +96,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName, $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { $this->_fileResolver = $fileResolver; diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php index 8b25078966e29..0fdbbf22e54ca 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php @@ -58,6 +58,6 @@ public function testGet() $this->assertEquals( ['magento/theme-adminhtml-backend' => 7, 'magento/theme-frontend-luma' => 8], (array)$this->object->get('nested', '/^magento\/theme/') - ); + ); } } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php index 68352f1f2a2b1..496da72ceef9b 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php @@ -29,9 +29,9 @@ class ScopedTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_readerMock = $this->getMock('Magento\Framework\Config\ReaderInterface'); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->_readerMock = $this->getMock(\Magento\Framework\Config\ReaderInterface::class); + $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); + $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); $this->_model = new \Magento\Framework\Config\Data\Scoped( $this->_readerMock, diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php index 0aa2310ed0929..5c58310e096bb 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php @@ -19,10 +19,10 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->reader = $this->getMockBuilder('Magento\\Framework\\Config\\ReaderInterface') + $this->reader = $this->getMockBuilder(\Magento\Framework\Config\ReaderInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->cache = $this->getMockBuilder('Magento\\Framework\\Config\\CacheInterface') + $this->cache = $this->getMockBuilder(\Magento\Framework\Config\CacheInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/ArrayNodeConfigTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/ArrayNodeConfigTest.php index da74d499282bb..afe17fa67d4f1 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/ArrayNodeConfigTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/ArrayNodeConfigTest.php @@ -21,7 +21,7 @@ class ArrayNodeConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->nodePathMatcher = $this->getMock('\Magento\Framework\Config\Dom\NodePathMatcher'); + $this->nodePathMatcher = $this->getMock(\Magento\Framework\Config\Dom\NodePathMatcher::class); $this->object = new ArrayNodeConfig( $this->nodePathMatcher, ['/root/assoc/one' => 'name', '/root/assoc/two' => 'id', '/root/assoc/three' => 'key'], diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodeMergingConfigTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodeMergingConfigTest.php index 2ed75a92ead78..fcbbc035f8cfe 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodeMergingConfigTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodeMergingConfigTest.php @@ -21,7 +21,7 @@ class NodeMergingConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->nodePathMatcher = $this->getMock('\Magento\Framework\Config\Dom\NodePathMatcher'); + $this->nodePathMatcher = $this->getMock(\Magento\Framework\Config\Dom\NodePathMatcher::class); $this->object = new NodeMergingConfig( $this->nodePathMatcher, ['/root/one' => 'name', '/root/two' => 'id', '/root/three' => 'key'] diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php index 2f581752e4803..7a3b028bfc93a 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php @@ -23,7 +23,7 @@ class UrnResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urnResolver = $this->objectManagerHelper->getObject('Magento\Framework\Config\Dom\UrnResolver'); + $this->urnResolver = $this->objectManagerHelper->getObject(\Magento\Framework\Config\Dom\UrnResolver::class); } public function testGetRealPathNoUrn() diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php index 411f84b64ac3a..15d95d3894730 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php @@ -15,7 +15,7 @@ class DomTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->validationStateMock = $this->getMock( - '\Magento\Framework\Config\ValidationStateInterface', + \Magento\Framework\Config\ValidationStateInterface::class, [], [], '', @@ -172,7 +172,7 @@ public function testValidateUnknownError() $xml = ''; $schemaFile = __DIR__ . '/_files/sample.xsd'; $dom = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock); - $domMock = $this->getMock('DOMDocument', ['schemaValidate'], []); + $domMock = $this->getMock(\DOMDocument::class, ['schemaValidate'], []); $domMock->expects($this->once()) ->method('schemaValidate') ->with($schemaFile) diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/FileIteratorTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/FileIteratorTest.php index c665111b39557..d27ae345af594 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/FileIteratorTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/FileIteratorTest.php @@ -37,8 +37,14 @@ class FileIteratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->filePaths = ['/file1', '/file2']; - $this->fileReadFactory = $this->getMock('Magento\Framework\Filesystem\File\ReadFactory', [], [], '', false); - $this->fileRead = $this->getMock('Magento\Framework\Filesystem\File\Read', [], [], '', false); + $this->fileReadFactory = $this->getMock( + \Magento\Framework\Filesystem\File\ReadFactory::class, + [], + [], + '', + false + ); + $this->fileRead = $this->getMock(\Magento\Framework\Filesystem\File\Read::class, [], [], '', false); $this->fileIterator = new FileIterator($this->fileReadFactory, $this->filePaths); } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php index f4a29cef154ad..668f774f6186c 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php @@ -45,16 +45,16 @@ protected function setUp() $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } $this->_file = file_get_contents(__DIR__ . '/../_files/reader/config.xml'); - $this->_fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); + $this->_fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); $this->_converterMock = $this->getMock( - 'Magento\Framework\Config\ConverterInterface', + \Magento\Framework\Config\ConverterInterface::class, [], [], '', false ); - $this->_schemaLocatorMock = $this->getMock('Magento\Framework\Config\SchemaLocatorInterface'); - $this->_validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->_schemaLocatorMock = $this->getMock(\Magento\Framework\Config\SchemaLocatorInterface::class); + $this->_validationStateMock = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ScopeTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ScopeTest.php index c25780753d220..257d95d8c37e8 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ScopeTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ScopeTest.php @@ -22,7 +22,7 @@ class ScopeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->areaListMock = $this->getMock('Magento\Framework\App\AreaList', ['getCodes'], [], '', false); + $this->areaListMock = $this->getMock(\Magento\Framework\App\AreaList::class, ['getCodes'], [], '', false); $this->model = new Scope($this->areaListMock); } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ThemeTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ThemeTest.php index 3763a0cae266c..2d8ed59d22b0f 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ThemeTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ThemeTest.php @@ -16,7 +16,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); } public function testGetSchemaFile() diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php index d81b38be7feff..d6cf7a12e7b5c 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php @@ -31,17 +31,17 @@ class ViewFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Framework\Config\ViewFactory($this->objectManager); - $this->theme = $this->getMock('Magento\Framework\View\Design\ThemeInterface'); - $this->view = $this->getMock('Magento\Framework\Config\View', [], [], '', false); + $this->theme = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class); + $this->view = $this->getMock(\Magento\Framework\Config\View::class, [], [], '', false); } public function testCreate() { $this->objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\Config\View', []) + ->with(\Magento\Framework\Config\View::class, []) ->willReturn($this->view); $this->assertEquals($this->view, $this->model->create()); } @@ -49,18 +49,18 @@ public function testCreate() public function testCreateWithArguments() { /** @var \Magento\Theme\Model\View\Design|\PHPUnit_Framework_MockObject_MockObject $design */ - $design = $this->getMock('Magento\Theme\Model\View\Design', [], [], '', false); + $design = $this->getMock(\Magento\Theme\Model\View\Design::class, [], [], '', false); $design->expects($this->once()) ->method('setDesignTheme') ->with($this->theme, self::AREA); /** @var \Magento\Framework\Config\FileResolver|\PHPUnit_Framework_MockObject_MockObject $fileResolver */ - $fileResolver = $this->getMock('Magento\Framework\Config\FileResolver', [], [], '', false); + $fileResolver = $this->getMock(\Magento\Framework\Config\FileResolver::class, [], [], '', false); $valueMap = [ - ['Magento\Theme\Model\View\Design', [], $design], - ['Magento\Framework\Config\FileResolver', ['designInterface' => $design], $fileResolver], - ['Magento\Framework\Config\View', ['fileResolver' => $fileResolver], $this->view], + [\Magento\Theme\Model\View\Design::class, [], $design], + [\Magento\Framework\Config\FileResolver::class, ['designInterface' => $design], $fileResolver], + [\Magento\Framework\Config\View::class, ['fileResolver' => $fileResolver], $this->view], ]; $this->objectManager->expects($this->exactly(3)) ->method('create') @@ -75,10 +75,12 @@ public function testCreateWithArguments() */ public function testCreateException() { - $this->model->create([ - 'themeModel' => 'wrong theme', - 'area' => self::AREA - ]); + $this->model->create( + [ + 'themeModel' => 'wrong theme', + 'area' => self::AREA + ] + ); } /** diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php index efae41b823e08..d0c9af09b3dac 100644 --- a/lib/internal/Magento/Framework/Config/View.php +++ b/lib/internal/Magento/Framework/Config/View.php @@ -46,7 +46,7 @@ public function __construct( ValidationStateInterface $validationState, $fileName, $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global', $xpath = [] ) { diff --git a/lib/internal/Magento/Framework/Config/ViewFactory.php b/lib/internal/Magento/Framework/Config/ViewFactory.php index 3a8a45e4ced5b..7adff4f50cf59 100644 --- a/lib/internal/Magento/Framework/Config/ViewFactory.php +++ b/lib/internal/Magento/Framework/Config/ViewFactory.php @@ -43,11 +43,11 @@ public function create(array $arguments = []) ); } /** @var \Magento\Theme\Model\View\Design $design */ - $design = $this->objectManager->create('Magento\Theme\Model\View\Design'); + $design = $this->objectManager->create(\Magento\Theme\Model\View\Design::class); $design->setDesignTheme($arguments['themeModel'], $arguments['area']); /** @var \Magento\Framework\Config\FileResolver $fileResolver */ $fileResolver = $this->objectManager->create( - 'Magento\Framework\Config\FileResolver', + \Magento\Framework\Config\FileResolver::class, [ 'designInterface' => $design, ] @@ -56,7 +56,7 @@ public function create(array $arguments = []) } return $this->objectManager->create( - 'Magento\Framework\Config\View', + \Magento\Framework\Config\View::class, $viewConfigArguments ); } diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index 9742acbbd237c..9f4aa15d3a4f8 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -113,17 +113,17 @@ protected function getApplicationCommands() $bootstrap = Bootstrap::create(BP, $params); $objectManager = $bootstrap->getObjectManager(); /** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */ - $omProvider = $this->serviceManager->get('Magento\Setup\Model\ObjectManagerProvider'); + $omProvider = $this->serviceManager->get(\Magento\Setup\Model\ObjectManagerProvider::class); $omProvider->setObjectManager($objectManager); - if (class_exists('Magento\Setup\Console\CommandList')) { + if (class_exists(\Magento\Setup\Console\CommandList::class)) { $setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager); $commands = array_merge($commands, $setupCommandList->getCommands()); } - if ($objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { + if ($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) { /** @var \Magento\Framework\Console\CommandList $commandList */ - $commandList = $objectManager->create('Magento\Framework\Console\CommandList'); + $commandList = $objectManager->create(\Magento\Framework\Console\CommandList::class); $commands = array_merge($commands, $commandList->getCommands()); } diff --git a/lib/internal/Magento/Framework/Controller/Result/JsonFactory.php b/lib/internal/Magento/Framework/Controller/Result/JsonFactory.php index e98afb9f8e0e0..599e970a1f49f 100644 --- a/lib/internal/Magento/Framework/Controller/Result/JsonFactory.php +++ b/lib/internal/Magento/Framework/Controller/Result/JsonFactory.php @@ -33,7 +33,7 @@ class JsonFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = '\\Magento\\Framework\\Controller\\Result\\Json' + $instanceName = \Magento\Framework\Controller\Result\Json::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php b/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php index 9fdb062287d47..90435b36f0619 100644 --- a/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php +++ b/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php @@ -29,7 +29,7 @@ class RedirectFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Controller\Result\Redirect' + $instanceName = \Magento\Framework\Controller\Result\Redirect::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php index 9359e149ccdf7..7a2e9e9aeceaa 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php @@ -15,7 +15,7 @@ public function testExecute() /** * @var \Magento\Framework\Controller\Index\Index */ - $controller = $objectManager->getObject('Magento\Framework\Controller\Index\Index'); + $controller = $objectManager->getObject(\Magento\Framework\Controller\Index\Index::class); // The execute method is empty and returns void, just calling to verify // the method exists and does not throw an exception diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php index 06cb789fd1b77..8dee04e1db8df 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php @@ -30,11 +30,11 @@ class NorouteTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->_viewMock = $this->getMock('\Magento\Framework\App\ViewInterface'); - $this->_statusMock = $this->getMock('Magento\Framework\DataObject', ['getLoaded'], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->_viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->_statusMock = $this->getMock(\Magento\Framework\DataObject::class, ['getLoaded'], [], '', false); $this->_controller = $helper->getObject( - 'Magento\Framework\Controller\Noroute\Index', + \Magento\Framework\Controller\Noroute\Index::class, ['request' => $this->_requestMock, 'view' => $this->_viewMock] ); } diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/ForwardTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/ForwardTest.php index 81fb2b82a2aa5..d027204398c3f 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/ForwardTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/ForwardTest.php @@ -23,10 +23,10 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->requestInterface = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestInterface = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->forward = $this->objectManagerHelper->getObject( - 'Magento\Framework\Controller\Result\Forward', + \Magento\Framework\Controller\Result\Forward::class, [ 'request' => $this->requestInterface ] @@ -36,14 +36,17 @@ protected function setUp() public function testSetModule() { $module = 'test_module'; - $this->assertInstanceOf('Magento\Framework\Controller\Result\Forward', $this->forward->setModule($module)); + $this->assertInstanceOf( + \Magento\Framework\Controller\Result\Forward::class, + $this->forward->setModule($module) + ); } public function testSetController() { $controller = 'test_controller'; $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Forward', + \Magento\Framework\Controller\Result\Forward::class, $this->forward->setController($controller) ); } @@ -52,7 +55,7 @@ public function testSetParams() { $params = ['param1', 'param2', 3]; $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Forward', + \Magento\Framework\Controller\Result\Forward::class, $this->forward->setParams($params) ); } @@ -64,7 +67,7 @@ public function testForward() $this->requestInterface->expects($this->once())->method('setActionName')->with($action); $this->requestInterface->expects($this->once())->method('setDispatched'); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Forward', + \Magento\Framework\Controller\Result\Forward::class, $this->forward->forward($action) ); } @@ -85,7 +88,7 @@ public function testForwardWithParams() $this->requestInterface->expects($this->once())->method('setActionName')->with($action); $this->requestInterface->expects($this->once())->method('setDispatched'); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Forward', + \Magento\Framework\Controller\Result\Forward::class, $this->forward->forward($action) ); } diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php index d43ffa10f8124..2d43a4a72af39 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php @@ -24,17 +24,17 @@ public function testRenderResult() /** @var \Magento\Framework\Translate\InlineInterface|\PHPUnit_Framework_MockObject_MockObject * $translateInline */ - $translateInline = $this->getMock('Magento\Framework\Translate\InlineInterface', [], [], '', false); + $translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class, [], [], '', false); $translateInline->expects($this->any())->method('processResponseBody')->with($json, true)->will( $this->returnValue($translatedJson) ); - $response = $this->getMock('Magento\Framework\App\Response\Http', ['representJson'], [], '', false); + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, ['representJson'], [], '', false); $response->expects($this->atLeastOnce())->method('representJson')->with($json)->will($this->returnSelf()); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Controller\Result\Json', ['translateInline' => $translateInline]); + ->getObject(\Magento\Framework\Controller\Result\Json::class, ['translateInline' => $translateInline]); $resultJson->setJsonData($json); $this->assertSame($resultJson, $resultJson->renderResult($response)); } diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RawTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RawTest.php index b0f70ddb7cc57..402838fb09104 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RawTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RawTest.php @@ -24,21 +24,21 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setBody', 'sendResponse'], [], '', false ); $this->raw = $this->objectManagerHelper->getObject( - 'Magento\Framework\Controller\Result\Raw' + \Magento\Framework\Controller\Result\Raw::class ); } public function testSetContents() { $content = 'test'; - $this->assertInstanceOf('Magento\Framework\Controller\Result\Raw', $this->raw->setContents($content)); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Raw::class, $this->raw->setContents($content)); } public function testRender() diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php index b382c14713afc..ba102c00027b5 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php @@ -23,15 +23,16 @@ class RedirectFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->model = $objectManager->getObject('Magento\Framework\Controller\Result\RedirectFactory', + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->model = $objectManager->getObject( + \Magento\Framework\Controller\Result\RedirectFactory::class, ['objectManager' => $this->objectManagerMock] ); } public function testCreate() { - $redirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -39,7 +40,7 @@ public function testCreate() ->willReturn($redirect); $resultRedirect = $this->model->create(); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $resultRedirect); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $resultRedirect); $this->assertSame($redirect, $resultRedirect); } } diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php index 189a501839fc0..ce703f02bd702 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php @@ -28,28 +28,28 @@ class RedirectTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->redirectInterface = $this->getMock( - 'Magento\Framework\App\Response\RedirectInterface', + \Magento\Framework\App\Response\RedirectInterface::class, [], [], '', false ); $this->urlBuilder = $this->getMock( - 'Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, [], [], '', false ); $this->urlInterface = $this->getMock( - 'Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, [], [], '', false ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', @@ -61,19 +61,25 @@ protected function setUp() public function testSetRefererUrl() { $this->redirectInterface->expects($this->once())->method('getRefererUrl'); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->redirect->setRefererUrl()); + $this->assertInstanceOf( + \Magento\Framework\Controller\Result\Redirect::class, + $this->redirect->setRefererUrl() + ); } public function testSetRefererOrBaseUrl() { $this->redirectInterface->expects($this->once())->method('getRedirectUrl'); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->redirect->setRefererOrBaseUrl()); + $this->assertInstanceOf( + \Magento\Framework\Controller\Result\Redirect::class, + $this->redirect->setRefererOrBaseUrl() + ); } public function testSetUrl() { $url = 'http://test.com'; - $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->redirect->setUrl($url)); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $this->redirect->setUrl($url)); } public function testSetPath() @@ -84,7 +90,7 @@ public function testSetPath() $this->returnValue($params) ); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Redirect', + \Magento\Framework\Controller\Result\Redirect::class, $this->redirect->setPath($path, $params) ); } @@ -93,7 +99,7 @@ public function testRender() { $this->response->expects($this->once())->method('setRedirect'); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Redirect', + \Magento\Framework\Controller\Result\Redirect::class, $this->redirect->renderResult($this->response) ); } diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php index b329ea7f1b6c9..c578c29cb5673 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php @@ -25,11 +25,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager = new ObjectManager($this); $this->factory = $objectManager->getObject( - 'Magento\Framework\Controller\Router\Route\Factory', + \Magento\Framework\Controller\Router\Route\Factory::class, [ 'objectManager' => $this->objectManager, ] @@ -45,7 +45,7 @@ public function testCreateRoute() $routeClass = 'router'; $paramRoute = 'route'; - $router = $this->getMockBuilder('Magento\Framework\App\RouterInterface') + $router = $this->getMockBuilder(\Magento\Framework\App\RouterInterface::class) ->setMockClassName($routeClass) ->getMock(); @@ -57,7 +57,7 @@ public function testCreateRoute() $result = $this->factory->createRoute($routeClass, $paramRoute); $this->assertInstanceOf($routeClass, $result); - $this->assertInstanceOf('Magento\Framework\App\RouterInterface', $result); + $this->assertInstanceOf(\Magento\Framework\App\RouterInterface::class, $result); } /** diff --git a/lib/internal/Magento/Framework/Convert/ExcelFactory.php b/lib/internal/Magento/Framework/Convert/ExcelFactory.php index d14b47697b839..80a4098534397 100644 --- a/lib/internal/Magento/Framework/Convert/ExcelFactory.php +++ b/lib/internal/Magento/Framework/Convert/ExcelFactory.php @@ -25,7 +25,7 @@ class ExcelFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = '\\Magento\\Framework\\Convert\\Excel' + $instanceName = \Magento\Framework\Convert\Excel::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php b/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php index 6a1a9ce6cb29d..a38ea3af0fa49 100644 --- a/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php +++ b/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php @@ -22,7 +22,7 @@ class ExcelFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->setMethods(['create']) ->getMockForAbstractClass(); @@ -33,15 +33,15 @@ protected function setUp() public function testCreate() { - $excel = $this->getMockBuilder('Magento\Framework\Convert\Excel') + $excel = $this->getMockBuilder(\Magento\Framework\Convert\Excel::class) ->disableOriginalConstructor() ->getMock(); $this->objectManager->expects($this->once()) ->method('create') - ->with('\\Magento\\Framework\\Convert\\Excel', []) + ->with(\Magento\Framework\Convert\Excel::class, []) ->willReturn($excel); - $this->assertInstanceOf('Magento\Framework\Convert\Excel', $this->model->create()); + $this->assertInstanceOf(\Magento\Framework\Convert\Excel::class, $this->model->create()); } } diff --git a/lib/internal/Magento/Framework/Convert/Test/Unit/ObjectTest.php b/lib/internal/Magento/Framework/Convert/Test/Unit/ObjectTest.php index c730dfe54eb2a..d43a618e1f49a 100644 --- a/lib/internal/Magento/Framework/Convert/Test/Unit/ObjectTest.php +++ b/lib/internal/Magento/Framework/Convert/Test/Unit/ObjectTest.php @@ -21,14 +21,14 @@ protected function setUp() public function testToOptionArray() { - $mockFirst = $this->getMock('Magento\Framework\DataObject', ['getId', 'getCode'], []); + $mockFirst = $this->getMock(\Magento\Framework\DataObject::class, ['getId', 'getCode'], []); $mockFirst->expects($this->once()) ->method('getId') ->will($this->returnValue(1)); $mockFirst->expects($this->once()) ->method('getCode') ->will($this->returnValue('code1')); - $mockSecond = $this->getMock('Magento\Framework\DataObject', ['getId', 'getCode'], []); + $mockSecond = $this->getMock(\Magento\Framework\DataObject::class, ['getId', 'getCode'], []); $mockSecond->expects($this->once()) ->method('getId') ->will($this->returnValue(2)); @@ -53,14 +53,14 @@ public function testToOptionArray() public function testToOptionHash() { - $mockFirst = $this->getMock('Magento\Framework\DataObject', ['getSome', 'getId'], []); + $mockFirst = $this->getMock(\Magento\Framework\DataObject::class, ['getSome', 'getId'], []); $mockFirst->expects($this->once()) ->method('getId') ->will($this->returnValue(3)); $mockFirst->expects($this->once()) ->method('getSome') ->will($this->returnValue('code3')); - $mockSecond = $this->getMock('Magento\Framework\DataObject', ['getSome', 'getId'], []); + $mockSecond = $this->getMock(\Magento\Framework\DataObject::class, ['getSome', 'getId'], []); $mockSecond->expects($this->once()) ->method('getId') ->will($this->returnValue(4)); @@ -87,8 +87,8 @@ public function testConvertDataToArray() { $object = new \stdClass(); $object->a = [[1]]; - $mockFirst = $this->getMock('Magento\Framework\DataObject', ['getData']); - $mockSecond = $this->getMock('Magento\Framework\DataObject', ['getData']); + $mockFirst = $this->getMock(\Magento\Framework\DataObject::class, ['getData']); + $mockSecond = $this->getMock(\Magento\Framework\DataObject::class, ['getData']); $mockFirst->expects($this->any()) ->method('getData') diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Aggregated.php b/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Aggregated.php index 86b3112e40e72..9b87ebea75fea 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Aggregated.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Aggregated.php @@ -74,7 +74,7 @@ public function __construct( */ public function getFiles(ThemeInterface $theme, $filePath) { - $list = $this->fileListFactory->create('Magento\Framework\Css\PreProcessor\File\FileList\Collator'); + $list = $this->fileListFactory->create(\Magento\Framework\Css\PreProcessor\File\FileList\Collator::class); $list->add($this->libraryFiles->getFiles($theme, $filePath)); $list->add($this->baseFiles->getFiles($theme, $filePath)); diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Library.php b/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Library.php index 4d828f670f35e..bb4490d2c3e09 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Library.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/File/Collector/Library.php @@ -77,7 +77,7 @@ public function __construct( */ public function getFiles(ThemeInterface $theme, $filePath) { - $list = $this->fileListFactory->create('Magento\Framework\Css\PreProcessor\File\FileList\Collator'); + $list = $this->fileListFactory->create(\Magento\Framework\Css\PreProcessor\File\FileList\Collator::class); $files = $this->libraryDirectory->search($filePath); $list->add($this->createFiles($this->libraryDirectory, $theme, $files)); diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php index d9c5fc6fab08c..852a2138c773b 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php @@ -57,15 +57,15 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMockForAbstractClass(); - $this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->assetSourceMock = $this->getMockBuilder('Magento\Framework\View\Asset\Source') + $this->assetSourceMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Source::class) ->disableOriginalConstructor() ->getMock(); - $this->temporaryFileMock = $this->getMockBuilder('Magento\Framework\Css\PreProcessor\File\Temporary') + $this->temporaryFileMock = $this->getMockBuilder(\Magento\Framework\Css\PreProcessor\File\Temporary::class) ->disableOriginalConstructor() ->getMock(); @@ -181,7 +181,7 @@ public function testProcessContentNotEmpty() */ private function getAssetMock() { - $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/AggregatedTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/AggregatedTest.php index 21fedbc32c262..e2cf89e5c9193 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/AggregatedTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/AggregatedTest.php @@ -53,21 +53,21 @@ class AggregatedTest extends \PHPUnit_Framework_TestCase */ public function setup() { - $this->fileListFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\FileList\Factory') + $this->fileListFactoryMock = $this->getMockBuilder(\Magento\Framework\View\File\FileList\Factory::class) ->disableOriginalConstructor()->getMock(); - $this->fileListMock = $this->getMockBuilder('Magento\Framework\View\File\FileList') + $this->fileListMock = $this->getMockBuilder(\Magento\Framework\View\File\FileList::class) ->disableOriginalConstructor()->getMock(); $this->fileListFactoryMock->expects($this->any())->method('create') ->will($this->returnValue($this->fileListMock)); - $this->libraryFilesMock = $this->getMockBuilder('Magento\Framework\View\File\CollectorInterface') + $this->libraryFilesMock = $this->getMockBuilder(\Magento\Framework\View\File\CollectorInterface::class) ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); - $this->baseFilesMock = $this->getMockBuilder('Magento\Framework\View\File\CollectorInterface')->getMock(); - $this->overriddenBaseFilesMock = $this->getMockBuilder('Magento\Framework\View\File\CollectorInterface') + $this->baseFilesMock = $this->getMockBuilder(\Magento\Framework\View\File\CollectorInterface::class)->getMock(); + $this->overriddenBaseFilesMock = $this->getMockBuilder(\Magento\Framework\View\File\CollectorInterface::class) ->getMock(); - $this->themeMock = $this->getMockBuilder('\Magento\Framework\View\Design\ThemeInterface')->getMock(); + $this->themeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class)->getMock(); } public function testGetFilesEmpty() @@ -133,7 +133,7 @@ public function testGetFiles($libraryFiles, $baseFiles, $themeFiles) $this->loggerMock ); - $inheritedThemeMock = $this->getMockBuilder('\Magento\Framework\View\Design\ThemeInterface')->getMock(); + $inheritedThemeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class)->getMock(); $this->themeMock->expects($this->any())->method('getInheritedThemes') ->will($this->returnValue([$inheritedThemeMock])); diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/LibraryTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/LibraryTest.php index c993b50a9bf58..1cab06baa6343 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/LibraryTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/Collector/LibraryTest.php @@ -12,6 +12,8 @@ /** * Tests Library + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class LibraryTest extends \PHPUnit_Framework_TestCase { @@ -68,23 +70,25 @@ class LibraryTest extends \PHPUnit_Framework_TestCase */ public function setup() { - $this->fileListFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\FileList\Factory') + $this->fileListFactoryMock = $this->getMockBuilder(\Magento\Framework\View\File\FileList\Factory::class) ->disableOriginalConstructor()->getMock(); - $this->fileListMock = $this->getMockBuilder('Magento\Framework\View\File\FileList') + $this->fileListMock = $this->getMockBuilder(\Magento\Framework\View\File\FileList::class) ->disableOriginalConstructor()->getMock(); $this->fileListFactoryMock->expects($this->any()) ->method('create') - ->with('Magento\Framework\Css\PreProcessor\File\FileList\Collator') + ->with(\Magento\Framework\Css\PreProcessor\File\FileList\Collator::class) ->will($this->returnValue($this->fileListMock)); - $this->readFactoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadFactory') + $this->readFactoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadFactory::class) ->disableOriginalConstructor()->getMock(); - $this->componentRegistrarMock = $this->getMockBuilder('Magento\Framework\Component\ComponentRegistrarInterface') - ->disableOriginalConstructor()->getMock(); - $this->fileSystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->componentRegistrarMock = $this->getMockBuilder( + \Magento\Framework\Component\ComponentRegistrarInterface::class + )->disableOriginalConstructor()->getMock(); + $this->fileSystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->libraryDirectoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') - ->getMock(); + $this->libraryDirectoryMock = $this->getMockBuilder( + \Magento\Framework\Filesystem\Directory\ReadInterface::class + )->getMock(); $this->fileSystemMock->expects($this->any())->method('getDirectoryRead') ->will( $this->returnValueMap( @@ -94,10 +98,10 @@ public function setup() ) ); - $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory') + $this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\View\File\Factory::class) ->disableOriginalConstructor() ->getMock(); - $this->themeMock = $this->getMockBuilder('\Magento\Framework\View\Design\ThemeInterface')->getMock(); + $this->themeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class)->getMock(); $this->library = new Library( $this->fileListFactoryMock, $this->fileSystemMock, @@ -142,7 +146,7 @@ function ($file) { )); $themePath = '/var/Magento/ATheme'; $subPath = '*'; - $readerMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')->getMock(); + $readerMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class)->getMock(); $this->readFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($readerMock)); @@ -153,7 +157,7 @@ function ($file) { $readerMock->expects($this->once()) ->method('search') ->will($this->returnValue($themeFiles)); - $inheritedThemeMock = $this->getMockBuilder('\Magento\Framework\View\Design\ThemeInterface')->getMock(); + $inheritedThemeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class)->getMock(); $inheritedThemeMock->expects($this->any())->method('getFullPath')->will($this->returnValue($themePath)); $this->themeMock->expects($this->any())->method('getInheritedThemes') ->will($this->returnValue([$inheritedThemeMock])); diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/FileList/CollatorTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/FileList/CollatorTest.php index 7b0fe942a8fba..55dc6d1c51ae1 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/FileList/CollatorTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/File/FileList/CollatorTest.php @@ -52,7 +52,7 @@ protected function createLayoutFile($filename, $module, $themeFullPath = null) { $theme = null; if ($themeFullPath !== null) { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath)); } return new \Magento\Framework\View\File($filename, $module, $theme); diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php index 3c0938d05073d..2441422bb1821 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php @@ -39,10 +39,10 @@ class ImportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->notationResolver = $this->getMock( - '\Magento\Framework\View\Asset\NotationResolver\Module', [], [], '', false + $this->notationResolver = $this->getMock( + \Magento\Framework\View\Asset\NotationResolver\Module::class, [], [], '', false ); - $this->asset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $this->asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $this->asset->expects($this->any())->method('getContentType')->will($this->returnValue('css')); $this->relatedFileGeneratorMock = $this->getMockBuilder(RelatedGenerator::class) diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php index ddaec4ef17e8b..f5c81d78436aa 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/MagentoImportTest.php @@ -8,6 +8,9 @@ namespace Magento\Framework\Css\Test\Unit\PreProcessor\Instruction; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MagentoImportTest extends \PHPUnit_Framework_TestCase { /** @@ -47,15 +50,15 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->design = $this->getMockForAbstractClass('\Magento\Framework\View\DesignInterface'); - $this->fileSource = $this->getMockForAbstractClass('\Magento\Framework\View\File\CollectorInterface'); + $this->design = $this->getMockForAbstractClass(\Magento\Framework\View\DesignInterface::class); + $this->fileSource = $this->getMockForAbstractClass(\Magento\Framework\View\File\CollectorInterface::class); $this->errorHandler = $this->getMockForAbstractClass( - '\Magento\Framework\Css\PreProcessor\ErrorHandlerInterface' + \Magento\Framework\Css\PreProcessor\ErrorHandlerInterface::class ); - $this->asset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $this->asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $this->asset->expects($this->any())->method('getContentType')->will($this->returnValue('css')); - $this->assetRepo = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->themeList = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Theme\ListInterface'); + $this->assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->themeList = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Theme\ListInterface::class); $this->object = new \Magento\Framework\Css\PreProcessor\Instruction\MagentoImport( $this->design, $this->fileSource, @@ -77,21 +80,21 @@ protected function setUp() public function testProcess($originalContent, $foundPath, $resolvedPath, $foundFiles, $expectedContent) { $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($this->asset, $originalContent, 'css', 'path'); - $relatedAsset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $relatedAsset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $relatedAsset->expects($this->once()) ->method('getFilePath') ->will($this->returnValue($resolvedPath)); - $context = $this->getMock('\Magento\Framework\View\Asset\File\FallbackContext', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Asset\File\FallbackContext::class, [], [], '', false); $this->assetRepo->expects($this->once()) ->method('createRelated') ->with($foundPath, $this->asset) ->will($this->returnValue($relatedAsset)); $relatedAsset->expects($this->once())->method('getContext')->will($this->returnValue($context)); - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->themeList->expects($this->once())->method('getThemeByFullPath')->will($this->returnValue($theme)); $files = []; foreach ($foundFiles as $file) { - $fileObject = $this->getMock('Magento\Framework\View\File', [], [], '', false); + $fileObject = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); $fileObject->expects($this->any()) ->method('getModule') ->will($this->returnValue($file['module'])); diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index d183a0f436ffb..8893a11a0f7d4 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -62,7 +62,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface * * @var string */ - protected $_defaultStmtClass = 'Magento\Framework\DB\Statement\Pdo\Mysql'; + protected $_defaultStmtClass = \Magento\Framework\DB\Statement\Pdo\Mysql::class; /** * Current Transaction Level diff --git a/lib/internal/Magento/Framework/DB/Ddl/TriggerFactory.php b/lib/internal/Magento/Framework/DB/Ddl/TriggerFactory.php index 0fbb236e3a685..032c2386f07eb 100644 --- a/lib/internal/Magento/Framework/DB/Ddl/TriggerFactory.php +++ b/lib/internal/Magento/Framework/DB/Ddl/TriggerFactory.php @@ -15,7 +15,7 @@ class TriggerFactory /** * @var string */ - const INSTANCE_NAME = 'Magento\Framework\DB\Ddl\Trigger'; + const INSTANCE_NAME = \Magento\Framework\DB\Ddl\Trigger::class; /** * @param \Magento\Framework\ObjectManagerInterface $objectManager diff --git a/lib/internal/Magento/Framework/DB/QueryBuilder.php b/lib/internal/Magento/Framework/DB/QueryBuilder.php index 0d44ce07fe6c6..021f5b820eda7 100644 --- a/lib/internal/Magento/Framework/DB/QueryBuilder.php +++ b/lib/internal/Magento/Framework/DB/QueryBuilder.php @@ -83,7 +83,7 @@ public function create() $mapperInstance = $this->mapperFactory->create($mapper); $select = $mapperInstance->map($this->criteria); $query = $this->queryFactory->create( - 'Magento\Framework\DB\Query', + \Magento\Framework\DB\Query::class, [ 'select' => $select, 'criteria' => $this->criteria, diff --git a/lib/internal/Magento/Framework/DB/Select/RendererProxy.php b/lib/internal/Magento/Framework/DB/Select/RendererProxy.php index ed74716319d06..0d151eeeb69c7 100644 --- a/lib/internal/Magento/Framework/DB/Select/RendererProxy.php +++ b/lib/internal/Magento/Framework/DB/Select/RendererProxy.php @@ -47,7 +47,7 @@ class RendererProxy extends SelectRenderer */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = '\\Magento\\Framework\\DB\\Select\\SelectRenderer', + $instanceName = \Magento\Framework\DB\Select\SelectRenderer::class, $shared = true ) { $this->_objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php index c783420f6db3d..c01121595f795 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php @@ -63,7 +63,7 @@ class AbstractMapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -72,7 +72,7 @@ protected function setUp() [] ); $this->connectionMock = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false, @@ -81,15 +81,15 @@ protected function setUp() [] ); $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, [], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->fetchStrategyMock = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\Db\FetchStrategyInterface', + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class, [], '', false, @@ -98,14 +98,14 @@ protected function setUp() [] ); $this->objectFactoryMock = $this->getMock( - 'Magento\Framework\Data\ObjectFactory', + \Magento\Framework\Data\ObjectFactory::class, [], [], '', false ); $this->mapperFactoryMock = $this->getMock( - 'Magento\Framework\DB\MapperFactory', + \Magento\Framework\DB\MapperFactory::class, [], [], '', @@ -126,7 +126,7 @@ public function testMap(array $mapperMethods, array $criteriaParts) { /** @var \Magento\Framework\DB\AbstractMapper|\PHPUnit_Framework_MockObject_MockObject $mapper */ $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\DB\AbstractMapper', + \Magento\Framework\DB\AbstractMapper::class, [ 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, @@ -141,7 +141,7 @@ public function testMap(array $mapperMethods, array $criteriaParts) $mapperMethods ); $criteriaMock = $this->getMockForAbstractClass( - 'Magento\Framework\Api\CriteriaInterface', + \Magento\Framework\Api\CriteriaInterface::class, [], '', false, @@ -173,7 +173,7 @@ public function testAddExpressionFieldToSelect() ]; /** @var \Magento\Framework\DB\AbstractMapper|\PHPUnit_Framework_MockObject_MockObject $mapper */ $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\DB\AbstractMapper', + \Magento\Framework\DB\AbstractMapper::class, [ 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, @@ -210,7 +210,7 @@ public function testAddFieldToFilter($field, $condition) /** @var \Magento\Framework\DB\AbstractMapper|\PHPUnit_Framework_MockObject_MockObject $mapper */ $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\DB\AbstractMapper', + \Magento\Framework\DB\AbstractMapper::class, [ 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, @@ -225,7 +225,7 @@ public function testAddFieldToFilter($field, $condition) ['getConnection'] ); $connectionMock = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', true, diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php index 20a8ec9b83307..dbee5b11c03ce 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php @@ -46,10 +46,10 @@ class MysqlTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $string = $this->getMock('Magento\Framework\Stdlib\StringUtils'); - $dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); - $logger = $this->getMockForAbstractClass('Magento\Framework\DB\LoggerInterface'); - $selectFactory = $this->getMockBuilder('Magento\Framework\DB\SelectFactory') + $string = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class); + $dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime::class); + $logger = $this->getMockForAbstractClass(\Magento\Framework\DB\LoggerInterface::class); + $selectFactory = $this->getMockBuilder(\Magento\Framework\DB\SelectFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -58,8 +58,8 @@ protected function setUp() // LoggerInterface $logger, // SelectFactory $selectFactory, // array $config = [] - $this->_mockAdapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + $this->_mockAdapter = $this->getMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['beginTransaction', 'getTransactionLevel'], [ 'string' => $string, @@ -80,8 +80,8 @@ protected function setUp() ->method('getTransactionLevel') ->will($this->returnValue(1)); - $this->_adapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + $this->_adapter = $this->getMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ 'getCreateTable', '_connect', @@ -106,8 +106,8 @@ protected function setUp() true ); - $profiler = $this->getMock( - 'Zend_Db_Profiler' + $profiler = $this->getMock( + \Zend_Db_Profiler::class ); $resourceProperty = new \ReflectionProperty( @@ -446,7 +446,7 @@ public function testInsertOnDuplicateWithQuotedColumnName() $sqlQuery = "INSERT INTO `some_table` (`index`,`row`,`select`,`insert`) VALUES (?, ?, ?, ?) " . "ON DUPLICATE KEY UPDATE `select` = VALUES(`select`), `insert` = VALUES(`insert`)"; - $stmtMock = $this->getMock('Zend_Db_Statement_Pdo', [], [], '', false); + $stmtMock = $this->getMock(\Zend_Db_Statement_Pdo::class, [], [], '', false); $bind = ['indexValue', 'rowValue', 'selectValue', 'insertValue']; $this->_adapter->expects($this->once()) ->method('query') @@ -466,8 +466,8 @@ public function testInsertOnDuplicateWithQuotedColumnName() */ public function testAddColumn($options, $expectedQuery) { - $connectionMock = $this->getMock( - '\Magento\Framework\DB\Adapter\Pdo\Mysql', + $connectionMock = $this->getMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['tableColumnExists', '_getTableName', 'rawQuery', 'resetDdlCache', 'quote'], [], '', false ); diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/GenericMapperTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/GenericMapperTest.php index 63b597ce5edec..2da0cae1bb41c 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/GenericMapperTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/GenericMapperTest.php @@ -35,14 +35,14 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['orWhere', 'where', 'setPart', 'getPart'], [], '', false ); $this->mapperFactoryMock = $this->getMock( - 'Magento\Framework\DB\MapperFactory', + \Magento\Framework\DB\MapperFactory::class, ['create'], [], '', @@ -50,7 +50,7 @@ protected function setUp() ); $this->geneticMapper = $objectManager->getObject( - 'Magento\Framework\DB\GenericMapper', + \Magento\Framework\DB\GenericMapper::class, [ 'select' => $this->selectMock, 'mapperFactory' => $this->mapperFactoryMock, @@ -66,7 +66,7 @@ protected function setUp() public function testMapCriteriaList() { $criteriaMock = $this->getMockForAbstractClass( - 'Magento\Framework\Api\CriteriaInterface', + \Magento\Framework\Api\CriteriaInterface::class, [], '', false, @@ -75,7 +75,7 @@ public function testMapCriteriaList() ['getMapperInterfaceName'] ); $mapperInstanceMock = $this->getMockForAbstractClass( - 'Magento\Framework\DB\MapperInterface', + \Magento\Framework\DB\MapperInterface::class, [], '', false, @@ -129,7 +129,7 @@ public function testMapFilters() ]; $connectionMock = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false, @@ -140,7 +140,7 @@ public function testMapFilters() /** @var \Magento\Framework\DB\GenericMapper|\PHPUnit_Framework_MockObject_MockObject $geneticMapper */ $geneticMapper = $this->getMock( - 'Magento\Framework\DB\GenericMapper', + \Magento\Framework\DB\GenericMapper::class, ['getConnection', 'getSelect'], [], '', @@ -198,7 +198,7 @@ public function testMapFields() /** @var \Magento\Framework\DB\GenericMapper|\PHPUnit_Framework_MockObject_MockObject $geneticMapper */ $geneticMapper = $this->getMock( - 'Magento\Framework\DB\GenericMapper', + \Magento\Framework\DB\GenericMapper::class, ['getSelect'], [], '', diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Helper/AbstractHelperTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Helper/AbstractHelperTest.php index 316de4aad39e3..c783b467d8db6 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Helper/AbstractHelperTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Helper/AbstractHelperTest.php @@ -26,16 +26,16 @@ class AbstractHelperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_adapterMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); + $this->_adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); - $this->_resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->_resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->_resourceMock->expects($this->any()) ->method('getConnection') ->with('prefix') ->will($this->returnValue($this->_adapterMock)); $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Helper\AbstractHelper', + \Magento\Framework\DB\Helper\AbstractHelper::class, [$this->_resourceMock, 'prefix'], '', true, diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php index 49dc1d5f9be50..fbee0c5127662 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php @@ -15,7 +15,7 @@ public function testGetMatchQuery() { /** @var Fulltext $select */ $select = (new ObjectManager($this))->getObject( - 'Magento\Framework\DB\Helper\Mysql\Fulltext', + \Magento\Framework\DB\Helper\Mysql\Fulltext::class, ['resource' => $this->getResourceMock()] ); @@ -40,7 +40,7 @@ public function testMatch($isCondition) $resource = $this->getResourceMock(); /** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject $select */ - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $select->expects($this->once()) @@ -49,7 +49,7 @@ public function testMatch($isCondition) /** @var Fulltext $fulltext */ $fulltext = (new ObjectManager($this))->getObject( - 'Magento\Framework\DB\Helper\Mysql\Fulltext', + \Magento\Framework\DB\Helper\Mysql\Fulltext::class, ['resource' => $resource] ); @@ -74,7 +74,7 @@ public function matchProvider() */ protected function getResourceMock() { - $connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $connection->expects($this->at(0)) @@ -82,7 +82,7 @@ protected function getResourceMock() ->with($this->equalTo('some searchable text')) ->will($this->returnValue("'some searchable text'")); - $resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $resource->expects($this->any()) diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Logger/FileTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Logger/FileTest.php index 065363296ee4c..e67ac60b58a79 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Logger/FileTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Logger/FileTest.php @@ -28,13 +28,13 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->stream = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\File\WriteInterface'); - $this->dir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->stream = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\File\WriteInterface::class); + $this->dir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->dir->expects($this->any()) ->method('openFile') ->with(self::DEBUG_FILE, 'a') ->will($this->returnValue($this->stream)); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValue($this->dir)); @@ -107,7 +107,7 @@ public function logStatsDataProvider() public function testLogStatsWithResult() { - $result = $this->getMock('\Zend_Db_Statement_Pdo', [], [], '', false); + $result = $this->getMock(\Zend_Db_Statement_Pdo::class, [], [], '', false); $result->expects($this->once()) ->method('rowCount') ->will($this->returnValue(10)); diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Platform/QuoteTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Platform/QuoteTest.php index 320bf3536f85d..8d07b7b7826ea 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Platform/QuoteTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Platform/QuoteTest.php @@ -36,9 +36,9 @@ class QuoteTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('\Magento\Framework\DB\Platform\Quote'); - $this->zendDbExprMock = $this->getMock('Zend_Db_Expr', ['__toString'], [], '', false); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['assemble'], [], '', false); + $this->model = $objectManager->getObject(\Magento\Framework\DB\Platform\Quote::class); + $this->zendDbExprMock = $this->getMock(\Zend_Db_Expr::class, ['__toString'], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['assemble'], [], '', false); } public function testQuoteIdentifierWithZendDbExpr() diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php index 359ce0e5c1ac9..33c4893bacbd9 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php @@ -55,14 +55,14 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['reset', 'columns', 'getConnection'], [], '', false ); $this->criteriaMock = $this->getMockForAbstractClass( - 'Magento\Framework\Api\CriteriaInterface', + \Magento\Framework\Api\CriteriaInterface::class, [], '', false, @@ -71,7 +71,7 @@ protected function setUp() [] ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -80,15 +80,15 @@ protected function setUp() ['getIdFieldName'] ); $this->fetchStmtMock = $this->getMock( - 'Zend_Db_Statement_Pdo', + \Zend_Db_Statement_Pdo::class, ['fetch'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->fetchStrategyMock = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\Db\FetchStrategyInterface', + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class, [], '', false, @@ -98,7 +98,7 @@ protected function setUp() ); $this->query = $objectManager->getObject( - 'Magento\Framework\DB\Query', + \Magento\Framework\DB\Query::class, [ 'select' => $this->selectMock, 'criteria' => $this->criteriaMock, @@ -115,7 +115,7 @@ protected function setUp() */ public function testGetAllIds() { - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['fetchCol'], [], '', false); + $adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['fetchCol'], [], '', false); $this->resourceMock->expects($this->once()) ->method('getIdFieldName') ->will($this->returnValue('return-value')); @@ -136,7 +136,7 @@ public function testGetAllIds() */ public function testGetSize() { - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['fetchOne'], [], '', false); + $adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['fetchOne'], [], '', false); $this->selectMock->expects($this->once()) ->method('columns') @@ -172,7 +172,7 @@ public function testFetchAll() */ public function testFetchItem() { - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['query'], [], '', false); + $adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['query'], [], '', false); $this->selectMock->expects($this->once()) ->method('getConnection') ->will($this->returnValue($adapterMock)); diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php index 445c167c70a76..5faafd9e2f612 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php @@ -36,10 +36,16 @@ class ColumnsRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteMock = $this->getMock('\Magento\Framework\DB\Platform\Quote', ['quoteColumnAs'], [], '', false); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); + $this->quoteMock = $this->getMock( + \Magento\Framework\DB\Platform\Quote::class, + ['quoteColumnAs'], + [], + '', + false + ); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); $this->model = $objectManager->getObject( - '\Magento\Framework\DB\Select\ColumnsRenderer', + \Magento\Framework\DB\Select\ColumnsRenderer::class, ['quote' => $this->quoteMock] ); $this->sqlWildcard = new \Zend_Db_Expr(Select::SQL_WILDCARD); diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/DistinctRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/DistinctRendererTest.php index 5bd621455271c..05e8221072ac0 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/DistinctRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/DistinctRendererTest.php @@ -31,8 +31,8 @@ class DistinctRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); - $this->model = $objectManager->getObject('\Magento\Framework\DB\Select\DistinctRenderer'); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); + $this->model = $objectManager->getObject(\Magento\Framework\DB\Select\DistinctRenderer::class); } public function testRenderNoPart() diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/ForUpdateRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/ForUpdateRendererTest.php index 4480e789c5b65..0c88b36347c81 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/ForUpdateRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/ForUpdateRendererTest.php @@ -31,8 +31,8 @@ class ForUpdateRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); - $this->model = $objectManager->getObject('\Magento\Framework\DB\Select\ForUpdateRenderer'); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); + $this->model = $objectManager->getObject(\Magento\Framework\DB\Select\ForUpdateRenderer::class); } public function testRenderNoPart() diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/FromRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/FromRendererTest.php index b399cf8547c12..04691f9a1d983 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/FromRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/FromRendererTest.php @@ -37,15 +37,15 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->quoteMock = $this->getMock( - '\Magento\Framework\DB\Platform\Quote', + \Magento\Framework\DB\Platform\Quote::class, ['quoteTableAs', 'quoteIdentifier'], [], '', false ); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); $this->model = $objectManager->getObject( - '\Magento\Framework\DB\Select\FromRenderer', + \Magento\Framework\DB\Select\FromRenderer::class, ['quote' => $this->quoteMock] ); } diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/GroupRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/GroupRendererTest.php index b52e1836128ba..634f43d5a3a66 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/GroupRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/GroupRendererTest.php @@ -36,10 +36,16 @@ class GroupRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteMock = $this->getMock('\Magento\Framework\DB\Platform\Quote', ['quoteIdentifier'], [], '', false); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); + $this->quoteMock = $this->getMock( + \Magento\Framework\DB\Platform\Quote::class, + ['quoteIdentifier'], + [], + '', + false + ); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); $this->model = $objectManager->getObject( - '\Magento\Framework\DB\Select\GroupRenderer', + \Magento\Framework\DB\Select\GroupRenderer::class, ['quote' => $this->quoteMock] ); } diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/HavingRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/HavingRendererTest.php index 43ac1c47f0e0a..f542af6e6d2f8 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/HavingRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/HavingRendererTest.php @@ -31,8 +31,8 @@ class HavingRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); - $this->model = $objectManager->getObject('\Magento\Framework\DB\Select\HavingRenderer'); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); + $this->model = $objectManager->getObject(\Magento\Framework\DB\Select\HavingRenderer::class); } /** diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/LimitRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/LimitRendererTest.php index 4f8c039612409..b02b3aa31d934 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/LimitRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/LimitRendererTest.php @@ -11,7 +11,7 @@ class LimitRendererTest extends \PHPUnit_Framework_TestCase { public function testRender() { - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $offset = 10; @@ -20,7 +20,7 @@ public function testRender() ->willReturnMap([[Select::LIMIT_OFFSET, $offset], [Select::LIMIT_COUNT, 2]]); $model = new \Magento\Framework\DB\Select\LimitRenderer(); $result = $model->render($selectMock); - $this->assertInstanceOf('Magento\Framework\DB\Sql\LimitExpression', $result); + $this->assertInstanceOf(\Magento\Framework\DB\Sql\LimitExpression::class, $result); $this->assertEquals('LIMIT 2 OFFSET 10', $result->__toString()); } } diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/OrderRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/OrderRendererTest.php index d5f01dfad1378..52add413c36fc 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/OrderRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/OrderRendererTest.php @@ -9,10 +9,10 @@ class OrderRendererTest extends \PHPUnit_Framework_TestCase { public function testRender() { - $quoteMock = $this->getMockBuilder('Magento\Framework\DB\Platform\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Framework\DB\Platform\Quote::class) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $parts = [ diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/RendererProxyTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/RendererProxyTest.php index 008e6c24d9a87..203146fb650c3 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/RendererProxyTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/RendererProxyTest.php @@ -9,17 +9,17 @@ class RendererProxyTest extends \PHPUnit_Framework_TestCase { public function testRender() { - $objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $selectRender = $this->getMockBuilder('Magento\Framework\DB\Select\SelectRenderer') + $selectRender = $this->getMockBuilder(\Magento\Framework\DB\Select\SelectRenderer::class) ->disableOriginalConstructor() ->getMock(); $objectManager->expects($this->once()) ->method('get') - ->with('\\Magento\\Framework\\DB\\Select\\SelectRenderer') + ->with(\Magento\Framework\DB\Select\SelectRenderer::class) ->willReturn($selectRender); - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $selectRender->expects($this->once()) diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/SelectRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/SelectRendererTest.php index 8b0103523821e..8ba182b571244 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/SelectRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/SelectRendererTest.php @@ -9,7 +9,7 @@ class SelectRendererTest extends \PHPUnit_Framework_TestCase { public function testRender() { - $rendererOne = $this->getMockBuilder('Magento\Framework\DB\Select\RendererInterface') + $rendererOne = $this->getMockBuilder(\Magento\Framework\DB\Select\RendererInterface::class) ->disableOriginalConstructor() ->getMock(); $renders = [ @@ -17,7 +17,7 @@ public function testRender() ['renderer' => $rendererOne, 'sort' => 20, 'part' => 'from'], ['renderer' => $rendererOne, 'sort' => 5, 'part' => 'from'], ]; - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $rendererOne->expects($this->any()) diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/UnionRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/UnionRendererTest.php index eb853b61f9a60..d284d54186d09 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/UnionRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/UnionRendererTest.php @@ -12,10 +12,10 @@ class UnionRendererTest extends \PHPUnit_Framework_TestCase public function testRender() { $model = new \Magento\Framework\DB\Select\UnionRenderer(); - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $selectPart = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectPart = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $selectPart->expects($this->exactly(2)) diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/WhereRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/WhereRendererTest.php index 34cb7f89f8589..cc24d7e9c82e9 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/WhereRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/WhereRendererTest.php @@ -31,8 +31,8 @@ class WhereRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', ['getPart'], [], '', false); - $this->model = $objectManager->getObject('\Magento\Framework\DB\Select\WhereRenderer'); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['getPart'], [], '', false); + $this->model = $objectManager->getObject(\Magento\Framework\DB\Select\WhereRenderer::class); } /** diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/SelectFactoryTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/SelectFactoryTest.php index 32d66bd53a533..064d1af56f6d8 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/SelectFactoryTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/SelectFactoryTest.php @@ -9,14 +9,14 @@ class SelectFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $selectRenderer = $this->getMockBuilder('Magento\Framework\DB\Select\SelectRenderer') + $selectRenderer = $this->getMockBuilder(\Magento\Framework\DB\Select\SelectRenderer::class) ->disableOriginalConstructor() ->getMock(); $parts = []; - $adapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $adapter = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); $model = new \Magento\Framework\DB\SelectFactory($selectRenderer, $parts); - $this->assertInstanceOf('Magento\Framework\DB\Select', $model->create($adapter)); + $this->assertInstanceOf(\Magento\Framework\DB\Select::class, $model->create($adapter)); } } diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/SelectTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/SelectTest.php index becc060c2e012..66f0497e03ef0 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/SelectTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/SelectTest.php @@ -114,7 +114,7 @@ public function testWhere() protected function _getConnectionMockWithMockedQuote($callCount, $returnValue = null) { $connection = $this->getMock( - '\Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['supportStraightJoin', 'quote'], [], '', diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Sql/UnionExpressionTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Sql/UnionExpressionTest.php index ddf1ceb262e26..a3de20d9ce76c 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Sql/UnionExpressionTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Sql/UnionExpressionTest.php @@ -11,7 +11,7 @@ class UnionExpressionTest extends \PHPUnit_Framework_TestCase { public function testToString() { - $sqlMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $sqlMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $sqlMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php index bf107acdd6a21..4ca875170d8d3 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php @@ -92,24 +92,21 @@ public function constructorDataProvider() [ 'node_data' => null, 'keys' => null, - ], - '\Magento\Framework\Exception\LocalizedException', + ], \Magento\Framework\Exception\LocalizedException::class, 'Empty array of node information', ], [ [ 'node_data' => null, 'keys' => true, - ], - '\Magento\Framework\Exception\LocalizedException', + ], \Magento\Framework\Exception\LocalizedException::class, 'Empty array of node information' ], [ [ 'node_data' => true, 'keys' => null, - ], - '\Magento\Framework\Exception\LocalizedException', + ], \Magento\Framework\Exception\LocalizedException::class, 'Empty keys array' ] ]; diff --git a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php index b2abd7ab66827..3323bf0315ee2 100644 --- a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php +++ b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php @@ -16,7 +16,7 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search * * @var string */ - protected $dataInterface = 'Magento\Framework\DataObject'; + protected $dataInterface = \Magento\Framework\DataObject::class; /** * Name prefix of events that are dispatched by model diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index deda1304047bc..916f5c294762c 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -35,7 +35,7 @@ class Collection implements \IteratorAggregate, \Countable, ArrayInterface, Coll * * @var string */ - protected $_itemObjectClass = 'Magento\Framework\DataObject'; + protected $_itemObjectClass = \Magento\Framework\DataObject::class; /** * Order configuration @@ -593,7 +593,7 @@ public function setOrder($field, $direction = self::SORT_ORDER_DESC) */ public function setItemObjectClass($className) { - if (!is_a($className, 'Magento\Framework\DataObject', true)) { + if (!is_a($className, \Magento\Framework\DataObject::class, true)) { throw new \InvalidArgumentException($className . ' does not extend \Magento\Framework\DataObject'); } $this->_itemObjectClass = $className; diff --git a/lib/internal/Magento/Framework/Data/Form/Element/CollectionFactory.php b/lib/internal/Magento/Framework/Data/Form/Element/CollectionFactory.php index e198b18475b88..366f0ffcb20fe 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/CollectionFactory.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/CollectionFactory.php @@ -30,6 +30,6 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create(array $data = []) { - return $this->_objectManager->create('Magento\Framework\Data\Form\Element\Collection', $data); + return $this->_objectManager->create(\Magento\Framework\Data\Form\Element\Collection::class, $data); } } diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Gallery.php b/lib/internal/Magento/Framework/Data/Form/Element/Gallery.php index e6170a809c793..a2cf4843bb78d 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Gallery.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Gallery.php @@ -45,8 +45,8 @@ public function getElementHtml() $html = ''; $html .= ''; $widgetButton = $this->getForm()->getParent()->getLayout(); - $buttonHtml = $widgetButton->createBlock( - 'Magento\Backend\Block\Widget\Button' + $buttonHtml = $widgetButton->createBlock( + \Magento\Backend\Block\Widget\Button::class )->setData( ['label' => 'Add New Image', 'onclick' => 'addNewImg()', 'class' => 'add'] )->toHtml(); diff --git a/lib/internal/Magento/Framework/Data/Form/FilterFactory.php b/lib/internal/Magento/Framework/Data/Form/FilterFactory.php index a0d3ce0dd0930..2273846af5957 100644 --- a/lib/internal/Magento/Framework/Data/Form/FilterFactory.php +++ b/lib/internal/Magento/Framework/Data/Form/FilterFactory.php @@ -42,7 +42,7 @@ public function create($filterCode, array $data = []) throw new \InvalidArgumentException(sprintf( '%s class must implement %s', $filterClass, - '\Magento\Framework\Data\Form\Filter\FilterInterface' + \Magento\Framework\Data\Form\Filter\FilterInterface::class )); } diff --git a/lib/internal/Magento/Framework/Data/FormFactory.php b/lib/internal/Magento/Framework/Data/FormFactory.php index c305a349c0d3d..6602b2b609d85 100644 --- a/lib/internal/Magento/Framework/Data/FormFactory.php +++ b/lib/internal/Magento/Framework/Data/FormFactory.php @@ -35,7 +35,7 @@ class FormFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Data\Form' + $instanceName = \Magento\Framework\Data\Form::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Data/SearchResultProcessor.php b/lib/internal/Magento/Framework/Data/SearchResultProcessor.php index fbf66835244d6..203373a584e5c 100644 --- a/lib/internal/Magento/Framework/Data/SearchResultProcessor.php +++ b/lib/internal/Magento/Framework/Data/SearchResultProcessor.php @@ -15,7 +15,7 @@ class SearchResultProcessor extends AbstractDataObject implements SearchResultPr * * @var string */ - protected $dataInterface = 'Magento\Framework\DataObject'; + protected $dataInterface = \Magento\Framework\DataObject::class; /** * @var AbstractSearchResult diff --git a/lib/internal/Magento/Framework/Data/SearchResultProcessorFactory.php b/lib/internal/Magento/Framework/Data/SearchResultProcessorFactory.php index 28e3160e9e784..63fa246c184ec 100644 --- a/lib/internal/Magento/Framework/Data/SearchResultProcessorFactory.php +++ b/lib/internal/Magento/Framework/Data/SearchResultProcessorFactory.php @@ -10,7 +10,7 @@ */ class SearchResultProcessorFactory { - const DEFAULT_INSTANCE_NAME = 'Magento\Framework\Data\SearchResultProcessor'; + const DEFAULT_INSTANCE_NAME = \Magento\Framework\Data\SearchResultProcessor::class; /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/AbstractCriteriaTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/AbstractCriteriaTest.php index 4f97a453f3ce9..7ecb1637a4568 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/AbstractCriteriaTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/AbstractCriteriaTest.php @@ -25,7 +25,7 @@ class AbstractCriteriaTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->criteria = $objectManager->getObject('Magento\Framework\Data\Test\Unit\Criteria\Sample'); + $this->criteria = $objectManager->getObject(\Magento\Framework\Data\Test\Unit\Criteria\Sample::class); } /** @@ -376,7 +376,7 @@ public function dataProviderAddFilter() 'type' => 'test-type', 'result' => [ 'test-filter-name' => $objectManager->getObject( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, [ 'data' => [ 'name' => 'test-filter-name', diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/AbstractDataObjectTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/AbstractDataObjectTest.php index 2d884516c89c3..09bb2b558e755 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/AbstractDataObjectTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/AbstractDataObjectTest.php @@ -19,13 +19,13 @@ public function testToArray() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $subObject = $objectManager->getObject('Magento\Framework\Data\Test\Unit\Stub\DataObject'); + $subObject = $objectManager->getObject(\Magento\Framework\Data\Test\Unit\Stub\DataObject::class); $subObject->setData($subObjectData); - $nestedObject = $objectManager->getObject('Magento\Framework\Data\Test\Unit\Stub\DataObject'); + $nestedObject = $objectManager->getObject(\Magento\Framework\Data\Test\Unit\Stub\DataObject::class); $nestedObject->setData($nestedObjectData); - $dataObject = $objectManager->getObject('Magento\Framework\Data\Test\Unit\Stub\DataObject'); + $dataObject = $objectManager->getObject(\Magento\Framework\Data\Test\Unit\Stub\DataObject::class); $data = ['key' => 'value', 'object' => $subObject, 'nestedArray' => ['nestedObject' => $nestedObject]]; $dataObject->setData($data); @@ -39,7 +39,7 @@ public function testGet() $data = [$key => $value]; $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $dataObject = $objectManager->getObject('Magento\Framework\Data\Test\Unit\Stub\DataObject'); + $dataObject = $objectManager->getObject(\Magento\Framework\Data\Test\Unit\Stub\DataObject::class); $dataObject->setData($data); $this->assertEquals($value, $dataObject->get($key)); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/AbstractSearchResultTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/AbstractSearchResultTest.php index 06fd8d46fc8bb..5a17086ba5014 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/AbstractSearchResultTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/AbstractSearchResultTest.php @@ -46,22 +46,22 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->criteria = $this->getMockForAbstractClass('Magento\Framework\Api\CriteriaInterface'); - $this->query = $this->getMockForAbstractClass('Magento\Framework\DB\QueryInterface'); + $this->criteria = $this->getMockForAbstractClass(\Magento\Framework\Api\CriteriaInterface::class); + $this->query = $this->getMockForAbstractClass(\Magento\Framework\DB\QueryInterface::class); $this->query->expects($this->any()) ->method('getCriteria') ->willReturn($this->criteria); $this->entityFactory = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\EntityFactoryInterface' + \Magento\Framework\Data\Collection\EntityFactoryInterface::class ); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->searchResultIteratorMock = $this->getMockBuilder('Magento\Framework\Data\SearchResultIteratorFactory') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); + $this->searchResultIteratorMock = $this->getMockBuilder( + \Magento\Framework\Data\SearchResultIteratorFactory::class + )->disableOriginalConstructor()->getMock(); $this->searchResult = $objectManager->getObject( - 'Magento\Framework\Data\Test\Unit\Stub\SearchResult', + \Magento\Framework\Data\Test\Unit\Stub\SearchResult::class, [ 'query' => $this->query, 'entityFactory' => $this->entityFactory, @@ -82,7 +82,7 @@ public function testGetItems() ->willReturn([$itemData]); $this->entityFactory->expects($this->once()) ->method('create') - ->with('Magento\Framework\DataObject', ['data' => $itemData]) + ->with(\Magento\Framework\DataObject::class, ['data' => $itemData]) ->willReturn($testItem); $items = $this->searchResult->getItems(); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php index 204e70268535a..17bc5aef5def7 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php @@ -22,7 +22,7 @@ class ArrayTypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_itemInterpreter = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Argument\InterpreterInterface' + \Magento\Framework\Data\Argument\InterpreterInterface::class ); $this->_model = new ArrayType($this->_itemInterpreter); } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/BooleanTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/BooleanTest.php index 19804c88daf14..19271928cd428 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/BooleanTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/BooleanTest.php @@ -21,7 +21,7 @@ class BooleanTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_booleanUtils = $this->getMock('\Magento\Framework\Stdlib\BooleanUtils'); + $this->_booleanUtils = $this->getMock(\Magento\Framework\Stdlib\BooleanUtils::class); $this->_model = new Boolean($this->_booleanUtils); } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php index 92ddfa877e997..74a22255bfc2a 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php @@ -26,8 +26,8 @@ class CompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_interpreterOne = $this->getMock('Magento\Framework\Data\Argument\InterpreterInterface'); - $this->_interpreterTwo = $this->getMock('Magento\Framework\Data\Argument\InterpreterInterface'); + $this->_interpreterOne = $this->getMock(\Magento\Framework\Data\Argument\InterpreterInterface::class); + $this->_interpreterTwo = $this->getMock(\Magento\Framework\Data\Argument\InterpreterInterface::class); $this->_model = new Composite( ['one' => $this->_interpreterOne, 'two' => $this->_interpreterTwo], 'interpreter' @@ -41,8 +41,8 @@ protected function setUp() public function testConstructWrongInterpreter() { $interpreters = [ - 'correct' => $this->getMock('Magento\Framework\Data\Argument\InterpreterInterface'), - 'wrong' => $this->getMock('Magento\Framework\ObjectManagerInterface'), + 'correct' => $this->getMock(\Magento\Framework\Data\Argument\InterpreterInterface::class), + 'wrong' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), ]; new Composite($interpreters, 'interpreter'); } @@ -90,7 +90,7 @@ public function testEvaluate() public function testAddInterpreter() { $input = ['interpreter' => 'new', 'value' => 'test']; - $newInterpreter = $this->getMock('Magento\Framework\Data\Argument\InterpreterInterface'); + $newInterpreter = $this->getMock(\Magento\Framework\Data\Argument\InterpreterInterface::class); $this->_model->addInterpreter('new', $newInterpreter); $newInterpreter->expects($this->once())->method('evaluate')->with(['value' => 'test']); $this->_model->evaluate($input); @@ -103,7 +103,7 @@ public function testAddInterpreter() */ public function testAddInterpreterException() { - $newInterpreter = $this->getMock('Magento\Framework\Data\Argument\InterpreterInterface'); + $newInterpreter = $this->getMock(\Magento\Framework\Data\Argument\InterpreterInterface::class); $this->_model->addInterpreter('one', $newInterpreter); } } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/CacheTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/CacheTest.php index a330a2bb0c306..15485720df3d9 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/CacheTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/CacheTest.php @@ -37,7 +37,7 @@ class CacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_select = $this->getMock('Magento\Framework\DB\Select', ['assemble'], [], '', false); + $this->_select = $this->getMock(\Magento\Framework\DB\Select::class, ['assemble'], [], '', false); $this->_select->expects( $this->once() )->method( @@ -46,9 +46,9 @@ protected function setUp() $this->returnValue('SELECT * FROM fixture_table') ); - $this->_cache = $this->getMockForAbstractClass('Magento\Framework\Cache\FrontendInterface'); + $this->_cache = $this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class); $this->_fetchStrategy = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\Db\FetchStrategyInterface' + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class ); $this->_object = new \Magento\Framework\Data\Collection\Db\FetchStrategy\Cache( diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/QueryTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/QueryTest.php index bfadaa21f8606..2ecefed8afb6d 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/QueryTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/Db/FetchStrategy/QueryTest.php @@ -11,8 +11,8 @@ public function testFetchAll() { $expectedResult = new \stdClass(); $bindParams = ['param_one' => 'value_one', 'param_two' => 'value_two']; - $adapter = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['fetchAll'], [], '', false); - $renderer = $this->getMock('Magento\Framework\DB\Select\SelectRenderer', [], [], '', false); + $adapter = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['fetchAll'], [], '', false); + $renderer = $this->getMock(\Magento\Framework\DB\Select\SelectRenderer::class, [], [], '', false); $select = new \Magento\Framework\DB\Select($adapter, $renderer); $adapter->expects( $this->once() diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php index 901b7f7f67a36..09f4c08628e1d 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php @@ -8,6 +8,9 @@ namespace Magento\Framework\Data\Test\Unit\Collection; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DbTest extends \PHPUnit_Framework_TestCase { use \Magento\Framework\TestFramework\Unit\Helper\SelectRendererTrait; @@ -41,12 +44,12 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->fetchStrategyMock = $this->getMock( - 'Magento\Framework\Data\Collection\Db\FetchStrategy\Query', ['fetchAll'], [], '', false + \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, ['fetchAll'], [], '', false ); $this->entityFactoryMock = $this->getMock( - 'Magento\Framework\Data\Collection\EntityFactory', ['create'], [], '', false + \Magento\Framework\Data\Collection\EntityFactory::class, ['create'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->collection = new \Magento\Framework\Data\Test\Unit\Collection\DbCollection( $this->entityFactoryMock, $this->loggerMock, @@ -65,7 +68,7 @@ protected function tearDown() public function testSetAddOrder() { $adapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['fetchAll', 'select'], [], '', @@ -127,7 +130,7 @@ public function testUnshiftOrder($adapter) public function testAddFieldToFilter() { $adapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['prepareSqlCondition', 'select'], [], '', @@ -163,7 +166,7 @@ public function testAddFieldToFilter() public function testAddFieldToFilterWithMultipleParams() { $adapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['prepareSqlCondition', 'select'], [], '', @@ -213,7 +216,7 @@ public function testAddFieldToFilterWithMultipleParams() public function testAddFieldToFilterValueContainsQuestionMark() { $adapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'prepareSqlCondition', 'supportStraightJoin'], [], '', @@ -248,7 +251,7 @@ public function testAddFieldToFilterValueContainsQuestionMark() public function testAddFieldToFilterFieldIsQuoted() { $adapter = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['quoteIdentifier', 'prepareSqlCondition', 'select'], [], '', @@ -294,17 +297,17 @@ public function testAddFieldToFilterFieldIsQuoted() */ public function testClone() { - $adapter = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $adapter = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $adapter ->expects($this->any()) ->method('select') - ->willReturn($this->getMock('Magento\Framework\DB\Select', [], [], '', false)); + ->willReturn($this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false)); $this->collection->setConnection($adapter); - $this->assertInstanceOf('Magento\Framework\DB\Select', $this->collection->getSelect()); + $this->assertInstanceOf(\Magento\Framework\DB\Select::class, $this->collection->getSelect()); $clonedCollection = clone $this->collection; - $this->assertInstanceOf('Magento\Framework\DB\Select', $clonedCollection->getSelect()); + $this->assertInstanceOf(\Magento\Framework\DB\Select::class, $clonedCollection->getSelect()); $this->assertNotSame( $clonedCollection->getSelect(), $this->collection->getSelect(), @@ -363,17 +366,18 @@ public function testFetchItem() { $data = [1 => 'test']; $counter = 0; - $statementMock = $this->getMock('Zend_Db_Statement_Pdo', ['fetch'], [], '', false); + $statementMock = $this->getMock(\Zend_Db_Statement_Pdo::class, ['fetch'], [], '', false); $statementMock->expects($this->exactly(2)) ->method('fetch') ->will($this->returnCallback(function () use (&$counter, $data) { return ++$counter % 2 ? [] : $data; })); - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', + $adapterMock = $this->getMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'query'], [], '', false); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, [], ['adapter' => $adapterMock, 'selectRenderer' => $this->getSelectRenderer($this->objectManager)] ); @@ -388,13 +392,13 @@ public function testFetchItem() $this->collection->setConnection($adapterMock); $this->assertFalse($this->collection->fetchItem()); - $objectMock = $this->getMock('Magento\Framework\DataObject', ['setData'], []); + $objectMock = $this->getMock(\Magento\Framework\DataObject::class, ['setData'], []); $objectMock->expects($this->once()) ->method('setData') ->with($data); $this->entityFactoryMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\DataObject') + ->with(\Magento\Framework\DataObject::class) ->will($this->returnValue($objectMock)); $this->assertEquals($objectMock, $this->collection->fetchItem()); @@ -404,14 +408,14 @@ public function testGetSize() { $countSql = 500; $adapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'quoteInto', 'prepareSqlCondition', 'fetchOne'], [], '', false ); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['orWhere', 'where', 'reset', 'columns'], ['adapter' => $adapterMock, 'selectRenderer' => $this->getSelectRenderer($this->objectManager)] ); @@ -464,9 +468,9 @@ public function testGetSize() public function testGetSelectSql() { - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['select'], [], '', false); + $adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select'], [], '', false); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['__toString'], ['adapter' => $adapterMock, 'selectRenderer' => $this->getSelectRenderer($this->objectManager)] ); @@ -487,14 +491,14 @@ public function testGetSelectSql() public function testGetData() { $adapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'quoteInto', 'prepareSqlCondition', 'fetchOne'], [], '', false ); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['orWhere', 'where', 'reset', 'columns'], ['adapter' => $adapterMock, 'selectRenderer' => $this->getSelectRenderer($this->objectManager)] ); @@ -524,9 +528,9 @@ public function testGetData() */ public function testDistinct($flag, $expectedFlag) { - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['select'], [], '', false); + $adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select'], [], '', false); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['distinct'], ['adapter' => $adapterMock, 'selectRenderer' => $this->getSelectRenderer($this->objectManager)] ); @@ -552,10 +556,11 @@ public function distinctDataProvider() public function testToOptionHash() { $data = [10 => 'test']; - $adapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', + $adapterMock = $this->getMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'query'], [], '', false); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, [], ['adapter' => $adapterMock, 'selectRenderer' => $this->getSelectRenderer($this->objectManager)] ); @@ -569,7 +574,7 @@ public function testToOptionHash() ->will($this->returnValue([$data])); $objectMock = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['addData', 'setIdFieldName', 'getData'], [] ); @@ -584,7 +589,7 @@ public function testToOptionHash() ])); $this->entityFactoryMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\DataObject') + ->with(\Magento\Framework\DataObject::class) ->will($this->returnValue($objectMock)); $this->collection->setConnection($adapterMock); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php index 4b682c0894660..0ea496b4d11fe 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/FilesystemTest.php @@ -14,7 +14,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Data\Collection\Filesystem'); + $this->model = $objectManager->getObject(\Magento\Framework\Data\Collection\Filesystem::class); } /** diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/CollectionTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/CollectionTest.php index a0c3663b3bd5c..7705cf35c7e9b 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/CollectionTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/CollectionTest.php @@ -15,7 +15,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = new \Magento\Framework\Data\Collection( - $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) ); } @@ -34,7 +34,7 @@ public function testRemoveAllItems() */ public function testLoadWithFilter() { - $this->assertInstanceOf('Magento\Framework\Data\Collection', $this->_model->loadWithFilter()); + $this->assertInstanceOf(\Magento\Framework\Data\Collection::class, $this->_model->loadWithFilter()); $this->assertEmpty($this->_model->getItems()); $this->_model->addItem(new \Magento\Framework\DataObject()); $this->_model->addItem(new \Magento\Framework\DataObject()); @@ -55,7 +55,7 @@ public function testSetItemObjectClass($class) */ public function setItemObjectClassDataProvider() { - return [['Magento\Framework\Url'], ['Magento\Framework\DataObject']]; + return [[\Magento\Framework\Url::class], [\Magento\Framework\DataObject::class]]; } /** @@ -103,9 +103,15 @@ public function testGetCurPage() public function testPossibleFlowWithItem() { - $firstItemMock = $this->getMock('Magento\Framework\DataObject', ['getId', 'getData', 'toArray'], [], '', false); + $firstItemMock = $this->getMock( + \Magento\Framework\DataObject::class, + ['getId', 'getData', 'toArray'], + [], + '', + false + ); $secondItemMock = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getId', 'getData', 'toArray'], [], '', diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/AbstractFormTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/AbstractFormTest.php index d611f7faebce5..adef7590f5d81 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/AbstractFormTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/AbstractFormTest.php @@ -29,9 +29,6 @@ class AbstractFormTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject */ protected $allElementsMock; - /** - * @var \Magento\Framework\Data\Form - */ /** * @var \Magento\Framework\Data\Form\AbstractForm @@ -41,23 +38,23 @@ class AbstractFormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->factoryElementMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\Factory', + \Magento\Framework\Data\Form\Element\Factory::class, ['create'], [], '', false ); $this->factoryCollectionMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, ['create'], [], '', false ); $this->allElementsMock = - $this->getMock('Magento\Framework\Data\Form\Element\Collection', [], [], '', false); + $this->getMock(\Magento\Framework\Data\Form\Element\Collection::class, [], [], '', false); $this->elementMock = - $this->getMock('Magento\Framework\Data\Form\Element\AbstractElement', [], [], '', false); + $this->getMock(\Magento\Framework\Data\Form\Element\AbstractElement::class, [], [], '', false); $this->abstractForm = new AbstractForm($this->factoryElementMock, $this->factoryCollectionMock, []); } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php index 15d828c10ab2c..a6cdfd23c50e0 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php @@ -36,14 +36,15 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_factoryMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\Factory', [], [], '', false + \Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false ); $this->_collectionFactoryMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\CollectionFactory', [], [], '', false + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $this->_escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->_escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); - $this->_model = $this->getMockForAbstractClass('Magento\Framework\Data\Form\Element\AbstractElement', [ + $this->_model = $this->getMockForAbstractClass( + \Magento\Framework\Data\Form\Element\AbstractElement::class, [ $this->_factoryMock, $this->_collectionFactoryMock, $this->_escaperMock @@ -57,14 +58,14 @@ public function testAddElement() { $elementId = 11; $elementMock = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Form\Element\AbstractElement', [], '', false, true, true, ['getId'] + \Magento\Framework\Data\Form\Element\AbstractElement::class, [], '', false, true, true, ['getId'] ); $elementMock->expects($this->once()) ->method('getId') ->will($this->returnValue($elementId)); $formMock = $this->getMock( - 'Magento\Framework\Data\Form\AbstractForm', + \Magento\Framework\Data\Form\AbstractForm::class, ['checkElementId', 'addElementToCollection'], [], '', @@ -77,7 +78,7 @@ public function testAddElement() ->method('addElementToCollection') ->with($elementMock); - $collectionMock = $this->getMock('Magento\Framework\Data\Form\Element\Collection', [], [], '', false); + $collectionMock = $this->getMock(\Magento\Framework\Data\Form\Element\Collection::class, [], [], '', false); $this->_collectionFactoryMock->expects($this->any()) ->method('create') @@ -97,7 +98,7 @@ public function testGetHtmlId() $htmlId = 'some_id'; $formMock = $this->getMock( - 'Magento\Framework\Data\Form\AbstractForm', ['getHtmlIdPrefix', 'getHtmlIdSuffix'], [], '', false + \Magento\Framework\Data\Form\AbstractForm::class, ['getHtmlIdPrefix', 'getHtmlIdSuffix'], [], '', false ); $formMock->expects($this->any()) ->method('getHtmlIdPrefix') @@ -117,7 +118,7 @@ public function testGetHtmlId() public function testGetNameWithoutSuffix() { $formMock = $this->getMock( - 'Magento\Framework\Data\Form\AbstractForm', + \Magento\Framework\Data\Form\AbstractForm::class, ['getFieldNameSuffix', 'addSuffixToName'], [], '', @@ -141,7 +142,7 @@ public function testGetNameWithSuffix() $returnValue = 'some_value'; $formMock = $this->getMock( - 'Magento\Framework\Data\Form\AbstractForm', + \Magento\Framework\Data\Form\AbstractForm::class, ['getFieldNameSuffix', 'addSuffixToName'], [], '', @@ -167,14 +168,14 @@ public function testRemoveField() $elementId = 'element_id'; $formMock = $this->getMock( - 'Magento\Framework\Data\Form\AbstractForm', ['removeField'], [], '', false + \Magento\Framework\Data\Form\AbstractForm::class, ['removeField'], [], '', false ); $formMock->expects($this->once()) ->method('removeField') ->with($elementId); $collectionMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\Collection', ['remove'], [], '', false + \Magento\Framework\Data\Form\Element\Collection::class, ['remove'], [], '', false ); $collectionMock->expects($this->once()) ->method('remove') @@ -261,7 +262,7 @@ public function testGetEscapedValueWithFilter() $value = 'my \'quoted\' string'; $expectedValue = '<a href="#hash_tag">my \'quoted\' string</a>'; - $filterMock = $this->getMock('Magento\Framework\DataObject', ['filter'], [], '', false); + $filterMock = $this->getMock(\Magento\Framework\DataObject::class, ['filter'], [], '', false); $filterMock->expects($this->once()) ->method('filter') ->with($value) @@ -281,7 +282,7 @@ public function testGetEscapedValueWithFilter() public function testGetElementHtml(array $initialData, $expectedValue) { $this->_model->setForm( - $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [], '', false) ); $this->_model->setData($initialData); @@ -299,7 +300,7 @@ public function testGetLabelHtml(array $initialData, $expectedValue) $idSuffix = isset($initialData['id_suffix']) ? $initialData['id_suffix'] : null; $this->_model->setData($initialData); $this->_model->setForm( - $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [], '', false) ); $this->assertEquals($expectedValue, $this->_model->getLabelHtml($idSuffix)); } @@ -314,7 +315,7 @@ public function testGetDefaultHtml(array $initialData, $expectedValue) { $this->_model->setData($initialData); $this->_model->setForm( - $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [], '', false) ); $this->assertEquals($expectedValue, $this->_model->getDefaultHtml()); } @@ -326,7 +327,7 @@ public function testGetHtmlWithoutRenderer() { $this->_model->setRequired(true); $this->_model->setForm( - $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [], '', false) ); $expectedHtml = '
' . "\n" . '
' . "\n"; @@ -345,7 +346,7 @@ public function testGetHtmlWithRenderer() $expectedHtml = 'some-html'; $rendererMock = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Form\Element\Renderer\RendererInterface' + \Magento\Framework\Data\Form\Element\Renderer\RendererInterface::class ); $rendererMock->expects($this->once()) ->method('render') @@ -380,7 +381,7 @@ public function testSerialize(array $initialData, $expectedValue) public function testGetHtmlContainerIdWithoutId() { $this->_model->setForm( - $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [], '', false) ); $this->assertEquals('', $this->_model->getHtmlContainerId()); } @@ -393,7 +394,7 @@ public function testGetHtmlContainerIdWithContainerId() $containerId = 'some-id'; $this->_model->setContainerId($containerId); $this->_model->setForm( - $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [], '', false) ); $this->assertEquals($containerId, $this->_model->getHtmlContainerId()); } @@ -406,7 +407,7 @@ public function testGetHtmlContainerIdWithFieldContainerIdPrefix() $id = 'id'; $prefix = 'prefix_'; $formMock = $this->getMock( - 'Magento\Framework\Data\Form\AbstractForm', ['getFieldContainerIdPrefix'], [], '', false + \Magento\Framework\Data\Form\AbstractForm::class, ['getFieldContainerIdPrefix'], [], '', false ); $formMock->expects($this->once()) ->method('getFieldContainerIdPrefix') diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ButtonTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ButtonTest.php index c5d72a5fe552b..581a4b67b96c4 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ButtonTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ButtonTest.php @@ -23,15 +23,15 @@ class ButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Button( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CheckboxTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CheckboxTest.php index 5aa4df008dc7b..3070b141f8cbd 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CheckboxTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CheckboxTest.php @@ -23,15 +23,15 @@ class CheckboxTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Checkbox( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CollectionFactoryTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CollectionFactoryTest.php index f34c0dcc61a5c..9556a7734623b 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CollectionFactoryTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/CollectionFactoryTest.php @@ -24,13 +24,13 @@ class CollectionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $collectionMock = $this->getMock('Magento\Framework\Data\Form\Element\Collection', [], [], '', false); + $collectionMock = $this->getMock(\Magento\Framework\Data\Form\Element\Collection::class, [], [], '', false); $objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock)); $this->_model = new \Magento\Framework\Data\Form\Element\CollectionFactory($objectManagerMock); } @@ -40,6 +40,6 @@ protected function setUp() */ public function testCreate() { - $this->assertInstanceOf('Magento\Framework\Data\Form\Element\Collection', $this->_model->create([])); + $this->assertInstanceOf(\Magento\Framework\Data\Form\Element\Collection::class, $this->_model->create([])); } } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ColumnTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ColumnTest.php index 0f60fb7eb72df..17d8410f81328 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ColumnTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ColumnTest.php @@ -23,15 +23,15 @@ class ColumnTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Column( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php index 5c7e3292d2294..c61d5a596431c 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php @@ -40,17 +40,17 @@ class DateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->factoryMock = $this->getMock('Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $this->factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $this->collectionFactoryMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $this->escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->localeDateMock = $this->getMock( - '\Magento\Framework\Stdlib\DateTime\TimezoneInterface', + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, [], [], '', @@ -103,7 +103,7 @@ public function providerGetElementHtmlDateFormat() protected function getFormMock($exactly) { $functions = ['getFieldNameSuffix', 'getHtmlIdPrefix', 'getHtmlIdSuffix']; - $formMock = $this->getMock('stdClass', $functions); + $formMock = $this->getMock(\stdClass::class, $functions); foreach ($functions as $method) { switch ($exactly) { case 'once': diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditablemultiselectTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditablemultiselectTest.php index 6b4c84a0fe309..3832dd5fba3bb 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditablemultiselectTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditablemultiselectTest.php @@ -15,7 +15,7 @@ class EditablemultiselectTest extends \PHPUnit_Framework_TestCase protected function setUp() { $testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_model = $testHelper->getObject('Magento\Framework\Data\Form\Element\Editablemultiselect'); + $this->_model = $testHelper->getObject(\Magento\Framework\Data\Form\Element\Editablemultiselect::class); $values = [ ['value' => 1, 'label' => 'Value1'], ['value' => 2, 'label' => 'Value2'], diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php index 863d7d1ca8b9f..c36afc0ad58db 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php @@ -51,19 +51,19 @@ class EditorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $this->factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $this->collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $this->escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); - $this->configMock = $this->getMock('\Magento\Framework\DataObject', ['getData'], [], '', false); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\DataObject::class, ['getData'], [], '', false); $this->model = $this->objectManager->getObject( - 'Magento\Framework\Data\Form\Element\Editor', + \Magento\Framework\Data\Form\Element\Editor::class, [ 'factoryElement' => $this->factoryMock, 'factoryCollection' => $this->collectionFactoryMock, @@ -73,7 +73,7 @@ protected function setUp() ); $this->formMock = $this->getMock( - 'Magento\Framework\Data\Form', + \Magento\Framework\Data\Form::class, ['getHtmlIdPrefix', 'getHtmlIdSuffix'], [], '', @@ -93,7 +93,7 @@ public function testConstruct() $this->configMock->expects($this->once())->method('getData')->with('enabled')->willReturn(true); $model = $this->objectManager->getObject( - 'Magento\Framework\Data\Form\Element\Editor', + \Magento\Framework\Data\Form\Element\Editor::class, [ 'factoryElement' => $this->factoryMock, 'factoryCollection' => $this->collectionFactoryMock, @@ -190,7 +190,7 @@ public function testTranslate() public function testGetConfig() { - $config = $this->getMock('\Magento\Framework\DataObject', ['getData'], [], '', false); + $config = $this->getMock(\Magento\Framework\DataObject::class, ['getData'], [], '', false); $this->assertEquals($config, $this->model->getConfig()); $this->configMock->expects($this->once())->method('getData')->with('test')->willReturn('test'); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php index b9ff5c0ee3a2c..b76accc3cb739 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php @@ -24,7 +24,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -176,8 +176,12 @@ public function testCreateExceptionInvalidArgument($type) public function createExceptionInvalidArgumentDataProvider() { return [ - 'Magento\Framework\Data\Form\Element\Factory' => ['Magento\Framework\Data\Form\Element\Factory'], - 'Magento\Framework\Data\Form\Element\Collection' => ['Magento\Framework\Data\Form\Element\Collection'] + \Magento\Framework\Data\Form\Element\Factory::class => [ + \Magento\Framework\Data\Form\Element\Factory::class + ], + \Magento\Framework\Data\Form\Element\Collection::class => [ + \Magento\Framework\Data\Form\Element\Collection::class + ] ]; } } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FileTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FileTest.php index 0293ffa402fc3..b949a19b270ac 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FileTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FileTest.php @@ -23,15 +23,15 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\File( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/HiddenTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/HiddenTest.php index 56973f2aa088f..33cf8749cbbc5 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/HiddenTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/HiddenTest.php @@ -23,15 +23,15 @@ class HiddenTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Hidden( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImageTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImageTest.php index 927ca077235f1..94067dd526b19 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImageTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImageTest.php @@ -30,16 +30,16 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); - $this->urlBuilder = $this->getMock('\Magento\Framework\Url', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $this->urlBuilder = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); $this->_image = new \Magento\Framework\Data\Form\Element\Image( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImagefileTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImagefileTest.php index 941db3fef92fb..32d5361ecb71b 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImagefileTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ImagefileTest.php @@ -23,15 +23,15 @@ class ImagefileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_imagefile = new \Magento\Framework\Data\Form\Element\Imagefile( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LabelTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LabelTest.php index 03dd2b029c69a..7428745db6c5a 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LabelTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LabelTest.php @@ -23,15 +23,15 @@ class LabelTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_label = new \Magento\Framework\Data\Form\Element\Label( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LinkTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LinkTest.php index cbf499a7c3e86..cee12d40f36a9 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LinkTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/LinkTest.php @@ -23,15 +23,15 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_link = new \Magento\Framework\Data\Form\Element\Link( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultilineTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultilineTest.php index 8e5c0ceacb7c6..6b480905ede68 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultilineTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultilineTest.php @@ -29,15 +29,15 @@ class MultilineTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->elementFactory = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Factory') + $this->elementFactory = $this->getMockBuilder(\Magento\Framework\Data\Form\Element\Factory::class) ->disableOriginalConstructor() ->getMock(); - $this->collectionFactory = $this->getMockBuilder('Magento\Framework\Data\Form\Element\CollectionFactory') + $this->collectionFactory = $this->getMockBuilder(\Magento\Framework\Data\Form\Element\CollectionFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->escaper = $this->getMockBuilder('Magento\Framework\Escaper') + $this->escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultiselectTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultiselectTest.php index 383c61810231f..71e0fcd5755dc 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultiselectTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultiselectTest.php @@ -15,7 +15,7 @@ class MultiselectTest extends \PHPUnit_Framework_TestCase protected function setUp() { $testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_model = $testHelper->getObject('Magento\Framework\Data\Form\Element\Editablemultiselect'); + $this->_model = $testHelper->getObject(\Magento\Framework\Data\Form\Element\Editablemultiselect::class); $this->_model->setForm(new \Magento\Framework\DataObject()); } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php index ade0bd0839e14..6aa0008e543bb 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php @@ -23,15 +23,15 @@ class NoteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Note( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ObscureTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ObscureTest.php index 165ffe46ab312..0affd53225c3b 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ObscureTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ObscureTest.php @@ -23,15 +23,15 @@ class ObscureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Obscure( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/PasswordTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/PasswordTest.php index fc303fe93e031..fbba3ee96361e 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/PasswordTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/PasswordTest.php @@ -23,15 +23,15 @@ class PasswordTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Obscure( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/RadioTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/RadioTest.php index 8421550e5c403..5f7268cd785a2 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/RadioTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/RadioTest.php @@ -23,15 +23,15 @@ class RadioTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Radio( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ResetTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ResetTest.php index 365b9229a9e84..9f26e98a3214e 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ResetTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/ResetTest.php @@ -23,15 +23,15 @@ class ResetTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Reset( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/SubmitTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/SubmitTest.php index 9e92d114c117d..7da86b5db3d1d 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/SubmitTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/SubmitTest.php @@ -23,15 +23,15 @@ class SubmitTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Submit( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextTest.php index 1f66fc1f363ea..5759b9aa798d5 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextTest.php @@ -23,15 +23,15 @@ class TextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Text( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextareaTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextareaTest.php index b65ad8d38eac1..e31e9e017b91a 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextareaTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/TextareaTest.php @@ -23,15 +23,15 @@ class TextareaTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $factoryMock = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $collectionFactoryMock = $this->getMock( - '\Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, [], [], '', false ); - $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\Element\Textarea( $factoryMock, $collectionFactoryMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FilterFactoryTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FilterFactoryTest.php index 4bc1dfa68bf9c..29083bac3560a 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FilterFactoryTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FilterFactoryTest.php @@ -21,7 +21,7 @@ class FilterFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMockForAbstractClass(); $this->factory = new FilterFactory($this->objectManager); @@ -33,7 +33,7 @@ public function testCreate() $filterCode = 'Date'; $data = []; - $filterMock = $this->getMockBuilder('Magento\Framework\Data\Form\Filter\Date') + $filterMock = $this->getMockBuilder(\Magento\Framework\Data\Form\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); @@ -43,7 +43,7 @@ public function testCreate() ->willReturn($filterMock); $result = $this->factory->create($filterCode, $data); - $this->assertInstanceOf('\Magento\Framework\Data\Form\Filter\FilterInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Data\Form\Filter\FilterInterface::class, $result); } /** diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php index 00ccd8fc219d7..3f32da968a61e 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php @@ -25,13 +25,13 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_formKeyMock = $this->getMock( - '\Magento\Framework\Data\Form\FormKey', + \Magento\Framework\Data\Form\FormKey::class, ['getFormKey'], [], '', false ); - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->_model = new \Magento\Framework\Data\Form\FormKey\Validator($this->_formKeyMock); } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKeyTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKeyTest.php index d4301b047bed5..0078415db5b92 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKeyTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKeyTest.php @@ -34,10 +34,10 @@ class FormKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mathRandomMock = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); + $this->mathRandomMock = $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false); $methods = ['setData', 'getData']; - $this->sessionMock = $this->getMock('Magento\Framework\Session\SessionManager', $methods, [], '', false); - $this->escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Framework\Session\SessionManager::class, $methods, [], '', false); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->escaperMock->expects($this->any())->method('escapeHtmlAttr')->willReturnArgument(0); $this->formKey = new FormKey( $this->mathRandomMock, diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/FormFactoryTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/FormFactoryTest.php index 4f403ef746f89..ee1212e023335 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/FormFactoryTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/FormFactoryTest.php @@ -20,7 +20,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', @@ -45,7 +45,7 @@ public function testWrongTypeException() public function testCreate() { - $className = 'Magento\Framework\Data\Form'; + $className = \Magento\Framework\Data\Form::class; $formMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects( $this->once() diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/FormTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/FormTest.php index 63a35176f9d69..53df962b5dfe0 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/FormTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/FormTest.php @@ -36,7 +36,7 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_factoryElementMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\Factory', + \Magento\Framework\Data\Form\Element\Factory::class, [], [], '', @@ -44,7 +44,7 @@ protected function setUp() ); $this->_factoryCollectionMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, ['create'], [], '', @@ -52,7 +52,7 @@ protected function setUp() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $collectionModel = $objectManager->getObject('Magento\Framework\Data\Form\Element\Collection'); + $collectionModel = $objectManager->getObject(\Magento\Framework\Data\Form\Element\Collection::class); $this->_factoryCollectionMock ->expects($this->any()) @@ -60,7 +60,7 @@ protected function setUp() ->will($this->returnValue($collectionModel)); $this->_formKeyMock = $this->getMock( - 'Magento\Framework\Data\Form\FormKey', + \Magento\Framework\Data\Form\FormKey::class, ['getFormKey'], [], '', @@ -82,7 +82,7 @@ public function testFormKeyUsing() public function testSettersGetters() { - $setElementRenderer = $this->getMockBuilder('Magento\Backend\Block\Widget\Form\Renderer\Element') + $setElementRenderer = $this->getMockBuilder(\Magento\Backend\Block\Widget\Form\Renderer\Element::class) ->disableOriginalConstructor() ->getMock(); @@ -93,7 +93,7 @@ public function testSettersGetters() // restore our Form to its earlier state $this->_form->setElementRenderer(null); - $setFieldsetRenderer = $this->getMockBuilder('Magento\Backend\Block\Widget\Form\Renderer\Fieldset') + $setFieldsetRenderer = $this->getMockBuilder(\Magento\Backend\Block\Widget\Form\Renderer\Fieldset::class) ->disableOriginalConstructor() ->getMock(); @@ -101,7 +101,7 @@ public function testSettersGetters() $getFieldsetRenderer = $this->_form->getFieldsetRenderer(); $this->assertSame($setFieldsetRenderer, $getFieldsetRenderer); - $setFieldsetElementRenderer = $this->getMockBuilder('Magento\Backend\Block\Widget\Form\Renderer\Fieldset') + $setFieldsetElementRenderer = $this->getMockBuilder(\Magento\Backend\Block\Widget\Form\Renderer\Fieldset::class) ->disableOriginalConstructor() ->getMock(); @@ -125,7 +125,7 @@ public function testSettersGetters() */ public function testElementExistsException() { - $buttonElement = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Button') + $buttonElement = $this->getMockBuilder(\Magento\Framework\Data\Form\Element\Button::class) ->disableOriginalConstructor() ->getMock(); $buttonElement->expects($this->any())->method('getId')->will($this->returnValue('1')); @@ -138,7 +138,7 @@ public function testElementExistsException() public function testElementOperations() { - $buttonElement = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Button') + $buttonElement = $this->getMockBuilder(\Magento\Framework\Data\Form\Element\Button::class) ->disableOriginalConstructor() ->getMock(); $buttonElement->expects($this->any())->method('getId')->will($this->returnValue('1')); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Helper/PostHelperTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Helper/PostHelperTest.php index dbef842ee666b..5a14fa9532e91 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Helper/PostHelperTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Helper/PostHelperTest.php @@ -22,13 +22,13 @@ public function testGetPostData() ]); $contextMock = $this->getMock( - 'Magento\Framework\App\Helper\Context', + \Magento\Framework\App\Helper\Context::class, ['getUrlBuilder', 'getUrlEncoder'], [], '', false ); - $urlHelper = $this->getMockBuilder('Magento\Framework\Url\Helper\Data') + $urlHelper = $this->getMockBuilder(\Magento\Framework\Url\Helper\Data::class) ->disableOriginalConstructor()->getMock(); $urlHelper->expects($this->once()) ->method('getEncodedUrl') diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/SearchCriteriaBuilderTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/SearchCriteriaBuilderTest.php index 239b642e5921e..1c37ff79a8831 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/SearchCriteriaBuilderTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/SearchCriteriaBuilderTest.php @@ -9,12 +9,12 @@ class SearchCriteriaBuilderTest extends \PHPUnit_Framework_TestCase { public function testMake() { - $interface = 'Magento\Framework\Api\CriteriaInterface'; + $interface = \Magento\Framework\Api\CriteriaInterface::class; $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $factory = $this->getMock('Magento\Framework\Data\ObjectFactory', [], [], '', false); + $factory = $this->getMock(\Magento\Framework\Data\ObjectFactory::class, [], [], '', false); $builder = $objectManager->getObject( - 'Magento\Framework\Data\Test\Unit\Stub\SearchCriteriaBuilder', + \Magento\Framework\Data\Test\Unit\Stub\SearchCriteriaBuilder::class, ['objectFactory' => $factory] ); $factory->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/SearchResultProcessorTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/SearchResultProcessorTest.php index 160cf842bfad4..b2b42f412d625 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/SearchResultProcessorTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/SearchResultProcessorTest.php @@ -29,11 +29,11 @@ class SearchResultProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->searchCriteriaMock = $this->getMockBuilder('Magento\Framework\Api\CriteriaInterface') + $this->searchCriteriaMock = $this->getMockBuilder(\Magento\Framework\Api\CriteriaInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->searchResultCollectionMock = $this->getMockBuilder('Magento\Framework\Data\AbstractSearchResult') + $this->searchResultCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\AbstractSearchResult::class) ->disableOriginalConstructor() ->setMethods(['getSearchCriteria', 'getItems', 'getItemId']) ->getMockForAbstractClass(); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Stub/SearchCriteriaBuilder.php b/lib/internal/Magento/Framework/Data/Test/Unit/Stub/SearchCriteriaBuilder.php index bf7d698011012..faf21e8da0791 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Stub/SearchCriteriaBuilder.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Stub/SearchCriteriaBuilder.php @@ -14,6 +14,6 @@ class SearchCriteriaBuilder extends AbstractSearchCriteriaBuilder */ public function init() { - $this->resultObjectInterface = 'Magento\Framework\Api\CriteriaInterface'; + $this->resultObjectInterface = \Magento\Framework\Api\CriteriaInterface::class; } } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php index 9c4c49aedafb3..6303ceb334a40 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php @@ -40,7 +40,7 @@ public function testOffsets() $this->assertSame($this->collection->offsetExists('node1'), true); $this->collection->offsetSet('node1', 'Hello'); $this->assertSame($this->collection->offsetExists('node1'), true); - $this->assertSame($this->collection->offsetGet('node1'), 'Hello'); + $this->assertSame($this->collection->offsetget(\node1::class), 'Hello'); $this->collection->offsetUnset('node1'); $this->assertSame($this->collection->offsetExists('node1'), false); } diff --git a/lib/internal/Magento/Framework/Data/Tree/NodeFactory.php b/lib/internal/Magento/Framework/Data/Tree/NodeFactory.php index 7f8ca284f265f..065a8fe3a804a 100644 --- a/lib/internal/Magento/Framework/Data/Tree/NodeFactory.php +++ b/lib/internal/Magento/Framework/Data/Tree/NodeFactory.php @@ -35,7 +35,7 @@ class NodeFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = '\Magento\Framework\Data\Tree\Node' + $instanceName = \Magento\Framework\Data\Tree\Node::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Data/TreeFactory.php b/lib/internal/Magento/Framework/Data/TreeFactory.php index 456bc741b8420..e2cf04dbad772 100644 --- a/lib/internal/Magento/Framework/Data/TreeFactory.php +++ b/lib/internal/Magento/Framework/Data/TreeFactory.php @@ -35,7 +35,7 @@ class TreeFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = '\Magento\Framework\Data\Tree' + $instanceName = \Magento\Framework\Data\Tree::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php b/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php index 589daf2710ac0..2410997b08a5a 100644 --- a/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php +++ b/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php @@ -48,7 +48,7 @@ class Proxy extends \Magento\Framework\DataObject\Copy\Config\Data implements */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = '\\Magento\\Framework\\DataObject\\Copy\\Config\\Data', + $instanceName = \Magento\Framework\DataObject\Copy\Config\Data::class, $shared = true ) { $this->_objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/DataObject/Copy/Config/Reader.php b/lib/internal/Magento/Framework/DataObject/Copy/Config/Reader.php index c67844a9adc00..80b4a58e7eb86 100644 --- a/lib/internal/Magento/Framework/DataObject/Copy/Config/Reader.php +++ b/lib/internal/Magento/Framework/DataObject/Copy/Config/Reader.php @@ -38,7 +38,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'fieldset.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/Config/SchemaLocatorTest.php index d6e48db02fb0d..533aa5b4151ff 100644 --- a/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/Config/SchemaLocatorTest.php @@ -18,7 +18,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $urnResolverMock = $this->getMock( - 'Magento\Framework\Config\Dom\UrnResolver', + \Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', diff --git a/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/ConfigTest.php b/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/ConfigTest.php index 515227f775bdd..23542d02cc80d 100644 --- a/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/ConfigTest.php +++ b/lib/internal/Magento/Framework/DataObject/Test/Unit/Copy/ConfigTest.php @@ -22,7 +22,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storageMock = $this->getMock( - 'Magento\Framework\DataObject\Copy\Config\Data', + \Magento\Framework\DataObject\Copy\Config\Data::class, ['get'], [], '', diff --git a/lib/internal/Magento/Framework/DataObject/Test/Unit/CopyTest.php b/lib/internal/Magento/Framework/DataObject/Test/Unit/CopyTest.php index 1d48f67823188..320df0e36484d 100644 --- a/lib/internal/Magento/Framework/DataObject/Test/Unit/CopyTest.php +++ b/lib/internal/Magento/Framework/DataObject/Test/Unit/CopyTest.php @@ -40,12 +40,12 @@ class CopyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fieldsetConfigMock = $this->getMock('Magento\Framework\DataObject\Copy\Config', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->sourceMock = $this->getMock('Magento\Framework\DataObject', [], [], '', false); - $this->targetMock = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $this->fieldsetConfigMock = $this->getMock(\Magento\Framework\DataObject\Copy\Config::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->sourceMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); + $this->targetMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->extensionAttributesFactoryMock = - $this->getMock('Magento\Framework\Api\ExtensionAttributesFactory', [], [], '', false); + $this->getMock(\Magento\Framework\Api\ExtensionAttributesFactory::class, [], [], '', false); $this->copy = new \Magento\Framework\DataObject\Copy( $this->eventManagerMock, $this->fieldsetConfigMock, @@ -177,7 +177,7 @@ public function testGetCopyFieldsetToTargetWhenTargetIsExtensibleDataInterface() ->will($this->returnValue($fields)); $sourceMock = $this->getMock( - 'Magento\Framework\Api\ExtensibleDataInterface', + \Magento\Framework\Api\ExtensibleDataInterface::class, [ 'getExtensionAttributes', 'getCode' ], @@ -186,7 +186,7 @@ public function testGetCopyFieldsetToTargetWhenTargetIsExtensibleDataInterface() false ); $targetMock = $this->getMock( - 'Magento\Framework\Api\ExtensibleDataInterface', + \Magento\Framework\Api\ExtensibleDataInterface::class, [ 'getExtensionAttributes', 'setCode', @@ -235,7 +235,7 @@ public function testGetCopyFieldsetToTargetWhenTargetIsAbstractSimpleObject() ->will($this->returnValue($fields)); $sourceMock = $this->getMock( - 'Magento\Framework\Api\AbstractSimpleObject', + \Magento\Framework\Api\AbstractSimpleObject::class, [ '__toArray' ], @@ -244,7 +244,7 @@ public function testGetCopyFieldsetToTargetWhenTargetIsAbstractSimpleObject() false ); $targetMock = $this->getMock( - 'Magento\Framework\Api\AbstractSimpleObject', + \Magento\Framework\Api\AbstractSimpleObject::class, [ 'setData' ], diff --git a/lib/internal/Magento/Framework/DataObject/Test/Unit/MapperTest.php b/lib/internal/Magento/Framework/DataObject/Test/Unit/MapperTest.php index 50ee2316c9050..4583d38c5014e 100644 --- a/lib/internal/Magento/Framework/DataObject/Test/Unit/MapperTest.php +++ b/lib/internal/Magento/Framework/DataObject/Test/Unit/MapperTest.php @@ -25,8 +25,8 @@ class MapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fromMock = $this->getMock('Magento\Framework\DataObject', [], [], '', false); - $this->toMock = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $this->fromMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); + $this->toMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->mapper = new \Magento\Framework\DataObject\Mapper(); } diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php index 23f083a0483d9..3b9edc05958f6 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php @@ -23,8 +23,8 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_randomGenerator = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); - $deploymentConfigMock = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->_randomGenerator = $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false); + $deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfigMock->expects($this->any()) ->method('get') ->with(Encryptor::PARAM_CRYPT_KEY) @@ -102,7 +102,7 @@ public function validateHashDataProvider() */ public function testEncryptWithEmptyKey($key) { - $deploymentConfigMock = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfigMock->expects($this->any()) ->method('get') ->with(Encryptor::PARAM_CRYPT_KEY) @@ -124,7 +124,7 @@ public function encryptWithEmptyKeyDataProvider() */ public function testDecryptWithEmptyKey($key) { - $deploymentConfigMock = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfigMock->expects($this->any()) ->method('get') ->with(Encryptor::PARAM_CRYPT_KEY) @@ -176,7 +176,7 @@ public function testDecrypt() public function testEncryptDecryptNewKeyAdded() { - $deploymentConfigMock = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfigMock->expects($this->at(0)) ->method('get') ->with(Encryptor::PARAM_CRYPT_KEY) diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/UrlCoderTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/UrlCoderTest.php index 20fc8b0629928..d4ef4951d0c99 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/UrlCoderTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/UrlCoderTest.php @@ -29,7 +29,7 @@ class UrlCoderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_urlMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $this->_urlMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); $this->_urlCoder = new \Magento\Framework\Encryption\UrlCoder($this->_urlMock); } diff --git a/lib/internal/Magento/Framework/EntityManager/Sequence/SequenceFactory.php b/lib/internal/Magento/Framework/EntityManager/Sequence/SequenceFactory.php index f7325dbc93180..e5efff1d15a95 100644 --- a/lib/internal/Magento/Framework/EntityManager/Sequence/SequenceFactory.php +++ b/lib/internal/Magento/Framework/EntityManager/Sequence/SequenceFactory.php @@ -37,7 +37,7 @@ class SequenceFactory public function __construct( SequenceRegistry $sequenceRegistry, ObjectManagerInterface $objectManager, - $instanceName = 'Magento\\Framework\\EntityManager\\Sequence\\Sequence' + $instanceName = \Magento\Framework\EntityManager\Sequence\Sequence::class ) { $this->sequenceRegistry = $sequenceRegistry; $this->objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/Event/Config/Reader.php b/lib/internal/Magento/Framework/Event/Config/Reader.php index fd5179b6c513a..5a1bcc9962337 100644 --- a/lib/internal/Magento/Framework/Event/Config/Reader.php +++ b/lib/internal/Magento/Framework/Event/Config/Reader.php @@ -33,7 +33,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'events.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Event/Invoker/InvokerDefault.php b/lib/internal/Magento/Framework/Event/Invoker/InvokerDefault.php index 41f8075b4f8d3..20743df52198a 100644 --- a/lib/internal/Magento/Framework/Event/Invoker/InvokerDefault.php +++ b/lib/internal/Magento/Framework/Event/Invoker/InvokerDefault.php @@ -75,8 +75,7 @@ protected function _callObserverMethod($object, $observer) throw new \LogicException( sprintf( 'Observer "%s" must implement interface "%s"', - get_class($object), - 'Magento\Framework\Event\ObserverInterface' + get_class($object), \Magento\Framework\Event\ObserverInterface::class ) ); } diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/CollectionTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/CollectionTest.php index f8a4fe92e5d09..250e0ff370678 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/CollectionTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/CollectionTest.php @@ -66,7 +66,7 @@ public function testGetEventByName() public function testGetEventByNameNotSet() { $eventName = 'eventName'; - $eventMock = $this->getMock('\Magento\Framework\Event', ['getName'], [], '', false, false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getName'], [], '', false, false); $eventMock->setData('name', $eventName); $eventObj = $this->collection->getEventByName($eventName); $this->assertEquals($eventMock->getData('name'), $eventObj->getName()); @@ -75,7 +75,7 @@ public function testGetEventByNameNotSet() public function testAddEvent() { $eventName = 'eventName'; - $eventMock = $this->getMock('\Magento\Framework\Event', ['getName'], [], '', false, false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getName'], [], '', false, false); $eventMock->expects($this->once()) ->method('getName') ->will($this->returnValue($eventName)); @@ -89,7 +89,7 @@ public function testAddObserver() $observer->setData('event_name', $testEvent); $eventName = 'eventName'; - $eventMock = $this->getMock('\Magento\Framework\Event', ['getName'], [], '', false, false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getName'], [], '', false, false); $eventMock->setData('name', $eventName); $this->collection->addObserver($observer); diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Config/SchemaLocatorTest.php index d142c6c32024f..07271af209137 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Config/SchemaLocatorTest.php @@ -21,7 +21,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->model = new \Magento\Framework\Event\Config\SchemaLocator($this->urnResolverMock); } diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/ConfigTest.php index 1eb4872f8fca6..5a7fc373bab10 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/ConfigTest.php @@ -29,7 +29,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataContainerMock = $this->getMock('Magento\Framework\Event\Config\Data', ['get'], [], '', false, false); + $this->dataContainerMock = $this->getMock( + \Magento\Framework\Event\Config\Data::class, + ['get'], + [], + '', + false, + false + ); $this->config = new Config($this->dataContainerMock); } diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Invoker/InvokerDefaultTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Invoker/InvokerDefaultTest.php index d23b1f03e136e..06eda37235943 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Invoker/InvokerDefaultTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Invoker/InvokerDefaultTest.php @@ -35,21 +35,21 @@ class InvokerDefaultTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_observerFactoryMock = $this->getMock( - 'Magento\Framework\Event\ObserverFactory', + \Magento\Framework\Event\ObserverFactory::class, [], [], '', false ); - $this->_observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->_observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $this->_listenerMock = $this->getMock( - 'Magento\Framework\Event\Test\Unit\Invoker\ObserverExample', + \Magento\Framework\Event\Test\Unit\Invoker\ObserverExample::class, ['execute'], [], '', false ); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->_appStateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->_invokerDefault = new \Magento\Framework\Event\Invoker\InvokerDefault( $this->_observerFactoryMock, diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php index 8ef53caef218a..ee66fa67c8997 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php @@ -37,7 +37,7 @@ protected function tearDown() */ protected function getObserverMock($name, $event = null) { - $observer = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $observer->expects($this->any()) ->method('getName') ->will($this->returnValue($name)); @@ -111,7 +111,7 @@ public function testRemoveObserverByName() public function testDispatch() { - $eventMock = $this->getMock('Magento\Framework\Event', [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, [], [], '', false); $observer1 = $this->getObserverMock('test_observer1', $eventMock); $observer2 = $this->getObserverMock('test_observer2', $eventMock); diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php index 7ed355e1b6c68..bb7a2f75571e5 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php @@ -99,7 +99,7 @@ public function matchCronExpressionProvider() */ public function testIsValidFor($time, $expression, $expectedResult) { - $eventMock = $this->getMock('Magento\Framework\Event', [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, [], [], '', false); $this->cron->setCronExpr($expression); $this->cron->setNow($time); diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php index 0ae4264325e82..f47a54aa9d3cd 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php @@ -36,7 +36,7 @@ protected function tearDown() public function testIsValidFor($pattern, $name, $expectedResult) { $this->regex->setEventRegex($pattern); - $eventMock = $this->getMock('Magento\Framework\Event', [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, [], [], '', false); $eventMock->expects($this->any()) ->method('getName') ->will($this->returnValue($name)); diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/ObserverFactoryTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/ObserverFactoryTest.php index dd7d4ede6855c..9e230f872de1d 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/ObserverFactoryTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/ObserverFactoryTest.php @@ -28,7 +28,7 @@ class ObserverFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['get', 'create'], [], '', @@ -41,7 +41,7 @@ protected function setUp() public function testGet() { $className = 'Magento\Class'; - $observerMock = $this->getMock('Magento\Observer', [], [], '', false, false); + $observerMock = $this->getMock(\Magento\Observer::class, [], [], '', false, false); $this->objectManagerMock->expects($this->once()) ->method('get') ->with($className) @@ -54,7 +54,7 @@ public function testGet() public function testCreate() { $className = 'Magento\Class'; - $observerMock = $this->getMock('Magento\Observer', [], [], '', false, false); + $observerMock = $this->getMock(\Magento\Observer::class, [], [], '', false, false); $arguments = ['arg1', 'arg2']; $this->objectManagerMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/ObserverTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/ObserverTest.php index 82fe99f1d1523..b109c3cac7a4f 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/ObserverTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/ObserverTest.php @@ -30,7 +30,7 @@ protected function setUp() public function testIsValidFor() { $eventName = 'eventName'; - $eventMock = $this->getMock('Magento\Framework\Event', ['getName']); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getName']); $eventMock->expects($this->once()) ->method('getName') ->will($this->returnValue($eventName)); @@ -102,11 +102,11 @@ public function testDispatch() { $eventName = 'eventName'; $callbackName = 'testCallback'; - $callbackMock = [$this->getMock('stdClass', [$callbackName]), $callbackName]; + $callbackMock = [$this->getMock(\stdClass::class, [$callbackName]), $callbackName]; $callbackMock[0]->expects($this->once()) ->method('testCallback') ->will($this->returnValue(true)); - $eventMock = $this->getMock('Magento\Framework\Event', ['getName']); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getName']); $eventMock->expects($this->once()) ->method('getName') ->will($this->returnValue($eventName)); @@ -120,7 +120,7 @@ public function testDispatchNotValidEvent() { $eventName = 'eventName'; $notValidName = 'event_name_2'; - $eventMock = $this->getMock('Magento\Framework\Event', ['getName']); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getName']); $eventMock->expects($this->once()) ->method('getName') ->will($this->returnValue($eventName)); diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/WrapperFactoryTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/WrapperFactoryTest.php index 5eab39b7dfae8..94e544868240d 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/WrapperFactoryTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/WrapperFactoryTest.php @@ -19,8 +19,8 @@ class WrapperFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $expectedInstance = 'Magento\Framework\Event\Observer'; - $objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface'); + $expectedInstance = \Magento\Framework\Event\Observer::class; + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $wrapperFactory = new WrapperFactory($objectManagerMock); $arguments = ['argument' => 'value', 'data' => 'data']; diff --git a/lib/internal/Magento/Framework/Event/WrapperFactory.php b/lib/internal/Magento/Framework/Event/WrapperFactory.php index c674d3df8a114..aca2250905e2c 100644 --- a/lib/internal/Magento/Framework/Event/WrapperFactory.php +++ b/lib/internal/Magento/Framework/Event/WrapperFactory.php @@ -30,6 +30,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $arguments = []) { - return $this->_objectManager->create('Magento\Framework\Event\Observer', $arguments); + return $this->_objectManager->create(\Magento\Framework\Event\Observer::class, $arguments); } } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php index 3e564b390b9b0..f4a426a1cf656 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php @@ -25,7 +25,7 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); - $rendererMock = $this->getMockBuilder('Magento\Framework\Phrase\Renderer\Placeholder') + $rendererMock = $this->getMockBuilder(\Magento\Framework\Phrase\Renderer\Placeholder::class) ->disableOriginalConstructor() ->getMock(); $this->renderedMessage = 'rendered message'; diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php index 711045beaf8d8..9c8d72cf96220 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php @@ -30,7 +30,7 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); - $this->rendererMock = $this->getMockBuilder('Magento\Framework\Phrase\Renderer\Placeholder') + $this->rendererMock = $this->getMockBuilder(\Magento\Framework\Phrase\Renderer\Placeholder::class) ->setMethods(['render']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php index 2afd426c72d90..42a7dc212f712 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php @@ -22,7 +22,7 @@ class ExpiredExceptionTest extends \PHPUnit_Framework_TestCase */ public function testConstructor() { - $instanceClass = 'Magento\Framework\Exception\State\ExpiredException'; + $instanceClass = \Magento\Framework\Exception\State\ExpiredException::class; $message = 'message %1 %2'; $params = [ 'parameter1', diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php index da91836301692..89c92010e89eb 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php @@ -17,7 +17,7 @@ class InputMismatchExceptionTest extends \PHPUnit_Framework_TestCase */ public function testConstructor() { - $instanceClass = 'Magento\Framework\Exception\State\InputMismatchException'; + $instanceClass = \Magento\Framework\Exception\State\InputMismatchException::class; $message = 'message %1 %2'; $params = [ 'parameter1', diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php index 0a39468d3cf4f..a268faf5497c9 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php @@ -17,7 +17,7 @@ class InvalidTransitionExceptionTest extends \PHPUnit_Framework_TestCase */ public function testConstructor() { - $instanceClass = 'Magento\Framework\Exception\State\InvalidTransitionException'; + $instanceClass = \Magento\Framework\Exception\State\InvalidTransitionException::class; $message = 'message %1 %2'; $params = [ 'parameter1', diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php index 7cb66c6b57e80..4efa475c68b09 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php @@ -11,8 +11,6 @@ /** * Class StateExceptionTest - * - * @package Magento\Framework\Exception */ class StateExceptionTest extends \PHPUnit_Framework_TestCase { @@ -21,7 +19,7 @@ class StateExceptionTest extends \PHPUnit_Framework_TestCase */ public function testStateExceptionInstance() { - $instanceClass = 'Magento\Framework\Exception\StateException'; + $instanceClass = \Magento\Framework\Exception\StateException::class; $message = 'message %1 %2'; $params = [ 'parameter1', diff --git a/lib/internal/Magento/Framework/File/Size.php b/lib/internal/Magento/Framework/File/Size.php index 2d08ba1ca8c9a..269053cc54d02 100644 --- a/lib/internal/Magento/Framework/File/Size.php +++ b/lib/internal/Magento/Framework/File/Size.php @@ -26,7 +26,7 @@ class Size */ public function getPostMaxSize() { - return $this->_iniGet('post_max_size'); + return $this->_iniget('post_max_size'); } /** @@ -36,7 +36,7 @@ public function getPostMaxSize() */ public function getUploadMaxSize() { - return $this->_iniGet('upload_max_filesize'); + return $this->_iniget('upload_max_filesize'); } /** diff --git a/lib/internal/Magento/Framework/File/Test/Unit/CsvTest.php b/lib/internal/Magento/Framework/File/Test/Unit/CsvTest.php index b6b21359a5441..609be97a8ec77 100644 --- a/lib/internal/Magento/Framework/File/Test/Unit/CsvTest.php +++ b/lib/internal/Magento/Framework/File/Test/Unit/CsvTest.php @@ -36,9 +36,7 @@ public function testSetLineLength() { $expected = 4; $this->_model->setLineLength($expected); - $lineLengthProperty = new \ReflectionProperty( - 'Magento\Framework\File\Csv', '_lineLength' - ); + $lineLengthProperty = new \ReflectionProperty(\Magento\Framework\File\Csv::class, '_lineLength'); $lineLengthProperty->setAccessible(true); $actual = $lineLengthProperty->getValue($this->_model); $this->assertEquals($expected, $actual); @@ -46,12 +44,12 @@ public function testSetLineLength() public function testSetDelimiter() { - $this->assertInstanceOf('\Magento\Framework\File\Csv', $this->_model->setDelimiter(',')); + $this->assertInstanceOf(\Magento\Framework\File\Csv::class, $this->_model->setDelimiter(',')); } public function testSetEnclosure() { - $this->assertInstanceOf('\Magento\Framework\File\Csv', $this->_model->setEnclosure('"')); + $this->assertInstanceOf(\Magento\Framework\File\Csv::class, $this->_model->setEnclosure('"')); } /** diff --git a/lib/internal/Magento/Framework/File/Test/Unit/Transfer/Adapter/HttpTest.php b/lib/internal/Magento/Framework/File/Test/Unit/Transfer/Adapter/HttpTest.php index 770c732e5929e..309a6b2e3559d 100644 --- a/lib/internal/Magento/Framework/File/Test/Unit/Transfer/Adapter/HttpTest.php +++ b/lib/internal/Magento/Framework/File/Test/Unit/Transfer/Adapter/HttpTest.php @@ -27,13 +27,13 @@ class HttpTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->response = $this->getMock( - '\Magento\Framework\HTTP\PhpEnvironment\Response', + \Magento\Framework\HTTP\PhpEnvironment\Response::class, ['setHeader', 'sendHeaders'], [], '', false ); - $this->mime = $this->getMock('Magento\Framework\File\Mime'); + $this->mime = $this->getMock(\Magento\Framework\File\Mime::class); $this->object = new Http($this->response, $this->mime); } diff --git a/lib/internal/Magento/Framework/File/UploaderFactory.php b/lib/internal/Magento/Framework/File/UploaderFactory.php index 8a0c4d8e664af..8f0b6dc9fe690 100644 --- a/lib/internal/Magento/Framework/File/UploaderFactory.php +++ b/lib/internal/Magento/Framework/File/UploaderFactory.php @@ -30,6 +30,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $data = []) { - return $this->_objectManager->create('Magento\Framework\File\Uploader', $data); + return $this->_objectManager->create(\Magento\Framework\File\Uploader::class, $data); } } diff --git a/lib/internal/Magento/Framework/Filesystem/DriverPool.php b/lib/internal/Magento/Framework/Filesystem/DriverPool.php index 2d66e8a69ca91..6999bbfdd4897 100644 --- a/lib/internal/Magento/Framework/Filesystem/DriverPool.php +++ b/lib/internal/Magento/Framework/Filesystem/DriverPool.php @@ -26,10 +26,10 @@ class DriverPool * @var string[] */ protected $types = [ - self::FILE => 'Magento\Framework\Filesystem\Driver\File', - self::HTTP => 'Magento\Framework\Filesystem\Driver\Http', - self::HTTPS => 'Magento\Framework\Filesystem\Driver\Https', - self::ZLIB => 'Magento\Framework\Filesystem\Driver\Zlib', + self::FILE => \Magento\Framework\Filesystem\Driver\File::class, + self::HTTP => \Magento\Framework\Filesystem\Driver\Http::class, + self::HTTPS => \Magento\Framework\Filesystem\Driver\Https::class, + self::ZLIB => \Magento\Framework\Filesystem\Driver\Zlib::class, ]; /** @@ -55,7 +55,7 @@ public function __construct($extraTypes = []) $type = $typeOrObject; $object = false; } - if (!is_subclass_of($type, '\Magento\Framework\Filesystem\DriverInterface')) { + if (!is_subclass_of($type, \Magento\Framework\Filesystem\DriverInterface::class)) { throw new \InvalidArgumentException("The specified type '{$type}' does not implement DriverInterface."); } $this->types[$code] = $type; diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/ReadTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/ReadTest.php index 64d60f76b2404..67b6bafa80c7a 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/ReadTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/ReadTest.php @@ -40,9 +40,9 @@ class ReadTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->driver = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $this->driver = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class, [], [], '', false); $this->fileFactory = $this->getMock( - 'Magento\Framework\Filesystem\File\ReadFactory', + \Magento\Framework\Filesystem\File\ReadFactory::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/WriteTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/WriteTest.php index e7b687bcf279c..5c93c890f04de 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/WriteTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Directory/WriteTest.php @@ -38,9 +38,9 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->driver = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $this->driver = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class, [], [], '', false); $this->fileFactory = $this->getMock( - 'Magento\Framework\Filesystem\File\WriteFactory', + \Magento\Framework\Filesystem\File\WriteFactory::class, [], [], '', @@ -68,7 +68,7 @@ protected function tearDown() public function testGetDriver() { $this->assertInstanceOf( - 'Magento\Framework\Filesystem\DriverInterface', + \Magento\Framework\Filesystem\DriverInterface::class, $this->write->getDriver(), 'getDriver method expected to return instance of Magento\Framework\Filesystem\DriverInterface' ); @@ -88,10 +88,9 @@ public function testIsWritable() $this->assertTrue($this->write->isWritable('correct-path')); } - public function testCreateSymlinkTargetDirectoryExists() { - $targetDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $targetDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMock(); $targetDir->driver = $this->driver; $sourcePath = 'source/path/file'; diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php index 6a490c3524d15..e93b9003e3ca6 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php @@ -14,22 +14,22 @@ public function testGetDriver() { $object = new DriverPool(); foreach ([DriverPool::FILE, DriverPool::HTTP, DriverPool::HTTPS, DriverPool::ZLIB] as $code) { - $this->assertInstanceOf('\Magento\Framework\Filesystem\DriverInterface', $object->getDriver($code)); + $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverInterface::class, $object->getDriver($code)); } $default = $object->getDriver(''); - $this->assertInstanceOf('\Magento\Framework\Filesystem\Driver\File', $default); + $this->assertInstanceOf(\Magento\Framework\Filesystem\Driver\File::class, $default); $this->assertSame($default, $object->getDriver('')); } public function testCustomDriver() { - $customOne = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\DriverInterface'); - $customTwo = get_class($this->getMockForAbstractClass('\Magento\Framework\Filesystem\DriverInterface')); + $customOne = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); + $customTwo = get_class($this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class)); $object = new DriverPool(['customOne' => $customOne, 'customTwo' => $customTwo]); $this->assertSame($customOne, $object->getDriver('customOne')); - $this->assertInstanceOf('\Magento\Framework\Filesystem\DriverInterface', $object->getDriver('customOne')); + $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverInterface::class, $object->getDriver('customOne')); $this->assertEquals($customTwo, get_class($object->getDriver('customTwo'))); - $this->assertInstanceOf('\Magento\Framework\Filesystem\DriverInterface', $object->getDriver('customTwo')); + $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverInterface::class, $object->getDriver('customTwo')); } /** diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php index bca9b5b667685..59e02387aa91a 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php @@ -48,7 +48,9 @@ private function getFilesIterator () ]; foreach ($files as $file) { - $item = $this->getMockBuilder('SplFileInfoClass')->setMethods(['__toString', 'getFilename'])->getMock(); + $item = $this->getMockBuilder( + \SplFileInfoClass::class + )->setMethods(['__toString', 'getFilename'])->getMock(); $item->expects($this->any())->method('__toString')->willReturn($file); $item->expects($this->any())->method('getFilename')->willReturn('notDots'); yield $item; diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadFactoryTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadFactoryTest.php index 7e03386b38f4f..d9f62fc3f33a3 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadFactoryTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadFactoryTest.php @@ -16,23 +16,23 @@ class ReadFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); + $driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); $driverPool->expects($this->never())->method('getDriver'); - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driver->expects($this->any())->method('isExists')->willReturn(true); $factory = new ReadFactory($driverPool); $result = $factory->create('path', $driver); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $result); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $result); } public function testCreateWithDriverCode() { - $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); - $driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); + $driverMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driverMock->expects($this->any())->method('isExists')->willReturn(true); $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); $factory = new ReadFactory($driverPool); $result = $factory->create('path', 'driverCode'); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $result); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $result); } } diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadTest.php index f5ba5b4558d74..e0263a2e49c92 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ReadTest.php @@ -39,7 +39,7 @@ class ReadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $this->driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $this->resource = $this->getMock('resource'); $this->driver->expects($this->any()) ->method('isExists') @@ -63,13 +63,13 @@ public function tearDown() */ public function testInstanceFileNotExists() { - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driver->expects($this->once()) ->method('isExists') ->with($this->path) ->will($this->returnValue(false)); $file = new Read($this->path, $driver); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $file); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $file); } public function testRead() diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteFactoryTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteFactoryTest.php index ed670d08ca059..56c376c78f28c 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteFactoryTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteFactoryTest.php @@ -14,34 +14,34 @@ class WriteFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); + $driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); $driverPool->expects($this->never())->method('getDriver'); $factory = new WriteFactory($driverPool); - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driver->expects($this->any())->method('isExists')->willReturn(true); $result = $factory->create('path', $driver); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Write::class, $result); } public function testCreateWithDriverCode() { - $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); - $driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); + $driverMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driverMock->expects($this->any())->method('isExists')->willReturn(true); $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); $factory = new WriteFactory($driverPool); $result = $factory->create('path', 'driverCode'); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Write::class, $result); } public function testCreateWithMode() { - $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); + $driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); $driverPool->expects($this->never())->method('getDriver'); - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driver->expects($this->any())->method('isExists')->willReturn(true); $factory = new WriteFactory($driverPool); $result = $factory->create('path', $driver, 'a+'); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Write::class, $result); } } diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteTest.php index 62360d99adcd6..4728143e0c3cf 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/WriteTest.php @@ -41,7 +41,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $this->driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $this->resource = $this->getMock('resource'); $this->driver->expects($this->any()) ->method('isExists') @@ -65,13 +65,13 @@ public function tearDown() */ public function testInstanceFileNotExists() { - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driver->expects($this->once()) ->method('isExists') ->with($this->path) ->will($this->returnValue(false)); $file = new Write($this->path, $driver, 'r'); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $file); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $file); } /** @@ -79,13 +79,13 @@ public function testInstanceFileNotExists() */ public function testInstanceFileAlreadyExists() { - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); $driver->expects($this->once()) ->method('isExists') ->with($this->path) ->will($this->returnValue(true)); $file = new Write($this->path, $driver, 'x'); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $file); + $this->assertInstanceOf(\Magento\Framework\Filesystem\File\Read::class, $file); } public function testWrite() diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/FileResolverTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/FileResolverTest.php index 5491ce44a7b50..a90d1ae9d6762 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/FileResolverTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/FileResolverTest.php @@ -20,7 +20,7 @@ class FileResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->model = (new ObjectManager($this))->getObject('Magento\Framework\Filesystem\FileResolver'); + $this->model = (new ObjectManager($this))->getObject(\Magento\Framework\Filesystem\FileResolver::class); } public function testGetFilePath() diff --git a/lib/internal/Magento/Framework/Filter/Factory.php b/lib/internal/Magento/Framework/Filter/Factory.php index 8ddfcc639dca9..27b9f6f9b0fa2 100644 --- a/lib/internal/Magento/Framework/Filter/Factory.php +++ b/lib/internal/Magento/Framework/Filter/Factory.php @@ -16,22 +16,22 @@ class Factory extends AbstractFactory * @var array */ protected $invokableClasses = [ - 'email' => 'Magento\Framework\Filter\Email', - 'money' => 'Magento\Framework\Filter\Money', - 'simple' => 'Magento\Framework\Filter\Template\Simple', - 'object' => 'Magento\Framework\Filter\DataObject', - 'sprintf' => 'Magento\Framework\Filter\Sprintf', - 'template' => 'Magento\Framework\Filter\Template', - 'arrayFilter' => 'Magento\Framework\Filter\ArrayFilter', - 'removeAccents' => 'Magento\Framework\Filter\RemoveAccents', - 'splitWords' => 'Magento\Framework\Filter\SplitWords', - 'removeTags' => 'Magento\Framework\Filter\RemoveTags', - 'stripTags' => 'Magento\Framework\Filter\StripTags', - 'truncate' => 'Magento\Framework\Filter\Truncate', - 'encrypt' => 'Magento\Framework\Filter\Encrypt', - 'decrypt' => 'Magento\Framework\Filter\Decrypt', - 'translit' => 'Magento\Framework\Filter\Translit', - 'translitUrl' => 'Magento\Framework\Filter\TranslitUrl', + 'email' => \Magento\Framework\Filter\Email::class, + 'money' => \Magento\Framework\Filter\Money::class, + 'simple' => \Magento\Framework\Filter\Template\Simple::class, + 'object' => \Magento\Framework\Filter\DataObject::class, + 'sprintf' => \Magento\Framework\Filter\Sprintf::class, + 'template' => \Magento\Framework\Filter\Template::class, + 'arrayFilter' => \Magento\Framework\Filter\ArrayFilter::class, + 'removeAccents' => \Magento\Framework\Filter\RemoveAccents::class, + 'splitWords' => \Magento\Framework\Filter\SplitWords::class, + 'removeTags' => \Magento\Framework\Filter\RemoveTags::class, + 'stripTags' => \Magento\Framework\Filter\StripTags::class, + 'truncate' => \Magento\Framework\Filter\Truncate::class, + 'encrypt' => \Magento\Framework\Filter\Encrypt::class, + 'decrypt' => \Magento\Framework\Filter\Decrypt::class, + 'translit' => \Magento\Framework\Filter\Translit::class, + 'translitUrl' => \Magento\Framework\Filter\TranslitUrl::class, ]; /** @@ -40,11 +40,11 @@ class Factory extends AbstractFactory * @var array */ protected $shared = [ - 'Magento\Framework\Filter\Sprintf' => false, - 'Magento\Framework\Filter\Money' => false, - 'Magento\Framework\Filter\RemoveAccents' => false, - 'Magento\Framework\Filter\SplitWords' => false, - 'Magento\Framework\Filter\StripTags' => false, - 'Magento\Framework\Filter\Truncate' => false, + \Magento\Framework\Filter\Sprintf::class => false, + \Magento\Framework\Filter\Money::class => false, + \Magento\Framework\Filter\RemoveAccents::class => false, + \Magento\Framework\Filter\SplitWords::class => false, + \Magento\Framework\Filter\StripTags::class => false, + \Magento\Framework\Filter\Truncate::class => false, ]; } diff --git a/lib/internal/Magento/Framework/Filter/FilterManager/Config.php b/lib/internal/Magento/Framework/Filter/FilterManager/Config.php index 82a0ac7a15786..72e0b316914ff 100644 --- a/lib/internal/Magento/Framework/Filter/FilterManager/Config.php +++ b/lib/internal/Magento/Framework/Filter/FilterManager/Config.php @@ -13,7 +13,7 @@ class Config implements ConfigInterface /** * @var string[] */ - protected $factories = ['Magento\Framework\Filter\Factory', 'Magento\Framework\Filter\ZendFactory']; + protected $factories = [\Magento\Framework\Filter\Factory::class, \Magento\Framework\Filter\ZendFactory::class]; /** * @param string[] $factories diff --git a/lib/internal/Magento/Framework/Filter/Input.php b/lib/internal/Magento/Framework/Filter/Input.php index 3008700b09642..76870cdfb07da 100644 --- a/lib/internal/Magento/Framework/Filter/Input.php +++ b/lib/internal/Magento/Framework/Filter/Input.php @@ -23,7 +23,7 @@ * 'zend' => 'StringToUpper', * 'args' => array('encoding' => 'utf-8'))), * 'item2' => array( - * array('model' => 'Magento\Framework\Filter\Input\MaliciousCode') + * array('model' => \Magento\Framework\Filter\Input\MaliciousCode::class) * ), * 'item3' => array( * array( diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/AbstractFactoryTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/AbstractFactoryTest.php index fd34c568edf4a..1be7a0e1bfb15 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/AbstractFactoryTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/AbstractFactoryTest.php @@ -16,17 +16,17 @@ class AbstractFactoryTest extends \PHPUnit_Framework_TestCase * @var array */ protected $_invokableList = [ - 'sprintf' => 'Magento\Framework\Filter\Sprintf', - 'template' => 'Magento\Framework\Filter\Template', - 'arrayFilter' => 'Magento\Framework\Filter\ArrayFilter', + 'sprintf' => \Magento\Framework\Filter\Sprintf::class, + 'template' => \Magento\Framework\Filter\Template::class, + 'arrayFilter' => \Magento\Framework\Filter\ArrayFilter::class, ]; /** * @var array */ protected $_sharedList = [ - 'Magento\Framework\Filter\Template' => true, - 'Magento\Framework\Filter\ArrayFilter' => false, + \Magento\Framework\Filter\Template::class => true, + \Magento\Framework\Filter\ArrayFilter::class => false, ]; /** @@ -36,17 +36,17 @@ class AbstractFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_factory = $this->getMockForAbstractClass( - 'Magento\Framework\Filter\AbstractFactory', + \Magento\Framework\Filter\AbstractFactory::class, ['objectManger' => $this->_objectManager] ); - $property = new \ReflectionProperty('Magento\Framework\Filter\AbstractFactory', 'invokableClasses'); + $property = new \ReflectionProperty(\Magento\Framework\Filter\AbstractFactory::class, 'invokableClasses'); $property->setAccessible(true); $property->setValue($this->_factory, $this->_invokableList); - $property = new \ReflectionProperty('Magento\Framework\Filter\AbstractFactory', 'shared'); + $property = new \ReflectionProperty(\Magento\Framework\Filter\AbstractFactory::class, 'shared'); $property->setAccessible(true); $property->setValue($this->_factory, $this->_sharedList); } @@ -85,9 +85,9 @@ public function testIsShared($alias, $expectedResult) public function isSharedDataProvider() { return [ - 'shared' => ['Magento\Framework\Filter\Template', true], - 'not shared' => ['Magento\Framework\Filter\ArrayFilter', false], - 'default value' => ['Magento\Framework\Filter\Sprintf', true] + 'shared' => [\Magento\Framework\Filter\Template::class, true], + 'not shared' => [\Magento\Framework\Filter\ArrayFilter::class, false], + 'default value' => [\Magento\Framework\Filter\Sprintf::class, true] ]; } @@ -99,7 +99,7 @@ public function isSharedDataProvider() */ public function testCreateFilter($alias, $arguments, $isShared) { - $property = new \ReflectionProperty('Magento\Framework\Filter\AbstractFactory', 'sharedInstances'); + $property = new \ReflectionProperty(\Magento\Framework\Filter\AbstractFactory::class, 'sharedInstances'); $property->setAccessible(true); $filterMock = $this->getMock('FactoryInterface', ['filter']); diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/ArrayFilterTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/ArrayFilterTest.php index 7581f633ebf19..6d4affbe7c9e1 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/ArrayFilterTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/ArrayFilterTest.php @@ -16,7 +16,7 @@ public function testFilter() /** @var \Zend_Filter_Interface $filterMock */ /** This filter should be applied to all fields values */ - $filterMock = $this->getMock('Zend_Filter_Interface', [], [], '', false); + $filterMock = $this->getMock(\Zend_Filter_Interface::class, [], [], '', false); $filterMock->expects($this->exactly(3))->method('filter')->will( $this->returnCallback( function ($input) { @@ -28,7 +28,7 @@ function ($input) { /** @var \Zend_Filter_Interface $fieldFilterMock */ /** This filter should be applied to 'field2' field value only */ - $fieldFilterMock = $this->getMock('Zend_Filter_Interface', [], [], '', false); + $fieldFilterMock = $this->getMock(\Zend_Filter_Interface::class, [], [], '', false); $fieldFilterMock->expects($this->exactly(1))->method('filter')->will( $this->returnCallback( function ($input) { diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/DataObject/GridTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/DataObject/GridTest.php index e46968c39cf0d..57729751b1ddb 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/DataObject/GridTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/DataObject/GridTest.php @@ -15,7 +15,7 @@ class GridTest extends \PHPUnit_Framework_TestCase public function testFilter() { $entityFactoryMock = $this->getMock( - 'Magento\Framework\Data\Collection\EntityFactoryInterface', + \Magento\Framework\Data\Collection\EntityFactoryInterface::class, [], [], '', @@ -24,7 +24,7 @@ public function testFilter() $entityFactoryMock ->expects($this->any()) ->method('create') - ->with('Magento\Framework\DataObject', []) + ->with(\Magento\Framework\DataObject::class, []) ->will( $this->returnCallback( function () { @@ -41,7 +41,7 @@ function () { /** @var \Zend_Filter_Interface $filterMock */ /** This filter should be applied to all fields values */ - $filterMock = $this->getMock('Zend_Filter_Interface', [], [], '', false); + $filterMock = $this->getMock(\Zend_Filter_Interface::class, [], [], '', false); $filterMock->expects($this->exactly(4))->method('filter')->will( $this->returnCallback( function ($input) { @@ -53,7 +53,7 @@ function ($input) { /** @var \Zend_Filter_Interface $fieldFilterMock */ /** This filter should be applied to 'field2' field value only */ - $fieldFilterMock = $this->getMock('Zend_Filter_Interface', [], [], '', false); + $fieldFilterMock = $this->getMock(\Zend_Filter_Interface::class, [], [], '', false); $fieldFilterMock->expects($this->exactly(2))->method('filter')->will( $this->returnCallback( function ($input) { diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManager/ConfigTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManager/ConfigTest.php index 57b6376934979..2c12992b5267b 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManager/ConfigTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManager/ConfigTest.php @@ -20,9 +20,7 @@ protected function setUp() public function testGetFactories() { $expectedConfig = [ - 'test' => 'test', - 'Magento\Framework\Filter\Factory', - 'Magento\Framework\Filter\ZendFactory', + 'test' => 'test', \Magento\Framework\Filter\Factory::class, \Magento\Framework\Filter\ZendFactory::class, ]; $this->assertEquals($expectedConfig, $this->_config->getFactories()); } diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManagerTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManagerTest.php index 054b86fad27a9..b651117962ef8 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManagerTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/FilterManagerTest.php @@ -29,7 +29,7 @@ class FilterManagerTest extends \PHPUnit_Framework_TestCase protected function initMocks() { - $factoryName = 'Magento\Framework\Filter\Factory'; + $factoryName = \Magento\Framework\Filter\Factory::class; $this->_factoryMock = $this->getMock( $factoryName, ['canCreateFilter', 'createFilter'], @@ -37,7 +37,7 @@ protected function initMocks() '', false ); - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_objectManager->expects( $this->atLeastOnce() )->method( @@ -48,7 +48,7 @@ protected function initMocks() $this->returnValue($this->_factoryMock) ); $this->_config = $this->getMock( - '\Magento\Framework\Filter\FilterManager\Config', + \Magento\Framework\Filter\FilterManager\Config::class, ['getFactories'], [], '', @@ -67,7 +67,7 @@ protected function initMocks() public function testGetFilterFactories() { $this->initMocks(); - $method = new \ReflectionMethod('Magento\Framework\Filter\FilterManager', 'getFilterFactories'); + $method = new \ReflectionMethod(\Magento\Framework\Filter\FilterManager::class, 'getFilterFactories'); $method->setAccessible(true); $this->assertEquals([$this->_factoryMock], $method->invoke($this->_filterManager)); } @@ -78,9 +78,9 @@ public function testGetFilterFactories() */ public function testGetFilterFactoriesWrongInstance() { - $factoryName = 'Magento\Framework\Filter\Factory'; + $factoryName = \Magento\Framework\Filter\Factory::class; $this->_factoryMock = new \stdClass(); - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_objectManager->expects( $this->atLeastOnce() )->method( @@ -91,7 +91,7 @@ public function testGetFilterFactoriesWrongInstance() $this->returnValue($this->_factoryMock) ); $this->_config = $this->getMock( - '\Magento\Framework\Filter\FilterManager\Config', + \Magento\Framework\Filter\FilterManager\Config::class, ['getFactories'], [], '', @@ -106,7 +106,7 @@ public function testGetFilterFactoriesWrongInstance() ); $this->_filterManager = new \Magento\Framework\Filter\FilterManager($this->_objectManager, $this->_config); - $method = new \ReflectionMethod('Magento\Framework\Filter\FilterManager', 'getFilterFactories'); + $method = new \ReflectionMethod(\Magento\Framework\Filter\FilterManager::class, 'getFilterFactories'); $method->setAccessible(true); $method->invoke($this->_filterManager); } @@ -117,7 +117,7 @@ public function testCreateFilterInstance() $filterMock = $this->getMock('FactoryInterface'); $this->configureFactoryMock($filterMock, 'alias', ['123']); - $method = new \ReflectionMethod('Magento\Framework\Filter\FilterManager', 'createFilterInstance'); + $method = new \ReflectionMethod(\Magento\Framework\Filter\FilterManager::class, 'createFilterInstance'); $method->setAccessible(true); $this->assertEquals($filterMock, $method->invoke($this->_filterManager, 'alias', ['123'])); } @@ -140,7 +140,7 @@ public function testCreateFilterInstanceWrongAlias() $this->returnValue(false) ); - $method = new \ReflectionMethod('Magento\Framework\Filter\FilterManager', 'createFilterInstance'); + $method = new \ReflectionMethod(\Magento\Framework\Filter\FilterManager::class, 'createFilterInstance'); $method->setAccessible(true); $method->invoke($this->_filterManager, $filterAlias, []); } diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/InputTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/InputTest.php index a00e902c026d3..1f1d2fb18fdc5 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/InputTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/InputTest.php @@ -12,12 +12,12 @@ class InputTest extends \PHPUnit_Framework_TestCase { public function testFilterZendFilterAsObject() { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $inputFilter = new Input($objectManagerMock); /** @var \Zend_Filter_Interface $filterMock */ /** This filter should be applied to 'field1' field value only */ - $filterMock = $this->getMock('Zend_Filter_Interface', [], [], '', false); + $filterMock = $this->getMock(\Zend_Filter_Interface::class, [], [], '', false); $filterMock->expects($this->exactly(1))->method('filter')->will( $this->returnCallback( function ($input) { @@ -35,7 +35,7 @@ function ($input) { public function testFilterZendFilterAsArray() { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $inputFilter = new Input($objectManagerMock); /** This filter should be applied to 'field1' field value only */ diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php index 22e0bd20d4eed..0bd5d176aa7c4 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php @@ -16,7 +16,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->templateFilter = $objectManager->getObject('Magento\Framework\Filter\Template'); + $this->templateFilter = $objectManager->getObject(\Magento\Framework\Filter\Template::class); } public function testFilter() @@ -80,7 +80,7 @@ public function testAfterFilter() $expectedResult = 'TEST STRING'; // Build arbitrary object to pass into the addAfterFilterCallback method - $callbackObject = $this->getMockBuilder('stdObject') + $callbackObject = $this->getMockBuilder(\stdObject::class) ->setMethods(['afterFilterCallbackMethod']) ->getMock(); @@ -108,7 +108,7 @@ public function testAfterFilterCallbackReset() $expectedResult = 'TEST STRING'; // Build arbitrary object to pass into the addAfterFilterCallback method - $callbackObject = $this->getMockBuilder('stdObject') + $callbackObject = $this->getMockBuilder(\stdObject::class) ->setMethods(['afterFilterCallbackMethod']) ->getMock(); @@ -141,7 +141,7 @@ public function testVarDirective($construction, $variables, $expectedResult) public function varDirectiveDataProvider() { /* @var $stub \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject */ - $stub = $this->getMockBuilder('\Magento\Framework\DataObject') + $stub = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->disableProxyingToOriginalMethods() ->setMethods(['bar']) diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitTest.php index 626cb6f926c34..d3fda89c597da 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitTest.php @@ -15,7 +15,7 @@ class TranslitTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Filter\Translit'); + $this->model = $objectManager->getObject(\Magento\Framework\Filter\Translit::class); } /** @@ -62,7 +62,7 @@ public function filterDataProvider() public function testFilterConfigured() { $config = $this->getMockBuilder( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class )->disableOriginalConstructor()->setMethods( ['getValue', 'setValue', 'isSetFlag'] )->getMock(); @@ -79,7 +79,7 @@ public function testFilterConfigured() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Filter\Translit', ['config' => $config]); + $this->model = $objectManager->getObject(\Magento\Framework\Filter\Translit::class, ['config' => $config]); $this->assertEquals('TM', $this->model->filter('™')); } diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitUrlTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitUrlTest.php index 0393ece202e0a..1b4e2e87d43c8 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitUrlTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TranslitUrlTest.php @@ -15,7 +15,7 @@ class TranslitUrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Filter\TranslitUrl'); + $this->model = $objectManager->getObject(\Magento\Framework\Filter\TranslitUrl::class); } /** From cdfbcbdd47597a8752e9765ddb38b9573c417277 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:16:17 +0300 Subject: [PATCH 03/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- lib/internal/Magento/Framework/Flag.php | 2 +- .../Magento/Framework/HTTP/ClientFactory.php | 2 +- .../HTTP/Test/Unit/AuthenticationTest.php | 10 +- .../Framework/HTTP/Test/Unit/HeaderTest.php | 10 +- .../Unit/PhpEnvironment/RemoteAddressTest.php | 4 +- .../Test/Unit/PhpEnvironment/RequestTest.php | 8 +- .../Test/Unit/PhpEnvironment/ResponseTest.php | 10 +- .../Unit/PhpEnvironment/ServerAddressTest.php | 4 +- .../Magento/Framework/HTTP/ZendClient.php | 2 +- .../Magento/Framework/Image/Factory.php | 3 +- .../Image/Test/Unit/Adapter/AbstractTest.php | 8 +- .../Image/Test/Unit/Adapter/Gd2Test.php | 4 +- .../Test/Unit/Adapter/ImageMagickTest.php | 12 +- .../Image/Test/Unit/AdapterFactoryTest.php | 22 +-- .../Framework/Indexer/Config/Reader.php | 2 +- .../Framework/Indexer/IndexerRegistry.php | 5 +- .../Indexer/Test/Unit/ActionFactoryTest.php | 10 +- .../Indexer/Test/Unit/Config/ReaderTest.php | 6 +- .../Test/Unit/Config/SchemaLocatorTest.php | 2 +- .../Indexer/Test/Unit/GridStructureTest.php | 10 +- .../Indexer/Test/Unit/IndexStructureTest.php | 20 +-- .../Indexer/Test/Unit/IndexerRegistryTest.php | 6 +- .../ScopeResolver/IndexScopeResolverTest.php | 12 +- .../Indexer/Test/Unit/StrategyTest.php | 2 +- .../Framework/Interception/Interceptor.php | 4 +- .../Test/Unit/Chain/ChainTest.php | 8 +- .../Unit/Code/Generator/InterceptorTest.php | 9 +- .../Test/Unit/Code/InterfaceValidatorTest.php | 27 ++-- .../Test/Unit/Config/ConfigTest.php | 86 ++++++------ .../ObjectManager/Config/DeveloperTest.php | 2 +- .../Test/Unit/PluginList/PluginListTest.php | 62 +++++---- .../Test/Unit/_files/reader_mock_map.php | 30 +++-- .../Json/Test/Unit/Helper/DataTest.php | 6 +- .../Framework/Locale/Test/Unit/ConfigTest.php | 16 ++- .../Locale/Test/Unit/CurrencyTest.php | 9 +- .../Locale/Test/Unit/TranslatedListsTest.php | 4 +- .../Framework/Locale/TranslatedLists.php | 3 +- .../Framework/Mail/Template/Factory.php | 2 +- .../Mail/Template/TransportBuilder.php | 2 +- .../Framework/Mail/Test/Unit/MessageTest.php | 2 +- .../Mail/Test/Unit/Template/FactoryTest.php | 13 +- .../Unit/Template/TransportBuilderTest.php | 23 ++-- .../Mail/Test/Unit/TransportTest.php | 4 +- .../Mail/TransportInterfaceFactory.php | 2 +- .../Math/Test/Unit/CalculatorTest.php | 4 +- .../Framework/Message/CollectionFactory.php | 2 +- .../Message/Test/Unit/CollectionTest.php | 68 +++++----- .../Framework/Message/Test/Unit/ErrorTest.php | 2 +- .../Message/Test/Unit/FactoryTest.php | 4 +- .../Message/Test/Unit/ManagerTest.php | 30 +++-- .../Message/Test/Unit/NoticeTest.php | 2 +- .../Message/Test/Unit/SuccessTest.php | 2 +- .../Message/Test/Unit/WarningTest.php | 2 +- .../Magento/Framework/Model/AbstractModel.php | 4 +- .../Model/ResourceModel/AbstractResource.php | 2 +- .../Model/ResourceModel/Db/AbstractDb.php | 2 +- .../Model/ResourceModel/Type/AbstractType.php | 2 +- .../Framework/Model/ResourceModel/Type/Db.php | 2 +- .../Test/Unit/AbstractExtensibleModelTest.php | 30 +++-- .../Model/Test/Unit/AbstractModelTest.php | 20 +-- .../Unit/ActionValidator/RemoveActionTest.php | 6 +- .../Unit/ResourceModel/Db/AbstractDbTest.php | 126 +++++++++++------- .../Db/Collection/AbstractCollectionTest.php | 34 ++--- .../ResourceModel/Db/CreateEntityRowTest.php | 6 +- .../ResourceModel/Db/DeleteEntityRowTest.php | 6 +- .../ResourceModel/Db/ExtensionPoolTest.php | 2 +- .../ResourceModel/Db/ReadEntityRowTest.php | 8 +- .../Db/Relation/ActionPoolTest.php | 4 +- .../ResourceModel/Db/UpdateEntityRowTest.php | 8 +- .../Db/VersionControl/MetadataTest.php | 8 +- .../VersionControl/RelationCompositeTest.php | 8 +- .../Db/VersionControl/SnapshotTest.php | 6 +- .../ResourceModel/Type/Db/Pdo/MysqlTest.php | 8 +- .../Framework/Module/PackageInfoFactory.php | 6 +- .../Module/Setup/MigrationFactory.php | 2 +- .../Module/Test/Unit/ConflictCheckerTest.php | 36 +++-- .../Module/Test/Unit/DbVersionInfoTest.php | 8 +- .../Test/Unit/DependencyCheckerTest.php | 8 +- .../Module/Test/Unit/Dir/ReaderTest.php | 16 +-- .../Test/Unit/Dir/ReverseResolverTest.php | 4 +- .../Framework/Module/Test/Unit/DirTest.php | 2 +- .../Module/Test/Unit/FullModuleListTest.php | 2 +- .../Module/Test/Unit/ManagerTest.php | 4 +- .../Test/Unit/ModuleList/LoaderTest.php | 14 +- .../Module/Test/Unit/ModuleListTest.php | 4 +- .../Test/Unit/PackageInfoFactoryTest.php | 14 +- .../Module/Test/Unit/PackageInfoTest.php | 12 +- .../Unit/Plugin/DbStatusValidatorTest.php | 18 +-- .../Module/Test/Unit/Setup/MigrationTest.php | 20 +-- .../Setup/_files/data_content_plain_model.php | 12 +- .../_files/data_content_plain_pk_fields.php | 4 +- .../_files/data_content_plain_resource.php | 4 +- .../Setup/_files/data_content_serialized.php | 2 +- .../Unit/Setup/_files/data_content_wiki.php | 4 +- .../Unit/Setup/_files/data_content_xml.php | 4 +- .../Framework/Module/Test/Unit/SetupTest.php | 4 +- .../Framework/Module/Test/Unit/StatusTest.php | 16 ++- .../Framework/Mview/Config/Data/Proxy.php | 2 +- .../Magento/Framework/Mview/Config/Reader.php | 2 +- .../Mview/Test/Unit/ActionFactoryTest.php | 10 +- .../Mview/Test/Unit/Config/Data/ProxyTest.php | 24 ++-- .../Mview/Test/Unit/Config/DataTest.php | 10 +- .../Mview/Test/Unit/Config/ReaderTest.php | 8 +- .../Framework/Mview/Test/Unit/ConfigTest.php | 4 +- .../Mview/Test/Unit/ProcessorTest.php | 6 +- .../Mview/Test/Unit/View/ChangelogTest.php | 14 +- .../Mview/Test/Unit/View/CollectionTest.php | 20 +-- .../Unit/View/SubscriptionFactoryTest.php | 6 +- .../Mview/Test/Unit/View/SubscriptionTest.php | 47 ++++--- .../Framework/Mview/Test/Unit/ViewTest.php | 20 +-- .../Framework/Mview/View/Collection.php | 2 +- .../Mview/View/CollectionFactory.php | 2 +- .../Mview/View/State/CollectionFactory.php | 2 +- .../Test/Unit/NotifierListTest.php | 16 +-- .../Test/Unit/NotifierPoolTest.php | 8 +- .../Oauth/Test/Unit/Helper/RequestTest.php | 4 +- .../Test/Unit/Renderer/CompositeTest.php | 4 +- .../Phrase/Test/Unit/Renderer/InlineTest.php | 16 ++- .../Test/Unit/Renderer/PlaceholderTest.php | 2 +- .../Test/Unit/Renderer/TranslateTest.php | 6 +- .../Pricing/Amount/AmountFactory.php | 2 +- .../Framework/Pricing/Render/RendererPool.php | 4 +- .../Test/Unit/Adjustment/CalculatorTest.php | 26 ++-- .../Test/Unit/Adjustment/CollectionTest.php | 10 +- .../Test/Unit/Adjustment/FactoryTest.php | 8 +- .../Pricing/Test/Unit/Adjustment/PoolTest.php | 2 +- .../Test/Unit/Amount/AmountFactoryTest.php | 8 +- .../Pricing/Test/Unit/Helper/DataTest.php | 4 +- .../Test/Unit/Price/AbstractPriceTest.php | 22 +-- .../Test/Unit/Price/CollectionTest.php | 6 +- .../Pricing/Test/Unit/Price/FactoryTest.php | 17 +-- .../Pricing/Test/Unit/PriceInfo/BaseTest.php | 4 +- .../Test/Unit/PriceInfo/FactoryTest.php | 8 +- .../Unit/Render/AbstractAdjustmentTest.php | 32 ++--- .../Pricing/Test/Unit/Render/AmountTest.php | 30 ++--- .../Pricing/Test/Unit/Render/LayoutTest.php | 14 +- .../Pricing/Test/Unit/Render/PriceBoxTest.php | 58 ++++---- .../Test/Unit/Render/RendererPoolTest.php | 62 ++++----- .../Pricing/Test/Unit/RenderTest.php | 22 +-- .../Framework/Profiler/Driver/Factory.php | 6 +- .../Profiler/Test/Unit/Driver/FactoryTest.php | 6 +- .../Driver/Standard/Output/FactoryTest.php | 6 +- .../Driver/Standard/Output/FirebugTest.php | 6 +- .../Driver/Standard/OutputAbstractTest.php | 8 +- .../Test/Unit/Driver/StandardTest.php | 16 +-- .../Framework/Reflection/MethodsMap.php | 2 +- .../Test/Unit/AttributeTypeResolverTest.php | 15 ++- .../Unit/ExtensionAttributesProcessorTest.php | 16 +-- .../Reflection/Test/Unit/FieldNamerTest.php | 2 +- .../Reflection/Test/Unit/MethodsMapTest.php | 43 +++--- .../Reflection/Test/Unit/TypeCasterTest.php | 2 +- .../Test/Unit/TypeProcessorTest.php | 10 +- .../Framework/Reflection/TypeProcessor.php | 2 +- .../RequireJs/Test/Unit/ConfigTest.php | 22 +-- .../Magento/Framework/Session/Config.php | 8 +- .../Framework/Session/SaveHandlerFactory.php | 2 +- .../Session/Test/Unit/ConfigTest.php | 31 +++-- .../Test/Unit/SaveHandler/DbTableTest.php | 22 +-- .../Unit/SaveHandler/Redis/LoggerTest.php | 8 +- .../Test/Unit/SaveHandlerFactoryTest.php | 8 +- .../Session/Test/Unit/SessionManagerTest.php | 10 +- .../Framework/Setup/BackupRollback.php | 12 +- .../Framework/Setup/BackupRollbackFactory.php | 4 +- .../Test/Unit/BackupRollbackFactoryTest.php | 19 ++- .../Setup/Test/Unit/BackupRollbackTest.php | 43 ++++-- .../Setup/Test/Unit/ConsoleLoggerTest.php | 6 +- .../Setup/Test/Unit/FilePermissionsTest.php | 18 ++- .../Framework/Setup/Test/Unit/ListsTest.php | 2 +- .../Setup/Test/Unit/SampleData/StateTest.php | 6 +- .../Unit/CommandRendererBackgroundTest.php | 2 +- .../Magento/Framework/Simplexml/Config.php | 2 +- .../Simplexml/Test/Unit/ConfigTest.php | 12 +- .../Simplexml/Test/Unit/ElementTest.php | 12 +- .../Unit/Unit/Helper/ProxyTestingTest.php | 4 +- .../Unit/AbstractFactoryTestCase.php | 10 +- .../TestFramework/Unit/Block/Adminhtml.php | 57 ++++---- .../Unit/Helper/ObjectManager.php | 21 +-- .../Unit/Helper/SelectRendererTrait.php | 24 ++-- .../Framework/Translate/AbstractAdapter.php | 2 +- .../Magento/Framework/Translate/Inline.php | 2 +- .../Translate/Inline/ParserFactory.php | 2 +- .../Framework/Translate/Inline/Proxy.php | 2 +- .../Test/Unit/AdapterAbstractTest.php | 10 +- .../Translate/Test/Unit/AdapterTest.php | 2 +- .../Translate/Test/Unit/Inline/ProxyTest.php | 20 +-- .../Translate/Test/Unit/InlineTest.php | 14 +- lib/internal/Magento/Framework/Url.php | 4 +- .../Url/RouteParamsResolverFactory.php | 2 +- .../Framework/Url/Test/Unit/DecoderTest.php | 2 +- .../Url/Test/Unit/Helper/DataTest.php | 14 +- .../Url/Test/Unit/QueryParamsResolverTest.php | 2 +- .../Unit/RouteParamsResolverFactoryTest.php | 8 +- .../Url/Test/Unit/ScopeResolverTest.php | 8 +- .../Framework/Url/Test/Unit/ValidatorTest.php | 2 +- .../Magento/Framework/Validator/Config.php | 2 +- .../Framework/Validator/ConstraintFactory.php | 2 +- .../Magento/Framework/Validator/Factory.php | 5 +- .../Validator/Test/Unit/BuilderTest.php | 26 ++-- .../Validator/Test/Unit/ConfigTest.php | 29 ++-- .../Unit/Constraint/Option/CallbackTest.php | 2 +- .../Test/Unit/Constraint/PropertyTest.php | 2 +- .../Validator/Test/Unit/ConstraintTest.php | 6 +- .../Validator/Test/Unit/CurrencyTest.php | 2 +- .../Test/Unit/Entity/PropertiesTest.php | 2 +- .../Validator/Test/Unit/FactoryTest.php | 22 +-- .../Validator/Test/Unit/LocaleTest.php | 2 +- .../Validator/Test/Unit/TimezoneTest.php | 2 +- .../Test/Unit/ValidatorAbstractTest.php | 10 +- .../Framework/View/Asset/MergeService.php | 6 +- .../View/Asset/PropertyGroupFactory.php | 2 +- .../Fallback/Rule/ModularSwitchFactory.php | 2 +- .../Design/Fallback/Rule/ModuleFactory.php | 2 +- .../Design/Fallback/Rule/SimpleFactory.php | 2 +- .../Design/Fallback/Rule/ThemeFactory.php | 2 +- .../View/Design/Theme/Domain/Factory.php | 6 +- .../View/Design/Theme/FileFactory.php | 2 +- .../View/Design/Theme/ImageFactory.php | 2 +- .../View/Design/Theme/LabelFactory.php | 2 +- .../Element/ExceptionHandlerBlockFactory.php | 2 +- .../AggregatedFileCollectorFactory.php | 3 +- .../UiComponent/Config/ReaderFactory.php | 2 +- .../Element/UiComponent/ContextFactory.php | 2 +- .../UiComponent/Control/ActionPoolFactory.php | 2 +- .../View/Element/UiComponentFactory.php | 10 +- .../Magento/Framework/View/File/Factory.php | 2 +- .../Framework/View/File/FileList/Factory.php | 4 +- .../Magento/Framework/View/Layout.php | 4 +- .../Framework/View/Layout/BuilderFactory.php | 4 +- .../View/Layout/Generator/ContextFactory.php | 2 +- .../View/Layout/Generator/UiComponent.php | 22 +-- .../Magento/Framework/View/Layout/Pool.php | 2 +- .../View/Layout/ProcessorFactory.php | 2 +- .../Magento/Framework/View/Layout/Proxy.php | 2 +- .../View/Layout/Reader/ContextFactory.php | 2 +- .../Magento/Framework/View/LayoutFactory.php | 2 +- .../Framework/View/Model/Layout/Merge.php | 2 +- .../Magento/Framework/View/Page/Config.php | 2 +- .../View/Page/Config/RendererFactory.php | 2 +- .../Framework/View/Page/ConfigFactory.php | 2 +- .../Framework/View/Result/LayoutFactory.php | 2 +- .../Framework/View/Result/PageFactory.php | 2 +- .../TemplateEngine/Xhtml/ResultFactory.php | 2 +- .../TemplateEngine/Xhtml/TemplateFactory.php | 2 +- .../Test/Unit/Asset/Bundle/ManagerTest.php | 30 ++--- .../View/Test/Unit/Asset/BundleTest.php | 12 +- .../View/Test/Unit/Asset/ConfigTest.php | 4 +- .../Unit/Asset/File/FallbackContextTest.php | 2 +- .../View/Test/Unit/Asset/FileTest.php | 6 +- .../Test/Unit/Asset/GroupedCollectionTest.php | 6 +- .../Test/Unit/Asset/LockerProcessTest.php | 5 +- .../View/Test/Unit/Asset/MergeServiceTest.php | 26 ++-- .../Unit/Asset/MergeStrategy/ChecksumTest.php | 16 ++- .../Unit/Asset/MergeStrategy/DirectTest.php | 10 +- .../Asset/MergeStrategy/FileExistsTest.php | 8 +- .../View/Test/Unit/Asset/MergedTest.php | 18 +-- .../View/Test/Unit/Asset/MinificationTest.php | 4 +- .../Asset/NotationResolver/ModuleTest.php | 6 +- .../Asset/NotationResolver/VariableTest.php | 4 +- .../PreProcessor/AlternativeSourceTest.php | 4 +- .../Unit/Asset/PreProcessor/ChainTest.php | 2 +- .../Unit/Asset/PreProcessor/MinifyTest.php | 6 +- .../Test/Unit/Asset/PreProcessor/PoolTest.php | 11 +- .../View/Test/Unit/Asset/RepositoryTest.php | 44 +++--- .../View/Test/Unit/Asset/SourceTest.php | 41 +++--- .../View/Test/Unit/BlockPoolTest.php | 22 +-- .../View/Test/Unit/BlockPoolTestBlock.php | 22 +++ .../Framework/View/Test/Unit/ConfigTest.php | 14 +- .../Framework/View/Test/Unit/ContextTest.php | 56 +++++--- .../View/Test/Unit/DataSourcePoolTest.php | 29 +--- .../Test/Unit/DataSourcePoolTestBlock.php | 22 +++ .../Design/Fallback/Rule/CompositeTest.php | 4 +- .../Fallback/Rule/ModularSwitchTest.php | 4 +- .../Unit/Design/Fallback/Rule/ModuleTest.php | 4 +- .../Unit/Design/Fallback/Rule/ThemeTest.php | 9 +- .../Unit/Design/Fallback/RulePoolTest.php | 39 ++++-- .../FileResolution/Fallback/FileTest.php | 6 +- .../Fallback/LocaleFileTest.php | 6 +- .../Fallback/Resolver/AlternativeTest.php | 18 ++- .../Fallback/Resolver/MinificationTest.php | 4 +- .../Fallback/Resolver/SimpleTest.php | 2 +- .../Fallback/StaticFileTest.php | 6 +- .../Fallback/TemplateFileTest.php | 18 ++- .../Theme/Customization/AbstractFileTest.php | 30 ++--- .../Design/Theme/Customization/PathTest.php | 8 +- .../Unit/Design/Theme/CustomizationTest.php | 18 +-- .../Unit/Design/Theme/Domain/FactoryTest.php | 14 +- .../Design/Theme/FlyweightFactoryTest.php | 8 +- .../Unit/Design/Theme/Image/UploaderTest.php | 16 +-- .../View/Test/Unit/Design/Theme/ImageTest.php | 28 ++-- .../View/Test/Unit/Design/Theme/LabelTest.php | 2 +- .../Design/Theme/ThemePackageListTest.php | 16 ++- .../View/Test/Unit/DesignExceptionsTest.php | 6 +- .../View/Test/Unit/DesignLoaderTest.php | 8 +- .../Test/Unit/Element/BlockFactoryTest.php | 15 ++- .../View/Test/Unit/Element/FormKeyTest.php | 4 +- .../Test/Unit/Element/Html/CalendarTest.php | 6 +- .../Unit/Element/Html/Link/CurrentTest.php | 14 +- .../View/Test/Unit/Element/Html/LinkTest.php | 16 +-- .../View/Test/Unit/Element/Html/LinksTest.php | 6 +- .../Test/Unit/Element/Html/SelectTest.php | 15 ++- .../View/Test/Unit/Element/Js/CookieTest.php | 12 +- .../Message/InterpretationMediatorTest.php | 4 +- .../Message/InterpretationStrategyTest.php | 10 +- .../Renderer/BlockRenderer/TemplateTest.php | 6 +- .../Message/Renderer/BlockRendererTest.php | 6 +- .../Message/Renderer/EscapeRendererTest.php | 4 +- .../Message/Renderer/RenderersPoolTest.php | 6 +- .../View/Test/Unit/Element/MessagesTest.php | 49 +++---- .../Test/Unit/Element/RendererListTest.php | 14 +- .../Element/Template/File/ResolverTest.php | 2 +- .../Element/Template/File/ValidatorTest.php | 16 ++- .../View/Test/Unit/Element/TemplateTest.php | 19 +-- .../Unit/Element/Text/TextList/ItemTest.php | 2 +- .../Unit/Element/Text/TextList/LinkTest.php | 2 +- .../View/Test/Unit/Element/TextTest.php | 4 +- .../Unit/Element/UiComponent/ContextTest.php | 18 +-- .../Element/UiComponent/ProcessorTest.php | 6 +- .../Test/Unit/File/Collector/BaseTest.php | 18 +-- .../Decorator/ModuleDependencyTest.php | 6 +- .../Collector/Decorator/ModuleOutputTest.php | 6 +- .../Unit/File/Collector/Override/BaseTest.php | 20 ++- .../Collector/Override/ThemeModularTest.php | 40 +++--- .../Unit/File/Collector/ThemeModularTest.php | 22 +-- .../Test/Unit/File/Collector/ThemeTest.php | 20 ++- .../View/Test/Unit/File/FactoryTest.php | 6 +- .../Test/Unit/File/FileList/CollatorTest.php | 2 +- .../Test/Unit/File/FileList/FactoryTest.php | 6 +- .../View/Test/Unit/File/FileListTest.php | 4 +- .../View/Test/Unit/FileSystemTest.php | 42 +++--- .../Framework/View/Test/Unit/FileTest.php | 2 +- .../View/Test/Unit/Helper/PathPatternTest.php | 2 +- .../Interpreter/Decorator/UpdaterTest.php | 16 ++- .../Argument/Interpreter/HelperMethodTest.php | 4 +- .../Argument/Interpreter/NamedParamsTest.php | 4 +- .../Argument/Interpreter/ObjectTest.php | 6 +- .../Argument/Interpreter/OptionsTest.php | 6 +- .../Layout/Argument/Interpreter/UrlTest.php | 4 +- .../Test/Unit/Layout/BuilderFactoryTest.php | 12 +- .../View/Test/Unit/Layout/BuilderTest.php | 10 +- .../Test/Unit/Layout/Data/StructureTest.php | 6 +- .../Layout/File/Collector/AggregateTest.php | 16 +-- .../Test/Unit/Layout/Generator/BlockTest.php | 31 +++-- .../Unit/Layout/Generator/ContainerTest.php | 12 +- .../Unit/Layout/Generator/UiComponentTest.php | 32 +++-- .../Test/Unit/Layout/GeneratorPoolTest.php | 14 +- .../Test/Unit/Layout/Reader/BlockTest.php | 12 +- .../Test/Unit/Layout/Reader/ContainerTest.php | 12 +- .../Test/Unit/Layout/Reader/FactoryTest.php | 12 +- .../View/Test/Unit/Layout/Reader/MoveTest.php | 6 +- .../Unit/Layout/Reader/UiComponentTest.php | 14 +- .../View/Test/Unit/Layout/ReaderPoolTest.php | 12 +- .../Layout/ScheduledStructure/HelperTest.php | 10 +- .../Unit/Layout/ScheduledStructureTest.php | 2 +- .../View/Test/Unit/LayoutFactoryTest.php | 6 +- .../Framework/View/Test/Unit/LayoutTest.php | 88 ++++++------ .../Test/Unit/Model/Layout/TranslatorTest.php | 2 +- .../Model/Layout/Update/ValidatorTest.php | 6 +- .../View/Test/Unit/Page/BuilderTest.php | 14 +- .../Unit/Page/Config/Generator/BodyTest.php | 10 +- .../Unit/Page/Config/Generator/HeadTest.php | 12 +- .../Test/Unit/Page/Config/Reader/HeadTest.php | 4 +- .../Test/Unit/Page/Config/RendererTest.php | 28 ++-- .../Test/Unit/Page/Config/StructureTest.php | 2 +- .../View/Test/Unit/Page/ConfigTest.php | 52 +++++--- .../View/Test/Unit/Page/Layout/ReaderTest.php | 16 +-- .../View/Test/Unit/Page/TitleTest.php | 4 +- .../View/Test/Unit/PageLayout/ConfigTest.php | 14 +- .../Test/Unit/Render/RenderFactoryTest.php | 10 +- .../View/Test/Unit/Result/LayoutTest.php | 22 +-- .../View/Test/Unit/Result/PageFactoryTest.php | 10 +- .../View/Test/Unit/Result/PageTest.php | 35 ++--- .../Test/Unit/Template/Html/MinifierTest.php | 2 +- .../View/Test/Unit/TemplateEngine/PhpTest.php | 10 +- .../Test/Unit/TemplateEngineFactoryTest.php | 10 +- .../View/Test/Unit/TemplateEnginePoolTest.php | 4 +- .../View/Test/Unit/Url/ConfigTest.php | 2 +- .../Framework/Webapi/ErrorProcessor.php | 2 +- .../Webapi/ServiceInputProcessor.php | 2 +- .../Webapi/Test/Unit/ErrorProcessorTest.php | 12 +- .../Webapi/Test/Unit/RequestTest.php | 2 +- .../Rest/Request/Deserializer/JsonTest.php | 8 +- .../Rest/Request/Deserializer/XmlTest.php | 8 +- .../Rest/Request/DeserializerFactoryTest.php | 14 +- .../Webapi/Test/Unit/Rest/RequestTest.php | 14 +- .../Unit/Rest/Response/FieldsFilterTest.php | 2 +- .../Unit/Rest/Response/Renderer/JsonTest.php | 2 +- .../Rest/Response/RendererFactoryTest.php | 16 +-- .../Webapi/Test/Unit/Rest/ResponseTest.php | 10 +- .../Test/Unit/ServiceInputProcessorTest.php | 64 ++++----- 389 files changed, 2416 insertions(+), 2032 deletions(-) create mode 100644 lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTestBlock.php create mode 100644 lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTestBlock.php diff --git a/lib/internal/Magento/Framework/Flag.php b/lib/internal/Magento/Framework/Flag.php index af7cc40f573f7..48789e50a1755 100644 --- a/lib/internal/Magento/Framework/Flag.php +++ b/lib/internal/Magento/Framework/Flag.php @@ -37,7 +37,7 @@ protected function _construct() if ($this->hasData('flag_code')) { $this->_flagCode = $this->getData('flag_code'); } - $this->_init('Magento\Framework\Flag\FlagResource'); + $this->_init(\Magento\Framework\Flag\FlagResource::class); } /** diff --git a/lib/internal/Magento/Framework/HTTP/ClientFactory.php b/lib/internal/Magento/Framework/HTTP/ClientFactory.php index 1b06d1d4c6a22..20509c18bce0f 100644 --- a/lib/internal/Magento/Framework/HTTP/ClientFactory.php +++ b/lib/internal/Magento/Framework/HTTP/ClientFactory.php @@ -35,7 +35,7 @@ class ClientFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\HTTP\Client\Curl' + $instanceName = \Magento\Framework\HTTP\Client\Curl::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/AuthenticationTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/AuthenticationTest.php index f841fd0d94c8b..9ac1432844331 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/AuthenticationTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/AuthenticationTest.php @@ -15,9 +15,9 @@ class AuthenticationTest extends \PHPUnit_Framework_TestCase */ public function testGetCredentials($server, $expectedLogin, $expectedPass) { - $request = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $request->expects($this->once())->method('getServerValue')->will($this->returnValue($server)); - $response = $this->getMock('\Magento\Framework\App\Response\Http', [], [], '', false); + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $authentication = new \Magento\Framework\HTTP\Authentication($request, $response); $this->assertSame([$expectedLogin, $expectedPass], $authentication->getCredentials()); } @@ -70,11 +70,11 @@ public function testSetAuthenticationFailed() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $request = $objectManager->getObject('Magento\Framework\App\Request\Http'); - $response = $objectManager->getObject('Magento\Framework\App\Response\Http'); + $request = $objectManager->getObject(\Magento\Framework\App\Request\Http::class); + $response = $objectManager->getObject(\Magento\Framework\App\Response\Http::class); $authentication = $objectManager->getObject( - 'Magento\Framework\HTTP\Authentication', + \Magento\Framework\HTTP\Authentication::class, [ 'httpRequest' => $request, 'httpResponse' => $response diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/HeaderTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/HeaderTest.php index 6dd49d63a0c6f..471c6dfb60454 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/HeaderTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/HeaderTest.php @@ -27,14 +27,14 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_request = $this->getMock( - 'Magento\Framework\App\Request\Http', + \Magento\Framework\App\Request\Http::class, ['getServer', 'getRequestUri'], [], '', false ); - $this->_converter = $this->getMock('\Magento\Framework\Stdlib\StringUtils', ['cleanString']); + $this->_converter = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class, ['cleanString']); } /** @@ -57,11 +57,11 @@ public function testHttpMethods($method, $clean, $expectedValue) $this->_prepareCleanString($clean); $headerObject = $this->_objectManager->getObject( - 'Magento\Framework\HTTP\Header', + \Magento\Framework\HTTP\Header::class, ['httpRequest' => $this->_request, 'converter' => $this->_converter] ); - $method = new \ReflectionMethod('\Magento\Framework\HTTP\Header', $method); + $method = new \ReflectionMethod(\Magento\Framework\HTTP\Header::class, $method); $result = $method->invokeArgs($headerObject, ['clean' => $clean]); $this->assertEquals($expectedValue, $result); @@ -139,7 +139,7 @@ public function testGetRequestUri($clean, $expectedValue) $this->_prepareCleanString($clean); $headerObject = $this->_objectManager->getObject( - 'Magento\Framework\HTTP\Header', + \Magento\Framework\HTTP\Header::class, ['httpRequest' => $this->_request, 'converter' => $this->_converter] ); diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RemoteAddressTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RemoteAddressTest.php index 1b2e613fe3ddf..725dfa89d26e0 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RemoteAddressTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RemoteAddressTest.php @@ -20,7 +20,7 @@ class RemoteAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_request = $this->getMockBuilder( - 'Magento\Framework\App\Request\Http' + \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->setMethods( ['getServer'] )->getMock(); @@ -34,7 +34,7 @@ protected function setUp() public function testGetRemoteAddress($alternativeHeaders, $serverValueMap, $expected, $ipToLong) { $remoteAddress = $this->_objectManager->getObject( - 'Magento\Framework\HTTP\PhpEnvironment\RemoteAddress', + \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class, ['httpRequest' => $this->_request, 'alternativeHeaders' => $alternativeHeaders] ); $this->_request->expects($this->any())->method('getServer')->will($this->returnValueMap($serverValueMap)); diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php index 18d5ad11e8ba5..8229a74291281 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php @@ -38,9 +38,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->cookieReader = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'); - $this->converter = $this->getMock('Magento\Framework\Stdlib\StringUtils'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->cookieReader = $this->getMock(\Magento\Framework\Stdlib\Cookie\CookieReaderInterface::class); + $this->converter = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class); // Stash the $_SERVER array to protect it from modification in test $this->serverArray = $_SERVER; } @@ -213,7 +213,6 @@ public function testGetAliasWhenAliasAreEmpty() $this->assertNull($this->model->getAlias('')); } - public function testGetCookie() { $key = "cookieName"; @@ -227,7 +226,6 @@ public function testGetCookie() $this->getModel()->getCookie($key, $default); } - public function testGetCookieDefault() { $key = "cookieName"; diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ResponseTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ResponseTest.php index e1b75cd1605fb..fb5432b7c2266 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ResponseTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ResponseTest.php @@ -18,11 +18,11 @@ class ResponseTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->response = $this->getMock( - 'Magento\Framework\HTTP\PhpEnvironment\Response', + \Magento\Framework\HTTP\PhpEnvironment\Response::class, ['getHeaders', 'send', 'clearHeader'] ); $this->headers = $this->getMock( - 'Zend\Http\Headers', + \Zend\Http\Headers::class, ['has', 'get', 'current', 'removeHeader'] ); } @@ -111,7 +111,7 @@ public function testSetHeaderWithReplacing() public function testClearHeaderIfHeaderExistsAndWasFound() { $response = $this->response = $this->getMock( - 'Magento\Framework\HTTP\PhpEnvironment\Response', + \Magento\Framework\HTTP\PhpEnvironment\Response::class, ['getHeaders', 'send'] ); @@ -146,7 +146,7 @@ public function testClearHeaderIfHeaderExistsAndWasFound() public function testClearHeaderAndHeaderNotExists() { $response = $this->response = $this->getMock( - 'Magento\Framework\HTTP\PhpEnvironment\Response', + \Magento\Framework\HTTP\PhpEnvironment\Response::class, ['getHeaders', 'send'] ); @@ -195,7 +195,7 @@ public function testSetRedirect() { /** @var \Magento\Framework\App\Response\Http $response */ $response = $this->getMock( - 'Magento\Framework\HTTP\PhpEnvironment\Response', + \Magento\Framework\HTTP\PhpEnvironment\Response::class, ['setHeader', 'setHttpResponseCode', 'sendHeaders'], [], '', diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ServerAddressTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ServerAddressTest.php index 75010fe84f51d..2c75c4f60767b 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ServerAddressTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/ServerAddressTest.php @@ -20,14 +20,14 @@ class ServerAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_request = $this->getMockBuilder( - 'Magento\Framework\App\Request\Http' + \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->setMethods( ['getServer'] )->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_serverAddress = $objectManager->getObject( - 'Magento\Framework\HTTP\PhpEnvironment\ServerAddress', + \Magento\Framework\HTTP\PhpEnvironment\ServerAddress::class, ['httpRequest' => $this->_request] ); } diff --git a/lib/internal/Magento/Framework/HTTP/ZendClient.php b/lib/internal/Magento/Framework/HTTP/ZendClient.php index 5b999a23352d6..e12930b9a7c1b 100644 --- a/lib/internal/Magento/Framework/HTTP/ZendClient.php +++ b/lib/internal/Magento/Framework/HTTP/ZendClient.php @@ -26,7 +26,7 @@ class ZendClient extends \Zend_Http_Client */ public function __construct($uri = null, $config = null) { - $this->config['useragent'] = 'Magento\Framework\HTTP\ZendClient'; + $this->config['useragent'] = \Magento\Framework\HTTP\ZendClient::class; parent::__construct($uri, $config); } diff --git a/lib/internal/Magento/Framework/Image/Factory.php b/lib/internal/Magento/Framework/Image/Factory.php index 398dd30f05efb..2239d141d2fc2 100644 --- a/lib/internal/Magento/Framework/Image/Factory.php +++ b/lib/internal/Magento/Framework/Image/Factory.php @@ -42,6 +42,7 @@ public function __construct(ObjectManagerInterface $objectManager, AdapterFactor public function create($fileName = null, $adapterName = null) { $adapter = $this->adapterFactory->create($adapterName); - return $this->objectManager->create('Magento\Framework\Image', ['adapter' => $adapter, 'fileName' => $fileName]); + return $this->objectManager->create( + \Magento\Framework\Image::class, ['adapter' => $adapter, 'fileName' => $fileName]); } } diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php index 8e38b98b929bb..b50fa56f89af9 100644 --- a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php +++ b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php @@ -34,14 +34,14 @@ class AbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->directoryWriteMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, [], [], '', false ); $this->filesystemMock = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryWrite', 'createDirectory'], [], '', @@ -54,10 +54,10 @@ protected function setUp() )->will( $this->returnValue($this->directoryWriteMock) ); - $this->loggerMock = $this->getMockBuilder( 'Psr\Log\LoggerInterface')->getMock(); + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Image\Adapter\AbstractAdapter', + \Magento\Framework\Image\Adapter\AbstractAdapter::class, [$this->filesystemMock, $this->loggerMock] ); } diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php index 858bdb91f1620..d26010a0bf938 100644 --- a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php +++ b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php @@ -42,7 +42,7 @@ protected function setUp() { require_once __DIR__ . '/_files/global_php_mock.php'; $this->objectManager = new ObjectManager($this); - $this->adapter = $this->objectManager->getObject('Magento\Framework\Image\Adapter\Gd2'); + $this->adapter = $this->objectManager->getObject(\Magento\Framework\Image\Adapter\Gd2::class); } /** @@ -50,7 +50,7 @@ protected function setUp() */ public function testParentClass() { - $this->assertInstanceOf('\Magento\Framework\Image\Adapter\AbstractAdapter', $this->adapter); + $this->assertInstanceOf(\Magento\Framework\Image\Adapter\AbstractAdapter::class, $this->adapter); } /** diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php index c895ca4d30cd6..63d7f16f45588 100644 --- a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php +++ b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php @@ -24,6 +24,7 @@ class ImageMagickTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Filesystem\Directory\WriteInterface */ protected $writeMock; + /** * @var \Magento\Framework\Image\Adapter\ImageMagick */ @@ -32,10 +33,12 @@ class ImageMagickTest extends \PHPUnit_Framework_TestCase public function setup() { $objectManager = new ObjectManager($this); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->writeMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface')->getMock(); + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $this->writeMock = $this->getMockBuilder( + \Magento\Framework\Filesystem\Directory\WriteInterface::class + )->getMock(); $this->filesystemMock = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryWrite'], [], '', @@ -48,11 +51,12 @@ public function setup() $this->imageMagic = $objectManager ->getObject( - 'Magento\Framework\Image\Adapter\ImageMagick', + \Magento\Framework\Image\Adapter\ImageMagick::class, ['filesystem' => $this->filesystemMock, 'logger' => $this->loggerMock] ); } + /** * @param string $imagePath * @param string $expectedMessage diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/AdapterFactoryTest.php b/lib/internal/Magento/Framework/Image/Test/Unit/AdapterFactoryTest.php index fb2f2509dd8bd..0c69762099ded 100644 --- a/lib/internal/Magento/Framework/Image/Test/Unit/AdapterFactoryTest.php +++ b/lib/internal/Magento/Framework/Image/Test/Unit/AdapterFactoryTest.php @@ -17,7 +17,7 @@ class AdapterFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMock( - 'Magento\Framework\Image\Adapter\ConfigInterface', + \Magento\Framework\Image\Adapter\ConfigInterface::class, ['getAdapterAlias', 'getAdapters'], [], '', @@ -31,8 +31,8 @@ protected function setUp() )->will( $this->returnValue( [ - 'GD2' => ['class' => 'Magento\Framework\Image\Adapter\Gd2'], - 'IMAGEMAGICK' => ['class' => 'Magento\Framework\Image\Adapter\ImageMagick'], + 'GD2' => ['class' => \Magento\Framework\Image\Adapter\Gd2::class], + 'IMAGEMAGICK' => ['class' => \Magento\Framework\Image\Adapter\ImageMagick::class], 'wrongInstance' => ['class' => 'stdClass'], 'test' => [], ] @@ -48,7 +48,7 @@ protected function setUp() public function testCreate($alias, $class) { $objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -79,8 +79,8 @@ public function testCreate($alias, $class) public function createDataProvider() { return [ - ['GD2', 'Magento\Framework\Image\Adapter\Gd2'], - ['IMAGEMAGICK', 'Magento\Framework\Image\Adapter\ImageMagick'] + ['GD2', \Magento\Framework\Image\Adapter\Gd2::class], + ['IMAGEMAGICK', \Magento\Framework\Image\Adapter\ImageMagick::class] ]; } @@ -90,12 +90,12 @@ public function createDataProvider() public function testCreateWithoutName() { $adapterAlias = 'IMAGEMAGICK'; - $adapterClass = 'Magento\Framework\Image\Adapter\ImageMagick'; + $adapterClass = \Magento\Framework\Image\Adapter\ImageMagick::class; $this->configMock->expects($this->once())->method('getAdapterAlias')->will($this->returnValue($adapterAlias)); $objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -128,7 +128,7 @@ public function testInvalidArgumentException() { $this->configMock->expects($this->once())->method('getAdapterAlias')->will($this->returnValue('')); $objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -147,7 +147,7 @@ public function testNonAdapterClass() { $alias = 'test'; $objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -168,7 +168,7 @@ public function testWrongInstance() $alias = 'wrongInstance'; $class = 'stdClass'; $objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', diff --git a/lib/internal/Magento/Framework/Indexer/Config/Reader.php b/lib/internal/Magento/Framework/Indexer/Config/Reader.php index 19d0f92b67c92..1179c2df98d49 100644 --- a/lib/internal/Magento/Framework/Indexer/Config/Reader.php +++ b/lib/internal/Magento/Framework/Indexer/Config/Reader.php @@ -39,7 +39,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'indexer.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Indexer/IndexerRegistry.php b/lib/internal/Magento/Framework/Indexer/IndexerRegistry.php index 22a8dc928eda2..10f585152f161 100644 --- a/lib/internal/Magento/Framework/Indexer/IndexerRegistry.php +++ b/lib/internal/Magento/Framework/Indexer/IndexerRegistry.php @@ -34,8 +34,9 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan public function get($indexerId) { if (!isset($this->indexers[$indexerId])) { - $this->indexers[$indexerId] = $this->objectManager->create('Magento\Framework\Indexer\IndexerInterface') - ->load($indexerId); + $this->indexers[$indexerId] = $this->objectManager->create( + \Magento\Framework\Indexer\IndexerInterface::class + )->load($indexerId); } return $this->indexers[$indexerId]; } diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php index 6912f86da0273..d8de8664cb1f3 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php @@ -19,7 +19,7 @@ class ActionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Framework\Indexer\ActionFactory($this->objectManagerMock); } @@ -40,16 +40,16 @@ public function testGetWithException() public function testCreate() { $actionInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\ActionInterface', + \Magento\Framework\Indexer\ActionInterface::class, [], '', false ); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\Indexer\ActionInterface', []) + ->with(\Magento\Framework\Indexer\ActionInterface::class, []) ->willReturn($actionInterfaceMock); - $this->model->create('Magento\Framework\Indexer\ActionInterface'); - $this->assertInstanceOf('Magento\Framework\Indexer\ActionInterface', $actionInterfaceMock); + $this->model->create(\Magento\Framework\Indexer\ActionInterface::class); + $this->assertInstanceOf(\Magento\Framework\Indexer\ActionInterface::class, $actionInterfaceMock); } } diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php index 24fcb9e24fd81..b0500681d7b2b 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php @@ -25,15 +25,15 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_fileResolverMock = $this->getMock( - 'Magento\Framework\App\Config\FileResolver', + \Magento\Framework\App\Config\FileResolver::class, ['get'], [], '', false ); - $this->_converter = $this->getMock('Magento\Framework\Indexer\Config\Converter', ['convert']); - $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->_converter = $this->getMock(\Magento\Framework\Indexer\Config\Converter::class, ['convert']); + $validationState = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(false); diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/SchemaLocatorTest.php index 02ae7f3035ad6..3a796959218a7 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/SchemaLocatorTest.php @@ -22,7 +22,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->model = new \Magento\Framework\Indexer\Config\SchemaLocator($this->urnResolverMock); } diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php index 115391230434c..416e35dc23d87 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php @@ -33,12 +33,14 @@ class GridStructureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->getMock(); - $this->resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); - $this->flatScopeResolver = $this->getMockBuilder('Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver') + $this->flatScopeResolver = $this->getMockBuilder( + \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class + ) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->any()) @@ -84,7 +86,7 @@ public function testCreate() $tableName = 'index_table'; $idxName = 'idxName'; - $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); $this->flatScopeResolver->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php index 2fc005058d24d..99326c32bacb9 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php @@ -43,21 +43,25 @@ class IndexStructureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connectionInterface = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionInterface = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->resource = $this->getMockBuilder('\Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->setMethods(['getConnection']) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->atLeastOnce()) ->method('getConnection') ->willReturn($this->connectionInterface); - $this->indexScopeResolver = $this->getMockBuilder('\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver') + $this->indexScopeResolver = $this->getMockBuilder( + \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver::class + ) ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMock(); - $this->flatScopeResolver = $this->getMockBuilder('\Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver') + $this->flatScopeResolver = $this->getMockBuilder( + \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class + ) ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMock(); @@ -65,7 +69,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->target = $objectManager->getObject( - '\Magento\Framework\Indexer\IndexStructure', + \Magento\Framework\Indexer\IndexStructure::class, [ 'resource' => $this->resource, 'indexScopeResolver' => $this->indexScopeResolver, @@ -169,7 +173,7 @@ public function testCreateWithEmptyFields() */ private function createDimensionMock($name, $value) { - $dimension = $this->getMockBuilder('\Magento\Framework\Search\Request\Dimension') + $dimension = $this->getMockBuilder(\Magento\Framework\Search\Request\Dimension::class) ->setMethods(['getName', 'getValue']) ->disableOriginalConstructor() ->getMock(); @@ -199,7 +203,7 @@ private function mockDropTable($callNumber, $tableName, $isTableExist) private function mockFlatTable($callNumber, $tableName) { - $table = $this->getMockBuilder('\Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->setMethods(['addColumn', 'getColumns']) ->disableOriginalConstructor() ->getMock(); @@ -221,7 +225,7 @@ private function mockFlatTable($callNumber, $tableName) private function mockFulltextTable($callNumber, $tableName) { - $table = $this->getMockBuilder('\Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->setMethods(['addColumn', 'addIndex']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php index 05455acb83ab7..6fdc8fe52311a 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php @@ -9,13 +9,13 @@ class IndexerRegistryTest extends \PHPUnit_Framework_TestCase { public function testGetCreatesIndexerInstancesAndReusesExistingOnes() { - $firstIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); + $firstIndexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); $firstIndexer->expects($this->once())->method('load')->with('first-indexer')->willReturnSelf(); - $secondIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); + $secondIndexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); $secondIndexer->expects($this->once())->method('load')->with('second-indexer')->willReturnSelf(); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager->expects($this->at(0))->method('create')->willReturn($firstIndexer); $objectManager->expects($this->at(1))->method('create')->willReturn($secondIndexer); diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php index 75880ab1275df..4f0e7a8d76ab2 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php @@ -31,21 +31,19 @@ class IndexScopeResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMockBuilder('\Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->setMethods(['getTableName']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - - $this->scopeResolver = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface') + $this->scopeResolver = $this->getMockBuilder(\Magento\Framework\App\ScopeResolverInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $objectManager = new ObjectManager($this); $this->target = $objectManager->getObject( - '\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver', + \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver::class, [ 'resource' => $this->resource, 'scopeResolver' => $this->scopeResolver @@ -67,7 +65,7 @@ function ($demension) { }, $dimensions ); - $scope = $this->getMockBuilder('Magento\Framework\App\ScopeInterface') + $scope = $this->getMockBuilder(\Magento\Framework\App\ScopeInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -119,7 +117,7 @@ public function resolveDataProvider() */ private function createDimension($name, $value) { - $dimension = $this->getMockBuilder('\Magento\Framework\Search\Request\Dimension') + $dimension = $this->getMockBuilder(\Magento\Framework\Search\Request\Dimension::class) ->setMethods(['getName', 'getValue']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php index 22c78bbac8b0e..877c18290c648 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php @@ -31,7 +31,7 @@ class StrategyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_resourceMock = $this->getMock( - '\Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Interception/Interceptor.php b/lib/internal/Magento/Framework/Interception/Interceptor.php index 2964ac8c7cb3d..0120c4c569f62 100644 --- a/lib/internal/Magento/Framework/Interception/Interceptor.php +++ b/lib/internal/Magento/Framework/Interception/Interceptor.php @@ -54,8 +54,8 @@ trait Interceptor public function ___init() { $this->pluginLocator = ObjectManager::getInstance(); - $this->pluginList = $this->pluginLocator->get('Magento\Framework\Interception\PluginListInterface'); - $this->chain = $this->pluginLocator->get('Magento\Framework\Interception\ChainInterface'); + $this->pluginList = $this->pluginLocator->get(\Magento\Framework\Interception\PluginListInterface::class); + $this->chain = $this->pluginLocator->get(\Magento\Framework\Interception\ChainInterface::class); $this->subjectType = get_parent_class($this); if (method_exists($this->subjectType, '___init')) { parent::___init(); diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Chain/ChainTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Chain/ChainTest.php index 9f60ecd624e8b..747ad56520c8c 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Chain/ChainTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Chain/ChainTest.php @@ -20,7 +20,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_pluginListMock = $this->getMock('Magento\Framework\Interception\PluginListInterface'); + $this->_pluginListMock = $this->getMock(\Magento\Framework\Interception\PluginListInterface::class); $this->_model = new \Magento\Framework\Interception\Chain\Chain($this->_pluginListMock); } @@ -33,7 +33,7 @@ public function testInvokeNextBeforePlugin() $type = 'type'; $method = 'method'; - $subjectMock = $this->getMock('Magento\Framework\Interception\InterceptorInterface'); + $subjectMock = $this->getMock(\Magento\Framework\Interception\InterceptorInterface::class); $pluginMock = $this->getMock('PluginClass', ['beforeMethod']); $pluginMock->expects($this->once()) @@ -71,7 +71,7 @@ public function testInvokeNextAroundPlugin() $type = 'type'; $method = 'method'; - $subjectMock = $this->getMock('Magento\Framework\Interception\InterceptorInterface'); + $subjectMock = $this->getMock(\Magento\Framework\Interception\InterceptorInterface::class); $pluginMock = $this->getMock('PluginClass', ['aroundMethod']); $pluginMock->expects($this->once()) @@ -102,7 +102,7 @@ public function testInvokeNextAfterPlugin() $type = 'type'; $method = 'method'; - $subjectMock = $this->getMock('Magento\Framework\Interception\InterceptorInterface'); + $subjectMock = $this->getMock(\Magento\Framework\Interception\InterceptorInterface::class); $pluginMock = $this->getMock('PluginClass', ['afterMethod']); $pluginMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/InterceptorTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/InterceptorTest.php index d8ced99fc9127..4c26b41a1547a 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/InterceptorTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/InterceptorTest.php @@ -22,9 +22,9 @@ class InterceptorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ioObjectMock = $this->getMock('\Magento\Framework\Code\Generator\Io', [], [], '', false); - $this->classGeneratorMock = $this->getMock( - '\Magento\Framework\Code\Generator\CodeGeneratorInterface', + $this->ioObjectMock = $this->getMock(\Magento\Framework\Code\Generator\Io::class, [], [], '', false); + $this->classGeneratorMock = $this->getMock( + \Magento\Framework\Code\Generator\CodeGeneratorInterface::class, [], [], '', @@ -35,7 +35,8 @@ protected function setUp() public function testGetDefaultResultClassName() { // resultClassName should be stdClass_Interceptor - $model = $this->getMock('\Magento\Framework\Interception\Code\Generator\Interceptor', + $model = $this->getMock( + \Magento\Framework\Interception\Code\Generator\Interceptor::class, ['_validateData'], [ 'Exception', diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php index 97fa71f726909..8760f84b59212 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php @@ -25,7 +25,7 @@ class InterfaceValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->argumentsReaderMock = $this->getMock( - '\Magento\Framework\Code\Reader\ArgumentsReader', [], [], '', false + \Magento\Framework\Code\Reader\ArgumentsReader::class, [], [], '', false ); $this->argumentsReaderMock->expects($this->any())->method('isCompatibleType') @@ -47,8 +47,7 @@ protected function setUp() public function testValidate() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ValidPlugin', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ValidPlugin::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class ); } @@ -60,8 +59,7 @@ public function testValidate() public function testValidateIncorrectInterface() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncompatibleInterface', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncompatibleInterface::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -73,8 +71,7 @@ public function testValidateIncorrectInterface() public function testValidateIncorrectSubjectType() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncorrectSubject', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncorrectSubject::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -87,9 +84,8 @@ public function testValidateIncorrectSubjectType() public function testValidateIncompatibleMethodArgumentsCount() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model' - . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsCount', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class + . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsCount', \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -102,9 +98,8 @@ public function testValidateIncompatibleMethodArgumentsCount() public function testValidateIncompatibleMethodArgumentsType() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model' - . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsType', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class + . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsType', \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class ); } @@ -116,8 +111,7 @@ public function testValidateIncompatibleMethodArgumentsType() public function testValidateExtraParameters() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ExtraParameters', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ExtraParameters::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -129,8 +123,7 @@ public function testValidateExtraParameters() public function testValidateInvalidProceed() { $this->model->validate( - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\InvalidProceed', - '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item' + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\InvalidProceed::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } } diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php index 6a2a706341107..992ed838b7c52 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php @@ -14,6 +14,9 @@ require_once __DIR__ . '/../Custom/Module/Model/ItemPlugin/Simple.php'; require_once __DIR__ . '/../Custom/Module/Model/ItemPlugin/Advanced.php'; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ConfigTest extends \PHPUnit_Framework_TestCase { /** @@ -49,19 +52,21 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->readerMock = $this->getMock( - '\Magento\Framework\ObjectManager\Config\Reader\Dom', + \Magento\Framework\ObjectManager\Config\Reader\Dom::class, [], [], '', false ); - $this->configScopeMock = $this->getMock('Magento\Framework\Config\ScopeListInterface'); - $this->cacheMock = $this->getMock('Magento\Framework\Cache\FrontendInterface'); + $this->configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeListInterface::class); + $this->cacheMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $this->omConfigMock = $this->getMockForAbstractClass( - 'Magento\Framework\Interception\ObjectManager\ConfigInterface' + \Magento\Framework\Interception\ObjectManager\ConfigInterface::class + ); + $this->definitionMock = $this->getMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); + $this->relationsMock = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManager\RelationsInterface::class ); - $this->definitionMock = $this->getMock('Magento\Framework\ObjectManager\DefinitionInterface'); - $this->relationsMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManager\RelationsInterface'); } /** @@ -87,43 +92,40 @@ public function testHasPluginsWhenDataIsNotCached($expectedResult, $type, $entit ->will($this->returnValueMap( [ [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, ], [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, ], [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class, ], [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced::class, ], [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class, ], [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class, ], [ - 'Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy', - 'Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy' + \Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy::class, + \Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy::class ], [ - 'virtual_custom_item', - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + 'virtual_custom_item', \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, ], ] )); $this->definitionMock->expects($this->any())->method('getClasses')->will($this->returnValue( - [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', - 'Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy', + [\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class, \Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy::class, ] )); $this->relationsMock->expects($this->any())->method('has')->will($this->returnValue($expectedResult)); @@ -151,12 +153,12 @@ public function testHasPluginsWhenDataIsCached($expectedResult, $type) { $cacheId = 'interception'; $interceptionData = [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer' => true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item' => true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced' => true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced' => true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy' => true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy' => false, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class => true, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class => true, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class => true, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced::class => true, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class => true, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class => false, 'virtual_custom_item' => true, ]; $this->readerMock->expects($this->never())->method('read'); @@ -183,35 +185,29 @@ public function hasPluginsDataProvider() return [ // item container has plugins only in the backend scope [ - true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', + true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, [], ], [ - true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, [], ], [ - true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced', + true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class, [], ], [ // the following model has only inherited plugins - true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', - ['Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer'], + true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class, + [\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class], ], [ // the following model has only inherited plugins - true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', - ['Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer'], + true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class, + [\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class], ], [ - false, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', + false, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class, [], ], [ diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/ObjectManager/Config/DeveloperTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/ObjectManager/Config/DeveloperTest.php index 20550090e340d..45a125252c733 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/ObjectManager/Config/DeveloperTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/ObjectManager/Config/DeveloperTest.php @@ -21,7 +21,7 @@ class DeveloperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->interceptionConfig = $this->getMock('\Magento\Framework\Interception\ConfigInterface'); + $this->interceptionConfig = $this->getMock(\Magento\Framework\Interception\ConfigInterface::class); $this->model = new Developer(); } diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php index d29858c92a763..1291ae44bce65 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php @@ -15,6 +15,9 @@ require_once __DIR__ . '/../Custom/Module/Model/StartingBackslash.php'; require_once __DIR__ . '/../Custom/Module/Model/StartingBackslash/Plugin.php'; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class PluginListTest extends \PHPUnit_Framework_TestCase { /** @@ -40,21 +43,23 @@ class PluginListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $readerMap = include __DIR__ . '/../_files/reader_mock_map.php'; - $readerMock = $this->getMock('\Magento\Framework\ObjectManager\Config\Reader\Dom', [], [], '', false); + $readerMock = $this->getMock(\Magento\Framework\ObjectManager\Config\Reader\Dom::class, [], [], '', false); $readerMock->expects($this->any())->method('read')->will($this->returnValueMap($readerMap)); - $this->_configScopeMock = $this->getMock('\Magento\Framework\Config\ScopeInterface'); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); + $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); // turn cache off $this->_cacheMock->expects($this->any()) ->method('get') ->will($this->returnValue(false)); - $omConfigMock = $this->getMockForAbstractClass('Magento\Framework\Interception\ObjectManager\ConfigInterface'); + $omConfigMock = $this->getMockForAbstractClass( + \Magento\Framework\Interception\ObjectManager\ConfigInterface::class + ); $omConfigMock->expects($this->any())->method('getOriginalInstanceType')->will($this->returnArgument(0)); - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnArgument(0)); $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime(); @@ -76,38 +81,41 @@ protected function setUp() public function testGetPlugin() { $this->_configScopeMock->expects($this->any())->method('getCurrentScope')->will($this->returnValue('backend')); - $this->_model->getNext('Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', 'getName'); - $this->_model->getNext('Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', 'getName'); + $this->_model->getNext(\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'getName'); + $this->_model->getNext( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, + 'getName' + ); $this->_model->getNext( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash::class, 'getName' ); $this->assertEquals( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple::class, $this->_model->getPlugin( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'simple_plugin' ) ); $this->assertEquals( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Advanced', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Advanced::class, $this->_model->getPlugin( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'advanced_plugin' ) ); $this->assertEquals( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainerPlugin\Simple', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainerPlugin\Simple::class, $this->_model->getPlugin( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, 'simple_plugin' ) ); $this->assertEquals( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash\Plugin', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash\Plugin::class, $this->_model->getPlugin( - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash::class, 'simple_plugin' ) ); @@ -140,47 +148,51 @@ public function getPluginsDataProvider() { return [ [ - [4 => ['simple_plugin']], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + [4 => ['simple_plugin']], \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'getName', 'global', ], [ // advanced plugin has lower sort order [2 => 'advanced_plugin', 4 => ['advanced_plugin']], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'getName', 'backend' ], [ // advanced plugin has lower sort order [4 => ['simple_plugin']], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'getName', 'backend', 'advanced_plugin' ], // simple plugin is disabled in configuration for // \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item in frontend - [null, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', 'getName', 'frontend'], + [null, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'getName', 'frontend'], // test plugin inheritance [ [4 => ['simple_plugin']], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class, 'getName', 'global' ], [ // simple plugin is disabled in configuration for parent [2 => 'advanced_plugin', 4 => ['advanced_plugin']], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class, 'getName', 'frontend' ], - [null, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', 'getName', 'global'], + [ + null, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, + 'getName', + 'global' + ], [ [4 => ['simple_plugin']], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class, 'getName', 'backend' ] diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php b/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php index 2608f856371da..832a5a67599da 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php @@ -3,15 +3,19 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ +use Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainerPlugin\Simple; +use Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash\Plugin; + return [ [ 'global', [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item' => [ + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class => [ 'plugins' => [ 'simple_plugin' => [ 'sortOrder' => 10, - 'instance' => 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple', + 'instance' => + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple::class, ], ], ] @@ -20,27 +24,28 @@ [ 'backend', [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item' => [ + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class => [ 'plugins' => [ 'advanced_plugin' => [ 'sortOrder' => 5, - 'instance' => 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Advanced', + 'instance' => + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Advanced::class, ], ], ], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer' => [ + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class => [ 'plugins' => [ 'simple_plugin' => [ 'sortOrder' => 15, - 'instance' => 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainerPlugin\Simple', + 'instance' => Simple::class, ], ], ], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash' => [ + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash::class => [ 'plugins' => [ 'simple_plugin' => [ 'sortOrder' => 20, - 'instance' => '\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\StartingBackslash\Plugin', + 'instance' => Plugin::class, ], ], ] @@ -48,15 +53,14 @@ ], [ 'frontend', - [ - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item' => [ + [\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class => [ 'plugins' => ['simple_plugin' => ['disabled' => true]], - ], - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced' => [ + ], \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class => [ 'plugins' => [ 'advanced_plugin' => [ 'sortOrder' => 5, - 'instance' => 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Advanced', + 'instance' => + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Advanced::class, ], ], ], diff --git a/lib/internal/Magento/Framework/Json/Test/Unit/Helper/DataTest.php b/lib/internal/Magento/Framework/Json/Test/Unit/Helper/DataTest.php index f7d6ec850e06e..4686d14d17d64 100644 --- a/lib/internal/Magento/Framework/Json/Test/Unit/Helper/DataTest.php +++ b/lib/internal/Magento/Framework/Json/Test/Unit/Helper/DataTest.php @@ -21,14 +21,14 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoderMock = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonDecoderMock = $this->getMockBuilder('Magento\Framework\Json\DecoderInterface') + $this->jsonDecoderMock = $this->getMockBuilder(\Magento\Framework\Json\DecoderInterface::class) ->disableOriginalConstructor() ->getMock(); $this->helper = $objectManager->getObject( - 'Magento\Framework\Json\Helper\Data', + \Magento\Framework\Json\Helper\Data::class, [ 'jsonEncoder' => $this->jsonEncoderMock, 'jsonDecoder' => $this->jsonDecoderMock, diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php index ba486a053aa4c..5af8e61b2fc26 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php @@ -75,7 +75,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetAllowedLocalesNoDataArray() { $this->configObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Config'); + ->getObject(\Magento\Framework\Locale\Config::class); $retrievedLocales = $this->configObject->getAllowedLocales(); @@ -91,7 +91,8 @@ public function testGetAllowedLocalesNoDataArray() public function testGetAllowedLocalesGivenDataArray() { $this->configObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Config', + ->getObject( + \Magento\Framework\Locale\Config::class, [ 'data' => [ 'allowedLocales' => $this::$sampleAdditionalLocales, @@ -116,7 +117,8 @@ public function testGetAllowedLocalesGivenDataArray() public function testGetAllowedLocalesGivenRedundantDataArray() { $this->configObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Config', + ->getObject( + \Magento\Framework\Locale\Config::class, [ 'data' => [ 'allowedLocales' => $this::$samplePresentLocales, @@ -141,7 +143,7 @@ public function testGetAllowedLocalesGivenRedundantDataArray() public function testGetAllowedCurrenciesNoDataArray() { $this->configObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Config'); + ->getObject(\Magento\Framework\Locale\Config::class); $retrievedCurrencies = $this->configObject->getAllowedCurrencies(); @@ -157,7 +159,8 @@ public function testGetAllowedCurrenciesNoDataArray() public function testGetAllowedCurrenciesGivenDataArray() { $this->configObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Config', + ->getObject( + \Magento\Framework\Locale\Config::class, [ 'data' => [ 'allowedCurrencies' => $this::$sampleAdditionalCurrencies, @@ -182,7 +185,8 @@ public function testGetAllowedCurrenciesGivenDataArray() public function testGetAllowedCurrenciesGivenRedundantDataArray() { $this->configObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Config', + ->getObject( + \Magento\Framework\Locale\Config::class, [ 'data' => [ 'allowedCurrencies' => $this::$samplePresentCurrencies, diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php index 3833828d5ec2f..5883276fa1fe3 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/CurrencyTest.php @@ -45,20 +45,21 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->mockEventManager = $this - ->getMockBuilder('\Magento\Framework\Event\Manager') + ->getMockBuilder(\Magento\Framework\Event\Manager::class) ->disableOriginalConstructor() ->getMock(); $this->mockLocaleResolver = $this - ->getMockBuilder('\Magento\Framework\Locale\Resolver') + ->getMockBuilder(\Magento\Framework\Locale\Resolver::class) ->disableOriginalConstructor() ->getMock(); $this->mockCurrencyFactory = $this - ->getMockBuilder('\Magento\Framework\CurrencyFactory') + ->getMockBuilder(\Magento\Framework\CurrencyFactory::class) ->disableOriginalConstructor() ->getMock(); $this->testCurrencyObject = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Locale\Currency', + ->getObject( + \Magento\Framework\Locale\Currency::class, [ 'eventManager' => $this->mockEventManager, 'localeResolver' => $this->mockLocaleResolver, diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php index 2d38ab0c813d1..205b7b9d02c59 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php @@ -25,10 +25,10 @@ class TranslatedListsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mockConfig = $this->getMockBuilder('\Magento\Framework\Locale\ConfigInterface') + $this->mockConfig = $this->getMockBuilder(\Magento\Framework\Locale\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->mockLocaleResolver = $this->getMockBuilder('\Magento\Framework\Locale\ResolverInterface') + $this->mockLocaleResolver = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); $this->mockLocaleResolver->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Locale/TranslatedLists.php b/lib/internal/Magento/Framework/Locale/TranslatedLists.php index a9724176f198e..17d2a1399a50b 100644 --- a/lib/internal/Magento/Framework/Locale/TranslatedLists.php +++ b/lib/internal/Magento/Framework/Locale/TranslatedLists.php @@ -125,7 +125,8 @@ public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false) $options = []; $days = (new DataBundle()) ->get($this->localeResolver->getLocale())['calendar']['gregorian']['dayNames']['format']['wide'] ?: []; - $englishDays = (new DataBundle())->get('en_US')['calendar']['gregorian']['dayNames']['format']['abbreviated']; + $englishDays = (new DataBundle())->get( + \en_US::class)['calendar']['gregorian']['dayNames']['format']['abbreviated']; foreach ($days as $code => $name) { $code = $preserveCodes ? $englishDays[$code] : $code; $options[] = ['label' => $name, 'value' => $ucFirstCode ? ucfirst($code) : $code]; diff --git a/lib/internal/Magento/Framework/Mail/Template/Factory.php b/lib/internal/Magento/Framework/Mail/Template/Factory.php index ad353bedf7e4e..694a1f819a006 100644 --- a/lib/internal/Magento/Framework/Mail/Template/Factory.php +++ b/lib/internal/Magento/Framework/Mail/Template/Factory.php @@ -25,7 +25,7 @@ class Factory implements \Magento\Framework\Mail\Template\FactoryInterface */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Mail\TemplateInterface' + $instanceName = \Magento\Framework\Mail\TemplateInterface::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php b/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php index 245597e794bb0..72658cc767cb5 100644 --- a/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php +++ b/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php @@ -238,7 +238,7 @@ public function getTransport() */ protected function reset() { - $this->message = $this->objectManager->create('Magento\Framework\Mail\Message'); + $this->message = $this->objectManager->create(\Magento\Framework\Mail\Message::class); $this->templateIdentifier = null; $this->templateVars = null; $this->templateOptions = null; diff --git a/lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php b/lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php index 1213e164d359d..4056c01b01710 100644 --- a/lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php +++ b/lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php @@ -15,7 +15,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_messageMock = $this->getMock( - '\Magento\Framework\Mail\Message', + \Magento\Framework\Mail\Message::class, ['getBodyText', 'getBodyHtml', 'setBodyText', 'setBodyHtml'] ); } diff --git a/lib/internal/Magento/Framework/Mail/Test/Unit/Template/FactoryTest.php b/lib/internal/Magento/Framework/Mail/Test/Unit/Template/FactoryTest.php index cffafd7bc99c4..5d2867116459b 100644 --- a/lib/internal/Magento/Framework/Mail/Test/Unit/Template/FactoryTest.php +++ b/lib/internal/Magento/Framework/Mail/Test/Unit/Template/FactoryTest.php @@ -30,8 +30,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface'); - $this->templateMock = $this->getMock('\Magento\Framework\Mail\TemplateInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->templateMock = $this->getMock(\Magento\Framework\Mail\TemplateInterface::class); } /** @@ -43,7 +43,7 @@ protected function setUp() public function testGet($expectedArgument, $namespace) { $factory = $this->objectManagerHelper->getObject( - 'Magento\Framework\Mail\Template\Factory', + \Magento\Framework\Mail\Template\Factory::class, ['objectManager' => $this->objectManagerMock] ); @@ -52,7 +52,10 @@ public function testGet($expectedArgument, $namespace) ->with($expectedArgument, ['data' => ['template_id' => 'identifier']]) ->willReturn($this->templateMock); - $this->assertInstanceOf('\Magento\Framework\Mail\TemplateInterface', $factory->get('identifier', $namespace)); + $this->assertInstanceOf( + \Magento\Framework\Mail\TemplateInterface::class, + $factory->get('identifier', $namespace) + ); } /** @@ -62,7 +65,7 @@ public function getDataProvider() { return [ [ - 'expectedArgument' => 'Magento\Framework\Mail\TemplateInterface', + 'expectedArgument' => \Magento\Framework\Mail\TemplateInterface::class, 'namespace' => null ], [ diff --git a/lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php b/lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php index c756713077a7f..fa3a459807833 100644 --- a/lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php +++ b/lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php @@ -13,7 +13,7 @@ class TransportBuilderTest extends \PHPUnit_Framework_TestCase /** * @var string */ - protected $builderClassName = '\Magento\Framework\Mail\Template\TransportBuilder'; + protected $builderClassName = \Magento\Framework\Mail\Template\TransportBuilder::class; /** * @var \Magento\Framework\Mail\Template\TransportBuilder @@ -51,12 +51,13 @@ class TransportBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->templateFactoryMock = $this->getMock('Magento\Framework\Mail\Template\FactoryInterface'); - $this->messageMock = $this->getMock('Magento\Framework\Mail\Message'); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->senderResolverMock = $this->getMock('Magento\Framework\Mail\Template\SenderResolverInterface'); - $this->mailTransportFactoryMock = $this->getMockBuilder('Magento\Framework\Mail\TransportInterfaceFactory') - ->disableOriginalConstructor() + $this->templateFactoryMock = $this->getMock(\Magento\Framework\Mail\Template\FactoryInterface::class); + $this->messageMock = $this->getMock(\Magento\Framework\Mail\Message::class); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->senderResolverMock = $this->getMock(\Magento\Framework\Mail\Template\SenderResolverInterface::class); + $this->mailTransportFactoryMock = $this->getMockBuilder( + \Magento\Framework\Mail\TransportInterfaceFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->builder = $objectManagerHelper->getObject( @@ -86,7 +87,7 @@ public function testGetTransport($templateType, $messageType, $bodyText, $templa $vars = ['reason' => 'Reason', 'customer' => 'Customer']; $options = ['area' => 'frontend', 'store' => 1]; - $template = $this->getMock('\Magento\Framework\Mail\TemplateInterface'); + $template = $this->getMock(\Magento\Framework\Mail\TemplateInterface::class); $template->expects($this->once())->method('setVars')->with($this->equalTo($vars))->willReturnSelf(); $template->expects($this->once())->method('setOptions')->with($this->equalTo($options))->willReturnSelf(); $template->expects($this->once())->method('getSubject')->willReturn('Email Subject'); @@ -111,7 +112,7 @@ public function testGetTransport($templateType, $messageType, $bodyText, $templa ->with($this->equalTo($bodyText)) ->willReturnSelf(); - $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); + $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class); $this->mailTransportFactoryMock->expects($this->at(0)) ->method('create') @@ -120,11 +121,11 @@ public function testGetTransport($templateType, $messageType, $bodyText, $templa $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with($this->equalTo('Magento\Framework\Mail\Message')) + ->with($this->equalTo(\Magento\Framework\Mail\Message::class)) ->willReturn($transport); $this->builder->setTemplateIdentifier('identifier')->setTemplateVars($vars)->setTemplateOptions($options); - $this->assertInstanceOf('Magento\Framework\Mail\TransportInterface', $this->builder->getTransport()); + $this->assertInstanceOf(\Magento\Framework\Mail\TransportInterface::class, $this->builder->getTransport()); } /** diff --git a/lib/internal/Magento/Framework/Mail/Test/Unit/TransportTest.php b/lib/internal/Magento/Framework/Mail/Test/Unit/TransportTest.php index 807a5871e2e77..27158af133017 100644 --- a/lib/internal/Magento/Framework/Mail/Test/Unit/TransportTest.php +++ b/lib/internal/Magento/Framework/Mail/Test/Unit/TransportTest.php @@ -19,7 +19,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_messageMock = $this->getMock('\Magento\Framework\Mail\Message', [], [], '', false); + $this->_messageMock = $this->getMock(\Magento\Framework\Mail\Message::class, [], [], '', false); $this->_transport = new \Magento\Framework\Mail\Transport($this->_messageMock); } @@ -29,7 +29,7 @@ protected function setUp() */ public function testTransportWithIncorrectMessageObject() { - $this->_messageMock = $this->getMock('\Magento\Framework\Mail\MessageInterface'); + $this->_messageMock = $this->getMock(\Magento\Framework\Mail\MessageInterface::class); $this->_transport = new \Magento\Framework\Mail\Transport($this->_messageMock); } diff --git a/lib/internal/Magento/Framework/Mail/TransportInterfaceFactory.php b/lib/internal/Magento/Framework/Mail/TransportInterfaceFactory.php index efbc9dc8bba48..c834d60cbf399 100644 --- a/lib/internal/Magento/Framework/Mail/TransportInterfaceFactory.php +++ b/lib/internal/Magento/Framework/Mail/TransportInterfaceFactory.php @@ -33,7 +33,7 @@ class TransportInterfaceFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Mail\TransportInterface' + $instanceName = \Magento\Framework\Mail\TransportInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Math/Test/Unit/CalculatorTest.php b/lib/internal/Magento/Framework/Math/Test/Unit/CalculatorTest.php index c82de66453fa3..1023c225a208a 100644 --- a/lib/internal/Magento/Framework/Math/Test/Unit/CalculatorTest.php +++ b/lib/internal/Magento/Framework/Math/Test/Unit/CalculatorTest.php @@ -19,7 +19,9 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->priceCurrency = $this->getMockBuilder( + \Magento\Framework\Pricing\PriceCurrencyInterface::class + )->getMock(); $this->priceCurrency->expects($this->any()) ->method('round') ->will($this->returnCallback(function ($argument) { diff --git a/lib/internal/Magento/Framework/Message/CollectionFactory.php b/lib/internal/Magento/Framework/Message/CollectionFactory.php index 2f81714b8a4c7..504406a0dc5f8 100644 --- a/lib/internal/Magento/Framework/Message/CollectionFactory.php +++ b/lib/internal/Magento/Framework/Message/CollectionFactory.php @@ -35,6 +35,6 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\Message\Collection', $data); + return $this->objectManager->create(\Magento\Framework\Message\Collection::class, $data); } } diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/CollectionTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/CollectionTest.php index 583aef5acaeb3..9a65ea52077d1 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/CollectionTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/CollectionTest.php @@ -25,7 +25,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $this->objectManager->getObject('Magento\Framework\Message\Collection'); + $this->model = $this->objectManager->getObject(\Magento\Framework\Message\Collection::class); } /** @@ -35,9 +35,9 @@ protected function setUp() public function testAddMessage() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Error'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), ]; foreach ($messages as $message) { @@ -58,12 +58,12 @@ public function testAddMessage() public function testGetItems() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Notice'), - $this->objectManager->getObject('Magento\Framework\Message\Notice'), - $this->objectManager->getObject('Magento\Framework\Message\Warning'), - $this->objectManager->getObject('Magento\Framework\Message\Warning'), - $this->objectManager->getObject('Magento\Framework\Message\Success'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class), + $this->objectManager->getObject(\Magento\Framework\Message\Success::class), ]; foreach ($messages as $message) { @@ -83,13 +83,13 @@ public function testGetItems() public function testGetItemsByType() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Notice'), - $this->objectManager->getObject('Magento\Framework\Message\Success'), - $this->objectManager->getObject('Magento\Framework\Message\Notice'), - $this->objectManager->getObject('Magento\Framework\Message\Success'), - $this->objectManager->getObject('Magento\Framework\Message\Warning'), - $this->objectManager->getObject('Magento\Framework\Message\Error'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class), + $this->objectManager->getObject(\Magento\Framework\Message\Success::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class), + $this->objectManager->getObject(\Magento\Framework\Message\Success::class), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), ]; $messageTypes = [ @@ -124,12 +124,12 @@ public function testGetItemsByType() public function testGetErrors() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Notice'), - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Warning'), - $this->objectManager->getObject('Magento\Framework\Message\Error'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), ]; foreach ($messages as $message) { @@ -147,9 +147,9 @@ public function testGetErrors() public function testGetMessageByIdentifier() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error')->setIdentifier('error_id'), - $this->objectManager->getObject('Magento\Framework\Message\Notice')->setIdentifier('notice_id'), - $this->objectManager->getObject('Magento\Framework\Message\Warning')->setIdentifier('warning_id'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class)->setIdentifier('error_id'), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class)->setIdentifier('notice_id'), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class)->setIdentifier('warning_id'), ]; foreach ($messages as $message) { @@ -173,10 +173,10 @@ public function testGetMessageByIdentifier() public function testClear() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Warning'), - $this->objectManager->getObject('Magento\Framework\Message\Notice'), - $this->objectManager->getObject('Magento\Framework\Message\Success'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class), + $this->objectManager->getObject(\Magento\Framework\Message\Success::class), ]; foreach ($messages as $message) { @@ -194,10 +194,10 @@ public function testClear() public function testClearWithSticky() { $messages = [ - $this->objectManager->getObject('Magento\Framework\Message\Error'), - $this->objectManager->getObject('Magento\Framework\Message\Warning'), - $this->objectManager->getObject('Magento\Framework\Message\Notice')->setIsSticky(true), - $this->objectManager->getObject('Magento\Framework\Message\Success'), + $this->objectManager->getObject(\Magento\Framework\Message\Error::class), + $this->objectManager->getObject(\Magento\Framework\Message\Warning::class), + $this->objectManager->getObject(\Magento\Framework\Message\Notice::class)->setIsSticky(true), + $this->objectManager->getObject(\Magento\Framework\Message\Success::class), ]; foreach ($messages as $message) { diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/ErrorTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/ErrorTest.php index 36e33110c3f45..cc00f4360774f 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/ErrorTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/ErrorTest.php @@ -20,7 +20,7 @@ class ErrorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Message\Error'); + $this->model = $objectManager->getObject(\Magento\Framework\Message\Error::class); } public function testGetType() diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php index 4940dd78a7ee7..2eeac5fc614e3 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php @@ -20,7 +20,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->factory = new \Magento\Framework\Message\Factory( $this->objectManagerMock ); @@ -55,7 +55,7 @@ public function testCreateWithWrongInterfaceImplementation() public function testSuccessfulCreateMessage() { - $messageMock = $this->getMock('Magento\Framework\Message\Success', [], [], '', false); + $messageMock = $this->getMock(\Magento\Framework\Message\Success::class, [], [], '', false); $type = 'success'; $className = 'Magento\\Framework\\Message\\' . ucfirst($type); $this->objectManagerMock diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php index 0fec517ca33a8..1254ada95b376 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php @@ -15,6 +15,8 @@ /** * \Magento\Framework\Message\Manager test case + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ManagerTest extends \PHPUnit_Framework_TestCase { @@ -61,27 +63,27 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->messagesFactory = $this->getMockBuilder( - 'Magento\Framework\Message\CollectionFactory' + \Magento\Framework\Message\CollectionFactory::class ) ->disableOriginalConstructor() ->getMock(); $this->messageFactory = $this->getMockBuilder( - 'Magento\Framework\Message\Factory' + \Magento\Framework\Message\Factory::class ) ->disableOriginalConstructor() ->getMock(); $this->session = $this->getMockBuilder( - 'Magento\Framework\Message\Session' + \Magento\Framework\Message\Session::class ) ->disableOriginalConstructor() ->setMethods( ['getData', 'setData'] ) ->getMock(); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->messageMock = $this->getMock('Magento\Framework\Message\MessageInterface'); + $this->messageMock = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = new Manager( $this->session, @@ -100,7 +102,7 @@ public function testGetDefaultGroup() public function testGetMessages() { $messageCollection = $this->getMockBuilder( - 'Magento\Framework\Message\Collection' + \Magento\Framework\Message\Collection::class )->disableOriginalConstructor()->setMethods( ['addMessage'] )->getMock(); @@ -150,7 +152,7 @@ public function testGetMessages() public function testGetMessagesWithClear() { $messageCollection = $this->getMockBuilder( - 'Magento\Framework\Message\Collection' + \Magento\Framework\Message\Collection::class )->disableOriginalConstructor()->setMethods( ['addMessage', 'clear'] )->getMock(); @@ -182,7 +184,7 @@ public function testAddException() $logText = "Exception message: {$exceptionMessage}\nTrace:"; $messageError = $this->getMockBuilder( - 'Magento\Framework\Message\Error' + \Magento\Framework\Message\Error::class )->setConstructorArgs( ['text' => $alternativeText] )->getMock(); @@ -199,7 +201,7 @@ public function testAddException() ); $messageCollection = $this->getMockBuilder( - 'Magento\Framework\Message\Collection' + \Magento\Framework\Message\Collection::class )->disableOriginalConstructor()->setMethods( ['addMessage'] )->getMock(); @@ -229,7 +231,7 @@ public function testAddMessage($type, $methodName) $this->assertFalse($this->model->hasMessages()); $message = 'Message'; $messageCollection = $this->getMock( - 'Magento\Framework\Message\Collection', + \Magento\Framework\Message\Collection::class, ['addMessage'], [], '', @@ -265,7 +267,7 @@ public function addMessageDataProvider() public function testAddUniqueMessagesWhenMessagesImplementMessageInterface($messages, $expectation) { $messageCollection = - $this->getMock('Magento\Framework\Message\Collection', ['getItems', 'addMessage'], [], '', false); + $this->getMock(\Magento\Framework\Message\Collection::class, ['getItems', 'addMessage'], [], '', false); $this->session->expects($this->any()) ->method('getData') ->will($this->returnValue($messageCollection)); @@ -298,7 +300,7 @@ public function addUniqueMessagesWhenMessagesImplementMessageInterfaceDataProvid public function testAddUniqueMessages($messages) { $messageCollection = - $this->getMock('Magento\Framework\Message\Collection', ['getItems', 'addMessage'], [], '', false); + $this->getMock(\Magento\Framework\Message\Collection::class, ['getItems', 'addMessage'], [], '', false); $this->session->expects($this->any()) ->method('getData') ->will($this->returnValue($messageCollection)); @@ -321,7 +323,7 @@ public function addUniqueMessagesDataProvider() public function testAddMessages() { $messageCollection = $this->getMock( - 'Magento\Framework\Message\Collection', + \Magento\Framework\Message\Collection::class, ['getItems', 'addMessage'], [], '', diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/NoticeTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/NoticeTest.php index 449c601f8ae4f..58fd61b3ebf75 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/NoticeTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/NoticeTest.php @@ -20,7 +20,7 @@ class NoticeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Message\Notice'); + $this->model = $objectManager->getObject(\Magento\Framework\Message\Notice::class); } public function testGetType() diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/SuccessTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/SuccessTest.php index fedf9880ae762..2dd66536e58eb 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/SuccessTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/SuccessTest.php @@ -20,7 +20,7 @@ class SuccessTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Message\Success'); + $this->model = $objectManager->getObject(\Magento\Framework\Message\Success::class); } public function testGetType() diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/WarningTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/WarningTest.php index 3d3ee00ca34a1..49ea64fea60f1 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/WarningTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/WarningTest.php @@ -20,7 +20,7 @@ class WarningTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Message\Warning'); + $this->model = $objectManager->getObject(\Magento\Framework\Message\Warning::class); } public function testGetType() diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index f100b488652ac..1cdbd654d1a82 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -244,9 +244,9 @@ public function __sleep() public function __wakeup() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $this->_registry = $objectManager->get('Magento\Framework\Registry'); + $this->_registry = $objectManager->get(\Magento\Framework\Registry::class); - $context = $objectManager->get('Magento\Framework\Model\Context'); + $context = $objectManager->get(\Magento\Framework\Model\Context::class); if ($context instanceof \Magento\Framework\Model\Context) { $this->_appState = $context->getAppState(); $this->_eventManager = $context->getEventDispatcher(); diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php index 4e38d13aa72f6..8a8c23c728417 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php @@ -188,7 +188,7 @@ protected function _prepareTableValueForSave($value, $type) $type = strtolower($type); if ($type == 'decimal' || $type == 'numeric' || $type == 'float') { $value = \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Framework\Locale\FormatInterface' + \Magento\Framework\Locale\FormatInterface::class )->getNumber( $value ); diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php index 284d2e7189073..61e1ceabcc852 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php @@ -167,7 +167,7 @@ public function __sleep() public function __wakeup() { $this->_resources = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\App\ResourceConnection'); + ->get(\Magento\Framework\App\ResourceConnection::class); } /** diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php index 5a56588c7f418..72f6e1bc31a32 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php @@ -19,7 +19,7 @@ abstract class AbstractType * * @var String */ - protected $_entityClass = 'Magento\Framework\Model\ResourceModel\Entity\AbstractEntity'; + protected $_entityClass = \Magento\Framework\Model\ResourceModel\Entity\AbstractEntity::class; /** * Retrieve entity type diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php index 57133a1ccfa18..707b1c62c6a22 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php @@ -12,6 +12,6 @@ abstract class Db extends \Magento\Framework\Model\ResourceModel\Type\AbstractTy */ public function __construct() { - $this->_entityClass = 'Magento\Framework\Model\ResourceModel\Entity\Table'; + $this->_entityClass = \Magento\Framework\Model\ResourceModel\Entity\Table::class; } } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php index 404c077dcf020..13a9ed5be4f92 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php @@ -11,6 +11,9 @@ use Magento\Framework\Api\AttributeValue; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase { /** @@ -57,22 +60,22 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->actionValidatorMock = $this->getMock( - '\Magento\Framework\Model\ActionValidator\RemoveAction', + \Magento\Framework\Model\ActionValidator\RemoveAction::class, [], [], '', false ); $this->contextMock = new \Magento\Framework\Model\Context( - $this->getMock('Psr\Log\LoggerInterface'), - $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false), - $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false), - $this->getMock('Magento\Framework\App\State', [], [], '', false), + $this->getMock(\Psr\Log\LoggerInterface::class), + $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false), + $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false), + $this->getMock(\Magento\Framework\App\State::class, [], [], '', false), $this->actionValidatorMock ); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->resourceMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [ '_construct', 'getConnection', @@ -86,10 +89,11 @@ protected function setUp() '', false ); - $this->resourceCollectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $this->resourceCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->metadataServiceMock = $this->getMockBuilder('Magento\Framework\Api\MetadataServiceInterface')->getMock(); + $this->metadataServiceMock = $this->getMockBuilder(\Magento\Framework\Api\MetadataServiceInterface::class) + ->getMock(); $this->metadataServiceMock ->expects($this->any()) ->method('getCustomAttributesMetadata') @@ -100,18 +104,18 @@ protected function setUp() new \Magento\Framework\DataObject(['attribute_code' => 'attribute3']), ] ); - $extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + $extensionAttributesFactory = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesFactory::class) ->setMethods(['extractExtensionAttributes']) ->disableOriginalConstructor() ->getMock(); $extensionAttributesFactory->expects($this->any()) ->method('extractExtensionAttributes') ->willReturnArgument(1); - $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); $this->model = $this->getMockForAbstractClass( - 'Magento\Framework\Model\AbstractExtensibleModel', + \Magento\Framework\Model\AbstractExtensibleModel::class, [ $this->contextMock, $this->registryMock, @@ -234,7 +238,7 @@ public function testSetCustomAttributesAsLiterals() $this->model->expects($this->any())->method('getCustomAttributesCodes')->willReturn([]); $attributeCode = 'attribute2'; $attributeValue = 'attribute_value'; - $attributeMock = $this->getMockBuilder('\Magento\Framework\Api\AttributeValue') + $attributeMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->never()) diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php index 1b5241bbf9797..e4748e46ccdb4 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php @@ -47,22 +47,22 @@ class AbstractModelTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->actionValidatorMock = $this->getMock( - '\Magento\Framework\Model\ActionValidator\RemoveAction', + \Magento\Framework\Model\ActionValidator\RemoveAction::class, [], [], '', false ); $this->contextMock = new \Magento\Framework\Model\Context( - $this->getMock('Psr\Log\LoggerInterface'), - $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false), - $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false), - $this->getMock('Magento\Framework\App\State', [], [], '', false), + $this->getMock(\Psr\Log\LoggerInterface::class), + $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false), + $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false), + $this->getMock(\Magento\Framework\App\State::class, [], [], '', false), $this->actionValidatorMock ); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->resourceMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [ '_construct', 'getConnection', @@ -76,15 +76,15 @@ protected function setUp() '', false ); - $this->resourceCollectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $this->resourceCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->model = $this->getMockForAbstractClass( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [$this->contextMock, $this->registryMock, $this->resourceMock, $this->resourceCollectionMock] ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ActionValidator/RemoveActionTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ActionValidator/RemoveActionTest.php index 15052227ca4f9..1cb03c8ae94ed 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ActionValidator/RemoveActionTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ActionValidator/RemoveActionTest.php @@ -19,7 +19,7 @@ class RemoveActionTest extends \PHPUnit_Framework_TestCase */ public function testIsAllowed($modelToCheck, $protectedModel, $secureArea, $expectedResult) { - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $registryMock->expects($this->once()) ->method('registry')->with('isSecureArea')->will($this->returnValue($secureArea)); @@ -35,8 +35,8 @@ public function testIsAllowed($modelToCheck, $protectedModel, $secureArea, $expe */ public function isAllowedDataProvider() { - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $bannerMock = $this->getMock('\Magento\Wishlist\Model\Wishlist', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $bannerMock = $this->getMock(\Magento\Wishlist\Model\Wishlist::class, [], [], '', false); return [ [ diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php index 1939173ad374d..ed905f5b81059 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php @@ -8,6 +8,9 @@ namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractDbTest extends \PHPUnit_Framework_TestCase { /** @@ -33,7 +36,7 @@ class AbstractDbTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_resourcesMock = $this->getMock( - '\Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -41,16 +44,16 @@ protected function setUp() ); $this->relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); $this->transactionManagerMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface' + \Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface::class ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->_resourcesMock); $contextMock->expects($this->once()) ->method('getObjectRelationProcessor') @@ -60,7 +63,7 @@ protected function setUp() ->willReturn($this->transactionManagerMock); $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [$contextMock], '', true, @@ -113,7 +116,7 @@ public function addUniqueFieldDataProvider() public function testAddUniqueFieldArray() { $this->assertInstanceOf( - '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, $this->_model->addUniqueField(['someField']) ); } @@ -131,7 +134,7 @@ public function testGetIdFieldname() { $data = 'MainTableName'; $idFieldNameProperty = new \ReflectionProperty( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_idFieldName' + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, '_idFieldName' ); $idFieldNameProperty->setAccessible(true); $idFieldNameProperty->setValue($this->_model, $data); @@ -154,7 +157,10 @@ public function testGetMainTableException() */ public function testGetMainTable($tableName, $expectedResult) { - $mainTableProperty = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_mainTable'); + $mainTableProperty = new \ReflectionProperty( + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, + '_mainTable' + ); $mainTableProperty->setAccessible(true); $mainTableProperty->setValue($this->_model, $tableName); $this->_resourcesMock->expects($this->once()) @@ -188,7 +194,10 @@ public function testGetTable() $this->_resourcesMock->expects($this->once())->method('getTableName')->with($data)->will( $this->returnValue('tableName') ); - $tablesProperty = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_tables'); + $tablesProperty = new \ReflectionProperty( + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, + '_tables' + ); $tablesProperty->setAccessible(true); $tablesProperty->setValue($this->_model, [$data]); $this->assertEquals($data, $this->_model->getTable($data)); @@ -206,7 +215,7 @@ public function testGetChecksumNegative() */ public function testGetChecksum($checksum, $expected) { - $connectionMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $connectionMock->expects($this->once())->method('getTablesChecksum')->with($checksum)->will( $this->returnValue([$checksum => 'checksum']) ); @@ -232,7 +241,10 @@ public function getChecksumProvider() public function testResetUniqueField() { - $uniqueFields = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_uniqueFields'); + $uniqueFields = new \ReflectionProperty( + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, + '_uniqueFields' + ); $uniqueFields->setAccessible(true); $uniqueFields->setValue($this->_model, ['uniqueField1', 'uniqueField2']); $this->_model->resetUniqueField(); @@ -242,7 +254,7 @@ public function testResetUniqueField() public function testGetUniqueFields() { $uniqueFieldsReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, '_uniqueFields' ); $uniqueFieldsReflection->setAccessible(true); @@ -257,10 +269,10 @@ public function testGetValidationRulesBeforeSave() public function testLoad() { - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $abstractModelMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [$contextMock, $registryMock], '', false, @@ -270,23 +282,32 @@ public function testLoad() ); $value = 'some_value'; - $idFieldName = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_idFieldName'); + $idFieldName = new \ReflectionProperty( + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, + '_idFieldName' + ); $idFieldName->setAccessible(true); $idFieldName->setValue($this->_model, 'field_value'); $this->assertInstanceOf( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, $this->_model->load($abstractModelMock, $value, $idFieldName) ); } public function testDelete() { - $connectionInterfaceMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $connectionInterfaceMock = $this->getMock( + \Magento\Framework\DB\Adapter\AdapterInterface::class, + [], + [], + '', + false + ); + $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $abstractModelMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [$contextMock, $registryMock], '', false, @@ -300,7 +321,7 @@ public function testDelete() ); $abstractModelMock->expects($this->once())->method('getData')->willReturn(['data' => 'value']); - $connectionMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->transactionManagerMock->expects($this->once()) ->method('start') ->with($connectionInterfaceMock) @@ -323,13 +344,13 @@ public function testDelete() $this->returnValue('tableName') ); $mainTableReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, '_mainTable' ); $mainTableReflection->setAccessible(true); $mainTableReflection->setValue($this->_model, 'tableName'); $idFieldNameReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, '_idFieldName' ); $idFieldNameReflection->setAccessible(true); @@ -340,17 +361,17 @@ public function testDelete() $abstractModelMock->expects($this->once())->method('afterDelete'); $abstractModelMock->expects($this->once())->method('afterDeleteCommit'); $this->assertInstanceOf( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, $this->_model->delete($abstractModelMock) ); } public function testHasDataChangedNegative() { - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $abstractModelMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [$contextMock, $registryMock], '', false, @@ -369,14 +390,20 @@ public function testHasDataChangedNegative() */ public function testGetDataChanged($getOriginData, $expected) { - $connectionInterfaceMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionInterfaceMock = $this->getMock( + \Magento\Framework\DB\Adapter\AdapterInterface::class, + [], + [], + '', + false + ); $this->_resourcesMock->expects($this->any())->method('getConnection')->will( $this->returnValue($connectionInterfaceMock) ); - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $abstractModelMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [$contextMock, $registryMock], '', false, @@ -384,7 +411,10 @@ public function testGetDataChanged($getOriginData, $expected) true, ['__wakeup', 'getOrigData', 'getData'] ); - $mainTableProperty = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_mainTable'); + $mainTableProperty = new \ReflectionProperty( + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, + '_mainTable' + ); $mainTableProperty->setAccessible(true); $mainTableProperty->setValue($this->_model, 'table'); @@ -411,13 +441,13 @@ public function hasDataChangedDataProvider() public function testPrepareDataForUpdate() { - $connectionMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $context = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Framework\Model\Context' + \Magento\Framework\Model\Context::class ); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $resourceMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [ '_construct', 'getConnection', @@ -428,15 +458,21 @@ public function testPrepareDataForUpdate() '', false ); - $connectionInterfaceMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionInterfaceMock = $this->getMock( + \Magento\Framework\DB\Adapter\AdapterInterface::class, + [], + [], + '', + false + ); $resourceMock->expects($this->any()) ->method('getConnection') ->will($this->returnValue($connectionInterfaceMock)); - $resourceCollectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $resourceCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $abstractModelMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [$context, $registryMock, $resourceMock, $resourceCollectionMock] ); $data = 'tableName'; @@ -448,13 +484,13 @@ public function testPrepareDataForUpdate() $this->returnValue('tableName') ); $mainTableReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, '_mainTable' ); $mainTableReflection->setAccessible(true); $mainTableReflection->setValue($this->_model, 'tableName'); $idFieldNameReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, '_idFieldName' ); $idFieldNameReflection->setAccessible(true); @@ -499,7 +535,7 @@ public function testSaveNewObject($pkIncrement) /** * Mock SUT so as not to test extraneous logic */ - $model = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $model = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['_prepareDataForSave', 'getIdFieldName', 'getConnection', 'getMainTable']) ->getMockForAbstractClass(); @@ -516,7 +552,7 @@ public function testSaveNewObject($pkIncrement) $reflectionProperty->setValue($model, $pkIncrement); // Mocked behavior - $connectionMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->setMethods(['lastInsertId']) ->getMockForAbstractClass(); @@ -538,7 +574,7 @@ public function testSaveNewObject($pkIncrement) // Only set object id if not PK autoincrement $setIdInvokedCount = $pkIncrement ? 1 : 0; - $inputObject = $this->getMockBuilder('\Magento\Framework\Model\AbstractModel') + $inputObject = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->getMock(); $inputObject->expects($this->exactly($setIdInvokedCount))->method('setId'); diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php index 1097cce1b8f8a..d458810732b6b 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php @@ -58,13 +58,13 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactoryInterface'); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $this->fetchStrategyMock = $this->getMock('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $this->managerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); - $renderer = $this->getMock('Magento\Framework\DB\Select\SelectRenderer', [], [], '', false); - $this->resourceMock = $this->getMock('Magento\Framework\Flag\FlagResource', [], [], '', false); + $this->entityFactoryMock = $this->getMock(\Magento\Framework\Data\Collection\EntityFactoryInterface::class); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->fetchStrategyMock = $this->getMock(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class); + $this->managerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $renderer = $this->getMock(\Magento\Framework\DB\Select\SelectRenderer::class, [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\Flag\FlagResource::class, [], [], '', false); $this->resourceMock ->expects($this->any()) @@ -72,7 +72,7 @@ protected function setUp() ->will($this->returnValue($this->connectionMock)); $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['getPart', 'setPart', 'from', 'columns'], [$this->connectionMock, $renderer] ); @@ -82,7 +82,7 @@ protected function setUp() ->method('select') ->will($this->returnValue($this->selectMock)); - $this->objectManagerMock = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); + $this->objectManagerMock = $this->getMock(\Magento\Framework\App\ObjectManager::class, [], [], '', false); \Magento\Framework\App\ObjectManager::setInstance($this->objectManagerMock); @@ -94,14 +94,14 @@ protected function tearDown() { parent::tearDown(); /** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManagerMock*/ - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); } protected function getUut() { return $this->objectManagerHelper->getObject( - 'Magento\Framework\Model\Test\Unit\ResourceModel\Db\Collection\Uut', + \Magento\Framework\Model\Test\Unit\ResourceModel\Db\Collection\Uut::class, [ 'entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, @@ -221,7 +221,7 @@ public function testGetSelect($idFieldNameRet, $getPartRet, $expected) public function getSelectDataProvider() { - $columnMock = $this->getMock('Zend_Db_Expr', ['__toString'], [], '', false); + $columnMock = $this->getMock(\Zend_Db_Expr::class, ['__toString'], [], '', false); return [ [ @@ -328,13 +328,13 @@ public function testSetModelInvalidType() public function testSetModel() { - $this->assertTrue($this->uut->setModel('Magento\Framework\DataObject') instanceof Uut); + $this->assertTrue($this->uut->setModel(\Magento\Framework\DataObject::class) instanceof Uut); } public function testGetModelName() { - $this->uut->setModel('Magento\Framework\DataObject'); - $this->assertEquals('Magento\Framework\DataObject', $this->uut->getModelName()); + $this->uut->setModel(\Magento\Framework\DataObject::class); + $this->assertEquals(\Magento\Framework\DataObject::class, $this->uut->getModelName()); } public function testGetResourceModelName() @@ -387,7 +387,7 @@ public function testResetItemsDataChanged() { for ($i = 0; $i < 3; $i++) { /** @var \Magento\Framework\Model\AbstractModel $item */ - $item = $this->getMockForAbstractClass('Magento\Framework\Model\AbstractModel', [], '', false); + $item = $this->getMockForAbstractClass(\Magento\Framework\Model\AbstractModel::class, [], '', false); $this->uut->addItem($item->setDataChanges(true)); } @@ -402,7 +402,7 @@ public function testSave() { for ($i = 0; $i < 3; $i++) { /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Framework\DataObject', ['save']); + $item = $this->getMock(\Magento\Framework\DataObject::class, ['save']); $item->expects($this->once())->method('save'); $this->uut->addItem($item); } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/CreateEntityRowTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/CreateEntityRowTest.php index a18851cb3610e..09af66155c1c7 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/CreateEntityRowTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/CreateEntityRowTest.php @@ -30,7 +30,7 @@ class CreateEntityRowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->connection = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false, @@ -44,7 +44,7 @@ protected function setUp() ->willReturn(1); $metadata = $this->getMock( - 'Magento\Framework\EntityManager\EntityMetadata', + \Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', @@ -72,7 +72,7 @@ protected function setUp() ->willReturn('100000001'); $this->metadataPool = $this->getMock( - 'Magento\Framework\EntityManager\MetadataPool', + \Magento\Framework\EntityManager\MetadataPool::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/DeleteEntityRowTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/DeleteEntityRowTest.php index 951d385a43e37..86f8786eebb3d 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/DeleteEntityRowTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/DeleteEntityRowTest.php @@ -30,7 +30,7 @@ class DeleteEntityRowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->connection = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false, @@ -40,7 +40,7 @@ protected function setUp() ); $metadata = $this->getMock( - 'Magento\Framework\EntityManager\EntityMetadata', + \Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', @@ -60,7 +60,7 @@ protected function setUp() ->willReturn($this->connection); $this->metadataPool = $this->getMock( - 'Magento\Framework\EntityManager\MetadataPool', + \Magento\Framework\EntityManager\MetadataPool::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ExtensionPoolTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ExtensionPoolTest.php index 988fa02b52590..953f9385241c7 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ExtensionPoolTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ExtensionPoolTest.php @@ -28,7 +28,7 @@ class ExtensionPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false, diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ReadEntityRowTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ReadEntityRowTest.php index 33036b8162e5d..148edcb8fd352 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ReadEntityRowTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/ReadEntityRowTest.php @@ -35,7 +35,7 @@ class ReadEntityRowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->select = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, [], [], '', @@ -43,7 +43,7 @@ protected function setUp() ); $this->connection = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false, @@ -61,7 +61,7 @@ protected function setUp() ->willReturnArgument(0); $metadata = $this->getMock( - 'Magento\Framework\EntityManager\EntityMetadata', + \Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', @@ -81,7 +81,7 @@ protected function setUp() ->willReturn('identifier'); $this->metadataPool = $this->getMock( - 'Magento\Framework\EntityManager\MetadataPool', + \Magento\Framework\EntityManager\MetadataPool::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Relation/ActionPoolTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Relation/ActionPoolTest.php index 39cddfe13e96e..de97893404170 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Relation/ActionPoolTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Relation/ActionPoolTest.php @@ -21,7 +21,7 @@ class ActionPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManager($this); @@ -31,7 +31,7 @@ protected function setUp() $relationActions = [$entityType => $actionName]; $this->model = $objectManager->getObject( - 'Magento\Framework\Model\ResourceModel\Db\Relation\ActionPool', + \Magento\Framework\Model\ResourceModel\Db\Relation\ActionPool::class, [ 'objectManager' => $this->objectManagerMock, 'relationActions' => $relationActions diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/UpdateEntityRowTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/UpdateEntityRowTest.php index 741b9e3af8c16..ce6a161ba349f 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/UpdateEntityRowTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/UpdateEntityRowTest.php @@ -22,11 +22,11 @@ class UpdateEntityRowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->metadataPoolMock = $this->getMockBuilder('\Magento\Framework\EntityManager\MetadataPool') + $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); $this->model = $objectManager->getObject( - 'Magento\Framework\Model\ResourceModel\Db\UpdateEntityRow', + \Magento\Framework\Model\ResourceModel\Db\UpdateEntityRow::class, ['metadataPool' => $this->metadataPoolMock] ); } @@ -50,10 +50,10 @@ public function testExecute() $output['test_column_name'] = 'test_column_name'; $expectedResult = true; - $entityMetadataMock = $this->getMockBuilder('Magento\Framework\EntityManager\EntityMetadata') + $entityMetadataMock = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class) ->disableOriginalConstructor() ->getMock(); - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMock(); $connectionMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php index eae0015ce7307..32c9b10ca8a97 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php @@ -39,14 +39,14 @@ protected function setUp() { $objectManager = new ObjectManager($this); $this->model = $this->getMock( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [], [], '', false ); $this->resource = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], "", false, @@ -55,7 +55,7 @@ protected function setUp() ['getConnection', 'getMainTable'] ); $this->connection = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], "", false, @@ -64,7 +64,7 @@ protected function setUp() $this->model->expects($this->any())->method('getResource')->willReturn($this->resource); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection); $this->entityMetadata = $objectManager->getObject( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata' + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata::class ); } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php index 9a0e8f8321179..e706c2b0c574c 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php @@ -33,7 +33,7 @@ class RelationCompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->modelMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + $this->modelMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods( [ @@ -41,14 +41,14 @@ protected function setUp() ] ) ->getMockForAbstractClass(); - $this->relationProcessorMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + $this->relationProcessorMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->relationProcessorMock = $this->getMockBuilder( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationInterface' + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $this->entityRelationComposite = new \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite( diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php index 692b19c4d2414..fe6a952268deb 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php @@ -34,7 +34,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); $this->model = $this->getMock( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, ['getId'], [], '', @@ -42,7 +42,7 @@ protected function setUp() ); $this->entityMetadata = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata::class, ['getFields'], [], '', @@ -50,7 +50,7 @@ protected function setUp() ); $this->entitySnapshot = $objectManager->getObject( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, ['metadata' => $this->entityMetadata] ); } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php index ae3296b3d7133..37d3869302f0a 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php @@ -27,9 +27,9 @@ class MysqlTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->string = $this->getMock('Magento\Framework\Stdlib\StringUtils'); - $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); - $this->selectFactory = $this->getMockBuilder('Magento\Framework\DB\SelectFactory') + $this->string = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class); + $this->dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime::class); + $this->selectFactory = $this->getMockBuilder(\Magento\Framework\DB\SelectFactory::class) ->disableOriginalConstructor() ->getMock(); } @@ -96,7 +96,7 @@ public function testGetConnectionInactive() { $config = ['host' => 'localhost', 'active' => false]; $object = new Mysql($this->string, $this->dateTime, $this->selectFactory, $config); - $logger = $this->getMockForAbstractClass('Magento\Framework\DB\LoggerInterface'); + $logger = $this->getMockForAbstractClass(\Magento\Framework\DB\LoggerInterface::class); $this->assertNull($object->getConnection($logger)); } } diff --git a/lib/internal/Magento/Framework/Module/PackageInfoFactory.php b/lib/internal/Magento/Framework/Module/PackageInfoFactory.php index ae5ae0f5483a0..c4120526b77a9 100644 --- a/lib/internal/Magento/Framework/Module/PackageInfoFactory.php +++ b/lib/internal/Magento/Framework/Module/PackageInfoFactory.php @@ -34,11 +34,11 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create() { - $fullModuleList = $this->objectManager->create('Magento\Framework\Module\FullModuleList'); + $fullModuleList = $this->objectManager->create(\Magento\Framework\Module\FullModuleList::class); $reader = $this->objectManager->create( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['moduleList' => $fullModuleList] ); - return $this->objectManager->create('Magento\Framework\Module\PackageInfo', ['reader' => $reader]); + return $this->objectManager->create(\Magento\Framework\Module\PackageInfo::class, ['reader' => $reader]); } } diff --git a/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php b/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php index c5b0c8833a6ef..4fd60a6654585 100644 --- a/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php +++ b/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php @@ -33,7 +33,7 @@ class MigrationFactory * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param string $instanceName */ - public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = 'Magento\Framework\Module\Setup\Migration') + public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = \Magento\Framework\Module\Setup\Migration::class) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ConflictCheckerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ConflictCheckerTest.php index 5ee12efac6f84..6fe2d292d5806 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ConflictCheckerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ConflictCheckerTest.php @@ -22,8 +22,8 @@ public function testCheckConflictsWhenEnableModules( $moduleName, $expected ) { - $moduleListMock = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $packageInfoMock = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $moduleListMock = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $packageInfoMock = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $moduleListMock->expects($this->any()) ->method('getNames') ->will($this->returnValue($enabledModules)); @@ -33,7 +33,13 @@ public function testCheckConflictsWhenEnableModules( $packageInfoMock->expects($this->any()) ->method('getVersion') ->will($this->returnValue('0.1')); - $packageInfoFactoryMock = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); + $packageInfoFactoryMock = $this->getMock( + \Magento\Framework\Module\PackageInfoFactory::class, + [], + [], + '', + false + ); $packageInfoFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($packageInfoMock)); @@ -118,8 +124,8 @@ public function checkConflictWhenEnableModuleDataProvider() public function testCheckConflictWhenEnableModuleDifferentVersion() { - $moduleListMock = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $packageInfoMock = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $moduleListMock = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $packageInfoMock = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $moduleListMock->expects($this->any()) ->method('getNames') ->will($this->returnValue(['Vendor_A', 'Vendor_B'])); @@ -133,7 +139,13 @@ public function testCheckConflictWhenEnableModuleDifferentVersion() $packageInfoMock->expects($this->any()) ->method('getVersion') ->will($this->returnValueMap([['Vendor_A', '0.2'], ['Vendor_B', '0.4']])); - $packageInfoFactoryMock = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); + $packageInfoFactoryMock = $this->getMock( + \Magento\Framework\Module\PackageInfoFactory::class, + [], + [], + '', + false + ); $packageInfoFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($packageInfoMock)); @@ -146,8 +158,8 @@ public function testCheckConflictWhenEnableModuleDifferentVersion() public function testCheckConflictWhenEnableModuleDifferentVersionWithCurEnabledModules() { - $moduleListMock = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $packageInfoMock = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $moduleListMock = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $packageInfoMock = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $packageInfoMock->expects($this->any()) ->method('getConflict') ->will($this->returnValueMap([ @@ -158,7 +170,13 @@ public function testCheckConflictWhenEnableModuleDifferentVersionWithCurEnabledM $packageInfoMock->expects($this->any()) ->method('getVersion') ->will($this->returnValueMap([['Vendor_A', '0.2'], ['Vendor_B', '0.4']])); - $packageInfoFactoryMock = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); + $packageInfoFactoryMock = $this->getMock( + \Magento\Framework\Module\PackageInfoFactory::class, + [], + [], + '', + false + ); $packageInfoFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($packageInfoMock)); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/DbVersionInfoTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/DbVersionInfoTest.php index 4b096b17b1655..83ca33fbb939b 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/DbVersionInfoTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/DbVersionInfoTest.php @@ -7,7 +7,6 @@ use \Magento\Framework\Module\DbVersionInfo; - class DbVersionInfoTest extends \PHPUnit_Framework_TestCase { /** @@ -27,7 +26,7 @@ class DbVersionInfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); + $this->moduleList = $this->getMockForAbstractClass(\Magento\Framework\Module\ModuleListInterface::class); $this->moduleList->expects($this->any()) ->method('getOne') ->will($this->returnValueMap([ @@ -39,8 +38,8 @@ protected function setUp() ->method('getNames') ->will($this->returnValue(['Module_One', 'Module_Two'])); - $this->_outputConfig = $this->getMockForAbstractClass('Magento\Framework\Module\Output\ConfigInterface'); - $this->moduleResource = $this->getMockForAbstractClass('\Magento\Framework\Module\ResourceInterface'); + $this->_outputConfig = $this->getMockForAbstractClass(\Magento\Framework\Module\Output\ConfigInterface::class); + $this->moduleResource = $this->getMockForAbstractClass(\Magento\Framework\Module\ResourceInterface::class); $this->dbVersionInfo = new DbVersionInfo( $this->moduleList, @@ -86,7 +85,6 @@ public function testIsDbDataUpToDate($moduleName, $dbVersion, $expectedResult) ); } - /** * @return array */ diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/DependencyCheckerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/DependencyCheckerTest.php index 0c9fa88fd28f2..2c199d5bcf797 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/DependencyCheckerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/DependencyCheckerTest.php @@ -36,7 +36,7 @@ class DependencyCheckerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->packageInfoMock = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $this->packageInfoMock = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $requireMap = [ ['A', ['B']], ['B', ['D', 'E']], @@ -50,7 +50,7 @@ protected function setUp() ->will($this->returnValueMap($requireMap)); $this->packageInfoFactoryMock = $this->getMock( - 'Magento\Framework\Module\PackageInfoFactory', + \Magento\Framework\Module\PackageInfoFactory::class, [], [], '', @@ -60,8 +60,8 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->packageInfoMock)); - $this->listMock = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $this->loaderMock = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); + $this->listMock = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $this->loaderMock = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); $this->loaderMock ->expects($this->any()) ->method('load') diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReaderTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReaderTest.php index a7f85dd17c15e..8275196004f23 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReaderTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReaderTest.php @@ -54,25 +54,25 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_protFactoryMock = $this->getMock( - 'Magento\Framework\App\Config\BaseFactory', + \Magento\Framework\App\Config\BaseFactory::class, [], [], '', false, false ); - $this->_dirsMock = $this->getMock('Magento\Framework\Module\Dir', [], [], '', false, false); + $this->_dirsMock = $this->getMock(\Magento\Framework\Module\Dir::class, [], [], '', false, false); $this->_baseConfigMock = $this->getMock( - 'Magento\Framework\App\Config\Base', + \Magento\Framework\App\Config\Base::class, [], [], '', false, false ); - $this->_moduleListMock = $this->getMock('Magento\Framework\Module\ModuleListInterface'); + $this->_moduleListMock = $this->getMock(\Magento\Framework\Module\ModuleListInterface::class); $this->directoryReadFactoryMock = $this->getMock( - '\Magento\Framework\Filesystem\Directory\ReadFactory', + \Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', @@ -80,7 +80,7 @@ protected function setUp() false ); $this->_fileIteratorFactory = $this->getMock( - '\Magento\Framework\Config\FileIteratorFactory', + \Magento\Framework\Config\FileIteratorFactory::class, [], [], '', @@ -125,7 +125,7 @@ public function testGetModuleDirWhenCustomDirIsSet() public function testGetConfigurationFiles() { $configPath = 'app/code/Test/Module/etc/config.xml'; - $modulesDirectoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadInterface'); + $modulesDirectoryMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $modulesDirectoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); $modulesDirectoryMock->expects($this->any())->method('isExist') ->with($configPath) @@ -151,7 +151,7 @@ public function testGetConfigurationFiles() public function testGetComposerJsonFiles() { $configPath = 'app/code/Test/Module/composer.json'; - $modulesDirectoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadInterface'); + $modulesDirectoryMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $modulesDirectoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); $modulesDirectoryMock->expects($this->any())->method('isExist') ->with($configPath) diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php index 39737bf362b50..66012661ded54 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php @@ -24,8 +24,8 @@ class ReverseResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleList = $this->getMock('Magento\Framework\Module\ModuleListInterface'); - $this->_moduleDirs = $this->getMock('Magento\Framework\Module\Dir', [], [], '', false, false); + $this->_moduleList = $this->getMock(\Magento\Framework\Module\ModuleListInterface::class); + $this->_moduleDirs = $this->getMock(\Magento\Framework\Module\Dir::class, [], [], '', false, false); $this->_model = new \Magento\Framework\Module\Dir\ReverseResolver($this->_moduleList, $this->_moduleDirs); } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php index 6674368849d68..1eb51dad83f08 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php @@ -22,7 +22,7 @@ class DirTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->moduleRegistryMock = $this->getMock( - 'Magento\Framework\Component\ComponentRegistrarInterface', + \Magento\Framework\Component\ComponentRegistrarInterface::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/FullModuleListTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/FullModuleListTest.php index 6a741c8bd3618..d49adc0af70df 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/FullModuleListTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/FullModuleListTest.php @@ -16,7 +16,7 @@ class FullModuleListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $loaderMock = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); + $loaderMock = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); $modules = [ 'Vendor_A' => ['data' => 'a'], 'Vendor_B' => ['data' => 'b'], diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php index c1a4c7ce61b86..ed4616b7c6990 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php @@ -31,7 +31,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); + $this->_moduleList = $this->getMockForAbstractClass(\Magento\Framework\Module\ModuleListInterface::class); $this->_moduleList->expects($this->any()) ->method('getOne') ->will($this->returnValueMap([ @@ -39,7 +39,7 @@ protected function setUp() ['Module_Two', ['name' => 'Two_Module', 'setup_version' => '2']], ['Module_Three', ['name' => 'Two_Three']], ])); - $this->_outputConfig = $this->getMockForAbstractClass('Magento\Framework\Module\Output\ConfigInterface'); + $this->_outputConfig = $this->getMockForAbstractClass(\Magento\Framework\Module\Output\ConfigInterface::class); $this->_model = new \Magento\Framework\Module\Manager( $this->_outputConfig, $this->_moduleList, diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/LoaderTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/LoaderTest.php index faf3f29ad0305..5c5a64f53a086 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/LoaderTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/LoaderTest.php @@ -49,18 +49,24 @@ class LoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->converter = $this->getMock('Magento\Framework\Module\Declaration\Converter\Dom', [], [], '', false); - $this->parser = $this->getMock('Magento\Framework\Xml\Parser', [], [], '', false); + $this->converter = $this->getMock( + \Magento\Framework\Module\Declaration\Converter\Dom::class, + [], + [], + '', + false + ); + $this->parser = $this->getMock(\Magento\Framework\Xml\Parser::class, [], [], '', false); $this->parser->expects($this->once())->method('initErrorHandler'); $this->registry = $this->getMock( - 'Magento\Framework\Component\ComponentRegistrarInterface', + \Magento\Framework\Component\ComponentRegistrarInterface::class, [], [], '', false, false ); - $this->driver = $this->getMock('Magento\Framework\Filesystem\DriverInterface', [], [], '', false, false); + $this->driver = $this->getMock(\Magento\Framework\Filesystem\DriverInterface::class, [], [], '', false, false); $this->loader = new Loader($this->converter, $this->parser, $this->registry, $this->driver); } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php index 35ee7dd47ff93..bee9bc8e2f956 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php @@ -40,8 +40,8 @@ class ModuleListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->loader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->loader = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); $this->model = new ModuleList($this->config, $this->loader); } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoFactoryTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoFactoryTest.php index 3e50af4f330f7..02922e03fe1b6 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoFactoryTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoFactoryTest.php @@ -11,15 +11,15 @@ class PackageInfoFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); - $reader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); - $packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $fullModuleList = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); + $reader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); + $packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $returnValueMap = [ - ['Magento\Framework\Module\FullModuleList', [], $fullModuleList], - ['Magento\Framework\Module\Dir\Reader', ['moduleList' => $fullModuleList], $reader], - ['Magento\Framework\Module\PackageInfo', ['reader' => $reader], $packageInfo], + [\Magento\Framework\Module\FullModuleList::class, [], $fullModuleList], + [\Magento\Framework\Module\Dir\Reader::class, ['moduleList' => $fullModuleList], $reader], + [\Magento\Framework\Module\PackageInfo::class, ['reader' => $reader], $packageInfo], ]; - $objectManagerMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any()) ->method('create') ->will($this->returnValueMap($returnValueMap)); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoTest.php index 19fb536031d5c..8b9bcf01dde52 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/PackageInfoTest.php @@ -26,8 +26,14 @@ class PackageInfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); - $this->reader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->componentRegistrar = $this->getMock( + \Magento\Framework\Component\ComponentRegistrar::class, + [], + [], + '', + false + ); + $this->reader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->componentRegistrar->expects($this->once()) ->method('getPaths') ->will($this->returnValue(['A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E'])); @@ -39,7 +45,7 @@ protected function setUp() 'D/composer.json' => '{"name":"d", "conflict":{"c":"0.1"}, "version":"0.3"}', 'E/composer.json' => '{"name":"e", "version":"0.4"}', ]; - $fileIteratorMock = $this->getMock('Magento\Framework\Config\FileIterator', [], [], '', false); + $fileIteratorMock = $this->getMock(\Magento\Framework\Config\FileIterator::class, [], [], '', false); $fileIteratorMock->expects($this->once()) ->method('toArray') ->will($this->returnValue($composerData)); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php index c898f8609dcaa..fee050560815c 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php @@ -21,11 +21,6 @@ class DbStatusValidatorTest extends \PHPUnit_Framework_TestCase */ protected $_cacheMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_dbUpdaterMock; - /** * @var \Closure */ @@ -53,20 +48,19 @@ class DbStatusValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_cacheMock = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); - $this->_dbUpdaterMock = $this->getMock('\Magento\Framework\Module\Updater', [], [], '', false); + $this->_cacheMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); $this->closureMock = function () { return 'Expected'; }; - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', [], [], '', false); - $moduleList = $this->getMockForAbstractClass('\Magento\Framework\Module\ModuleListInterface'); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->subjectMock = $this->getMock(\Magento\Framework\App\FrontController::class, [], [], '', false); + $moduleList = $this->getMockForAbstractClass(\Magento\Framework\Module\ModuleListInterface::class); $moduleList->expects($this->any()) ->method('getNames') ->will($this->returnValue(['Module_One', 'Module_Two'])); - $this->moduleManager = $this->getMock('\Magento\Framework\Module\Manager', [], [], '', false); - $this->dbVersionInfoMock = $this->getMock('\Magento\Framework\Module\DbVersionInfo', [], [], '', false); + $this->moduleManager = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); + $this->dbVersionInfoMock = $this->getMock(\Magento\Framework\Module\DbVersionInfo::class, [], [], '', false); $this->_model = new DbStatusValidator( $this->_cacheMock, $this->dbVersionInfoMock diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/MigrationTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/MigrationTest.php index d17b7a90e7da3..cb565e03f52f1 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/MigrationTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/MigrationTest.php @@ -50,7 +50,7 @@ protected function tearDown() */ protected function _getModelDependencies($tableRowsCount = 0, $tableData = [], $aliasesMap = []) { - $this->_selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->_selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $this->_selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $this->_selectMock->expects( $this->any() @@ -61,7 +61,7 @@ protected function _getModelDependencies($tableRowsCount = 0, $tableData = [], $ ); $connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'update', 'fetchAll', 'fetchOne'], [], '', @@ -85,7 +85,7 @@ protected function _getModelDependencies($tableRowsCount = 0, $tableData = [], $ 'base_dir' => 'not_used', 'path_to_map_file' => 'not_used', 'connection' => $connectionMock, - 'core_helper' => $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false, false), + 'core_helper' => $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false, false), 'aliases_map' => $aliasesMap ]; } @@ -139,9 +139,9 @@ public function whereCallback($condition) */ public function testAppendClassAliasReplace() { - $setupMock = $this->getMockForAbstractClass('\Magento\Framework\Setup\ModuleDataSetupInterface'); - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $migrationData = $this->getMock('Magento\Framework\Module\Setup\MigrationData', [], [], '', false); + $setupMock = $this->getMockForAbstractClass(\Magento\Framework\Setup\ModuleDataSetupInterface::class); + $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $migrationData = $this->getMock(\Magento\Framework\Module\Setup\MigrationData::class, [], [], '', false); $setupModel = new \Magento\Framework\Module\Setup\Migration( $setupMock, @@ -194,9 +194,9 @@ public function testDoUpdateClassAliases($replaceRules, $tableData, $expected, $ $this->_actualUpdateResult = []; $tableRowsCount = count($tableData); - $setupMock = $this->getMockForAbstractClass('\Magento\Framework\Setup\ModuleDataSetupInterface'); - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $migrationData = $this->getMock('Magento\Framework\Module\Setup\MigrationData', [], [], '', false); + $setupMock = $this->getMockForAbstractClass(\Magento\Framework\Setup\ModuleDataSetupInterface::class); + $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $migrationData = $this->getMock(\Magento\Framework\Module\Setup\MigrationData::class, [], [], '', false); $setupModel = new \Magento\Framework\Module\Setup\Migration( $setupMock, @@ -245,7 +245,7 @@ public function updateClassAliasesDataProvider() */ protected function _getFilesystemMock() { - $mock = $this->getMockBuilder('Magento\Framework\Filesystem')->disableOriginalConstructor()->getMock(); + $mock = $this->getMockBuilder(\Magento\Framework\Filesystem::class)->disableOriginalConstructor()->getMock(); return $mock; } } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_model.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_model.php index b1616893f6365..9762ed6a3fe20 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_model.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_model.php @@ -17,20 +17,20 @@ ['field' => 'customer/customer'], ['field' => 'customer/attribute_data_postcode'], ['field' => 'customer/attribute_data_postcode::someMethod'], - ['field' => 'Magento\Customer\Model\Customer'], + ['field' => \Magento\Customer\Model\Customer::class], ], '$expected' => [ 'updates' => [ [ 'table' => 'table', 'field' => 'field', - 'to' => 'Magento\Customer\Model\Customer_FROM_MAP', + 'to' => \Magento\Customer\Model\Customer_FROM_MAP::class, 'from' => ['`field` = ?' => 'customer/customer'], ], [ 'table' => 'table', 'field' => 'field', - 'to' => 'Magento\Customer\Model\Attribute\Data\Postcode', + 'to' => \Magento\Customer\Model\Attribute\Data\Postcode::class, 'from' => ['`field` = ?' => 'customer/attribute_data_postcode'] ], [ @@ -42,14 +42,14 @@ ], 'aliases_map' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_MODEL => [ - 'customer/customer' => 'Magento\Customer\Model\Customer_FROM_MAP', - 'customer/attribute_data_postcode' => 'Magento\Customer\Model\Attribute\Data\Postcode', + 'customer/customer' => \Magento\Customer\Model\Customer_FROM_MAP::class, + 'customer/attribute_data_postcode' => \Magento\Customer\Model\Attribute\Data\Postcode::class, ], ], ], '$aliasesMap' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_MODEL => [ - 'customer/customer' => 'Magento\Customer\Model\Customer_FROM_MAP', + 'customer/customer' => \Magento\Customer\Model\Customer_FROM_MAP::class, ], ] ]; diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_pk_fields.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_pk_fields.php index b2f626cd10592..d4fcd03779d91 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_pk_fields.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_pk_fields.php @@ -22,13 +22,13 @@ [ 'table' => 'table', 'field' => 'collection', - 'to' => 'Magento\Customer\Model\ResourceModel\Attribute\Collection', + 'to' => \Magento\Customer\Model\ResourceModel\Attribute\Collection::class, 'from' => ['`pk_field1` = ?' => 'pk_value1', '`pk_field2` = ?' => 'pk_value2'], ], ], 'aliases_map' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_RESOURCE => [ - 'customer/attribute_collection' => 'Magento\Customer\Model\ResourceModel\Attribute\Collection', + 'customer/attribute_collection' => \Magento\Customer\Model\ResourceModel\Attribute\Collection::class, ], ], ] diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_resource.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_resource.php index e3b2b1d901fcb..abd9e6f277ebb 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_resource.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_plain_resource.php @@ -21,14 +21,14 @@ [ 'table' => 'table', 'field' => 'collection', - 'to' => 'Magento\Customer\Model\ResourceModel\Attribute\Collection', + 'to' => \Magento\Customer\Model\ResourceModel\Attribute\Collection::class, 'from' => ['`collection` = ?' => 'customer/attribute_collection'], ], ], 'where' => ['flag = 1'], 'aliases_map' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_RESOURCE => [ - 'customer/attribute_collection' => 'Magento\Customer\Model\ResourceModel\Attribute\Collection', + 'customer/attribute_collection' => \Magento\Customer\Model\ResourceModel\Attribute\Collection::class, ], ], ] diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_serialized.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_serialized.php index 9afde8cba4737..88b61e9e37671 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_serialized.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_serialized.php @@ -28,7 +28,7 @@ ], 'aliases_map' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_MODEL => [ - 'catalogrule/rule_condition_combine' => 'Magento\CatalogRule\Model\Rule\Condition\Combine', + 'catalogrule/rule_condition_combine' => \Magento\CatalogRule\Model\Rule\Condition\Combine::class, ], ], ] diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_wiki.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_wiki.php index 7a2dcaf62750c..0cce92090ae62 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_wiki.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_wiki.php @@ -35,8 +35,8 @@ ], 'aliases_map' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_BLOCK => [ - 'productalert/product_view' => 'Magento\ProductAlert\Block\Product\View', - 'catalogSearch/result' => 'Magento\CatalogSearch\Block\Result', + 'productalert/product_view' => \Magento\ProductAlert\Block\Product\View::class, + 'catalogSearch/result' => \Magento\CatalogSearch\Block\Result::class, ], ], ] diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_xml.php b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_xml.php index d2ebc3e49f848..5551641f8a38b 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_xml.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Setup/_files/data_content_xml.php @@ -35,8 +35,8 @@ ], 'aliases_map' => [ \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_BLOCK => [ - 'catalog/product_newProduct' => 'Magento\Catalog\Block\Product\NewProduct', - 'catalogSearch/result' => 'Magento\CatalogSearch\Block\Result', + 'catalog/product_newProduct' => \Magento\Catalog\Block\Product\NewProduct::class, + 'catalogSearch/result' => \Magento\CatalogSearch\Block\Result::class, ], ], ] diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php index 8490a735baa25..63b5d54e2e7d4 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php @@ -29,8 +29,8 @@ class SetupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceModel = $this->getMock('\Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->connection = $this->getMockForAbstractClass('\Magento\Framework\DB\Adapter\AdapterInterface'); + $this->resourceModel = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->connection = $this->getMockForAbstractClass(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->resourceModel->expects($this->any()) ->method('getConnection') ->with(self::CONNECTION_NAME) diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php index 486ab36570117..c9ebef011836b 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php @@ -43,11 +43,17 @@ class StatusTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->loader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $this->moduleList = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $this->writer = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); - $this->conflictChecker = $this->getMock('Magento\Framework\Module\ConflictChecker', [], [], '', false); - $this->dependencyChecker = $this->getMock('Magento\Framework\Module\DependencyChecker', [], [], '', false); + $this->loader = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); + $this->moduleList = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $this->writer = $this->getMock(\Magento\Framework\App\DeploymentConfig\Writer::class, [], [], '', false); + $this->conflictChecker = $this->getMock(\Magento\Framework\Module\ConflictChecker::class, [], [], '', false); + $this->dependencyChecker = $this->getMock( + \Magento\Framework\Module\DependencyChecker::class, + [], + [], + '', + false + ); $this->object = new Status( $this->loader, $this->moduleList, diff --git a/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php b/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php index fad23d21c8c81..694d88e63ae47 100644 --- a/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php +++ b/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php @@ -46,7 +46,7 @@ class Proxy extends \Magento\Framework\Mview\Config\Data implements */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Mview\Config\Data', + $instanceName = \Magento\Framework\Mview\Config\Data::class, $shared = true ) { $this->objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/Mview/Config/Reader.php b/lib/internal/Magento/Framework/Mview/Config/Reader.php index ee71d21783408..8870446d30af6 100644 --- a/lib/internal/Magento/Framework/Mview/Config/Reader.php +++ b/lib/internal/Magento/Framework/Mview/Config/Reader.php @@ -31,7 +31,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'mview.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ActionFactoryTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ActionFactoryTest.php index 8fb5e1a664f64..5233e353cce35 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ActionFactoryTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ActionFactoryTest.php @@ -19,7 +19,7 @@ class ActionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Framework\Mview\ActionFactory($this->objectManagerMock); } @@ -45,7 +45,7 @@ public function testGetWithException() public function testGet() { $actionInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ActionInterface', + \Magento\Framework\Mview\ActionInterface::class, [], '', false @@ -55,11 +55,11 @@ public function testGet() )->method( 'get' )->with( - 'Magento\Framework\Mview\ActionInterface' + \Magento\Framework\Mview\ActionInterface::class )->will( $this->returnValue($actionInterfaceMock) ); - $this->model->get('Magento\Framework\Mview\ActionInterface'); - $this->assertInstanceOf('Magento\Framework\Mview\ActionInterface', $actionInterfaceMock); + $this->model->get(\Magento\Framework\Mview\ActionInterface::class); + $this->assertInstanceOf(\Magento\Framework\Mview\ActionInterface::class, $actionInterfaceMock); } } diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/Data/ProxyTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/Data/ProxyTest.php index c439684780ee9..34ebdcca3f136 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/Data/ProxyTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/Data/ProxyTest.php @@ -29,9 +29,9 @@ class ProxyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->dataMock = $this->getMock( - 'Magento\Framework\Mview\Config\Data', [], [], '', false + \Magento\Framework\Mview\Config\Data::class, [], [], '', false ); } @@ -39,15 +39,14 @@ public function testMergeShared() { $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\Mview\Config\Data') + ->with(\Magento\Framework\Mview\Config\Data::class) ->will($this->returnValue($this->dataMock)); $this->dataMock->expects($this->once()) ->method('merge') ->with(['some_config']); $this->model = new Proxy( - $this->objectManagerMock, - 'Magento\Framework\Mview\Config\Data', + $this->objectManagerMock, \Magento\Framework\Mview\Config\Data::class, true ); @@ -58,15 +57,14 @@ public function testMergeNonShared() { $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\Mview\Config\Data') + ->with(\Magento\Framework\Mview\Config\Data::class) ->will($this->returnValue($this->dataMock)); $this->dataMock->expects($this->once()) ->method('merge') ->with(['some_config']); $this->model = new Proxy( - $this->objectManagerMock, - 'Magento\Framework\Mview\Config\Data', + $this->objectManagerMock, \Magento\Framework\Mview\Config\Data::class, false ); @@ -77,7 +75,7 @@ public function testGetShared() { $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\Mview\Config\Data') + ->with(\Magento\Framework\Mview\Config\Data::class) ->will($this->returnValue($this->dataMock)); $this->dataMock->expects($this->once()) ->method('get') @@ -85,8 +83,7 @@ public function testGetShared() ->will($this->returnValue('some_value')); $this->model = new Proxy( - $this->objectManagerMock, - 'Magento\Framework\Mview\Config\Data', + $this->objectManagerMock, \Magento\Framework\Mview\Config\Data::class, true ); @@ -97,7 +94,7 @@ public function testGetNonShared() { $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\Mview\Config\Data') + ->with(\Magento\Framework\Mview\Config\Data::class) ->will($this->returnValue($this->dataMock)); $this->dataMock->expects($this->once()) ->method('get') @@ -105,8 +102,7 @@ public function testGetNonShared() ->will($this->returnValue('some_value')); $this->model = new Proxy( - $this->objectManagerMock, - 'Magento\Framework\Mview\Config\Data', + $this->objectManagerMock, \Magento\Framework\Mview\Config\Data::class, false ); diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php index 664029723fbd6..244b1b1e1382d 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php @@ -39,9 +39,9 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->reader = $this->getMock('Magento\Framework\Mview\Config\Reader', ['read'], [], '', false); + $this->reader = $this->getMock(\Magento\Framework\Mview\Config\Reader::class, ['read'], [], '', false); $this->cache = $this->getMockForAbstractClass( - 'Magento\Framework\Config\CacheInterface', + \Magento\Framework\Config\CacheInterface::class, [], '', false, @@ -50,7 +50,7 @@ protected function setUp() ['test', 'load', 'save'] ); $this->stateCollection = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\State\CollectionInterface', + \Magento\Framework\Mview\View\State\CollectionInterface::class, [], '', false, @@ -91,7 +91,7 @@ public function testConstructorWithoutCache() $this->reader->expects($this->once())->method('read')->will($this->returnValue($this->views)); $stateExistent = $this->getMock( - 'Magento\Framework\Mview\Indexer\State', + \Magento\Framework\Mview\Indexer\State::class, ['getViewId', '__wakeup', 'delete'], [], '', @@ -101,7 +101,7 @@ public function testConstructorWithoutCache() $stateExistent->expects($this->never())->method('delete'); $stateNonexistent = $this->getMock( - 'Magento\Framework\Mview\Indexer\State', + \Magento\Framework\Mview\Indexer\State::class, ['getViewId', '__wakeup', 'delete'], [], '', diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php index 59f33a74804d2..a0f8e377862d0 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php @@ -27,23 +27,23 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_fileResolverMock = $this->getMock( - 'Magento\Framework\App\Config\FileResolver', + \Magento\Framework\App\Config\FileResolver::class, ['get'], [], '', false ); - $this->_converter = $this->getMock('Magento\Framework\Mview\Config\Converter', ['convert']); + $this->_converter = $this->getMock(\Magento\Framework\Mview\Config\Converter::class, ['convert']); - $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolverMock->expects($this->once()) ->method('getRealPath') ->with('urn:magento:framework:Mview/etc/mview.xsd') ->willReturn('test_folder'); $schemaLocator = new \Magento\Framework\Mview\Config\SchemaLocator($urnResolverMock); - $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $validationState = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(false); diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ConfigTest.php index df08de00214e8..52925e4a5a0e2 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ConfigTest.php @@ -24,8 +24,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataMock = $this->getMock( - 'Magento\Framework\Mview\Config\Data', [], [], '', false + $this->dataMock = $this->getMock( + \Magento\Framework\Mview\Config\Data::class, [], [], '', false ); $this->model = new Config( $this->dataMock diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ProcessorTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ProcessorTest.php index 88c65ed082b20..5f6b5be662abc 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ProcessorTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ProcessorTest.php @@ -20,7 +20,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->viewsFactoryMock = $this->getMock( - 'Magento\Framework\Mview\View\CollectionFactory', + \Magento\Framework\Mview\View\CollectionFactory::class, ['create'], [], '', @@ -37,7 +37,7 @@ protected function setUp() */ protected function getViews($method) { - $viewMock = $this->getMock('Magento\Framework\Mview\ViewInterface', [], [], '', false); + $viewMock = $this->getMock(\Magento\Framework\Mview\ViewInterface::class, [], [], '', false); $viewMock->expects($this->exactly(2))->method($method); return [$viewMock, $viewMock]; } @@ -49,7 +49,7 @@ protected function getViews($method) */ protected function getViewsMock() { - $viewsMock = $this->getMock('Magento\Framework\Mview\View\Collection', [], [], '', false); + $viewsMock = $this->getMock(\Magento\Framework\Mview\View\Collection::class, [], [], '', false); $this->viewsFactoryMock->expects($this->once())->method('create')->will($this->returnValue($viewsMock)); return $viewsMock; } diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php index 44c4e47c6cca7..633b015e01430 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php @@ -26,10 +26,10 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $this->resourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -44,10 +44,10 @@ protected function setUp() public function testInstanceOf() { $resourceMock = - $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false, false); + $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false, false); $resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue(true)); $model = new \Magento\Framework\Mview\View\Changelog($resourceMock); - $this->assertInstanceOf('\Magento\Framework\Mview\View\ChangelogInterface', $model); + $this->assertInstanceOf(\Magento\Framework\Mview\View\ChangelogInterface::class, $model); } /** @@ -57,7 +57,7 @@ public function testInstanceOf() public function testCheckConnectionException() { $resourceMock = - $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false, false); + $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false, false); $resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue(null)); $model = new \Magento\Framework\Mview\View\Changelog($resourceMock); $model->setViewId('ViewIdTest'); @@ -168,7 +168,7 @@ public function testCreate() $this->mockIsTableExists($changelogTableName, false); $this->mockGetTableName(); - $tableMock = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false, false); + $tableMock = $this->getMock(\Magento\Framework\DB\Ddl\Table::class, [], [], '', false, false); $tableMock->expects($this->exactly(2)) ->method('addColumn') ->will($this->returnSelf()); @@ -202,7 +202,7 @@ public function testGetList() $this->mockIsTableExists($changelogTableName, true); $this->mockGetTableName(); - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false, false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false, false); $selectMock->expects($this->once()) ->method('distinct') ->with(true) diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/CollectionTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/CollectionTest.php index ad690f9f204d3..d92241871423e 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/CollectionTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/CollectionTest.php @@ -16,27 +16,27 @@ public function testLoadDataAndGetViewsByStateMode() $indexerIdSecond = 'second_indexer_id'; $entityFactory = $this->getMockBuilder( - 'Magento\Framework\Data\Collection\EntityFactoryInterface' + \Magento\Framework\Data\Collection\EntityFactoryInterface::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); - $config = $this->getMockBuilder('Magento\Framework\Mview\ConfigInterface')->getMock(); + $config = $this->getMockBuilder(\Magento\Framework\Mview\ConfigInterface::class)->getMock(); $statesFactory = $this->getMockBuilder( - 'Magento\Framework\Mview\View\State\CollectionFactory' + \Magento\Framework\Mview\View\State\CollectionFactory::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); $states = $this->getMockBuilder( - 'Magento\Framework\Mview\View\State\Collection' + \Magento\Framework\Mview\View\State\Collection::class )->setMethods( ['getItems'] )->disableOriginalConstructor()->getMock(); $state = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\StateInterface', [], '', false, false, true, + \Magento\Framework\Mview\View\StateInterface::class, [], '', false, false, true, ['getViewId', 'getMode', '__wakeup'] ); @@ -51,7 +51,7 @@ public function testLoadDataAndGetViewsByStateMode() ); $view = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ViewInterface', [], '', false, false, true, + \Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, ['load', 'setState', 'getState', '__wakeup'] ); @@ -64,7 +64,7 @@ public function testLoadDataAndGetViewsByStateMode() )->method( 'create' )->with( - 'Magento\Framework\Mview\ViewInterface' + \Magento\Framework\Mview\ViewInterface::class )->will( $this->returnValue($view) ); @@ -82,12 +82,12 @@ public function testLoadDataAndGetViewsByStateMode() $states->expects($this->any())->method('getItems')->will($this->returnValue([$state])); $collection = new \Magento\Framework\Mview\View\Collection($entityFactory, $config, $statesFactory); - $this->assertInstanceOf('Magento\Framework\Mview\View\Collection', $collection->loadData()); + $this->assertInstanceOf(\Magento\Framework\Mview\View\Collection::class, $collection->loadData()); $views = $collection->getViewsByStateMode(\Magento\Framework\Mview\View\StateInterface::MODE_DISABLED); $this->assertCount(2, $views); - $this->assertInstanceOf('Magento\Framework\Mview\ViewInterface', $views[0]); - $this->assertInstanceOf('Magento\Framework\Mview\ViewInterface', $views[1]); + $this->assertInstanceOf(\Magento\Framework\Mview\ViewInterface::class, $views[0]); + $this->assertInstanceOf(\Magento\Framework\Mview\ViewInterface::class, $views[1]); $views = $collection->getViewsByStateMode(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED); $this->assertCount(0, $views); diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionFactoryTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionFactoryTest.php index b1e25c0874882..79d8e8d419e93 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionFactoryTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionFactoryTest.php @@ -24,18 +24,18 @@ class SubscriptionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new SubscriptionFactory($this->objectManagerMock); } public function testCreate() { $subscriptionInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\SubscriptionInterface', [], '', false + \Magento\Framework\Mview\View\SubscriptionInterface::class, [], '', false ); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\Mview\View\SubscriptionInterface', ['some_data']) + ->with(\Magento\Framework\Mview\View\SubscriptionInterface::class, ['some_data']) ->will($this->returnValue($subscriptionInterfaceMock)); $this->assertEquals($subscriptionInterfaceMock, $this->model->create(['some_data'])); } diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php index d8094cfa8d1ac..cd7a236f72359 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php @@ -39,8 +39,15 @@ class SubscriptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false, false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $this->resourceMock = $this->getMock( + \Magento\Framework\App\ResourceConnection::class, + [], + [], + '', + false, + false + ); $this->connectionMock->expects($this->any()) ->method('quoteIdentifier') @@ -50,14 +57,14 @@ protected function setUp() ->method('getConnection') ->willReturn($this->connectionMock); - $this->triggerFactoryMock = $this->getMock( - 'Magento\Framework\DB\Ddl\TriggerFactory', [], [], '', false, false + $this->triggerFactoryMock = $this->getMock( + \Magento\Framework\DB\Ddl\TriggerFactory::class, [], [], '', false, false ); - $this->viewCollectionMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\CollectionInterface', [], '', false, false, true, [] + $this->viewCollectionMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\View\CollectionInterface::class, [], '', false, false, true, [] ); - $this->viewMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ViewInterface', [], '', false, false, true, [] + $this->viewMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, [] ); $this->resourceMock->expects($this->any()) @@ -93,7 +100,7 @@ public function testCreate() { $triggerName = 'trigger_name'; $this->resourceMock->expects($this->atLeastOnce())->method('getTriggerName')->willReturn($triggerName); - $triggerMock = $this->getMockBuilder('Magento\Framework\DB\Ddl\Trigger') + $triggerMock = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Trigger::class) ->disableOriginalConstructor() ->getMock(); $triggerMock->expects($this->exactly(3)) @@ -118,8 +125,8 @@ public function testCreate() ->method('addStatement') ->will($this->returnSelf()); - $changelogMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\ChangelogInterface', [], '', false, false, true, [] + $changelogMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\View\ChangelogInterface::class, [], '', false, false, true, [] ); $changelogMock->expects($this->exactly(3)) ->method('getName') @@ -136,8 +143,8 @@ public function testCreate() ->method('create') ->will($this->returnValue($triggerMock)); - $otherChangelogMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\ChangelogInterface', [], '', false, false, true, [] + $otherChangelogMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\View\ChangelogInterface::class, [], '', false, false, true, [] ); $otherChangelogMock->expects($this->exactly(3)) ->method('getName') @@ -146,8 +153,8 @@ public function testCreate() ->method('getColumnName') ->will($this->returnValue('entity_id')); - $otherViewMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ViewInterface', [], '', false, false, true, [] + $otherViewMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, [] ); $otherViewMock->expects($this->exactly(1)) ->method('getId') @@ -183,7 +190,7 @@ public function testCreate() public function testRemove() { - $triggerMock = $this->getMock('Magento\Framework\DB\Ddl\Trigger', [], [], '', false, false); + $triggerMock = $this->getMock(\Magento\Framework\DB\Ddl\Trigger::class, [], [], '', false, false); $triggerMock->expects($this->exactly(3)) ->method('setName') ->will($this->returnSelf()); @@ -209,8 +216,8 @@ public function testRemove() ->method('create') ->will($this->returnValue($triggerMock)); - $otherChangelogMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\View\ChangelogInterface', [], '', false, false, true, [] + $otherChangelogMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\View\ChangelogInterface::class, [], '', false, false, true, [] ); $otherChangelogMock->expects($this->exactly(3)) ->method('getName') @@ -219,8 +226,8 @@ public function testRemove() ->method('getColumnName') ->will($this->returnValue('entity_id')); - $otherViewMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ViewInterface', [], '', false, false, true, [] + $otherViewMock = $this->getMockForAbstractClass( + \Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, [] ); $otherViewMock->expects($this->exactly(1)) ->method('getId') diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php index fdc3e5e34c264..91748455a02a7 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php @@ -42,7 +42,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ConfigInterface', + \Magento\Framework\Mview\ConfigInterface::class, [], '', false, @@ -51,14 +51,14 @@ protected function setUp() ['getView'] ); $this->actionFactoryMock = $this->getMock( - 'Magento\Framework\Mview\ActionFactory', + \Magento\Framework\Mview\ActionFactory::class, ['get'], [], '', false ); $this->stateMock = $this->getMock( - 'Magento\Indexer\Model\Mview\View\State', + \Magento\Indexer\Model\Mview\View\State::class, ['getViewId', 'loadByView', 'getVersionId', @@ -76,14 +76,14 @@ protected function setUp() false ); $this->changelogMock = $this->getMock( - 'Magento\Framework\Mview\View\Changelog', + \Magento\Framework\Mview\View\Changelog::class, ['getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList', 'clear'], [], '', false ); $this->subscriptionFactoryMock = $this->getMock( - 'Magento\Framework\Mview\View\SubscriptionFactory', + \Magento\Framework\Mview\View\SubscriptionFactory::class, ['create'], [], '', @@ -128,7 +128,7 @@ public function testLoad() )->will( $this->returnValue($this->getViewData()) ); - $this->assertInstanceOf('Magento\Framework\Mview\View', $this->model->load($viewId)); + $this->assertInstanceOf(\Magento\Framework\Mview\View::class, $this->model->load($viewId)); } /** @@ -162,7 +162,7 @@ public function testSubscribe() $this->changelogMock->expects($this->once()) ->method('create'); $subscriptionMock = $this->getMock( - 'Magento\Framework\Mview\View\Subscription', + \Magento\Framework\Mview\View\Subscription::class, ['create'], [], '', @@ -277,7 +277,7 @@ public function testUnsubscribeWithException() ->will($this->returnValue(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED)); $subscriptionMock = $this->getMock( - 'Magento\Framework\Mview\View\Subscription', + \Magento\Framework\Mview\View\Subscription::class, ['remove'], [], '', @@ -343,7 +343,7 @@ public function testUpdate() $this->returnValue($listId) ); - $actionMock = $this->getMock('Magento\Framework\Mview\Action', ['execute'], [], '', false); + $actionMock = $this->getMock(\Magento\Framework\Mview\ActionInterface::class, ['execute'], [], '', false); $actionMock->expects($this->once())->method('execute')->with($listId)->will($this->returnSelf()); $this->actionFactoryMock->expects( $this->once() @@ -407,7 +407,7 @@ public function testUpdateWithException() $this->returnValue($listId) ); - $actionMock = $this->getMock('Magento\Framework\Mview\Action', ['execute'], [], '', false); + $actionMock = $this->getMock(\Magento\Framework\Mview\ActionInterface::class, ['execute'], [], '', false); $actionMock->expects($this->once())->method('execute')->with($listId)->will( $this->returnCallback( function () { diff --git a/lib/internal/Magento/Framework/Mview/View/Collection.php b/lib/internal/Magento/Framework/Mview/View/Collection.php index 4720e05e0b1b9..adcee84c02773 100644 --- a/lib/internal/Magento/Framework/Mview/View/Collection.php +++ b/lib/internal/Magento/Framework/Mview/View/Collection.php @@ -12,7 +12,7 @@ class Collection extends \Magento\Framework\Data\Collection implements Collectio * * @var string */ - protected $_itemObjectClass = 'Magento\Framework\Mview\ViewInterface'; + protected $_itemObjectClass = \Magento\Framework\Mview\ViewInterface::class; /** * @var \Magento\Framework\Mview\ConfigInterface diff --git a/lib/internal/Magento/Framework/Mview/View/CollectionFactory.php b/lib/internal/Magento/Framework/Mview/View/CollectionFactory.php index fce9fc043c763..0106de090f303 100644 --- a/lib/internal/Magento/Framework/Mview/View/CollectionFactory.php +++ b/lib/internal/Magento/Framework/Mview/View/CollectionFactory.php @@ -10,5 +10,5 @@ class CollectionFactory extends AbstractFactory /** * Instance name */ - const INSTANCE_NAME = 'Magento\Framework\Mview\View\CollectionInterface'; + const INSTANCE_NAME = \Magento\Framework\Mview\View\CollectionInterface::class; } diff --git a/lib/internal/Magento/Framework/Mview/View/State/CollectionFactory.php b/lib/internal/Magento/Framework/Mview/View/State/CollectionFactory.php index 2fe3e44361aa2..69b44d305f813 100644 --- a/lib/internal/Magento/Framework/Mview/View/State/CollectionFactory.php +++ b/lib/internal/Magento/Framework/Mview/View/State/CollectionFactory.php @@ -10,5 +10,5 @@ class CollectionFactory extends \Magento\Framework\Mview\View\AbstractFactory /** * Instance name */ - const INSTANCE_NAME = 'Magento\Framework\Mview\View\State\CollectionInterface'; + const INSTANCE_NAME = \Magento\Framework\Mview\View\State\CollectionInterface::class; } diff --git a/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierListTest.php b/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierListTest.php index 53b0273abe759..0c38b552a632a 100644 --- a/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierListTest.php +++ b/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierListTest.php @@ -18,16 +18,16 @@ class NotifierListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); } public function testAsArraySuccess() { - $notifier1 = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierPool'); - $notifier2 = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierPool'); + $notifier1 = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierPool::class); + $notifier2 = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierPool::class); $notifierList = $this->objectManagerHelper->getObject( - 'Magento\Framework\Notification\NotifierList', + \Magento\Framework\Notification\NotifierList::class, [ 'objectManager' => $this->objectManager, 'notifiers' => [$notifier1, $notifier2] @@ -36,16 +36,16 @@ public function testAsArraySuccess() $this->setExpectedException('InvalidArgumentException'); $result = $notifierList->asArray(); foreach ($result as $notifier) { - $this->assertInstanceOf('Magento\Framework\Notification\NotifierInterface', $notifier); + $this->assertInstanceOf(\Magento\Framework\Notification\NotifierInterface::class, $notifier); } } public function testAsArrayException() { - $notifierCorrect = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierPool'); - $notifierIncorrect = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierList'); + $notifierCorrect = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierPool::class); + $notifierIncorrect = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierList::class); $notifierList = $this->objectManagerHelper->getObject( - 'Magento\Framework\Notification\NotifierList', + \Magento\Framework\Notification\NotifierList::class, [ 'objectManager' => $this->objectManager, 'notifiers' => [$notifierCorrect, $notifierIncorrect] diff --git a/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierPoolTest.php b/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierPoolTest.php index c7a1a253ec264..8e1dabcf077a9 100644 --- a/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierPoolTest.php +++ b/lib/internal/Magento/Framework/Notification/Test/Unit/NotifierPoolTest.php @@ -27,13 +27,13 @@ class NotifierPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $notifier1 = $this->getMock('Magento\Framework\Notification\NotifierPool', [], [], '', false); - $notifier2 = $this->getMock('Magento\Framework\Notification\NotifierPool', [], [], '', false); + $notifier1 = $this->getMock(\Magento\Framework\Notification\NotifierPool::class, [], [], '', false); + $notifier2 = $this->getMock(\Magento\Framework\Notification\NotifierPool::class, [], [], '', false); $this->notifiers = [$notifier1, $notifier2]; - $this->notifierList = $this->getMock('Magento\Framework\Notification\NotifierList', [], [], '', false); + $this->notifierList = $this->getMock(\Magento\Framework\Notification\NotifierList::class, [], [], '', false); $this->notifierList->expects($this->any())->method('asArray')->will($this->returnValue($this->notifiers)); $this->notifierPool = $this->objectManagerHelper->getObject( - 'Magento\Framework\Notification\NotifierPool', + \Magento\Framework\Notification\NotifierPool::class, [ 'notifierList' => $this->notifierList ] diff --git a/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php b/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php index da487e77a5124..59a20773f2f6d 100644 --- a/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php +++ b/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php @@ -24,7 +24,7 @@ protected function setUp() { $this->oauthRequestHelper = new \Magento\Framework\Oauth\Helper\Request(); $this->response = $this->getMock( - 'Magento\Framework\HTTP\PhpEnvironment\Response', + \Magento\Framework\HTTP\PhpEnvironment\Response::class, ['setHttpResponseCode'], [], '', @@ -90,7 +90,7 @@ public function dataProviderForPrepareErrorResponseTest() public function testGetRequestUrl($url, $host) { $httpRequestMock = $this->getMock( - 'Magento\Framework\App\Request\Http', + \Magento\Framework\App\Request\Http::class, ['getHttpHost', 'getScheme', 'getRequestUri'], [], '', diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php index bc57bd30765f8..cb453ef2cd4c5 100644 --- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php +++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php @@ -29,8 +29,8 @@ class CompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->rendererOne = $this->getMock('Magento\Framework\Phrase\RendererInterface'); - $this->rendererTwo = $this->getMock('Magento\Framework\Phrase\RendererInterface'); + $this->rendererOne = $this->getMock(\Magento\Framework\Phrase\RendererInterface::class); + $this->rendererTwo = $this->getMock(\Magento\Framework\Phrase\RendererInterface::class); $this->object = new \Magento\Framework\Phrase\Renderer\Composite([$this->rendererOne, $this->rendererTwo]); } diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php index 9fcf029c18bb9..82aed1744d2f6 100644 --- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php +++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php @@ -29,9 +29,15 @@ class InlineTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->translator = $this->getMock('Magento\Framework\TranslateInterface', [], [], '', false); - $this->provider = $this->getMock('Magento\Framework\Translate\Inline\ProviderInterface', [], [], '', false); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->translator = $this->getMock(\Magento\Framework\TranslateInterface::class, [], [], '', false); + $this->provider = $this->getMock( + \Magento\Framework\Translate\Inline\ProviderInterface::class, + [], + [], + '', + false + ); + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); $this->renderer = new \Magento\Framework\Phrase\Renderer\Inline( @@ -51,7 +57,7 @@ public function testRenderIfInlineTranslationIsAllowed() ->method('getTheme') ->will($this->returnValue($theme)); - $inlineTranslate = $this->getMock('Magento\Framework\Translate\InlineInterface', [], [], '', []); + $inlineTranslate = $this->getMock(\Magento\Framework\Translate\InlineInterface::class, [], [], '', []); $inlineTranslate->expects($this->once()) ->method('isAllowed') ->will($this->returnValue(true)); @@ -67,7 +73,7 @@ public function testRenderIfInlineTranslationIsNotAllowed() { $text = 'test'; - $inlineTranslate = $this->getMock('Magento\Framework\Translate\InlineInterface', [], [], '', []); + $inlineTranslate = $this->getMock(\Magento\Framework\Translate\InlineInterface::class, [], [], '', []); $inlineTranslate->expects($this->once()) ->method('isAllowed') ->will($this->returnValue(false)); diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/PlaceholderTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/PlaceholderTest.php index 37d5344951065..6239b3db01ce0 100644 --- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/PlaceholderTest.php +++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/PlaceholderTest.php @@ -15,7 +15,7 @@ class PlaceholderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_renderer = $objectManager->getObject('Magento\Framework\Phrase\Renderer\Placeholder'); + $this->_renderer = $objectManager->getObject(\Magento\Framework\Phrase\Renderer\Placeholder::class); } /** diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php index 0d22caa58d917..5200dd14b0027 100644 --- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php +++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php @@ -24,13 +24,13 @@ class TranslateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_translator = $this->getMock('Magento\Framework\TranslateInterface', [], [], '', false); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->_translator = $this->getMock(\Magento\Framework\TranslateInterface::class, [], [], '', false); + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_renderer = $objectManagerHelper->getObject( - 'Magento\Framework\Phrase\Renderer\Translate', + \Magento\Framework\Phrase\Renderer\Translate::class, [ 'translator' => $this->_translator, 'logger' => $this->loggerMock diff --git a/lib/internal/Magento/Framework/Pricing/Amount/AmountFactory.php b/lib/internal/Magento/Framework/Pricing/Amount/AmountFactory.php index bf7b689aa6b78..29036169c3883 100644 --- a/lib/internal/Magento/Framework/Pricing/Amount/AmountFactory.php +++ b/lib/internal/Magento/Framework/Pricing/Amount/AmountFactory.php @@ -14,7 +14,7 @@ class AmountFactory /** * Default amount class */ - const DEFAULT_PRICE_AMOUNT_CLASS = 'Magento\Framework\Pricing\Amount\AmountInterface'; + const DEFAULT_PRICE_AMOUNT_CLASS = \Magento\Framework\Pricing\Amount\AmountInterface::class; /** * @var \Magento\Framework\ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/Pricing/Render/RendererPool.php b/lib/internal/Magento/Framework/Pricing/Render/RendererPool.php index 7d52edbd1c4ce..8f3c117baa722 100644 --- a/lib/internal/Magento/Framework/Pricing/Render/RendererPool.php +++ b/lib/internal/Magento/Framework/Pricing/Render/RendererPool.php @@ -26,12 +26,12 @@ class RendererPool extends AbstractBlock /** * Default price renderer */ - const PRICE_RENDERER_DEFAULT = 'Magento\Framework\Pricing\Render\PriceBox'; + const PRICE_RENDERER_DEFAULT = \Magento\Framework\Pricing\Render\PriceBox::class; /** * Default amount renderer */ - const AMOUNT_RENDERER_DEFAULT = 'Magento\Framework\Pricing\Render\Amount'; + const AMOUNT_RENDERER_DEFAULT = \Magento\Framework\Pricing\Render\Amount::class; /** * Create amount renderer diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CalculatorTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CalculatorTest.php index 001e829a75385..55f68f47407f5 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CalculatorTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CalculatorTest.php @@ -23,7 +23,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->amountFactoryMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\AmountFactory') + $this->amountFactoryMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\AmountFactory::class) ->disableOriginalConstructor() ->getMock(); $this->model = new \Magento\Framework\Pricing\Adjustment\Calculator($this->amountFactoryMock); @@ -52,7 +52,7 @@ public function testGetAmount() $taxAdjustmentCode => $taxAdjustment, ]; - $amountBaseMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $amountBaseMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); $this->amountFactoryMock->expects($this->once()) @@ -60,12 +60,12 @@ public function testGetAmount() ->with($this->equalTo($totalAmount), $this->equalTo($expectedAdjustments)) ->will($this->returnValue($amountBaseMock)); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['getPriceInfo', '__wakeup']) ->getMock(); - $weeeAdjustmentMock = $this->getMockBuilder('Magento\Weee\Pricing\Adjustment') + $weeeAdjustmentMock = $this->getMockBuilder(\Magento\Weee\Pricing\Adjustment::class) ->disableOriginalConstructor() ->getMock(); $weeeAdjustmentMock->expects($this->once()) @@ -82,7 +82,7 @@ public function testGetAmount() ->with($this->equalTo($amountInclTax), $this->equalTo($productMock)) ->will($this->returnValue($weeeAdjustment + $amountInclTax)); - $taxAdjustmentMock = $this->getMockBuilder('Magento\Tax\Pricing\Adjustment') + $taxAdjustmentMock = $this->getMockBuilder(\Magento\Tax\Pricing\Adjustment::class) ->disableOriginalConstructor() ->getMock(); $taxAdjustmentMock->expects($this->once()) @@ -103,7 +103,7 @@ public function testGetAmount() ->method('isIncludedInDisplayPrice'); $adjustments = [$weeeAdjustmentMock, $taxAdjustmentMock]; - $priceInfoMock = $this->getMockBuilder('\Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->any()) @@ -115,7 +115,7 @@ public function testGetAmount() ->will($this->returnValue($priceInfoMock)); $result = $this->model->getAmount($amountInclTax, $productMock); - $this->assertInstanceOf('Magento\Framework\Pricing\Amount\AmountInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Pricing\Amount\AmountInterface::class, $result); } public function testGetAmountExclude() @@ -127,12 +127,12 @@ public function testGetAmountExclude() $adjustment = 5; $expectedAdjustments = []; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['getPriceInfo', '__wakeup']) ->getMock(); - $taxAdjustmentMock = $this->getMockBuilder('Magento\Tax\Pricing\Adjustment') + $taxAdjustmentMock = $this->getMockBuilder(\Magento\Tax\Pricing\Adjustment::class) ->disableOriginalConstructor() ->getMock(); $taxAdjustmentMock->expects($this->once()) @@ -150,7 +150,7 @@ public function testGetAmountExclude() ->with($this->equalTo($fullamount), $this->equalTo($productMock)) ->will($this->returnValue($amount)); - $weeeAdjustmentMock = $this->getMockBuilder('Magento\Weee\Pricing\Adjustment') + $weeeAdjustmentMock = $this->getMockBuilder(\Magento\Weee\Pricing\Adjustment::class) ->disableOriginalConstructor() ->getMock(); $weeeAdjustmentMock->expects($this->once()) @@ -168,7 +168,7 @@ public function testGetAmountExclude() $adjustments = [$taxAdjustmentMock, $weeeAdjustmentMock]; - $priceInfoMock = $this->getMockBuilder('\Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->any()) @@ -179,7 +179,7 @@ public function testGetAmountExclude() ->method('getPriceInfo') ->will($this->returnValue($priceInfoMock)); - $amountBaseMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $amountBaseMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); @@ -188,6 +188,6 @@ public function testGetAmountExclude() ->with($this->equalTo($amount), $this->equalTo($expectedAdjustments)) ->will($this->returnValue($amountBaseMock)); $result = $this->model->getAmount($amount, $productMock, true); - $this->assertInstanceOf('Magento\Framework\Pricing\Amount\AmountInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Pricing\Amount\AmountInterface::class, $result); } } diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php index 94999c8e302cc..a156104b57388 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php @@ -21,19 +21,19 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $adj1 = $this->getMock('Magento\Framework\Pricing\Adjustment\AdjustmentInterface'); + $adj1 = $this->getMock(\Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class); $adj1->expects($this->any()) ->method('getSortOrder') ->will($this->returnValue(10)); - $adj2 = $this->getMock('Magento\Framework\Pricing\Adjustment\AdjustmentInterface'); + $adj2 = $this->getMock(\Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class); $adj2->expects($this->any()) ->method('getSortOrder') ->will($this->returnValue(20)); - $adj3 = $this->getMock('Magento\Framework\Pricing\Adjustment\AdjustmentInterface'); + $adj3 = $this->getMock(\Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class); $adj3->expects($this->any()) ->method('getSortOrder') ->will($this->returnValue(5)); - $adj4 = $this->getMock('Magento\Framework\Pricing\Adjustment\AdjustmentInterface'); + $adj4 = $this->getMock(\Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class); $adj4->expects($this->any()) ->method('getSortOrder') ->will($this->returnValue(\Magento\Framework\Pricing\Adjustment\Pool::DEFAULT_SORT_ORDER)); @@ -46,7 +46,7 @@ protected function setUp() ]; /** @var \Magento\Framework\Pricing\Adjustment\Pool|\PHPUnit_Framework_MockObject_MockObject $adjustmentPool */ - $adjustmentPool = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\Pool') + $adjustmentPool = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\Pool::class) ->disableOriginalConstructor() ->setMethods(['getAdjustmentByCode']) ->getMock(); diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/FactoryTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/FactoryTest.php index 0b3bd26c2b026..3d73fe6f3a9b2 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/FactoryTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/FactoryTest.php @@ -22,7 +22,7 @@ protected function setUp() public function testCreate() { - $adjustmentInterface = 'Magento\Framework\Pricing\Adjustment\AdjustmentInterface'; + $adjustmentInterface = \Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class; $adjustmentFactory = $this->prepareAdjustmentFactory($adjustmentInterface); $this->assertInstanceOf( @@ -38,7 +38,7 @@ public function testCreate() protected function prepareAdjustmentFactory($adjustmentInterface) { return $this->objectManager->getObject( - 'Magento\Framework\Pricing\Adjustment\Factory', + \Magento\Framework\Pricing\Adjustment\Factory::class, ['objectManager' => $this->prepareObjectManager($adjustmentInterface)] ); } @@ -50,7 +50,7 @@ protected function prepareAdjustmentFactory($adjustmentInterface) protected function prepareObjectManager($adjustmentInterface) { $objectManager = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -67,7 +67,7 @@ protected function prepareObjectManager($adjustmentInterface) */ public function testCreateWithException() { - $invalidAdjustmentInterface = 'Magento\Framework\DataObject'; + $invalidAdjustmentInterface = \Magento\Framework\DataObject::class; $adjustmentFactory = $this->prepareAdjustmentFactory($invalidAdjustmentInterface); $adjustmentFactory->create($invalidAdjustmentInterface); } diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php index 326e65cdd682e..1e07ae93236ee 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php @@ -25,7 +25,7 @@ protected function setUp() ]; /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $adjustmentFactory */ - $adjustmentFactory = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\Factory') + $adjustmentFactory = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Amount/AmountFactoryTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Amount/AmountFactoryTest.php index 07fcf2803cc4a..7d8c97ecd460e 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Amount/AmountFactoryTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Amount/AmountFactoryTest.php @@ -31,8 +31,8 @@ class AmountFactoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); - $this->amountMock = $this->getMock('Magento\Framework\Pricing\Amount\Base', [], [], '', false); + $this->objectManagerMock = $this->getMock(\Magento\Framework\App\ObjectManager::class, [], [], '', false); + $this->amountMock = $this->getMock(\Magento\Framework\Pricing\Amount\Base::class, [], [], '', false); $this->factory = new \Magento\Framework\Pricing\Amount\AmountFactory($this->objectManagerMock); } @@ -44,7 +44,7 @@ public function testCreate() $this->objectManagerMock->expects($this->once()) ->method('create') ->with( - $this->equalTo('Magento\Framework\Pricing\Amount\AmountInterface'), + $this->equalTo(\Magento\Framework\Pricing\Amount\AmountInterface::class), $this->equalTo( [ 'amount' => 'this-is-float-amount', @@ -69,7 +69,7 @@ public function testCreateException() $this->objectManagerMock->expects($this->once()) ->method('create') ->with( - $this->equalTo('Magento\Framework\Pricing\Amount\AmountInterface'), + $this->equalTo(\Magento\Framework\Pricing\Amount\AmountInterface::class), $this->equalTo( [ 'amount' => 'this-is-float-amount', diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php index adad07741ecec..328735ef8f57f 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php @@ -22,7 +22,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCurrencyMock = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } @@ -101,6 +101,6 @@ public function currencyByStoreDataProvider() */ private function getHelper($arguments) { - return $this->objectManager->getObject('Magento\Framework\Pricing\Helper\Data', $arguments); + return $this->objectManager->getObject(\Magento\Framework\Pricing\Helper\Data::class, $arguments); } } diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/AbstractPriceTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/AbstractPriceTest.php index 5d7b93a5bb716..c1a95ec2cea87 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/AbstractPriceTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/AbstractPriceTest.php @@ -23,11 +23,6 @@ class AbstractPriceTest extends \PHPUnit_Framework_TestCase */ protected $priceInfoMock; - /** - * @var \Magento\Framework\Pricing\Amount\Base |\PHPUnit_Framework_MockObject_MockObject - */ - protected $amountMock; - /** * @var \Magento\Framework\Pricing\SaleableInterface |\PHPUnit_Framework_MockObject_MockObject */ @@ -49,20 +44,25 @@ class AbstractPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $qty = 1; - $this->saleableItemMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->priceInfoMock = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); - $this->amountMock = $this->getMock('Magento\Framework\Pricing\Amount', [], [], '', false); - $this->calculatorMock = $this->getMock('Magento\Framework\Pricing\Adjustment\Calculator', [], [], '', false); + $this->saleableItemMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->calculatorMock = $this->getMock( + \Magento\Framework\Pricing\Adjustment\Calculator::class, + [], + [], + '', + false + ); $this->saleableItemMock->expects($this->once()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->price = $objectManager->getObject( - 'Magento\Framework\Pricing\Test\Unit\Price\Stub', + \Magento\Framework\Pricing\Test\Unit\Price\Stub::class, [ 'saleableItem' => $this->saleableItemMock, 'quantity' => $qty, diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/CollectionTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/CollectionTest.php index 597c48c2200fb..d81071cbfc58a 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/CollectionTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/CollectionTest.php @@ -56,9 +56,9 @@ protected function setUp() ] ); - $this->saleableItemMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\SaleableInterface'); - $this->priceMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\Price\PriceInterface'); - $this->factoryMock = $this->getMock('Magento\Framework\Pricing\Price\Factory', [], [], '', false); + $this->saleableItemMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $this->priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class); + $this->factoryMock = $this->getMock(\Magento\Framework\Pricing\Price\Factory::class, [], [], '', false); $this->collection = new Collection( $this->saleableItemMock, diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/FactoryTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/FactoryTest.php index 9945c103cedd2..d3d0fcccbe29a 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/FactoryTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Price/FactoryTest.php @@ -25,20 +25,21 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Pricing\Price\Factory', [ - 'objectManager' => $this->objectManagerMock - ]); + $this->model = $objectManager->getObject( + \Magento\Framework\Pricing\Price\Factory::class, + ['objectManager' => $this->objectManagerMock] + ); } public function testCreate() { $quantity = 2.2; - $className = 'Magento\Framework\Pricing\Price\PriceInterface'; + $className = \Magento\Framework\Pricing\Price\PriceInterface::class; $priceMock = $this->getMock($className); - $saleableItem = $this->getMock('Magento\Framework\Pricing\SaleableInterface'); + $saleableItem = $this->getMock(\Magento\Framework\Pricing\SaleableInterface::class); $arguments = []; $argumentsResult = array_merge($arguments, ['saleableItem' => $saleableItem, 'quantity' => $quantity]); @@ -60,9 +61,9 @@ public function testCreate() public function testCreateWithException() { $quantity = 2.2; - $className = 'Magento\Framework\Pricing\PriceInfo\Base'; + $className = \Magento\Framework\Pricing\PriceInfo\Base::class; $priceMock = $this->getMockBuilder($className)->disableOriginalConstructor()->getMock(); - $saleableItem = $this->getMock('Magento\Framework\Pricing\SaleableInterface'); + $saleableItem = $this->getMock(\Magento\Framework\Pricing\SaleableInterface::class); $arguments = []; $argumentsResult = array_merge($arguments, ['saleableItem' => $saleableItem, 'quantity' => $quantity]); diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/BaseTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/BaseTest.php index 37e48144ea334..5a17106b1bb0c 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/BaseTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/BaseTest.php @@ -30,9 +30,9 @@ class BaseTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCollection = $this->getMock('Magento\Framework\Pricing\Price\Collection', [], [], '', false); + $this->priceCollection = $this->getMock(\Magento\Framework\Pricing\Price\Collection::class, [], [], '', false); $this->adjustmentCollection = $this->getMock( - 'Magento\Framework\Pricing\Adjustment\Collection', + \Magento\Framework\Pricing\Adjustment\Collection::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php index 5621162ff2cbd..ecfa6072b31ae 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php @@ -48,21 +48,21 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false ); $this->pricesMock = $this->getMock( - 'Magento\Framework\Pricing\Price\Collection', + \Magento\Framework\Pricing\Price\Collection::class, [], [], '', false ); $this->saleableItemMock = $this->getMockForAbstractClass( - 'Magento\Framework\Pricing\SaleableInterface', + \Magento\Framework\Pricing\SaleableInterface::class, [], '', false, @@ -71,7 +71,7 @@ protected function setUp() ['getQty'] ); $this->priceInfoMock = $this->getMockForAbstractClass( - 'Magento\Framework\Pricing\PriceInfoInterface', + \Magento\Framework\Pricing\PriceInfoInterface::class, [], '', false, diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AbstractAdjustmentTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AbstractAdjustmentTest.php index 85c82df62dc66..c2b5937b665b5 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AbstractAdjustmentTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AbstractAdjustmentTest.php @@ -29,18 +29,18 @@ class AbstractAdjustmentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCurrency = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrency = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->data = ['argument_one' => 1]; $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $constructorArgs = $objectManager->getConstructArguments( - 'Magento\Framework\Pricing\Render\AbstractAdjustment', + \Magento\Framework\Pricing\Render\AbstractAdjustment::class, [ 'priceCurrency' => $this->priceCurrency, 'data' => $this->data ] ); - $this->model = $this->getMockBuilder('Magento\Framework\Pricing\Render\AbstractAdjustment') + $this->model = $this->getMockBuilder(\Magento\Framework\Pricing\Render\AbstractAdjustment::class) ->setConstructorArgs($constructorArgs) ->setMethods(['getData', 'setData', 'apply']) ->getMockForAbstractClass(); @@ -64,7 +64,7 @@ public function testConvertAndFormatCurrency() public function testRender() { - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', [], [], '', false); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, [], [], '', false); $arguments = ['argument_two' => 2]; $mergedArguments = ['argument_one' => 1, 'argument_two' => 2]; $renderText = 'amount data'; @@ -88,7 +88,7 @@ public function testRender() public function testGetAmountRender() { - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', [], [], '', false); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, [], [], '', false); $this->model->expects($this->at(0)) ->method('getData') ->will($this->returnValue($this->data)); @@ -98,10 +98,10 @@ public function testGetAmountRender() public function testGetPriceType() { - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', [], [], '', false); - $price = $this->getMockForAbstractClass('Magento\Framework\Pricing\Price\PriceInterface'); - $sealableItem = $this->getMockForAbstractClass('Magento\Framework\Pricing\SaleableInterface'); - $priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, [], [], '', false); + $price = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class); + $sealableItem = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); $priceCode = 'regular_price'; $amountRender->expects($this->once()) @@ -125,7 +125,7 @@ public function testGetPriceType() public function testGetPrice() { $price = 100; - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', [], [], '', false); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, [], [], '', false); $amountRender->expects($this->once()) ->method('getPrice') ->with() @@ -140,8 +140,8 @@ public function testGetPrice() public function testGetSealableItem() { - $sealableItem = $this->getMockForAbstractClass('Magento\Framework\Pricing\SaleableInterface'); - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', [], [], '', false); + $sealableItem = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, [], [], '', false); $amountRender->expects($this->once()) ->method('getSaleableItem') ->with() @@ -156,10 +156,10 @@ public function testGetSealableItem() public function testGetAdjustment() { - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', [], [], '', false); - $adjustment = $this->getMockForAbstractClass('Magento\Framework\Pricing\Adjustment\AdjustmentInterface'); - $sealableItem = $this->getMockForAbstractClass('Magento\Framework\Pricing\SaleableInterface'); - $priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, [], [], '', false); + $adjustment = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class); + $sealableItem = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); $adjustmentCode = 'tax'; $amountRender->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php index fa5581f2988d1..b6a0c1e8f6b0f 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php @@ -12,6 +12,8 @@ /** * Test class for \Magento\Framework\Pricing\Render\Amount + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AmountTest extends \PHPUnit_Framework_TestCase { @@ -52,13 +54,13 @@ class AmountTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCurrency = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrency = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $data = [ 'default' => [ 'adjustments' => [ 'base_price_test' => [ 'tax' => [ - 'adjustment_render_class' => 'Magento\Framework\View\Element\Template', + 'adjustment_render_class' => \Magento\Framework\View\Element\Template::class, 'adjustment_render_template' => 'template.phtml', ], ], @@ -67,7 +69,7 @@ protected function setUp() ]; $this->rendererPool = $this->getMock( - 'Magento\Framework\Pricing\Render\RendererPool', + \Magento\Framework\Pricing\Render\RendererPool::class, [], ['data' => $data], '', @@ -75,21 +77,17 @@ protected function setUp() false ); - $this->layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); - $this->saleableItemMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\SaleableInterface'); - $this->priceMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\Price\PriceInterface'); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->amount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); + $this->saleableItemMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $this->priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class); - $eventManager = $this->getMock('Magento\Framework\Event\Test\Unit\ManagerStub', [], [], '', false); - $config = $this->getMock('Magento\Store\Model\Store\Config', [], [], '', false); - $scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\Test\Unit\ManagerStub::class, [], [], '', false); + $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any()) ->method('getEventManager') ->will($this->returnValue($eventManager)); - $context->expects($this->any()) - ->method('getStoreConfig') - ->will($this->returnValue($config)); $context->expects($this->any()) ->method('getLayout') ->will($this->returnValue($this->layout)); @@ -99,7 +97,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Framework\Pricing\Render\Amount', + \Magento\Framework\Pricing\Render\Amount::class, [ 'context' => $context, 'priceCurrency' => $this->priceCurrency, @@ -286,7 +284,7 @@ public function testAdjustmentsHtml() protected function getAdjustmentRenderMock($data = [], $html = '', $code = 'adjustment_code') { $adjustmentRender = $this->getMockForAbstractClass( - 'Magento\Framework\Pricing\Render\AdjustmentRenderInterface' + \Magento\Framework\Pricing\Render\AdjustmentRenderInterface::class ); $adjustmentRender->expects($this->once()) ->method('render') diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/LayoutTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/LayoutTest.php index 3b61c6ed2b1ec..3673261857947 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/LayoutTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/LayoutTest.php @@ -34,14 +34,14 @@ class LayoutTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layout = $this->getMock('Magento\Framework\View\LayoutInterface'); - $this->generalLayout = $this->getMock('Magento\Framework\View\LayoutInterface'); + $this->layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $this->generalLayout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); $isCacheable = false; $this->generalLayout->expects($this->once()) ->method('isCacheable') ->will($this->returnValue(false)); - $layoutFactory = $this->getMockBuilder('Magento\Framework\View\LayoutFactory') + $layoutFactory = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -52,7 +52,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Framework\Pricing\Render\Layout', + \Magento\Framework\Pricing\Render\Layout::class, [ 'layoutFactory' => $layoutFactory, 'generalLayout' => $this->generalLayout @@ -64,7 +64,7 @@ public function testAddHandle() { $handle = 'test_handle'; - $layoutProcessor = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface'); + $layoutProcessor = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class); $layoutProcessor->expects($this->once()) ->method('addHandle') ->with($handle); @@ -77,7 +77,7 @@ public function testAddHandle() public function testLoadLayout() { - $layoutProcessor = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface'); + $layoutProcessor = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class); $layoutProcessor->expects($this->once()) ->method('load'); $this->layout->expects($this->once()) @@ -97,7 +97,7 @@ public function testGetBlock() { $blockName = 'block.name'; - $block = $this->getMock('Magento\Framework\View\Element\BlockInterface'); + $block = $this->getMock(\Magento\Framework\View\Element\BlockInterface::class); $this->layout->expects($this->once()) ->method('getBlock') diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php index 70a53e1882840..86e2dde6359d8 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php @@ -9,6 +9,8 @@ /** * Test class for \Magento\Framework\Pricing\Render\PriceBox + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PriceBoxTest extends \PHPUnit_Framework_TestCase { @@ -46,20 +48,20 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool') + $this->rendererPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class) ->disableOriginalConstructor() ->setMethods(['createAmountRender']) ->getMock(); - $layout = $this->getMock('Magento\Framework\View\LayoutInterface'); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); + $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); $cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class) ->getMockForAbstractClass(); - $storeConfig = $this->getMockBuilder('Magento\Store\Model\Store\Config') + $storeConfig = $this->getMockBuilder(\Magento\Store\Model\Store\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any()) @@ -78,16 +80,19 @@ protected function setUp() ->method('getCacheState') ->will($this->returnValue($cacheState)); - $this->saleable = $this->getMock('Magento\Framework\Pricing\SaleableInterface'); + $this->saleable = $this->getMock(\Magento\Framework\Pricing\SaleableInterface::class); - $this->price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface'); + $this->price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); - $this->model = $this->objectManager->getObject('Magento\Framework\Pricing\Render\PriceBox', [ - 'context' => $this->context, - 'saleableItem' => $this->saleable, - 'price' => $this->price, - 'rendererPool' => $this->rendererPool - ]); + $this->model = $this->objectManager->getObject( + \Magento\Framework\Pricing\Render\PriceBox::class, + [ + 'context' => $this->context, + 'saleableItem' => $this->saleable, + 'price' => $this->price, + 'rendererPool' => $this->rendererPool + ] + ); } /** @@ -102,13 +107,16 @@ public function testToHtml($data, $priceCode, $cssClasses) ->method('getPriceCode') ->will($this->returnValue($priceCode)); - $priceBox = $this->objectManager->getObject('Magento\Framework\Pricing\Render\PriceBox', [ - 'context' => $this->context, - 'saleableItem' => $this->saleable, - 'price' => $this->price, - 'rendererPool' => $this->rendererPool, - 'data' => $data - ]); + $priceBox = $this->objectManager->getObject( + \Magento\Framework\Pricing\Render\PriceBox::class, + [ + 'context' => $this->context, + 'saleableItem' => $this->saleable, + 'price' => $this->price, + 'rendererPool' => $this->rendererPool, + 'data' => $data + ] + ); $priceBox->toHtml(); $this->assertEquals($cssClasses, $priceBox->getData('css_classes')); } @@ -142,9 +150,9 @@ public function testGetPriceType() { $priceCode = 'test_price'; - $price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface'); + $price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); - $priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); + $priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); $priceInfo->expects($this->once()) ->method('getPrice') ->with($priceCode) @@ -159,11 +167,11 @@ public function testGetPriceType() public function testRenderAmount() { - $amount = $this->getMock('Magento\Framework\Pricing\Amount\AmountInterface'); + $amount = $this->getMock(\Magento\Framework\Pricing\Amount\AmountInterface::class); $arguments = []; $resultHtml = 'result_html'; - $amountRender = $this->getMockBuilder('Magento\Framework\Pricing\Render\Amount') + $amountRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) ->disableOriginalConstructor() ->setMethods(['toHtml']) ->getMock(); diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/RendererPoolTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/RendererPoolTest.php index a15a19222f823..7d400b6933c54 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/RendererPoolTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/RendererPoolTest.php @@ -9,6 +9,8 @@ /** * Test class for \Magento\Framework\Pricing\Render\RendererPool + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class RendererPoolTest extends \PHPUnit_Framework_TestCase { @@ -39,19 +41,19 @@ class RendererPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('\Magento\Framework\View\Element\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) ->method('getLayout') ->will($this->returnValue($this->layoutMock)); - $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $this->productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $this->priceMock = $this->getMockBuilder('Magento\Catalog\Pricing\Price\BasePrice') + $this->priceMock = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\BasePrice::class) ->disableOriginalConstructor() ->getMock(); } @@ -100,7 +102,7 @@ public function testCreatePriceRenderNoPriceModel() ]; $priceModel = null; - $priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->once()) @@ -131,7 +133,7 @@ public function testCreatePriceRenderBlockNotPriceBox() $methodData = []; $priceCode = 'price_test'; $type = 'simple'; - $className = 'Magento\Framework\View\Element\Template\Context'; + $className = \Magento\Framework\View\Element\Template\Context::class; $data = [ $type => [ 'prices' => [ @@ -142,7 +144,7 @@ public function testCreatePriceRenderBlockNotPriceBox() ], ]; - $priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->once()) @@ -156,7 +158,7 @@ public function testCreatePriceRenderBlockNotPriceBox() ->method('getPriceInfo') ->will($this->returnValue($priceInfoMock)); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); $block = new \Magento\Framework\View\Element\Template($contextMock); @@ -186,7 +188,7 @@ public function testCreatePriceRender() $methodData = []; $priceCode = 'price_test'; $type = 'simple'; - $className = 'Magento\Framework\View\Element\Template\Context'; + $className = \Magento\Framework\View\Element\Template\Context::class; $template = 'template.phtml'; $data = [ $type => [ @@ -199,7 +201,7 @@ public function testCreatePriceRender() ], ]; - $priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->once()) @@ -213,7 +215,7 @@ public function testCreatePriceRender() ->method('getPriceInfo') ->will($this->returnValue($priceInfoMock)); - $renderBlock = $this->getMockBuilder('Magento\Framework\Pricing\Render\PriceBox') + $renderBlock = $this->getMockBuilder(\Magento\Framework\Pricing\Render\PriceBox::class) ->disableOriginalConstructor() ->getMock(); $renderBlock->expects($this->once()) @@ -234,7 +236,7 @@ public function testCreatePriceRender() ->will($this->returnValue($renderBlock)); $result = $testedClass->createPriceRender($priceCode, $this->productMock, $methodData); - $this->assertInstanceOf('Magento\Framework\Pricing\Render\PriceBoxRenderInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Pricing\Render\PriceBoxRenderInterface::class, $result); } /** @@ -250,7 +252,7 @@ public function testCreateAmountRenderNoAmountClass() $methodData = []; $priceCode = 'base_price_test'; - $amountMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $amountMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); $this->productMock->expects($this->once()) @@ -277,7 +279,7 @@ public function testCreateAmountRenderNotAmountInterface() $type = 'simple'; $methodData = []; $priceCode = 'base_price_test'; - $amountRenderClass = 'Magento\Framework\View\Element\Template\Context'; + $amountRenderClass = \Magento\Framework\View\Element\Template\Context::class; $data = [ $type => [ 'prices' => [ @@ -288,7 +290,7 @@ public function testCreateAmountRenderNotAmountInterface() ], ]; - $amountMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $amountMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); $this->productMock->expects($this->once()) @@ -298,7 +300,7 @@ public function testCreateAmountRenderNotAmountInterface() ->method('getPriceCode') ->will($this->returnValue($priceCode)); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); $block = new \Magento\Framework\View\Element\Template($contextMock); @@ -331,7 +333,7 @@ public function testCreateAmountRender() $methodData = []; $priceCode = 'base_price_test'; $template = 'template.phtml'; - $amountRenderClass = 'Magento\Framework\Pricing\Render\Amount'; + $amountRenderClass = \Magento\Framework\Pricing\Render\Amount::class; $data = [ $type => [ 'prices' => [ @@ -343,7 +345,7 @@ public function testCreateAmountRender() ], ]; - $amountMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $amountMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); $this->productMock->expects($this->once()) @@ -353,7 +355,7 @@ public function testCreateAmountRender() ->method('getPriceCode') ->will($this->returnValue($priceCode)); - $blockMock = $this->getMockBuilder('Magento\Framework\Pricing\Render\Amount') + $blockMock = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) ->disableOriginalConstructor() ->getMock(); @@ -377,7 +379,7 @@ public function testCreateAmountRender() ->with($this->equalTo($template)); $result = $testedClass->createAmountRender($amountMock, $this->productMock, $this->priceMock, $methodData); - $this->assertInstanceOf('Magento\Framework\Pricing\Render\AmountRenderInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Pricing\Render\AmountRenderInterface::class, $result); } /** @@ -444,7 +446,7 @@ public function testGetAdjustmentRenders() { $typeId = 'simple'; $priceCode = 'base_price_test'; - $class = 'Magento\Framework\View\Element\Template'; + $class = \Magento\Framework\View\Element\Template::class; $template = 'template.phtml'; $code = 'tax'; @@ -469,7 +471,7 @@ public function testGetAdjustmentRenders() ->method('getPriceCode') ->will($this->returnValue($priceCode)); - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\Template') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template::class) ->disableOriginalConstructor() ->getMock(); $blockMock->expects($this->once()) @@ -484,7 +486,7 @@ public function testGetAdjustmentRenders() $testedClass = $this->createTestedEntity($data); $result = $testedClass->getAdjustmentRenders($this->productMock, $this->priceMock); $this->assertArrayHasKey($code, $result); - $this->assertInstanceOf('Magento\Framework\View\Element\Template', $result[$code]); + $this->assertInstanceOf(\Magento\Framework\View\Element\Template::class, $result[$code]); } /** @@ -499,7 +501,7 @@ public function testGetAmountRenderBlockTemplateNoTemplate() $methodData = []; $priceCode = 'base_price_test'; $template = false; - $amountRenderClass = 'Magento\Framework\Pricing\Render\Amount'; + $amountRenderClass = \Magento\Framework\Pricing\Render\Amount::class; $data = [ $type => [ 'prices' => [ @@ -511,7 +513,7 @@ public function testGetAmountRenderBlockTemplateNoTemplate() ], ]; - $amountMock = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $amountMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); @@ -522,7 +524,7 @@ public function testGetAmountRenderBlockTemplateNoTemplate() ->method('getPriceCode') ->will($this->returnValue($priceCode)); - $blockMock = $this->getMockBuilder('Magento\Framework\Pricing\Render\Amount') + $blockMock = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) ->disableOriginalConstructor() ->getMock(); @@ -556,7 +558,7 @@ public function testGetRenderBlockTemplate() $methodData = []; $priceCode = 'price_test'; $type = 'simple'; - $className = 'Magento\Framework\View\Element\Template\Context'; + $className = \Magento\Framework\View\Element\Template\Context::class; $template = false; $data = [ $type => [ @@ -569,7 +571,7 @@ public function testGetRenderBlockTemplate() ], ]; - $priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->once()) @@ -583,7 +585,7 @@ public function testGetRenderBlockTemplate() ->method('getPriceInfo') ->will($this->returnValue($priceInfoMock)); - $renderBlock = $this->getMockBuilder('Magento\Framework\Pricing\Render\PriceBox') + $renderBlock = $this->getMockBuilder(\Magento\Framework\Pricing\Render\PriceBox::class) ->disableOriginalConstructor() ->getMock(); @@ -601,7 +603,7 @@ public function testGetRenderBlockTemplate() ->will($this->returnValue($renderBlock)); $result = $testedClass->createPriceRender($priceCode, $this->productMock, $methodData); - $this->assertInstanceOf('Magento\Framework\Pricing\Render\PriceBoxRenderInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Pricing\Render\PriceBoxRenderInterface::class, $result); } /** diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/RenderTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/RenderTest.php index 73e9f3e49331f..1f6c7b98c129d 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/RenderTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/RenderTest.php @@ -44,29 +44,29 @@ class RenderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceLayout = $this->getMockBuilder('Magento\Framework\Pricing\Render\Layout') + $this->priceLayout = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Layout::class) ->disableOriginalConstructor() ->getMock(); - $this->price = $this->getMockBuilder('\Magento\Catalog\Pricing\Price\BasePrice') + $this->price = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\BasePrice::class) ->disableOriginalConstructor() ->getMock(); - $this->amount = $this->getMockBuilder('Magento\Framework\Pricing\Amount\Base') + $this->amount = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) ->disableOriginalConstructor() ->getMock(); - $this->saleableItem = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $this->saleableItem = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $this->renderPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool') + $this->renderPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Framework\Pricing\Render', + \Magento\Framework\Pricing\Render::class, [ 'priceLayout' => $this->priceLayout ] @@ -84,7 +84,7 @@ public function testSetLayout() $this->priceLayout->expects($this->once()) ->method('loadLayout'); - $layout = $this->getMock('Magento\Framework\View\LayoutInterface'); + $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); $this->model->setPriceRenderHandle($priceRenderHandle); $this->model->setLayout($layout); } @@ -112,7 +112,7 @@ public function testRender() $arguments = ['param' => 1]; $result = 'simple.final'; - $pricingRender = $this->getMock('Magento\Framework\Pricing\Render', [], [], '', false, true, true, false); + $pricingRender = $this->getMock(\Magento\Framework\Pricing\Render::class, [], [], '', false, true, true, false); $this->renderPool->expects($this->once()) ->method('createPriceRender') ->will($this->returnValue($pricingRender)); @@ -131,7 +131,7 @@ public function testRenderDefault() $priceType = 'special'; $arguments = ['param' => 15]; $result = 'default.special'; - $pricingRender = $this->getMock('Magento\Framework\Pricing\Render', [], [], '', false, true, true, false); + $pricingRender = $this->getMock(\Magento\Framework\Pricing\Render::class, [], [], '', false, true, true, false); $this->renderPool->expects($this->once()) ->method('createPriceRender') ->will($this->returnValue($pricingRender)); @@ -152,7 +152,7 @@ public function testRenderDefaultDefault() $arguments = ['param' => 15]; $result = 'default.default'; - $pricingRender = $this->getMock('Magento\Framework\Pricing\Render', [], [], '', false, true, true, false); + $pricingRender = $this->getMock(\Magento\Framework\Pricing\Render::class, [], [], '', false, true, true, false); $this->renderPool->expects($this->once()) ->method('createPriceRender') ->will($this->returnValue($pricingRender)); @@ -173,7 +173,7 @@ public function testAmountRender() $expectedResult = 'default.default'; $pricingRender = $this->getMock( - 'Magento\Framework\Pricing\Render\Amount', + \Magento\Framework\Pricing\Render\Amount::class, [], [], '', diff --git a/lib/internal/Magento/Framework/Profiler/Driver/Factory.php b/lib/internal/Magento/Framework/Profiler/Driver/Factory.php index ba9d4de84783a..5975f60f41ddb 100644 --- a/lib/internal/Magento/Framework/Profiler/Driver/Factory.php +++ b/lib/internal/Magento/Framework/Profiler/Driver/Factory.php @@ -34,8 +34,10 @@ class Factory * @param string $defaultDriverPrefix * @param string $defaultDriverType */ - public function __construct($defaultDriverPrefix = 'Magento\Framework\Profiler\Driver\\', $defaultDriverType = 'standard') - { + public function __construct( + $defaultDriverPrefix = 'Magento\Framework\Profiler\Driver\\', + $defaultDriverType = 'standard' + ) { $this->_defaultDriverPrefix = $defaultDriverPrefix; $this->_defaultDriverType = $defaultDriverType; } diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php index 1d71ff550b0cc..61516192c629b 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php @@ -54,7 +54,7 @@ public function testCreate($config, $expectedClass) { $driver = $this->_factory->create($config); $this->assertInstanceOf($expectedClass, $driver); - $this->assertInstanceOf('Magento\Framework\Profiler\DriverInterface', $driver); + $this->assertInstanceOf(\Magento\Framework\Profiler\DriverInterface::class, $driver); } /** @@ -63,13 +63,13 @@ public function testCreate($config, $expectedClass) public function createDataProvider() { $defaultDriverClass = $this->getMockClass( - 'Magento\Framework\Profiler\DriverInterface', + \Magento\Framework\Profiler\DriverInterface::class, [], [], 'Magento_Framework_Profiler_Driver_Test_Default' ); $testDriverClass = $this->getMockClass( - 'Magento\Framework\Profiler\DriverInterface', + \Magento\Framework\Profiler\DriverInterface::class, [], [], 'Magento_Framework_Profiler_Driver_Test_Test' diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php index a7a6cb074fc68..5df0dfe4cd2c8 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php @@ -54,7 +54,7 @@ public function testCreate($configData, $expectedClass) { $driver = $this->_factory->create($configData); $this->assertInstanceOf($expectedClass, $driver); - $this->assertInstanceOf('Magento\Framework\Profiler\Driver\Standard\OutputInterface', $driver); + $this->assertInstanceOf(\Magento\Framework\Profiler\Driver\Standard\OutputInterface::class, $driver); } /** @@ -63,13 +63,13 @@ public function testCreate($configData, $expectedClass) public function createDataProvider() { $defaultOutputClass = $this->getMockClass( - 'Magento\Framework\Profiler\Driver\Standard\OutputInterface', + \Magento\Framework\Profiler\Driver\Standard\OutputInterface::class, [], [], 'Magento_Framework_Profiler_Driver_Standard_Output_Test_Default' ); $testOutputClass = $this->getMockClass( - 'Magento\Framework\Profiler\Driver\Standard\OutputInterface', + \Magento\Framework\Profiler\Driver\Standard\OutputInterface::class, [], [], 'Magento_Framework_Profiler_Driver_Standard_Output_Test_Test' diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FirebugTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FirebugTest.php index 55496c3e61da4..955a8e4b68588 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FirebugTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FirebugTest.php @@ -27,15 +27,15 @@ protected function tearDown() public function testGetAndSetRequest() { $this->assertInstanceOf('Zend_Controller_Request_Abstract', $this->_output->getRequest()); - $request = $this->getMock('Zend_Controller_Request_Abstract'); + $request = $this->getMock(\Zend_Controller_Request_Abstract::class); $this->_output->setRequest($request); $this->assertSame($request, $this->_output->getRequest()); } public function testGetAndSetResponse() { - $this->assertInstanceOf('Zend\Http\PhpEnvironment\Response', $this->_output->getResponse()); - $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); + $this->assertInstanceOf(\Zend\Http\PhpEnvironment\Response::class, $this->_output->getResponse()); + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, null, [], '', false); $this->_output->setResponse($response); $this->assertSame($response, $this->_output->getResponse()); } diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/OutputAbstractTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/OutputAbstractTest.php index 42bc5541b8d03..16cb1b09ec67b 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/OutputAbstractTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/OutputAbstractTest.php @@ -16,7 +16,9 @@ class OutputAbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_output = $this->getMockForAbstractClass('Magento\Framework\Profiler\Driver\Standard\AbstractOutput'); + $this->_output = $this->getMockForAbstractClass( + \Magento\Framework\Profiler\Driver\Standard\AbstractOutput::class + ); } /** @@ -55,7 +57,7 @@ public function testConstructor() $configuration = ['filterPattern' => '/filter pattern/', 'thresholds' => ['fetchKey' => 100]]; /** @var $output \Magento\Framework\Profiler\Driver\Standard\AbstractOutput */ $output = $this->getMockForAbstractClass( - 'Magento\Framework\Profiler\Driver\Standard\AbstractOutput', + \Magento\Framework\Profiler\Driver\Standard\AbstractOutput::class, [$configuration] ); $this->assertEquals('/filter pattern/', $output->getFilterPattern()); @@ -113,7 +115,7 @@ public function testGetTimerIds() { $this->_output->setFilterPattern('/filter pattern/'); - $mockStat = $this->getMock('Magento\Framework\Profiler\Driver\Standard\Stat'); + $mockStat = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\Stat::class); $expectedTimerIds = ['test']; $mockStat->expects( $this->once() diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/StandardTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/StandardTest.php index 8fc67e65427a7..fc8c1f052e071 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/StandardTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/StandardTest.php @@ -21,7 +21,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_stat = $this->getMock('Magento\Framework\Profiler\Driver\Standard\Stat'); + $this->_stat = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\Stat::class); $this->_driver = new \Magento\Framework\Profiler\Driver\Standard(['stat' => $this->_stat]); } @@ -36,7 +36,7 @@ protected function tearDown() public function testDefaultConstructor() { $driver = new \Magento\Framework\Profiler\Driver\Standard(); - $this->assertAttributeInstanceOf('Magento\Framework\Profiler\Driver\Standard\Stat', '_stat', $driver); + $this->assertAttributeInstanceOf(\Magento\Framework\Profiler\Driver\Standard\Stat::class, '_stat', $driver); } /** @@ -89,7 +89,7 @@ public function testStop() */ public function testInitOutputs() { - $outputFactory = $this->getMock('Magento\Framework\Profiler\Driver\Standard\Output\Factory'); + $outputFactory = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\Output\Factory::class); $config = [ 'outputs' => [ 'outputTypeOne' => ['baseDir' => '/custom/base/dir'], @@ -99,8 +99,8 @@ public function testInitOutputs() 'outputFactory' => $outputFactory, ]; - $outputOne = $this->getMock('Magento\Framework\Profiler\Driver\Standard\OutputInterface'); - $outputTwo = $this->getMock('Magento\Framework\Profiler\Driver\Standard\OutputInterface'); + $outputOne = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\OutputInterface::class); + $outputTwo = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\OutputInterface::class); $outputFactory->expects( $this->at(0) @@ -132,9 +132,9 @@ public function testInitOutputs() */ public function testDisplayAndRegisterOutput() { - $outputOne = $this->getMock('Magento\Framework\Profiler\Driver\Standard\OutputInterface'); + $outputOne = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\OutputInterface::class); $outputOne->expects($this->once())->method('display')->with($this->_stat); - $outputTwo = $this->getMock('Magento\Framework\Profiler\Driver\Standard\OutputInterface'); + $outputTwo = $this->getMock(\Magento\Framework\Profiler\Driver\Standard\OutputInterface::class); $outputTwo->expects($this->once())->method('display')->with($this->_stat); $this->_driver->registerOutput($outputOne); @@ -153,7 +153,7 @@ public function testDefaultOutputFactory() $method = new \ReflectionMethod($this->_driver, '_getOutputFactory'); $method->setAccessible(true); $this->assertInstanceOf( - 'Magento\Framework\Profiler\Driver\Standard\Output\Factory', + \Magento\Framework\Profiler\Driver\Standard\Output\Factory::class, $method->invoke($this->_driver) ); } diff --git a/lib/internal/Magento/Framework/Reflection/MethodsMap.php b/lib/internal/Magento/Framework/Reflection/MethodsMap.php index 3fa5ca7421775..f7f402ae4b8a0 100644 --- a/lib/internal/Magento/Framework/Reflection/MethodsMap.php +++ b/lib/internal/Magento/Framework/Reflection/MethodsMap.php @@ -18,7 +18,7 @@ class MethodsMap { const SERVICE_METHOD_PARAMS_CACHE_PREFIX = 'service_method_params_'; const SERVICE_INTERFACE_METHODS_CACHE_PREFIX = 'serviceInterfaceMethodsMap'; - const BASE_MODEL_CLASS = 'Magento\Framework\Model\AbstractExtensibleModel'; + const BASE_MODEL_CLASS = \Magento\Framework\Model\AbstractExtensibleModel::class; const METHOD_META_NAME = 'name'; const METHOD_META_TYPE = 'type'; diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php index ebcad9eb3b941..786be9e7b2e54 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/AttributeTypeResolverTest.php @@ -30,8 +30,8 @@ class AttributeTypeResolverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->typeProcessor = $this->getMock('Magento\Framework\Reflection\TypeProcessor', [], [], '', false); - $this->configMock = $this->getMock('Magento\Framework\Api\ExtensionAttribute\Config', [], [], '', false); + $this->typeProcessor = $this->getMock(\Magento\Framework\Reflection\TypeProcessor::class, [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\Api\ExtensionAttribute\Config::class, [], [], '', false); $this->model = new AttributeTypeResolver($this->typeProcessor, $this->configMock); } @@ -65,18 +65,21 @@ public function testResolveObjectTypeWithConfiguredAttribute() $config = [ 'Some\Class' => [ 'some_code' => [ - 'type' => '\Magento\Framework\DataObject', + 'type' => \Magento\Framework\DataObject::class, ], ] ]; $this->typeProcessor->expects($this->once()) ->method('getArrayItemType') - ->with('\Magento\Framework\DataObject') - ->willReturn('\Magento\Framework\DataObject'); + ->with(\Magento\Framework\DataObject::class) + ->willReturn(\Magento\Framework\DataObject::class); $this->configMock->expects($this->once())->method('get')->willReturn($config); - $this->assertEquals('\Magento\Framework\DataObject', $this->model->resolveObjectType($code, $value, $context)); + $this->assertEquals( + \Magento\Framework\DataObject::class, + $this->model->resolveObjectType($code, $value, $context) + ); } /** diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php index e9d6a05be92e0..74eb09b327b37 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php @@ -61,27 +61,27 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $this->dataObjectProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->methodsMapProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\MethodsMap') + $this->methodsMapProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\MethodsMap::class) ->disableOriginalConstructor() ->getMock(); - $this->typeCasterMock = $this->getMockBuilder('Magento\Framework\Reflection\TypeCaster') + $this->typeCasterMock = $this->getMockBuilder(\Magento\Framework\Reflection\TypeCaster::class) ->disableOriginalConstructor() ->getMock(); - $this->fieldNamerMock = $this->getMockBuilder('Magento\Framework\Reflection\FieldNamer') + $this->fieldNamerMock = $this->getMockBuilder(\Magento\Framework\Reflection\FieldNamer::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\Config') + $this->configMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttribute\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->authorizationMock = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') + $this->authorizationMock = $this->getMockBuilder(\Magento\Framework\AuthorizationInterface::class) ->disableOriginalConstructor() ->getMock(); $this->model = $objectManager->getObject( - 'Magento\Framework\Reflection\ExtensionAttributesProcessor', + \Magento\Framework\Reflection\ExtensionAttributesProcessor::class, [ 'dataObjectProcessor' => $this->dataObjectProcessorMock, 'methodsMapProcessor' => $this->methodsMapProcessorMock, @@ -102,7 +102,7 @@ protected function setUp() public function testBuildOutputDataArrayWithPermission($isPermissionAllowed, $expectedValue) { $dataObject = new \Magento\Framework\Reflection\Test\Unit\ExtensionAttributesObject(); - $dataObjectType = 'Magento\Framework\Reflection\Test\Unit\ExtensionAttributesObject'; + $dataObjectType = \Magento\Framework\Reflection\Test\Unit\ExtensionAttributesObject::class; $methodName = 'getAttrName'; $attributeName = 'attr_name'; $attributeValue = 'attrName'; diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/FieldNamerTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/FieldNamerTest.php index 59a5d01690d65..b77fbbde62baf 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/FieldNamerTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/FieldNamerTest.php @@ -23,7 +23,7 @@ class FieldNamerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Reflection\FieldNamer'); + $this->model = $objectManager->getObject(\Magento\Framework\Reflection\FieldNamer::class); } /** diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php index 2d33f53d8ee6e..6f4dc37b8faff 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php @@ -27,7 +27,7 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $cacheMock = $this->getMockBuilder('Magento\Framework\Cache\FrontendInterface') + $cacheMock = $this->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class) ->getMockForAbstractClass(); $cacheMock->expects($this->any()) ->method('save'); @@ -35,12 +35,12 @@ protected function setUp() ->method('load') ->will($this->returnValue(null)); - $attributeTypeResolverMock = $this->getMockBuilder('Magento\Framework\Api\AttributeTypeResolverInterface') + $attributeTypeResolverMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeTypeResolverInterface::class) ->getMockForAbstractClass(); - $fieldNamerMock = $this->getMockBuilder('Magento\Framework\Reflection\FieldNamer') + $fieldNamerMock = $this->getMockBuilder(\Magento\Framework\Reflection\FieldNamer::class) ->getMockForAbstractClass(); $this->model = $objectManager->getObject( - 'Magento\Framework\Reflection\MethodsMap', + \Magento\Framework\Reflection\MethodsMap::class, [ 'cache' => $cacheMock, 'typeProcessor' => new TypeProcessor(), @@ -54,21 +54,30 @@ public function testGetMethodReturnType() { $this->assertEquals( 'string', - $this->model->getMethodReturnType('Magento\Framework\Reflection\FieldNamer', 'getFieldNameForMethodName') + $this->model->getMethodReturnType( + \Magento\Framework\Reflection\FieldNamer::class, + 'getFieldNameForMethodName' + ) ); $this->assertEquals( 'mixed', - $this->model->getMethodReturnType('Magento\Framework\Reflection\TypeCaster', 'castValueToType') + $this->model->getMethodReturnType( + \Magento\Framework\Reflection\TypeCaster::class, + 'castValueToType' + ) ); $this->assertEquals( 'array', - $this->model->getMethodReturnType('Magento\Framework\Reflection\MethodsMap', 'getMethodsMap') + $this->model->getMethodReturnType( + \Magento\Framework\Reflection\MethodsMap::class, + 'getMethodsMap' + ) ); } public function testGetMethodsMap() { - $methodsMap = $this->model->getMethodsMap('Magento\Framework\Reflection\MethodsMap'); + $methodsMap = $this->model->getMethodsMap(\Magento\Framework\Reflection\MethodsMap::class); $this->assertEquals( [ 'getMethodReturnType' => [ @@ -125,18 +134,15 @@ public function testIsMethodValidForDataField($type, $methodName, $expectedResul public function isMethodValidForDataFieldProvider() { return [ - 'MethodsMap#isMethodValidForDataField' => [ - 'Magento\Framework\Reflection\MethodsMap', + 'MethodsMap#isMethodValidForDataField' => [\Magento\Framework\Reflection\MethodsMap::class, 'isMethodValidForDataField', false, ], - 'DataObject#getAttrName' => [ - 'Magento\Framework\Reflection\Test\Unit\DataObject', + 'DataObject#getAttrName' => [\Magento\Framework\Reflection\Test\Unit\DataObject::class, 'getAttrName', true, ], - 'DataObject#isActive' => [ - 'Magento\Framework\Reflection\Test\Unit\DataObject', + 'DataObject#isActive' => [\Magento\Framework\Reflection\Test\Unit\DataObject::class, 'isActive', true, ], @@ -160,18 +166,15 @@ public function testIsMethodReturnValueRequired($type, $methodName, $expectedRes public function isMethodReturnValueRequiredProvider() { return [ - 'DataObject#getAttrName' => [ - 'Magento\Framework\Reflection\Test\Unit\DataObject', + 'DataObject#getAttrName' => [\Magento\Framework\Reflection\Test\Unit\DataObject::class, 'getAttrName', true, ], - 'DataObject#isActive' => [ - 'Magento\Framework\Reflection\Test\Unit\DataObject', + 'DataObject#isActive' => [\Magento\Framework\Reflection\Test\Unit\DataObject::class, 'isActive', true, ], - 'FieldNamer#getFieldNameForMethodName' => [ - 'Magento\Framework\Reflection\FieldNamer', + 'FieldNamer#getFieldNameForMethodName' => [\Magento\Framework\Reflection\FieldNamer::class, 'getFieldNameForMethodName', false, ], diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeCasterTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeCasterTest.php index 8c52662ca7488..50ebb65698133 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeCasterTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeCasterTest.php @@ -23,7 +23,7 @@ class TypeCasterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Framework\Reflection\TypeCaster'); + $this->model = $objectManager->getObject(\Magento\Framework\Reflection\TypeCaster::class); } /** diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php index 4f65e318e3ba8..e7b2d5214267b 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php @@ -218,7 +218,7 @@ public function testProcessSimpleTypeInvalidType() public function testFindSetterMethodName() { - $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class); $setterName = $this->_typeProcessor->findSetterMethodName($class, 'AttrName'); $this->assertEquals("setAttrName", $setterName); @@ -232,7 +232,7 @@ public function testFindSetterMethodName() */ public function testFindSetterMethodNameInvalidAttribute() { - $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class); $this->_typeProcessor->findSetterMethodName($class, 'InvalidAttribute'); } @@ -242,7 +242,7 @@ public function testFindSetterMethodNameInvalidAttribute() */ public function testFindSetterMethodNameWrongCamelCasedAttribute() { - $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class); $this->_typeProcessor->findSetterMethodName($class, 'ActivE'); } @@ -252,7 +252,7 @@ public function testFindSetterMethodNameWrongCamelCasedAttribute() */ public function testGetParamType() { - $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class); $methodReflection = $class->getMethod('setName'); $paramsReflection = $methodReflection->getParameters(); $this->_typeProcessor->getParamType($paramsReflection[0]); @@ -260,7 +260,7 @@ public function testGetParamType() public function testGetParameterDescription() { - $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class); $methodReflection = $class->getMethod('setName'); $paramsReflection = $methodReflection->getParameters(); $this->assertEquals('Name of the attribute', $this->_typeProcessor->getParamDescription($paramsReflection[0])); diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php index ba56f8942e0e1..dad8fbdb83a8c 100644 --- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php @@ -170,7 +170,7 @@ protected function _processComplexType($class) $this->_types[$typeName]['documentation'] = $docBlock ? $this->getDescription($docBlock) : ''; /** @var \Zend\Code\Reflection\MethodReflection $methodReflection */ foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodReflection) { - if ($methodReflection->class === "Magento\Framework\Model\AbstractModel") { + if ($methodReflection->class === \Magento\Framework\Model\AbstractModel::class) { continue; } $this->_processMethod($methodReflection, $typeName); diff --git a/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php index 4993f51d5a266..fbec7dd8f4bde 100644 --- a/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php @@ -48,21 +48,21 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fileSource = $this->getMock( - '\Magento\Framework\RequireJs\Config\File\Collector\Aggregated', + \Magento\Framework\RequireJs\Config\File\Collector\Aggregated::class, [], [], '', false ); - $this->design = $this->getMockForAbstractClass('\Magento\Framework\View\DesignInterface'); + $this->design = $this->getMockForAbstractClass(\Magento\Framework\View\DesignInterface::class); - $readFactory = $this->getMock('\Magento\Framework\Filesystem\File\ReadFactory', [], [], '', false); - $this->fileReader = $this->getMock('\Magento\Framework\Filesystem\File\Read', [], [], '', false); + $readFactory = $this->getMock(\Magento\Framework\Filesystem\File\ReadFactory::class, [], [], '', false); + $this->fileReader = $this->getMock(\Magento\Framework\Filesystem\File\Read::class, [], [], '', false); $readFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->fileReader)); - $repo = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->context = $this->getMockBuilder('Magento\Framework\View\Asset\ContextInterface') + $repo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->context = $this->getMockBuilder(\Magento\Framework\View\Asset\ContextInterface::class) ->setMethods( [ 'getConfigPath', @@ -72,11 +72,11 @@ protected function setUp() ) ->getMock(); $repo->expects($this->once())->method('getStaticViewFileContext')->will($this->returnValue($this->context)); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); - $this->minifyAdapterMock = $this->getMockBuilder('Magento\Framework\Code\Minifier\AdapterInterface') + $this->minifyAdapterMock = $this->getMockBuilder(\Magento\Framework\Code\Minifier\AdapterInterface::class) ->getMockForAbstractClass(); $this->object = new Config( @@ -96,7 +96,7 @@ public function testGetConfig() ->will($this->returnCallback(function ($file) { return $file . ' content'; })); - $fileOne = $this->getMock('\Magento\Framework\View\File', [], [], '', false); + $fileOne = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); $fileOne->expects($this->once()) ->method('getFilename') ->will($this->returnValue('some/full/relative/path/file_one.js')); @@ -106,14 +106,14 @@ public function testGetConfig() $fileOne->expects($this->once()) ->method('getModule') ->will($this->returnValue('Module_One')); - $fileTwo = $this->getMock('\Magento\Framework\View\File', [], [], '', false); + $fileTwo = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); $fileTwo->expects($this->once()) ->method('getFilename') ->will($this->returnValue('some/full/relative/path/file_two.js')); $fileTwo->expects($this->once()) ->method('getName') ->will($this->returnValue('file_two.js')); - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->design->expects($this->once()) ->method('getDesignTheme') ->will($this->returnValue($theme)); diff --git a/lib/internal/Magento/Framework/Session/Config.php b/lib/internal/Magento/Framework/Session/Config.php index 67282dac1c114..f091dea2c812c 100644 --- a/lib/internal/Magento/Framework/Session/Config.php +++ b/lib/internal/Magento/Framework/Session/Config.php @@ -15,6 +15,8 @@ /** * Magento session configuration + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Config implements ConfigInterface { @@ -336,7 +338,7 @@ public function setCookieLifetime($cookieLifetime, $default = null) { $validator = $this->_validatorFactory->create( [], - 'Magento\Framework\Session\Config\Validator\CookieLifetimeValidator' + \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator::class ); if ($validator->isValid($cookieLifetime)) { $this->setOption('session.cookie_lifetime', (int)$cookieLifetime); @@ -369,7 +371,7 @@ public function setCookiePath($cookiePath, $default = null) $cookiePath = (string)$cookiePath; $validator = $this->_validatorFactory->create( [], - 'Magento\Framework\Session\Config\Validator\CookiePathValidator' + \Magento\Framework\Session\Config\Validator\CookiePathValidator::class ); if ($validator->isValid($cookiePath)) { $this->setOption('session.cookie_path', $cookiePath); @@ -401,7 +403,7 @@ public function setCookieDomain($cookieDomain, $default = null) { $validator = $this->_validatorFactory->create( [], - 'Magento\Framework\Session\Config\Validator\CookieDomainValidator' + \Magento\Framework\Session\Config\Validator\CookieDomainValidator::class ); if ($validator->isValid($cookieDomain)) { $this->setOption('session.cookie_domain', $cookieDomain); diff --git a/lib/internal/Magento/Framework/Session/SaveHandlerFactory.php b/lib/internal/Magento/Framework/Session/SaveHandlerFactory.php index d0e66b4d870c5..9c218398bce39 100644 --- a/lib/internal/Magento/Framework/Session/SaveHandlerFactory.php +++ b/lib/internal/Magento/Framework/Session/SaveHandlerFactory.php @@ -13,7 +13,7 @@ class SaveHandlerFactory /** * Php native session handler */ - const PHP_NATIVE_HANDLER = 'Magento\Framework\Session\SaveHandler\Native'; + const PHP_NATIVE_HANDLER = \Magento\Framework\Session\SaveHandler\Native::class; /** * Object manager diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php index 7866ee433dbcd..dab359163767f 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php @@ -13,6 +13,9 @@ use \Magento\Framework\Session\Config; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ConfigTest extends \PHPUnit_Framework_TestCase { /** mock session.save_handler value from deployment config */ @@ -57,7 +60,7 @@ protected function setUp() { $this->helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Validator\ValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); $this->validatorMock->expects($this->any()) @@ -116,7 +119,7 @@ public function optionsProvider() public function testGetOptions() { $this->getModel($this->validatorMock); - $appStateProperty = new \ReflectionProperty('Magento\Framework\Session\Config', 'options'); + $appStateProperty = new \ReflectionProperty(\Magento\Framework\Session\Config::class, 'options'); $appStateProperty->setAccessible(true); $original = $appStateProperty->getValue($this->config); $valueForTest = ['test' => 'test2']; @@ -172,7 +175,7 @@ public function testCookieLifetimeCanBeZero() public function testSettingInvalidCookieLifetime() { - $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') + $validatorMock = $this->getMockBuilder(\Magento\Framework\Validator\ValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); $validatorMock->expects($this->any()) @@ -186,7 +189,7 @@ public function testSettingInvalidCookieLifetime() public function testSettingInvalidCookieLifetime2() { - $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') + $validatorMock = $this->getMockBuilder(\Magento\Framework\Validator\ValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); $validatorMock->expects($this->any()) @@ -238,7 +241,7 @@ public function testCookieDomainCanBeEmpty() public function testSettingInvalidCookieDomain() { - $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') + $validatorMock = $this->getMockBuilder(\Magento\Framework\Validator\ValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); $validatorMock->expects($this->any()) @@ -252,7 +255,7 @@ public function testSettingInvalidCookieDomain() public function testSettingInvalidCookieDomain2() { - $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') + $validatorMock = $this->getMockBuilder(\Magento\Framework\Validator\ValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); $validatorMock->expects($this->any()) @@ -341,7 +344,7 @@ public function testSetSavePath() */ public function testConstructor($isValidSame, $isValid, $expected) { - $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') + $validatorMock = $this->getMockBuilder(\Magento\Framework\Validator\ValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); if ($isValidSame) { @@ -415,7 +418,7 @@ public function constructorDataProvider() protected function getModel($validator) { $this->requestMock = $this->getMock( - '\Magento\Framework\App\Request\Http', + \Magento\Framework\App\Request\Http::class, ['getBasePath', 'isSecure', 'getHttpHost'], [], '', @@ -431,7 +434,7 @@ protected function getModel($validator) $this->returnValue('init.host') ); - $this->validatorFactoryMock = $this->getMockBuilder('Magento\Framework\ValidatorFactory') + $this->validatorFactoryMock = $this->getMockBuilder(\Magento\Framework\ValidatorFactory::class) ->disableOriginalConstructor() ->getMock(); $this->validatorFactoryMock->expects($this->any()) @@ -441,20 +444,20 @@ protected function getModel($validator) ->method('create') ->willReturn($validator); - $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $getValueReturnMap = [ ['web/cookie/cookie_path', 'store', null, ''], ]; $this->configMock->method('getValue') ->will($this->returnValueMap($getValueReturnMap)); - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $dirMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $filesystemMock->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValue($dirMock)); - $deploymentConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deploymentConfigMock->expects($this->at(0)) ->method('get') ->with(Config::PARAM_SESSION_SAVE_METHOD, ini_get('session.save_handler') ?: 'files') @@ -469,7 +472,7 @@ protected function getModel($validator) ->will($this->returnValue('files')); $this->config = $this->helper->getObject( - 'Magento\Framework\Session\Config', + \Magento\Framework\Session\Config::class, [ 'scopeConfig' => $this->configMock, 'validatorFactory' => $this->validatorFactoryMock, diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/DbTableTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/DbTableTest.php index 2588ae6a1673c..3b646cca78e92 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/DbTableTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/DbTableTest.php @@ -65,7 +65,7 @@ public function readDataProvider() public function testCheckConnection() { $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['isTableExists'], [], '', @@ -82,7 +82,7 @@ public function testCheckConnection() ); $resource = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -94,7 +94,7 @@ public function testCheckConnection() $this->_model = new \Magento\Framework\Session\SaveHandler\DbTable($resource); - $method = new \ReflectionMethod('Magento\Framework\Session\SaveHandler\DbTable', 'checkConnection'); + $method = new \ReflectionMethod(\Magento\Framework\Session\SaveHandler\DbTable::class, 'checkConnection'); $method->setAccessible(true); $this->assertNull($method->invoke($this->_model)); } @@ -106,7 +106,7 @@ public function testCheckConnection() public function testCheckConnectionNoConnection() { $resource = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -118,7 +118,7 @@ public function testCheckConnectionNoConnection() $this->_model = new \Magento\Framework\Session\SaveHandler\DbTable($resource); - $method = new \ReflectionMethod('Magento\Framework\Session\SaveHandler\DbTable', 'checkConnection'); + $method = new \ReflectionMethod(\Magento\Framework\Session\SaveHandler\DbTable::class, 'checkConnection'); $method->setAccessible(true); $this->assertNull($method->invoke($this->_model)); } @@ -130,7 +130,7 @@ public function testCheckConnectionNoConnection() public function testCheckConnectionNoTable() { $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['isTableExists'], [], '', @@ -147,7 +147,7 @@ public function testCheckConnectionNoTable() ); $resource = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -159,7 +159,7 @@ public function testCheckConnectionNoTable() $this->_model = new \Magento\Framework\Session\SaveHandler\DbTable($resource); - $method = new \ReflectionMethod('Magento\Framework\Session\SaveHandler\DbTable', 'checkConnection'); + $method = new \ReflectionMethod(\Magento\Framework\Session\SaveHandler\DbTable::class, 'checkConnection'); $method->setAccessible(true); $this->assertNull($method->invoke($this->_model)); } @@ -184,7 +184,7 @@ public function testRead($isDataEncoded) protected function _prepareResourceMock($connection) { $resource = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -205,7 +205,7 @@ protected function _prepareResourceMock($connection) protected function _prepareMockForRead($isDataEncoded) { $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'from', 'where', 'fetchOne', 'isTableExists'], [], '', @@ -285,7 +285,7 @@ public function testWrite($sessionExists) protected function _prepareMockForWrite($sessionExists) { $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'from', 'where', 'fetchOne', 'update', 'insert', 'isTableExists'], [], '', diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php index 1badb26afd7a7..237358c5ed9c1 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php @@ -37,16 +37,16 @@ class LoggerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->config = $this->getMock('Cm\RedisSession\Handler\ConfigInterface', [], [], '', false); + $this->config = $this->getMock(\Cm\RedisSession\Handler\ConfigInterface::class, [], [], '', false); $this->config->expects($this->once()) ->method('getLogLevel') ->willReturn(LoggerInterface::DEBUG); - $this->psrLogger = $this->getMock('Psr\Log\LoggerInterface', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->psrLogger = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); //$this->logger = new Logger($this->config, $this->psrLogger, $this->request); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->logger = $objectManager->getObject( - 'Magento\Framework\Session\SaveHandler\Redis\Logger', + \Magento\Framework\Session\SaveHandler\Redis\Logger::class, [ 'config' => $this->config, 'logger' => $this->psrLogger, diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandlerFactoryTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandlerFactoryTest.php index 1ed060fd39a85..792b6f849dc76 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandlerFactoryTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandlerFactoryTest.php @@ -16,7 +16,7 @@ public function testCreate($handlers, $saveClass, $saveMethod) { $saveHandler = $this->getMock($saveClass); $objectManager = $this->getMock( - '\Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -35,7 +35,7 @@ public function testCreate($handlers, $saveClass, $saveMethod) $model = new SaveHandlerFactory($objectManager, $handlers); $result = $model->create($saveMethod); $this->assertInstanceOf($saveClass, $result); - $this->assertInstanceOf('\Magento\Framework\Session\SaveHandler\Native', $result); + $this->assertInstanceOf(\Magento\Framework\Session\SaveHandler\Native::class, $result); $this->assertInstanceOf('\SessionHandlerInterface', $result); } @@ -44,7 +44,7 @@ public function testCreate($handlers, $saveClass, $saveMethod) */ public function createDataProvider() { - return [[[], 'Magento\Framework\Session\SaveHandler\Native', 'files']]; + return [[[], \Magento\Framework\Session\SaveHandler\Native::class, 'files']]; } /** @@ -54,7 +54,7 @@ public function createDataProvider() public function testCreateInvalid() { $invalidSaveHandler = new \Magento\Framework\DataObject(); - $objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + $objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManager\ObjectManager::class) ->disableOriginalConstructor() ->getMock(); $objectManager->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/SessionManagerTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/SessionManagerTest.php index c32d045ac4947..08088711453bb 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/SessionManagerTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/SessionManagerTest.php @@ -58,12 +58,12 @@ protected function setUp() require_once __DIR__ . '/_files/mock_session_regenerate_id.php'; $mockPHPFunctions = true; - $this->mockSessionConfig = $this->getMockBuilder('\Magento\Framework\Session\Config\ConfigInterface') + $this->mockSessionConfig = $this->getMockBuilder(\Magento\Framework\Session\Config\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->mockCookieManager = $this->getMock('\Magento\Framework\Stdlib\CookieManagerInterface'); + $this->mockCookieManager = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); $this->mockCookieMetadataFactory = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -74,7 +74,7 @@ protected function setUp() 'cookieMetadataFactory' => $this->mockCookieMetadataFactory, ]; $this->sessionManager = $this->objectManager->getObject( - 'Magento\Framework\Session\SessionManager', + \Magento\Framework\Session\SessionManager::class, $arguments ); } @@ -82,7 +82,7 @@ protected function setUp() public function testSessionManagerConstructor() { self::$isIniSetInvoked = false; - $this->objectManager->getObject('Magento\Framework\Session\SessionManager'); + $this->objectManager->getObject(\Magento\Framework\Session\SessionManager::class); $this->assertTrue(SessionManagerTest::$isIniSetInvoked); } } diff --git a/lib/internal/Magento/Framework/Setup/BackupRollback.php b/lib/internal/Magento/Framework/Setup/BackupRollback.php index abc65749853a8..efb15267ae4a4 100644 --- a/lib/internal/Magento/Framework/Setup/BackupRollback.php +++ b/lib/internal/Magento/Framework/Setup/BackupRollback.php @@ -107,7 +107,7 @@ public function __construct( public function codeBackup($time, $type = Factory::TYPE_FILESYSTEM) { /** @var \Magento\Framework\Backup\Filesystem $fsBackup */ - $fsBackup = $this->objectManager->create('Magento\Framework\Backup\Filesystem'); + $fsBackup = $this->objectManager->create(\Magento\Framework\Backup\Filesystem::class); $fsBackup->setRootDir($this->directoryList->getRoot()); if ($type === Factory::TYPE_FILESYSTEM) { $fsBackup->addIgnorePaths($this->getCodeBackupIgnorePaths()); @@ -154,7 +154,7 @@ public function codeRollback($rollbackFile, $type = Factory::TYPE_FILESYSTEM) throw new LocalizedException(new Phrase('The rollback file does not exist.')); } /** @var \Magento\Framework\Backup\Filesystem $fsRollback */ - $fsRollback = $this->objectManager->create('Magento\Framework\Backup\Filesystem'); + $fsRollback = $this->objectManager->create(\Magento\Framework\Backup\Filesystem::class); if ($type === Factory::TYPE_FILESYSTEM) { $ignorePaths = $this->getCodeBackupIgnorePaths(); $granularType = 'Code'; @@ -198,7 +198,7 @@ public function codeRollback($rollbackFile, $type = Factory::TYPE_FILESYSTEM) public function dbBackup($time) { /** @var \Magento\Framework\Backup\Db $dbBackup */ - $dbBackup = $this->objectManager->create('Magento\Framework\Backup\Db'); + $dbBackup = $this->objectManager->create(\Magento\Framework\Backup\Db::class); $dbBackup->setRootDir($this->directoryList->getRoot()); if (!$this->file->isExists($this->backupsDir)) { $this->file->createDirectory($this->backupsDir); @@ -230,7 +230,7 @@ public function dbRollback($rollbackFile) throw new LocalizedException(new Phrase('The rollback file does not exist.')); } /** @var \Magento\Framework\Backup\Db $dbRollback */ - $dbRollback = $this->objectManager->create('Magento\Framework\Backup\Db'); + $dbRollback = $this->objectManager->create(\Magento\Framework\Backup\Db::class); $dbRollback->setRootDir($this->directoryList->getRoot()); $dbRollback->setBackupsDir($this->backupsDir); $dbRollback->setBackupExtension('sql'); @@ -241,7 +241,7 @@ public function dbRollback($rollbackFile) } $dbRollback->setTime($time[0]); $this->log->log('DB rollback is starting...'); - $dbRollback->setResourceModel($this->objectManager->create('Magento\Backup\Model\ResourceModel\Db')); + $dbRollback->setResourceModel($this->objectManager->create(\Magento\Backup\Model\ResourceModel\Db::class)); $dbRollback->rollback(); $this->log->log('DB rollback filename: ' . $dbRollback->getBackupFilename()); $this->log->log('DB rollback path: ' . $dbRollback->getBackupPath()); @@ -326,7 +326,7 @@ public function getFSDiskSpace($type = Factory::TYPE_FILESYSTEM) public function getDBDiskSpace() { /** @var \Magento\Framework\Backup\Db $dbBackup */ - $dbBackup = $this->objectManager->create('Magento\Framework\Backup\Db'); + $dbBackup = $this->objectManager->create(\Magento\Framework\Backup\Db::class); return $dbBackup->getDBSize(); } } diff --git a/lib/internal/Magento/Framework/Setup/BackupRollbackFactory.php b/lib/internal/Magento/Framework/Setup/BackupRollbackFactory.php index f96784aac465f..c11fe817136b0 100644 --- a/lib/internal/Magento/Framework/Setup/BackupRollbackFactory.php +++ b/lib/internal/Magento/Framework/Setup/BackupRollbackFactory.php @@ -33,7 +33,7 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create($output) { - $log = $this->_objectManager->create('Magento\Framework\Setup\ConsoleLogger', ['output' => $output]); - return $this->_objectManager->create('Magento\Framework\Setup\BackupRollback', ['log' => $log]); + $log = $this->_objectManager->create(\Magento\Framework\Setup\ConsoleLogger::class, ['output' => $output]); + return $this->_objectManager->create(\Magento\Framework\Setup\BackupRollback::class, ['log' => $log]); } } diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackFactoryTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackFactoryTest.php index e16d65b5032b6..740829bfe0ab9 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackFactoryTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackFactoryTest.php @@ -11,11 +11,16 @@ class BackupRollbackFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $consoleLogger = $this->getMock('Magento\Framework\Setup\ConsoleLogger', [], [], '', false); - $factory = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); + $consoleLogger = $this->getMock(\Magento\Framework\Setup\ConsoleLogger::class, [], [], '', false); + $factory = $this->getMock(\Magento\Framework\Setup\BackupRollback::class, [], [], '', false); $output = $this->getMockForAbstractClass( - 'Symfony\Component\Console\Output\OutputInterface', + \Symfony\Component\Console\Output\OutputInterface::class, [], '', false @@ -23,10 +28,10 @@ public function testCreate() $objectManager->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap([ - ['Magento\Framework\Setup\ConsoleLogger', ['output' => $output], $consoleLogger], - ['Magento\Framework\Setup\BackupRollback', ['log' => $consoleLogger], $factory], + [\Magento\Framework\Setup\ConsoleLogger::class, ['output' => $output], $consoleLogger], + [\Magento\Framework\Setup\BackupRollback::class, ['log' => $consoleLogger], $factory], ])); $model = new BackupRollbackFactory($objectManager); - $this->assertInstanceOf('Magento\Framework\Setup\BackupRollback', $model->create($output)); + $this->assertInstanceOf(\Magento\Framework\Setup\BackupRollback::class, $model->create($output)); } } diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php index f8fa352fbbbea..59e81939c11b0 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php @@ -9,6 +9,9 @@ use Magento\Framework\Setup\BackupRollback; use Magento\Framework\Setup\LoggerInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class BackupRollbackTest extends \PHPUnit_Framework_TestCase { /** @@ -58,9 +61,15 @@ class BackupRollbackTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); - $this->log = $this->getMock('Magento\Framework\Setup\LoggerInterface', [], [], '', false); - $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->log = $this->getMock(\Magento\Framework\Setup\LoggerInterface::class, [], [], '', false); + $this->directoryList = $this->getMock( + \Magento\Framework\App\Filesystem\DirectoryList::class, + [], + [], + '', + false + ); $this->path = realpath(__DIR__); $this->directoryList->expects($this->any()) ->method('getRoot') @@ -68,29 +77,37 @@ protected function setUp() $this->directoryList->expects($this->any()) ->method('getPath') ->willReturn($this->path); - $this->file = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\Backup\Filesystem', [], [], '', false); - $this->database = $this->getMock('Magento\Framework\Backup\Db', [], [], '', false); - $this->helper = $this->getMock('Magento\Framework\Backup\Filesystem\Helper', [], [], '', false); + $this->file = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Backup\Filesystem::class, [], [], '', false); + $this->database = $this->getMock(\Magento\Framework\Backup\Db::class, [], [], '', false); + $this->helper = $this->getMock(\Magento\Framework\Backup\Filesystem\Helper::class, [], [], '', false); $this->helper->expects($this->any()) ->method('getInfo') ->willReturn(['writable' => true, 'size' => 100]); - $configLoader = $this->getMock('Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false); + $configLoader = $this->getMock(\Magento\Framework\App\ObjectManager\ConfigLoader::class, [], [], '', false); $configLoader->expects($this->any()) ->method('load') ->willReturn([]); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\App\State', $this->getMock('Magento\Framework\App\State', [], [], '', false)], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + [ + \Magento\Framework\App\State::class, $this->getMock( + \Magento\Framework\App\State::class, + [], + [], + '', + false + ) + ], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $configLoader], ])); $this->objectManager->expects($this->any()) ->method('create') ->will($this->returnValueMap([ - ['Magento\Framework\Backup\Filesystem\Helper', [], $this->helper], - ['Magento\Framework\Backup\Filesystem', [], $this->filesystem], - ['Magento\Framework\Backup\Db', [], $this->database], + [\Magento\Framework\Backup\Filesystem\Helper::class, [], $this->helper], + [\Magento\Framework\Backup\Filesystem::class, [], $this->filesystem], + [\Magento\Framework\Backup\Db::class, [], $this->database], ])); $this->model = new BackupRollback( $this->objectManager, diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/ConsoleLoggerTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/ConsoleLoggerTest.php index b7040759c4cf4..756d65eec0eda 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/ConsoleLoggerTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/ConsoleLoggerTest.php @@ -22,9 +22,9 @@ class ConsoleLoggerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->console = $this->getMock('Symfony\Component\Console\Output\OutputInterface', [], [], '', false); + $this->console = $this->getMock(\Symfony\Component\Console\Output\OutputInterface::class, [], [], '', false); $outputFormatter = $this->getMock( - 'Symfony\Component\Console\Formatter\OutputFormatterInterface', + \Symfony\Component\Console\Formatter\OutputFormatterInterface::class, [], [], '', @@ -48,7 +48,7 @@ public function testLogSuccess() public function testLogError() { - $exception = $this->getMock('\Exception', [], [], '', false); + $exception = $this->getMock(\Exception::class, [], [], '', false); $this->console ->expects($this->once()) ->method('writeln') diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php index cff6323802083..0e1e96c0e6a0c 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php @@ -32,14 +32,26 @@ class FilePermissionsTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->directoryWriteMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->directoryWriteMock = $this->getMock( + \Magento\Framework\Filesystem\Directory\Write::class, + [], + [], + '', + false + ); + $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->filesystemMock ->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValue($this->directoryWriteMock)); - $this->directoryListMock = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $this->directoryListMock = $this->getMock( + \Magento\Framework\App\Filesystem\DirectoryList::class, + [], + [], + '', + false + ); $this->filePermissions = new FilePermissions( $this->filesystemMock, diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php index 8dcc587747f5d..4ce704c3b6adf 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php @@ -52,7 +52,7 @@ class ListsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mockConfig = $this->getMockBuilder('\Magento\Framework\Locale\ConfigInterface') + $this->mockConfig = $this->getMockBuilder(\Magento\Framework\Locale\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $this->mockConfig->expects($this->any()) diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php index 9043cf86d0772..435f7e1c3512a 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php @@ -32,12 +32,12 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->setMethods(['getDirectoryWrite']) ->disableOriginalConstructor() ->getMock(); $this->writeInterface = $this->getMockForAbstractClass( - 'Magento\Framework\Filesystem\Directory\WriteInterface', + \Magento\Framework\Filesystem\Directory\WriteInterface::class, [], '', false, @@ -47,7 +47,7 @@ protected function setUp() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->state = $objectManager->getObject( - 'Magento\Framework\Setup\SampleData\State', + \Magento\Framework\Setup\SampleData\State::class, ['filesystem' => $this->filesystem] ); } diff --git a/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererBackgroundTest.php b/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererBackgroundTest.php index bac1f118035eb..e466f8f1124b0 100644 --- a/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererBackgroundTest.php +++ b/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererBackgroundTest.php @@ -23,7 +23,7 @@ class CommandRendererBackgroundTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->osInfo = $this->getMockBuilder('Magento\Framework\OsInfo')->getMock(); + $this->osInfo = $this->getMockBuilder(\Magento\Framework\OsInfo::class)->getMock(); } /** diff --git a/lib/internal/Magento/Framework/Simplexml/Config.php b/lib/internal/Magento/Framework/Simplexml/Config.php index ead6ad0f73fbb..9f9cd4fe46169 100644 --- a/lib/internal/Magento/Framework/Simplexml/Config.php +++ b/lib/internal/Magento/Framework/Simplexml/Config.php @@ -64,7 +64,7 @@ class Config * * @var string */ - protected $_elementClass = 'Magento\Framework\Simplexml\Element'; + protected $_elementClass = \Magento\Framework\Simplexml\Element::class; /** * Xpath describing nodes in configuration that need to be extended diff --git a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php index 83c6de6f94356..dac1935ba2640 100644 --- a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php @@ -31,7 +31,7 @@ public function testConstruct() $this->assertXmlStringEqualsXmlString($xml, $config->getXmlString()); /** @var Element $simpleXml */ - $simpleXml = simplexml_load_string(file_get_contents($file), 'Magento\Framework\Simplexml\Element'); + $simpleXml = simplexml_load_string(file_get_contents($file), \Magento\Framework\Simplexml\Element::class); $config = new Config($simpleXml); $this->assertXmlStringEqualsXmlString($xml, $config->getXmlString()); } @@ -65,7 +65,7 @@ public function testGetXpath() $this->assertFalse($config->getXpath('wrong_xpath')); $element = $config->getXpath('/root/node_2/node_2_1'); $this->assertArrayHasKey(0, $element); - $this->assertInstanceOf('Magento\Framework\Simplexml\Element', $element[0]); + $this->assertInstanceOf(\Magento\Framework\Simplexml\Element::class, $element[0]); $this->assertSame('Value 2.1', $element[0]->asArray()); } @@ -115,7 +115,7 @@ public function testValidateCacheChecksum() $this->config->setCacheId('cacheId'); $this->config->setCacheChecksum('CacheChecksum'); - $cache = $this->getMock('Magento\Framework\Simplexml\Config\Cache\File', ['load']); + $cache = $this->getMock(\Magento\Framework\Simplexml\Config\Cache\File::class, ['load']); $cache->expects($this->once())->method('load')->with('cacheId__CHECKSUM') ->will($this->returnValue('415a5472d4f94b71ff80fd1c8e9eca7f')); $this->config->setCache($cache); @@ -129,7 +129,7 @@ public function testLoadCache() $this->config->setCacheId('cacheId'); $this->config->setCacheChecksum('CacheChecksum'); - $cache = $this->getMock('Magento\Framework\Simplexml\Config\Cache\File', ['load']); + $cache = $this->getMock(\Magento\Framework\Simplexml\Config\Cache\File::class, ['load']); $this->config->setCache($cache); $cache->expects($this->at(0))->method('load')->with('cacheId__CHECKSUM') @@ -150,7 +150,7 @@ public function testSaveCache() { $xml = '1'; - $cache = $this->getMock('Magento\Framework\Simplexml\Config\Cache\File', ['save']); + $cache = $this->getMock(\Magento\Framework\Simplexml\Config\Cache\File::class, ['save']); $cache->expects($this->at(0))->method('save') ->with(null, 'cacheId__CHECKSUM', ['cacheTags'], 10) ->will($this->returnValue(true)); @@ -175,7 +175,7 @@ public function testSaveCache() public function testRemoveCache() { - $cache = $this->getMock('Magento\Framework\Simplexml\Config\Cache\File', ['remove']); + $cache = $this->getMock(\Magento\Framework\Simplexml\Config\Cache\File::class, ['remove']); $cache->expects($this->at(0))->method('remove') ->with('cacheId') ->will($this->returnValue(true)); diff --git a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php index 6e470ea58a8b5..d79efc4f92fc5 100644 --- a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php +++ b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php @@ -40,7 +40,7 @@ public function testGetParent($xmlData) public static function xmlDataProvider() { return [ - [[__DIR__ . '/_files/data.xml', 'Magento\Framework\Simplexml\Element']] + [[__DIR__ . '/_files/data.xml', \Magento\Framework\Simplexml\Element::class]] ]; } @@ -48,7 +48,7 @@ public function testAsNiceXmlMixedData() { $dataFile = file_get_contents(__DIR__ . '/_files/mixed_data.xml'); /** @var \Magento\Framework\Simplexml\Element $xml */ - $xml = simplexml_load_string($dataFile, 'Magento\Framework\Simplexml\Element'); + $xml = simplexml_load_string($dataFile, \Magento\Framework\Simplexml\Element::class); $expected = << @@ -69,11 +69,11 @@ public function testAsNiceXmlMixedData() public function testAppendChild() { /** @var \Magento\Framework\Simplexml\Element $baseXml */ - $baseXml = simplexml_load_string('', 'Magento\Framework\Simplexml\Element'); + $baseXml = simplexml_load_string('', \Magento\Framework\Simplexml\Element::class); /** @var \Magento\Framework\Simplexml\Element $appendXml */ $appendXml = simplexml_load_string( 'text', - 'Magento\Framework\Simplexml\Element' + \Magento\Framework\Simplexml\Element::class ); $baseXml->appendChild($appendXml); @@ -86,7 +86,7 @@ public function testSetNode() $path = '/node1/node2'; $value = 'value'; /** @var \Magento\Framework\Simplexml\Element $xml */ - $xml = simplexml_load_string('', 'Magento\Framework\Simplexml\Element'); + $xml = simplexml_load_string('', \Magento\Framework\Simplexml\Element::class); $this->assertEmpty($xml->xpath('/root/node1/node2')); $xml->setNode($path, $value); $this->assertNotEmpty($xml->xpath('/root/node1/node2')); @@ -101,7 +101,7 @@ public function testSetNode() public function testSetAttribute($name, $value) { /** @var \Magento\Framework\Simplexml\Element $xml */ - $xml = simplexml_load_string('', 'Magento\Framework\Simplexml\Element'); + $xml = simplexml_load_string('', \Magento\Framework\Simplexml\Element::class); $this->assertEquals($xml->getAttribute('name'), 'test2'); $this->assertNull($xml->getAttribute('new')); $xml->setAttribute($name, $value); diff --git a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php index 148aa72a94613..83cc52c3cf200 100644 --- a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php +++ b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php @@ -30,14 +30,14 @@ public function testInvokeWithExpectations( $expectedResult ) { // Create proxied object with $callProxiedMethod - $proxiedObject = $this->getMock('stdClass', [$callProxiedMethod]); + $proxiedObject = $this->getMock(\stdClass::class, [$callProxiedMethod]); // Create object, which reacts on called $method by calling $callProxiedMethod from proxied object $callProxy = function () use ($proxiedObject, $callProxiedMethod, $passProxiedParams) { return call_user_func_array([$proxiedObject, $callProxiedMethod], $passProxiedParams); }; - $object = $this->getMock('stdClass', [$method]); + $object = $this->getMock(\stdClass::class, [$method]); $builder = $object->expects($this->once())->method($method); call_user_func_array([$builder, 'with'], $params); $builder->will($this->returnCallback($callProxy)); diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/AbstractFactoryTestCase.php b/lib/internal/Magento/Framework/TestFramework/Unit/AbstractFactoryTestCase.php index 4896d190734a6..1efff6d6761dd 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/AbstractFactoryTestCase.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/AbstractFactoryTestCase.php @@ -38,10 +38,14 @@ abstract class AbstractFactoryTestCase extends \PHPUnit_Framework_TestCase */ protected $factory; + /** + * Setup function + * @return void + */ protected function setUp() { $this->objectManager = new Helper\ObjectManager($this); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->factory = $this->objectManager->getObject( @@ -50,6 +54,10 @@ protected function setUp() ); } + /** + * Test create + * @return void + */ public function testCreate() { $instanceMock = $this->getMockBuilder($this->instanceClassName) diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php b/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php index f0afc6bc2c52f..e197248382956 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php @@ -13,6 +13,7 @@ /** * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Adminhtml extends \PHPUnit_Framework_TestCase { @@ -73,33 +74,33 @@ class Adminhtml extends \PHPUnit_Framework_TestCase protected function setUp() { // These mocks are accessed via context - $this->_designMock = $this->_makeMock('Magento\Framework\View\DesignInterface'); - $this->_sessionMock = $this->_makeMock('Magento\Framework\Session\Generic'); - $this->_sidResolver = $this->_makeMock('Magento\Framework\Session\SidResolver'); - $this->_translatorMock = $this->_makeMock('Magento\Framework\TranslateInterface'); - $this->_layoutMock = $this->_makeMock('Magento\Framework\View\Layout'); - $this->_requestMock = $this->_makeMock('Magento\Framework\App\RequestInterface'); - $this->_messagesMock = $this->_makeMock('Magento\Framework\View\Element\Messages'); - $this->_urlMock = $this->_makeMock('Magento\Framework\UrlInterface'); - $this->_eventManagerMock = $this->_makeMock('Magento\Framework\Event\ManagerInterface'); - $this->_controllerMock = $this->_makeMock('Magento\Framework\App\FrontController'); - $this->_loggerMock = $this->_makeMock('Psr\Log\LoggerInterface'); - $this->_filesystemMock = $this->_makeMock('Magento\Framework\Filesystem'); - $this->_cacheMock = $this->_makeMock('Magento\Framework\App\CacheInterface'); - $this->_scopeConfigMock = $this->_makeMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->_storeManagerMock = $this->_makeMock('Magento\Store\Model\StoreManager'); - $assetRepoMock = $this->_makeMock('Magento\Framework\View\Asset\Repository'); - $viewConfigMock = $this->_makeMock('Magento\Framework\View\ConfigInterface'); - $viewFileSystemMock = $this->_makeMock('Magento\Framework\View\FileSystem'); - $templatePoolMock = $this->_makeMock('Magento\Framework\View\TemplateEnginePool'); - $authorizationMock = $this->_makeMock('Magento\Framework\AuthorizationInterface'); - $cacheStateMock = $this->_makeMock('Magento\Framework\App\Cache\StateInterface'); - $escaperMock = $this->_makeMock('Magento\Framework\Escaper'); - $filterManagerMock = $this->_makeMock('Magento\Framework\Filter\FilterManager'); - $backendSessionMock = $this->_makeMock('Magento\Backend\Model\Session'); - $appState = $this->_makeMock('Magento\Framework\App\State'); - $this->_mathMock = $this->_makeMock('Magento\Framework\Math\Random'); - $this->_formKey = $this->_makeMock('Magento\Framework\Data\Form\FormKey'); + $this->_designMock = $this->_makeMock(\Magento\Framework\View\DesignInterface::class); + $this->_sessionMock = $this->_makeMock(\Magento\Framework\Session\Generic::class); + $this->_sidResolver = $this->_makeMock(\Magento\Framework\Session\SidResolver::class); + $this->_translatorMock = $this->_makeMock(\Magento\Framework\TranslateInterface::class); + $this->_layoutMock = $this->_makeMock(\Magento\Framework\View\Layout::class); + $this->_requestMock = $this->_makeMock(\Magento\Framework\App\RequestInterface::class); + $this->_messagesMock = $this->_makeMock(\Magento\Framework\View\Element\Messages::class); + $this->_urlMock = $this->_makeMock(\Magento\Framework\UrlInterface::class); + $this->_eventManagerMock = $this->_makeMock(\Magento\Framework\Event\ManagerInterface::class); + $this->_controllerMock = $this->_makeMock(\Magento\Framework\App\FrontController::class); + $this->_loggerMock = $this->_makeMock(\Psr\Log\LoggerInterface::class); + $this->_filesystemMock = $this->_makeMock(\Magento\Framework\Filesystem::class); + $this->_cacheMock = $this->_makeMock(\Magento\Framework\App\CacheInterface::class); + $this->_scopeConfigMock = $this->_makeMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_storeManagerMock = $this->_makeMock(\Magento\Store\Model\StoreManager::class); + $assetRepoMock = $this->_makeMock(\Magento\Framework\View\Asset\Repository::class); + $viewConfigMock = $this->_makeMock(\Magento\Framework\View\ConfigInterface::class); + $viewFileSystemMock = $this->_makeMock(\Magento\Framework\View\FileSystem::class); + $templatePoolMock = $this->_makeMock(\Magento\Framework\View\TemplateEnginePool::class); + $authorizationMock = $this->_makeMock(\Magento\Framework\AuthorizationInterface::class); + $cacheStateMock = $this->_makeMock(\Magento\Framework\App\Cache\StateInterface::class); + $escaperMock = $this->_makeMock(\Magento\Framework\Escaper::class); + $filterManagerMock = $this->_makeMock(\Magento\Framework\Filter\FilterManager::class); + $backendSessionMock = $this->_makeMock(\Magento\Backend\Model\Session::class); + $appState = $this->_makeMock(\Magento\Framework\App\State::class); + $this->_mathMock = $this->_makeMock(\Magento\Framework\Math\Random::class); + $this->_formKey = $this->_makeMock(\Magento\Framework\Data\Form\FormKey::class); $appState->setAreaCode(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); @@ -177,7 +178,7 @@ protected function _setStub( /** * Return the English text passed into the translate method * - * @param $args + * @param array $args * @return mixed */ public function translateCallback($args) diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php index 7dc84bda14563..fd8fd44b25829 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php @@ -9,6 +9,9 @@ */ namespace Magento\Framework\TestFramework\Unit\Helper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ObjectManager { /** @@ -17,8 +20,8 @@ class ObjectManager * @var array */ protected $_specialCases = [ - 'Magento\Framework\Model\ResourceModel\AbstractResource' => '_getResourceModelMock', - 'Magento\Framework\TranslateInterface' => '_getTranslatorMock', + \Magento\Framework\Model\ResourceModel\AbstractResource::class => '_getResourceModelMock', + \Magento\Framework\TranslateInterface::class => '_getTranslatorMock', ]; /** @@ -68,7 +71,7 @@ protected function _processSpecialCases($className, $arguments) { $object = null; $interfaces = class_implements($className); - if (in_array('Magento\Framework\ObjectManager\ContextInterface', $interfaces)) { + if (in_array(\Magento\Framework\ObjectManager\ContextInterface::class, $interfaces)) { $object = $this->getObject($className, $arguments); } elseif (isset($this->_specialCases[$className])) { $method = $this->_specialCases[$className]; @@ -86,7 +89,7 @@ protected function _processSpecialCases($className, $arguments) protected function _getResourceModelMock() { $resourceMock = $this->_testObject->getMock( - 'Magento\Framework\Module\ModuleResource', + \Magento\Framework\Module\ModuleResource::class, ['getIdFieldName', '__sleep', '__wakeup'], [], '', @@ -152,8 +155,8 @@ protected function _getMockWithoutConstructorCall($className) */ public function getObject($className, array $arguments = []) { - if (is_subclass_of($className, '\Magento\Framework\Api\AbstractSimpleObjectBuilder') - || is_subclass_of($className, '\Magento\Framework\Api\Builder') + if (is_subclass_of($className, \Magento\Framework\Api\AbstractSimpleObjectBuilder::class) + || is_subclass_of($className, \Magento\Framework\Api\Builder::class) ) { return $this->getBuilder($className, $arguments); } @@ -181,7 +184,7 @@ public function getObject($className, array $arguments = []) */ protected function getBuilder($className, array $arguments) { - $objectFactory = $this->_testObject->getMock('Magento\Framework\Api\ObjectFactory', [], [], '', false); + $objectFactory = $this->_testObject->getMock(\Magento\Framework\Api\ObjectFactory::class, [], [], '', false); if (!isset($arguments['objectFactory'])) { $arguments['objectFactory'] = $objectFactory; @@ -287,7 +290,7 @@ public function getConstructArguments($className, array $arguments = []) */ public function getCollectionMock($className, array $data) { - if (!is_subclass_of($className, '\Magento\Framework\Data\Collection')) { + if (!is_subclass_of($className, \Magento\Framework\Data\Collection::class)) { throw new \InvalidArgumentException( $className . ' does not instance of \Magento\Framework\Data\Collection' ); @@ -315,7 +318,7 @@ public function getCollectionMock($className, array $data) */ private function _getMockObject($argClassName, array $arguments) { - if (is_subclass_of($argClassName, '\Magento\Framework\Api\ExtensibleObjectBuilder')) { + if (is_subclass_of($argClassName, \Magento\Framework\Api\ExtensibleObjectBuilder::class)) { $object = $this->getBuilder($argClassName, $arguments); return $object; } else { diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/SelectRendererTrait.php b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/SelectRendererTrait.php index 3da179594385e..e810ca039450e 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/SelectRendererTrait.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/SelectRendererTrait.php @@ -18,21 +18,21 @@ trait SelectRendererTrait protected function getSelectRenderer(\Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManager) { return $objectManager->getObject( - 'Magento\Framework\DB\Select\SelectRenderer', + \Magento\Framework\DB\Select\SelectRenderer::class, [ 'renderers' => [ 'distinct' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\DistinctRenderer' + \Magento\Framework\DB\Select\DistinctRenderer::class ), 'sort' => 11, 'part' => 'distinct', ], 'columns' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\ColumnsRenderer', + \Magento\Framework\DB\Select\ColumnsRenderer::class, [ - 'quote' => $objectManager->getObject('Magento\Framework\DB\Platform\Quote') + 'quote' => $objectManager->getObject(\Magento\Framework\DB\Platform\Quote::class) ] ), 'sort' => 11, @@ -40,16 +40,16 @@ protected function getSelectRenderer(\Magento\Framework\TestFramework\Unit\Helpe ], 'union' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\UnionRenderer' + \Magento\Framework\DB\Select\UnionRenderer::class ), 'sort' => 11, 'part' => 'union', ], 'from' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\FromRenderer', + \Magento\Framework\DB\Select\FromRenderer::class, [ - 'quote' => $objectManager->getObject('Magento\Framework\DB\Platform\Quote') + 'quote' => $objectManager->getObject(\Magento\Framework\DB\Platform\Quote::class) ] ), 'sort' => 11, @@ -57,35 +57,35 @@ protected function getSelectRenderer(\Magento\Framework\TestFramework\Unit\Helpe ], 'where' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\WhereRenderer' + \Magento\Framework\DB\Select\WhereRenderer::class ), 'sort' => 11, 'part' => 'where', ], 'group' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\GroupRenderer' + \Magento\Framework\DB\Select\GroupRenderer::class ), 'sort' => 11, 'part' => 'group', ], 'having' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\HavingRenderer' + \Magento\Framework\DB\Select\HavingRenderer::class ), 'sort' => 11, 'part' => 'having', ], 'order' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\OrderRenderer' + \Magento\Framework\DB\Select\OrderRenderer::class ), 'sort' => 11, 'part' => 'order', ], 'limit' => [ 'renderer' => $objectManager->getObject( - 'Magento\Framework\DB\Select\LimitRenderer' + \Magento\Framework\DB\Select\LimitRenderer::class ), 'sort' => 11, 'part' => 'limitcount', diff --git a/lib/internal/Magento/Framework/Translate/AbstractAdapter.php b/lib/internal/Magento/Framework/Translate/AbstractAdapter.php index 986ebb677e328..2f0ceb7735eae 100644 --- a/lib/internal/Magento/Framework/Translate/AbstractAdapter.php +++ b/lib/internal/Magento/Framework/Translate/AbstractAdapter.php @@ -60,6 +60,6 @@ public function setLocale($locale) */ public function toString() { - return 'Magento\Framework\Translate\Adapter'; + return \Magento\Framework\Translate\Adapter::class; } } diff --git a/lib/internal/Magento/Framework/Translate/Inline.php b/lib/internal/Magento/Framework/Translate/Inline.php index 6425bfbb53dc8..6ba3cb9dcb330 100644 --- a/lib/internal/Magento/Framework/Translate/Inline.php +++ b/lib/internal/Magento/Framework/Translate/Inline.php @@ -207,7 +207,7 @@ protected function addInlineScript() protected function getInlineScript() { /** @var $block \Magento\Framework\View\Element\Template */ - $block = $this->layout->createBlock('Magento\Framework\View\Element\Template'); + $block = $this->layout->createBlock(\Magento\Framework\View\Element\Template::class); $block->setAjaxUrl($this->getAjaxUrl()); $block->setTemplate($this->templateFileName); diff --git a/lib/internal/Magento/Framework/Translate/Inline/ParserFactory.php b/lib/internal/Magento/Framework/Translate/Inline/ParserFactory.php index ccf64d56ac3e7..f0b44a5a6426a 100644 --- a/lib/internal/Magento/Framework/Translate/Inline/ParserFactory.php +++ b/lib/internal/Magento/Framework/Translate/Inline/ParserFactory.php @@ -12,7 +12,7 @@ class ParserFactory /** * Default instance type */ - const DEFAULT_INSTANCE_TYPE = 'Magento\Framework\Translate\Inline\ParserInterface'; + const DEFAULT_INSTANCE_TYPE = \Magento\Framework\Translate\Inline\ParserInterface::class; /** * Object Manager diff --git a/lib/internal/Magento/Framework/Translate/Inline/Proxy.php b/lib/internal/Magento/Framework/Translate/Inline/Proxy.php index 9d59fe0e31821..4072a6f372975 100644 --- a/lib/internal/Magento/Framework/Translate/Inline/Proxy.php +++ b/lib/internal/Magento/Framework/Translate/Inline/Proxy.php @@ -46,7 +46,7 @@ class Proxy extends \Magento\Framework\Translate\Inline implements */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Translate\Inline', + $instanceName = \Magento\Framework\Translate\Inline::class, $shared = true ) { $this->objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterAbstractTest.php b/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterAbstractTest.php index 8d50068404c75..72b22d4b15d5d 100644 --- a/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterAbstractTest.php +++ b/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterAbstractTest.php @@ -14,7 +14,8 @@ class AdapterAbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_model = $this->getMockBuilder('Magento\Framework\Translate\AbstractAdapter')->getMockForAbstractClass(); + $this->_model = $this->getMockBuilder(\Magento\Framework\Translate\AbstractAdapter::class) + ->getMockForAbstractClass(); } /** @@ -30,7 +31,10 @@ public function testIsTranslated() */ public function testSetLocale() { - $this->assertInstanceOf('Magento\Framework\Translate\AbstractAdapter', $this->_model->setLocale('en_US')); + $this->assertInstanceOf( + \Magento\Framework\Translate\AbstractAdapter::class, + $this->_model->setLocale('en_US') + ); } /** @@ -38,6 +42,6 @@ public function testSetLocale() */ public function testToString() { - $this->assertEquals('Magento\Framework\Translate\Adapter', $this->_model->toString()); + $this->assertEquals(\Magento\Framework\Translate\Adapter::class, $this->_model->toString()); } } diff --git a/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php b/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php index acfd8b5b324c2..992ee64f0d1ce 100644 --- a/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php +++ b/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php @@ -17,7 +17,7 @@ class AdapterTest extends \PHPUnit_Framework_TestCase */ public function testTranslate($method, $strToTranslate, $translatedStr) { - $translatorMock = $this->getMockBuilder('stdClass')->setMethods(['translate'])->getMock(); + $translatorMock = $this->getMockBuilder(\stdClass::class)->setMethods(['translate'])->getMock(); $translatorMock->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/Translate/Test/Unit/Inline/ProxyTest.php b/lib/internal/Magento/Framework/Translate/Test/Unit/Inline/ProxyTest.php index e8156cf5e3e17..d8054da842a0f 100644 --- a/lib/internal/Magento/Framework/Translate/Test/Unit/Inline/ProxyTest.php +++ b/lib/internal/Magento/Framework/Translate/Test/Unit/Inline/ProxyTest.php @@ -21,8 +21,8 @@ class ProxyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->translateMock = $this->getMock('Magento\Framework\Translate\Inline', [], [], '', false); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->translateMock = $this->getMock(\Magento\Framework\Translate\Inline::class, [], [], '', false); } public function testIsAllowed() @@ -32,7 +32,7 @@ public function testIsAllowed() )->method( 'get' )->with( - 'Magento\Framework\Translate\Inline' + \Magento\Framework\Translate\Inline::class )->will( $this->returnValue($this->translateMock) ); @@ -41,7 +41,7 @@ public function testIsAllowed() $model = new Proxy( $this->objectManagerMock, - 'Magento\Framework\Translate\Inline', + \Magento\Framework\Translate\Inline::class, true ); @@ -56,7 +56,7 @@ public function testGetParser() )->method( 'create' )->with( - 'Magento\Framework\Translate\Inline' + \Magento\Framework\Translate\Inline::class )->will( $this->returnValue($this->translateMock) ); @@ -65,7 +65,7 @@ public function testGetParser() $model = new Proxy( $this->objectManagerMock, - 'Magento\Framework\Translate\Inline', + \Magento\Framework\Translate\Inline::class, false ); @@ -80,7 +80,7 @@ public function testProcessResponseBody() )->method( 'get' )->with( - 'Magento\Framework\Translate\Inline' + \Magento\Framework\Translate\Inline::class )->will( $this->returnValue($this->translateMock) ); @@ -93,7 +93,7 @@ public function testProcessResponseBody() $model = new Proxy( $this->objectManagerMock, - 'Magento\Framework\Translate\Inline', + \Magento\Framework\Translate\Inline::class, true ); $body = ''; @@ -108,7 +108,7 @@ public function testGetAdditionalHtmlAttribute() )->method( 'create' )->with( - 'Magento\Framework\Translate\Inline' + \Magento\Framework\Translate\Inline::class )->will( $this->returnValue($this->translateMock) ); @@ -120,7 +120,7 @@ public function testGetAdditionalHtmlAttribute() $model = new Proxy( $this->objectManagerMock, - 'Magento\Framework\Translate\Inline', + \Magento\Framework\Translate\Inline::class, false ); diff --git a/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php b/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php index 63233d7424b99..2f1f8666860f9 100644 --- a/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php +++ b/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php @@ -42,25 +42,25 @@ class InlineTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeResolverMock = - $this->getMock('Magento\Framework\App\ScopeResolverInterface', [], [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\LayoutInterface', [], [], '', false); + $this->getMock(\Magento\Framework\App\ScopeResolverInterface::class, [], [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); $this->configMock = $this->getMock( - 'Magento\Framework\Translate\Inline\ConfigInterface', + \Magento\Framework\Translate\Inline\ConfigInterface::class, [], [], '', false ); $this->parserMock = $this->getMock( - 'Magento\Framework\Translate\Inline\ParserInterface', + \Magento\Framework\Translate\Inline\ParserInterface::class, [], [], '', false ); $this->stateMock = $this->getMock( - 'Magento\Framework\Translate\Inline\StateInterface', + \Magento\Framework\Translate\Inline\StateInterface::class, [], [], '', @@ -288,7 +288,7 @@ public function processResponseBodyGetInlineScriptDataProvider() */ protected function prepareIsAllowed($isEnabled, $isActive, $isDevAllowed, $scope = null) { - $scopeMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $scopeMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); $this->stateMock->expects($this->any())->method('isEnabled')->will($this->returnValue($isEnabled)); $this->scopeResolverMock->expects( $this->once() diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php index 2da5b6f1ec068..9f576e61641d7 100644 --- a/lib/internal/Magento/Framework/Url.php +++ b/lib/internal/Magento/Framework/Url.php @@ -1154,8 +1154,8 @@ protected function getRouteParamsResolver() private function getUrlModifier() { if ($this->urlModifier === null) { - $this->urlModifier = \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Framework\Url\ModifierInterface' + $this->urlModifier = \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Framework\Url\ModifierInterface::class ); } diff --git a/lib/internal/Magento/Framework/Url/RouteParamsResolverFactory.php b/lib/internal/Magento/Framework/Url/RouteParamsResolverFactory.php index 1f66ac7b5e210..4b31a8a0f9062 100644 --- a/lib/internal/Magento/Framework/Url/RouteParamsResolverFactory.php +++ b/lib/internal/Magento/Framework/Url/RouteParamsResolverFactory.php @@ -23,7 +23,7 @@ class RouteParamsResolverFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Url\RouteParamsResolverInterface' + $instanceName = \Magento\Framework\Url\RouteParamsResolverInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/DecoderTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/DecoderTest.php index bccff27e12686..cb7b623493b43 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/DecoderTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/DecoderTest.php @@ -16,7 +16,7 @@ class DecoderTest extends \PHPUnit_Framework_TestCase */ public function testDecode() { - $urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); /** @var $urlBuilderMock \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ $decoder = new Decoder($urlBuilderMock); $encoder = new Encoder(); diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php index a982aaba5ef72..8e6d3c6485695 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php @@ -19,7 +19,7 @@ protected function setUp() public function testGetCurrentBase64Url() { - $urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); $url = 'http://example.com'; @@ -27,14 +27,14 @@ public function testGetCurrentBase64Url() ->method('getCurrentUrl') ->will($this->returnValue($url)); $encodedUrl = 'encodedUrl'; - $urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface') + $urlEncoder = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); $urlEncoder->expects($this->once()) ->method('encode') ->will($this->returnValue($encodedUrl)); $context = $this->objectManager->getObject( - 'Magento\Framework\App\Helper\Context', + \Magento\Framework\App\Helper\Context::class, [ 'urlBuilder' => $urlBuilderMock, 'urlEncoder' => $urlEncoder, @@ -52,7 +52,7 @@ public function testGetCurrentBase64Url() */ public function testGetEncodedUrl($url, $callNum) { - $urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); $encodingUrl = $url ? $url : 'http://example.com'; @@ -60,14 +60,14 @@ public function testGetEncodedUrl($url, $callNum) ->method('getCurrentUrl') ->will($this->returnValue($encodingUrl)); $encodedUrl = 'encodedUrl'; - $urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface') + $urlEncoder = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); $urlEncoder->expects($this->once()) ->method('encode') ->will($this->returnValue($encodedUrl)); $context = $this->objectManager->getObject( - 'Magento\Framework\App\Helper\Context', + \Magento\Framework\App\Helper\Context::class, [ 'urlBuilder' => $urlBuilderMock, 'urlEncoder' => $urlEncoder, @@ -171,6 +171,6 @@ public function removeRequestParamDataProvider() */ private function getHelper($arguments) { - return $this->objectManager->getObject('Magento\Framework\Url\Helper\Data', $arguments); + return $this->objectManager->getObject(\Magento\Framework\Url\Helper\Data::class, $arguments); } } diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/QueryParamsResolverTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/QueryParamsResolverTest.php index 94da9eed2769c..ea94ea270eb17 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/QueryParamsResolverTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/QueryParamsResolverTest.php @@ -16,7 +16,7 @@ class QueryParamsResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->object = $objectManager->getObject('Magento\Framework\Url\QueryParamsResolver'); + $this->object = $objectManager->getObject(\Magento\Framework\Url\QueryParamsResolver::class); } public function testGetQuery() diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/RouteParamsResolverFactoryTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/RouteParamsResolverFactoryTest.php index 107cd6444a16c..efa31ac6d85fe 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/RouteParamsResolverFactoryTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/RouteParamsResolverFactoryTest.php @@ -17,21 +17,21 @@ class RouteParamsResolverFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager = new ObjectManager($this); $this->object = $objectManager->getObject( - 'Magento\Framework\Url\RouteParamsResolverFactory', + \Magento\Framework\Url\RouteParamsResolverFactory::class, ['objectManager' => $this->objectManager] ); } public function testCreate() { - $producedInstance = $this->getMock('Magento\Framework\Url\RouteParamsResolverInterface'); + $producedInstance = $this->getMock(\Magento\Framework\Url\RouteParamsResolverInterface::class); $this->objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\Url\RouteParamsResolverInterface') + ->with(\Magento\Framework\Url\RouteParamsResolverInterface::class) ->will($this->returnValue($producedInstance)); $this->assertSame($producedInstance, $this->object->create([])); diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/ScopeResolverTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/ScopeResolverTest.php index 908b2eba9ad8e..affc0cd27b34f 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/ScopeResolverTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/ScopeResolverTest.php @@ -20,9 +20,11 @@ class ScopeResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeResolverMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface')->getMock(); + $this->scopeResolverMock = $this->getMockBuilder( + \Magento\Framework\App\ScopeResolverInterface::class + )->getMock(); $this->_object = $objectManager->getObject( - 'Magento\Framework\Url\ScopeResolver', + \Magento\Framework\Url\ScopeResolver::class, ['scopeResolver' => $this->scopeResolverMock] ); } @@ -33,7 +35,7 @@ protected function setUp() */ public function testGetScope($scopeId) { - $scopeMock = $this->getMockBuilder('Magento\Framework\Url\ScopeInterface')->getMock(); + $scopeMock = $this->getMockBuilder(\Magento\Framework\Url\ScopeInterface::class)->getMock(); $this->scopeResolverMock->expects( $this->at(0) )->method( diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/ValidatorTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/ValidatorTest.php index 4ee36995021d8..47e68cfd5eea8 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/ValidatorTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/ValidatorTest.php @@ -18,7 +18,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->object = $objectManager->getObject('Magento\Framework\Url\Validator'); + $this->object = $objectManager->getObject(\Magento\Framework\Url\Validator::class); } public function testConstruct() diff --git a/lib/internal/Magento/Framework/Validator/Config.php b/lib/internal/Magento/Framework/Validator/Config.php index 6ed6277faf8ab..dc0d6a6259db2 100644 --- a/lib/internal/Magento/Framework/Validator/Config.php +++ b/lib/internal/Magento/Framework/Validator/Config.php @@ -24,7 +24,7 @@ class Config extends \Magento\Framework\Config\AbstractXml /** * @var string */ - protected $_defaultBuilderClass = 'Magento\Framework\Validator\Builder'; + protected $_defaultBuilderClass = \Magento\Framework\Validator\Builder::class; /** * @var \Magento\Framework\Validator\UniversalFactory diff --git a/lib/internal/Magento/Framework/Validator/ConstraintFactory.php b/lib/internal/Magento/Framework/Validator/ConstraintFactory.php index a54c1f3bd4d4e..1077f21bfa2bd 100644 --- a/lib/internal/Magento/Framework/Validator/ConstraintFactory.php +++ b/lib/internal/Magento/Framework/Validator/ConstraintFactory.php @@ -33,7 +33,7 @@ class ConstraintFactory * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param string $instanceName */ - public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = 'Magento\Framework\Validator\Constraint') + public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = \Magento\Framework\Validator\Constraint::class) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php index d390e737c665d..d2e3837d13138 100644 --- a/lib/internal/Magento/Framework/Validator/Factory.php +++ b/lib/internal/Magento/Framework/Validator/Factory.php @@ -91,7 +91,7 @@ protected function _initializeDefaultTranslator() return (string)new \Magento\Framework\Phrase(array_shift($argc), $argc); }; /** @var \Magento\Framework\Translate\Adapter $translator */ - $translator = $this->_objectManager->create('Magento\Framework\Translate\Adapter'); + $translator = $this->_objectManager->create(\Magento\Framework\Translate\Adapter::class); $translator->setOptions(['translator' => $translatorCallback]); \Magento\Framework\Validator\AbstractValidator::setDefaultTranslator($translator); $this->isDefaultTranslatorInitialized = true; @@ -109,7 +109,8 @@ public function getValidatorConfig() { $this->_initializeConfigList(); $this->_initializeDefaultTranslator(); - return $this->_objectManager->create('Magento\Framework\Validator\Config', ['configFiles' => $this->_configFiles]); + return $this->_objectManager->create( + \Magento\Framework\Validator\Config::class, ['configFiles' => $this->_configFiles]); } /** diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php index 0ba7f79d72528..b12a802585ae5 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php @@ -46,7 +46,7 @@ public function testCreateValidator(array $constraints, $expectedValidator) { /** @var $builder \Magento\Framework\Validator\Builder */ $builder = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, [ 'constraintFactory' => new \Magento\Framework\Validator\ConstraintFactory($this->_realObjectManager), 'validatorFactory' => new \Magento\Framework\ValidatorFactory($this->_realObjectManager), @@ -68,14 +68,16 @@ public function createValidatorDataProvider() $result = []; /** @var \Magento\Framework\Translate\AbstractAdapter $translator */ - $translator = $this->getMockBuilder('Magento\Framework\Translate\AbstractAdapter')->getMockForAbstractClass(); + $translator = $this->getMockBuilder( + \Magento\Framework\Translate\AbstractAdapter::class + )->getMockForAbstractClass(); \Magento\Framework\Validator\AbstractValidator::setDefaultTranslator($translator); // Case 1. Check constructor with arguments $actualConstraints = [ [ 'alias' => 'name_alias', - 'class' => 'Magento\Framework\Validator\Test\Unit\Test\StringLength', + 'class' => \Magento\Framework\Validator\Test\Unit\Test\StringLength::class, 'options' => [ 'arguments' => [ 'options' => ['min' => 1, 'max' => new \Magento\Framework\Validator\Constraint\Option(20)], @@ -101,7 +103,7 @@ public function createValidatorDataProvider() $actualConstraints = [ [ 'alias' => 'description_alias', - 'class' => 'Magento\Framework\Validator\Test\Unit\Test\StringLength', + 'class' => \Magento\Framework\Validator\Test\Unit\Test\StringLength::class, 'options' => [ 'methods' => [ ['method' => 'setMin', 'arguments' => [10]], @@ -128,7 +130,7 @@ public function createValidatorDataProvider() $actualConstraints = [ [ 'alias' => 'sku_alias', - 'class' => 'Magento\Framework\Validator\Test\Unit\Test\StringLength', + 'class' => \Magento\Framework\Validator\Test\Unit\Test\StringLength::class, 'options' => [ 'callback' => [ new \Magento\Framework\Validator\Constraint\Option\Callback( @@ -166,7 +168,7 @@ public function testAddConfiguration($constraints, $alias, $configuration, $expe { /** @var $builder \Magento\Framework\Validator\Builder */ $builder = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, ['constraints' => $constraints] ); $builder->addConfiguration($alias, $configuration); @@ -187,7 +189,7 @@ public function testAddConfigurations($constraints, $alias, $configuration, $exp { /** @var $builder \Magento\Framework\Validator\Builder */ $builder = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, ['constraints' => $constraints] ); $configurations = [$alias => [$configuration]]; @@ -204,7 +206,7 @@ public function testAddConfigurations($constraints, $alias, $configuration, $exp public function configurationDataProvider() { $callback = new \Magento\Framework\Validator\Constraint\Option\Callback( - ['Magento\Framework\Validator\Test\Unit\Test\Callback', 'getId'] + [\Magento\Framework\Validator\Test\Unit\Test\Callback::class, 'getId'] ); $someMethod = ['method' => 'getMessages']; $methodWithArgs = ['method' => 'someMethod', 'arguments' => ['some_value_to_pass']]; @@ -346,7 +348,7 @@ public function testConstructorConfigValidation(array $options, $exception, $exc $constraints = [ ['alias' => 'alias', 'class' => 'Some\Validator\Class', 'options' => $options, 'type' => 'entity'], ]; - $this->_objectManager->getObject('Magento\Framework\Validator\Builder', ['constraints' => $constraints]); + $this->_objectManager->getObject(\Magento\Framework\Validator\Builder::class, ['constraints' => $constraints]); } /** @@ -367,7 +369,7 @@ public function testAddConfigurationConfigValidation(array $options, $exception, ]; /** @var $builder \Magento\Framework\Validator\Builder */ $builder = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, ['constraints' => $constraints] ); $builder->addConfiguration('alias', $options); @@ -414,7 +416,7 @@ public function testCreateValidatorInvalidInstance() 'Constraint class "StdClass" must implement \Magento\Framework\Validator\ValidatorInterface' ); $builder = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, [ 'constraints' => [ ['alias' => 'alias', 'class' => 'StdClass', 'options' => null, 'type' => 'entity'], @@ -442,7 +444,7 @@ public function testAddConfigurationInvalidFormat($configuration) ]; /** @var $builder \Magento\Framework\Validator\Builder */ $builder = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, ['constraints' => $constraints] ); $builder->addConfigurations($configuration); diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php index cfeb3854e0049..8eb1409eae753 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php @@ -7,6 +7,9 @@ */ namespace Magento\Framework\Validator\Test\Unit; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ConfigTest extends \PHPUnit_Framework_TestCase { /** @@ -61,9 +64,9 @@ protected function _initConfig(array $files = null) $appObjectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config); $factory->setObjectManager($appObjectManager); /** @var \Magento\Framework\Validator\UniversalFactory $universalFactory */ - $universalFactory = $appObjectManager->get('Magento\Framework\Validator\UniversalFactory'); + $universalFactory = $appObjectManager->get(\Magento\Framework\Validator\UniversalFactory::class); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolverMock->expects($this->any()) ->method('getRealPath') ->with('urn:magento:framework:Validator/etc/validation.xsd') @@ -71,10 +74,10 @@ protected function _initConfig(array $files = null) $appObjectManager->configure( [ 'preferences' => [ - 'Magento\Framework\Config\ValidationStateInterface' => - 'Magento\Framework\App\Arguments\ValidationState', + \Magento\Framework\Config\ValidationStateInterface::class => + \Magento\Framework\App\Arguments\ValidationState::class, ], - 'Magento\Framework\App\Arguments\ValidationState' => [ + \Magento\Framework\App\Arguments\ValidationState::class => [ 'arguments' => [ 'appMode' => 'developer', ] @@ -82,7 +85,7 @@ protected function _initConfig(array $files = null) ] ); $this->_config = $this->_objectManager->getObject( - 'Magento\Framework\Validator\Config', + \Magento\Framework\Validator\Config::class, [ 'configFiles' => $configFiles, 'builderFactory' => $universalFactory, @@ -149,7 +152,7 @@ public function testGetValidatorBuilderInstance() { $this->_initConfig(); $builder = $this->_config->createValidatorBuilder('test_entity_a', 'check_alnum'); - $this->assertInstanceOf('Magento\Framework\Validator\Builder', $builder); + $this->assertInstanceOf(\Magento\Framework\Validator\Builder::class, $builder); } /** @@ -222,16 +225,16 @@ public function getValidationRulesDataProvider() */ public function testBuilderConfiguration() { - $this->getMockBuilder('Magento\Framework\Validator\Builder')->disableOriginalConstructor()->getMock(); + $this->getMockBuilder(\Magento\Framework\Validator\Builder::class)->disableOriginalConstructor()->getMock(); $this->_initConfig([__DIR__ . '/_files/validation/positive/builder/validation.xml']); $builder = $this->_config->createValidatorBuilder('test_entity_a', 'check_builder'); - $this->assertInstanceOf('Magento\Framework\Validator\Builder', $builder); + $this->assertInstanceOf(\Magento\Framework\Validator\Builder::class, $builder); $expected = [ [ 'alias' => '', - 'class' => 'Magento\Framework\Validator\Test\Unit\Test\NotEmpty', + 'class' => \Magento\Framework\Validator\Test\Unit\Test\NotEmpty::class, 'options' => null, 'property' => 'int', 'type' => 'property', @@ -246,14 +249,14 @@ public function testBuilderConfiguration() ['option1' => 'value1', 'option2' => 'value2'] ), new \Magento\Framework\Validator\Constraint\Option\Callback( - ['Magento\Framework\Validator\Test\Unit\Test\Callback', 'getId'], + [\Magento\Framework\Validator\Test\Unit\Test\Callback::class, 'getId'], null, true ), ], 'callback' => [ new \Magento\Framework\Validator\Constraint\Option\Callback( - ['Magento\Framework\Validator\Test\Unit\Test\Callback', 'configureValidator'], + [\Magento\Framework\Validator\Test\Unit\Test\Callback::class, 'configureValidator'], null, true ), @@ -266,7 +269,7 @@ public function testBuilderConfiguration() ['argOption' => 'argOptionValue'] ), new \Magento\Framework\Validator\Constraint\Option\Callback( - ['Magento\Framework\Validator\Test\Unit\Test\Callback', 'getId'], + [\Magento\Framework\Validator\Test\Unit\Test\Callback::class, 'getId'], null, true ), diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php index 0ebdcb741bfa5..7af86e54e4fb9 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php @@ -61,7 +61,7 @@ public function getConfigDataProvider() [[__CLASS__, 'getTestValueStatically'], self::TEST_VALUE], [[$mock, 'getValue'], 'Value from mock', ['arg1', 'arg2']], [ - ['Magento\Framework\Validator\Test\Unit\Test\Callback', 'getId'], + [\Magento\Framework\Validator\Test\Unit\Test\Callback::class, 'getId'], \Magento\Framework\Validator\Test\Unit\Test\Callback::ID, null, true diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/PropertyTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/PropertyTest.php index 2204e2a5bc1e4..ac114a8d27bd8 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/PropertyTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/PropertyTest.php @@ -28,7 +28,7 @@ class PropertyTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_validatorMock = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $this->_validatorMock = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $this->_constraint = new \Magento\Framework\Validator\Constraint\Property( $this->_validatorMock, self::PROPERTY_NAME diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ConstraintTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ConstraintTest.php index 76ee3ed1ea34a..b2a48b8fed051 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ConstraintTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ConstraintTest.php @@ -27,7 +27,7 @@ class ConstraintTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_validatorMock = $this->getMockBuilder( - 'Magento\Framework\Validator\AbstractValidator' + \Magento\Framework\Validator\AbstractValidator::class )->setMethods( ['isValid', 'getMessages'] )->getMock(); @@ -98,7 +98,9 @@ public function isValidDataProvider() public function testSetTranslator() { /** @var \Magento\Framework\Translate\AbstractAdapter $translator */ - $translator = $this->getMockBuilder('Magento\Framework\Translate\AdapterInterface')->getMockForAbstractClass(); + $translator = $this->getMockBuilder( + \Magento\Framework\Translate\AdapterInterface::class + )->getMockForAbstractClass(); $this->_constraint->setTranslator($translator); $this->assertEquals($translator, $this->_validatorMock->getTranslator()); $this->assertEquals($translator, $this->_constraint->getTranslator()); diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php index 2f1bfa4c08c3c..7e1e2846c647d 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php @@ -20,7 +20,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase public function testIsValid() { - $lists = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $lists = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); $lists->expects($this->any())->method('getCurrencyList')->will($this->returnValue($this->expectedCurrencies)); $currency = new \Magento\Framework\Validator\Currency($lists); $this->assertEquals(true, $currency->isValid('EUR')); diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/Entity/PropertiesTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/Entity/PropertiesTest.php index 0d5758b7e872f..dfbbb72a98e9b 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/Entity/PropertiesTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/Entity/PropertiesTest.php @@ -19,7 +19,7 @@ class PropertiesTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_object = $this->getMock( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, ['hasDataChanges', 'getData', 'getOrigData'], [], '', diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php index 74992fe9cfa1c..bb829010795e8 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php @@ -42,9 +42,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_defaultTranslator = \Magento\Framework\Validator\AbstractValidator::getDefaultTranslator(); - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_validatorConfig = $this->getMockBuilder( - 'Magento\Framework\Validator\Config' + \Magento\Framework\Validator\Config::class )->setMethods( ['createValidatorBuilder', 'createValidator'] )->disableOriginalConstructor()->getMock(); @@ -54,7 +54,7 @@ protected function setUp() )->method( 'create' )->with( - 'Magento\Framework\Translate\Adapter' + \Magento\Framework\Translate\Adapter::class )->will( $this->returnValue(new \Magento\Framework\Translate\Adapter()) ); @@ -64,7 +64,7 @@ protected function setUp() )->method( 'create' )->with( - 'Magento\Framework\Validator\Config', + \Magento\Framework\Validator\Config::class, ['configFiles' => ['/tmp/moduleOne/etc/validation.xml']] )->will( $this->returnValue($this->_validatorConfig) @@ -72,7 +72,7 @@ protected function setUp() // Config mock $this->_config = $this->getMockBuilder( - 'Magento\Framework\Module\Dir\Reader' + \Magento\Framework\Module\Dir\Reader::class )->setMethods( ['getConfigurationFiles'] )->disableOriginalConstructor()->getMock(); @@ -88,7 +88,7 @@ protected function setUp() // Translate adapter mock $this->_translateAdapter = $this->getMockBuilder( - 'Magento\Framework\TranslateInterface' + \Magento\Framework\TranslateInterface::class )->disableOriginalConstructor()->getMock(); $this->cache = $this->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class) @@ -116,7 +116,7 @@ public function testGetValidatorConfig() ); $actualConfig = $factory->getValidatorConfig(); $this->assertInstanceOf( - 'Magento\Framework\Validator\Config', + \Magento\Framework\Validator\Config::class, $actualConfig, 'Object of incorrect type was created' ); @@ -124,7 +124,7 @@ public function testGetValidatorConfig() // Check that validator translator was correctly instantiated $validatorTranslator = \Magento\Framework\Validator\AbstractValidator::getDefaultTranslator(); $this->assertInstanceOf( - 'Magento\Framework\Translate\Adapter', + \Magento\Framework\Translate\Adapter::class, $validatorTranslator, 'Default validator translate adapter was not set correctly' ); @@ -146,7 +146,7 @@ public function testCreateValidatorBuilder() [] )->will( $this->returnValue( - $objectManager->getObject('Magento\Framework\Validator\Builder', ['constraints' => []]) + $objectManager->getObject(\Magento\Framework\Validator\Builder::class, ['constraints' => []]) ) ); $factory = new \Magento\Framework\Validator\Factory( @@ -155,7 +155,7 @@ public function testCreateValidatorBuilder() $this->cache ); $this->assertInstanceOf( - 'Magento\Framework\Validator\Builder', + \Magento\Framework\Validator\Builder::class, $factory->createValidatorBuilder('test', 'class', []) ); } @@ -181,6 +181,6 @@ public function testCreateValidator() $this->_config, $this->cache ); - $this->assertInstanceOf('Magento\Framework\Validator', $factory->createValidator('test', 'class', [])); + $this->assertInstanceOf(\Magento\Framework\Validator::class, $factory->createValidator('test', 'class', [])); } } diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php index 8006512b3211b..673a5616020da 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php @@ -20,7 +20,7 @@ class LocaleTest extends \PHPUnit_Framework_TestCase public function testIsValid() { - $lists = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $lists = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); $lists->expects($this->any())->method('getLocaleList')->will($this->returnValue($this->expectedLocales)); $locale = new \Magento\Framework\Validator\Locale($lists); $this->assertEquals(true, $locale->isValid('en_US')); diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php index 9db139294683e..8bdf2e9190a4e 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php @@ -20,7 +20,7 @@ class TimezoneTest extends \PHPUnit_Framework_TestCase public function testIsValid() { - $lists = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $lists = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); $lists->expects($this->any())->method('getTimezoneList')->will($this->returnValue($this->expectedTimezones)); $timezone = new \Magento\Framework\Validator\Timezone($lists); $this->assertEquals(true, $timezone->isValid('America/Los_Angeles')); diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ValidatorAbstractTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ValidatorAbstractTest.php index 5d23ed88b8793..f7e03928fd03d 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ValidatorAbstractTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ValidatorAbstractTest.php @@ -33,7 +33,7 @@ protected function tearDown() */ protected function _getTranslator() { - return $this->getMockBuilder('Magento\Framework\Translate\AdapterInterface')->getMockForAbstractClass(); + return $this->getMockBuilder(\Magento\Framework\Translate\AdapterInterface::class)->getMockForAbstractClass(); } /** @@ -52,7 +52,9 @@ public function testDefaultTranslatorGetSet() public function testTranslatorGetSetHas() { /** @var \Magento\Framework\Validator\AbstractValidator $validator */ - $validator = $this->getMockBuilder('Magento\Framework\Validator\AbstractValidator')->getMockForAbstractClass(); + $validator = $this->getMockBuilder( + \Magento\Framework\Validator\AbstractValidator::class + )->getMockForAbstractClass(); $translator = $this->_getTranslator(); $validator->setTranslator($translator); $this->assertEquals($translator, $validator->getTranslator()); @@ -65,7 +67,9 @@ public function testTranslatorGetSetHas() public function testGetTranslatorDefault() { /** @var \Magento\Framework\Validator\AbstractValidator $validator */ - $validator = $this->getMockBuilder('Magento\Framework\Validator\AbstractValidator')->getMockForAbstractClass(); + $validator = $this->getMockBuilder( + \Magento\Framework\Validator\AbstractValidator::class + )->getMockForAbstractClass(); $translator = $this->_getTranslator(); \Magento\Framework\Validator\AbstractValidator::setDefaultTranslator($translator); $this->assertEquals($translator, $validator->getTranslator()); diff --git a/lib/internal/Magento/Framework/View/Asset/MergeService.php b/lib/internal/Magento/Framework/View/Asset/MergeService.php index 612e0312eead8..f6103048c0573 100644 --- a/lib/internal/Magento/Framework/View/Asset/MergeService.php +++ b/lib/internal/Magento/Framework/View/Asset/MergeService.php @@ -80,14 +80,14 @@ public function getMergedAssets(array $assets, $contentType) $isJsMergeEnabled = $this->config->isMergeJsFiles(); if (($isCss && $isCssMergeEnabled) || ($isJs && $isJsMergeEnabled)) { if ($this->state->getMode() == \Magento\Framework\App\State::MODE_PRODUCTION) { - $mergeStrategyClass = 'Magento\Framework\View\Asset\MergeStrategy\FileExists'; + $mergeStrategyClass = \Magento\Framework\View\Asset\MergeStrategy\FileExists::class; } else { - $mergeStrategyClass = 'Magento\Framework\View\Asset\MergeStrategy\Checksum'; + $mergeStrategyClass = \Magento\Framework\View\Asset\MergeStrategy\Checksum::class; } $mergeStrategy = $this->objectManager->get($mergeStrategyClass); $assets = $this->objectManager->create( - 'Magento\Framework\View\Asset\Merged', + \Magento\Framework\View\Asset\Merged::class, ['assets' => $assets, 'mergeStrategy' => $mergeStrategy] ); } diff --git a/lib/internal/Magento/Framework/View/Asset/PropertyGroupFactory.php b/lib/internal/Magento/Framework/View/Asset/PropertyGroupFactory.php index bff3e12f5053a..1e632fc48bdda 100644 --- a/lib/internal/Magento/Framework/View/Asset/PropertyGroupFactory.php +++ b/lib/internal/Magento/Framework/View/Asset/PropertyGroupFactory.php @@ -35,6 +35,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Asset\PropertyGroup', $data); + return $this->objectManager->create(\Magento\Framework\View\Asset\PropertyGroup::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModularSwitchFactory.php b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModularSwitchFactory.php index 12eca9a669c07..c8c9ffee2f613 100644 --- a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModularSwitchFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModularSwitchFactory.php @@ -34,6 +34,6 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Design\Fallback\Rule\ModularSwitch', $data); + return $this->objectManager->create(\Magento\Framework\View\Design\Fallback\Rule\ModularSwitch::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModuleFactory.php b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModuleFactory.php index 621eb98808d2f..57fa8f36a7732 100644 --- a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModuleFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ModuleFactory.php @@ -34,6 +34,6 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Design\Fallback\Rule\Module', $data); + return $this->objectManager->create(\Magento\Framework\View\Design\Fallback\Rule\Module::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/SimpleFactory.php b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/SimpleFactory.php index 8b73f247289b8..991dd1eb2d2a8 100644 --- a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/SimpleFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/SimpleFactory.php @@ -30,6 +30,6 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Design\Fallback\Rule\Simple', $data); + return $this->objectManager->create(\Magento\Framework\View\Design\Fallback\Rule\Simple::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ThemeFactory.php b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ThemeFactory.php index 6fb8effa12e5f..dc6329124956f 100644 --- a/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ThemeFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Fallback/Rule/ThemeFactory.php @@ -30,6 +30,6 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Design\Fallback\Rule\Theme', $data); + return $this->objectManager->create(\Magento\Framework\View\Design\Fallback\Rule\Theme::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Design/Theme/Domain/Factory.php b/lib/internal/Magento/Framework/View/Design/Theme/Domain/Factory.php index 9549fb12e449e..ce0ad7ec84f0a 100644 --- a/lib/internal/Magento/Framework/View/Design/Theme/Domain/Factory.php +++ b/lib/internal/Magento/Framework/View/Design/Theme/Domain/Factory.php @@ -25,9 +25,9 @@ class Factory * @var array */ protected $_types = [ - ThemeInterface::TYPE_PHYSICAL => 'Magento\Framework\View\Design\Theme\Domain\PhysicalInterface', - ThemeInterface::TYPE_VIRTUAL => 'Magento\Framework\View\Design\Theme\Domain\VirtualInterface', - ThemeInterface::TYPE_STAGING => 'Magento\Framework\View\Design\Theme\Domain\StagingInterface', + ThemeInterface::TYPE_PHYSICAL => \Magento\Framework\View\Design\Theme\Domain\PhysicalInterface::class, + ThemeInterface::TYPE_VIRTUAL => \Magento\Framework\View\Design\Theme\Domain\VirtualInterface::class, + ThemeInterface::TYPE_STAGING => \Magento\Framework\View\Design\Theme\Domain\StagingInterface::class, ]; /** diff --git a/lib/internal/Magento/Framework/View/Design/Theme/FileFactory.php b/lib/internal/Magento/Framework/View/Design/Theme/FileFactory.php index a929fe4d30269..a61f80ec7464d 100644 --- a/lib/internal/Magento/Framework/View/Design/Theme/FileFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Theme/FileFactory.php @@ -35,6 +35,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $data = []) { - return $this->_objectManager->create('Magento\Framework\View\Design\Theme\FileInterface', $data); + return $this->_objectManager->create(\Magento\Framework\View\Design\Theme\FileInterface::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Design/Theme/ImageFactory.php b/lib/internal/Magento/Framework/View/Design/Theme/ImageFactory.php index efdc350f2ce1f..c74cc864d3938 100644 --- a/lib/internal/Magento/Framework/View/Design/Theme/ImageFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Theme/ImageFactory.php @@ -32,7 +32,7 @@ class ImageFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Design\Theme\Image' + $instanceName = \Magento\Framework\View\Design\Theme\Image::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Design/Theme/LabelFactory.php b/lib/internal/Magento/Framework/View/Design/Theme/LabelFactory.php index 4d9beabd64d82..49e29ba314ec8 100644 --- a/lib/internal/Magento/Framework/View/Design/Theme/LabelFactory.php +++ b/lib/internal/Magento/Framework/View/Design/Theme/LabelFactory.php @@ -33,7 +33,7 @@ class LabelFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Design\Theme\Label' + $instanceName = \Magento\Framework\View\Design\Theme\Label::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Element/ExceptionHandlerBlockFactory.php b/lib/internal/Magento/Framework/View/Element/ExceptionHandlerBlockFactory.php index 0992300d870b9..270da70aacdf6 100644 --- a/lib/internal/Magento/Framework/View/Element/ExceptionHandlerBlockFactory.php +++ b/lib/internal/Magento/Framework/View/Element/ExceptionHandlerBlockFactory.php @@ -11,7 +11,7 @@ */ class ExceptionHandlerBlockFactory { - const DEFAULT_INSTANCE_NAME = 'Magento\Framework\View\Element\ExceptionHandlerBlock'; + const DEFAULT_INSTANCE_NAME = \Magento\Framework\View\Element\ExceptionHandlerBlock::class; /** * @var \Magento\Framework\ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollectorFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollectorFactory.php index 27d6c511e0eea..a28e7c39edbc6 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollectorFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollectorFactory.php @@ -12,7 +12,8 @@ */ class AggregatedFileCollectorFactory { - const INSTANCE_NAME = 'Magento\Framework\View\Element\UiComponent\Config\FileCollector\AggregatedFileCollector'; + const INSTANCE_NAME = + \Magento\Framework\View\Element\UiComponent\Config\FileCollector\AggregatedFileCollector::class; /** * @var ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/ReaderFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/ReaderFactory.php index aa4c3865e1cea..bfdd56718c244 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/ReaderFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/ReaderFactory.php @@ -12,7 +12,7 @@ */ class ReaderFactory { - const INSTANCE_NAME = 'Magento\Framework\View\Element\UiComponent\Config\Reader'; + const INSTANCE_NAME = \Magento\Framework\View\Element\UiComponent\Config\Reader::class; /** * @var ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextFactory.php index d7efafe51b2dd..d32008802b231 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextFactory.php @@ -12,7 +12,7 @@ */ class ContextFactory { - const INSTANCE_NAME = 'Magento\Framework\View\Element\UiComponent\ContextInterface'; + const INSTANCE_NAME = \Magento\Framework\View\Element\UiComponent\ContextInterface::class; /** * @var ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Control/ActionPoolFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Control/ActionPoolFactory.php index 4a9c626a86f99..6833111433685 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Control/ActionPoolFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Control/ActionPoolFactory.php @@ -12,7 +12,7 @@ */ class ActionPoolFactory { - const INSTANCE = 'Magento\Framework\View\Element\UiComponent\Control\ActionPoolInterface'; + const INSTANCE = \Magento\Framework\View\Element\UiComponent\Control\ActionPoolInterface::class; /** * @var ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php index 20501a4f35917..a48c33bc14dcc 100755 --- a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php @@ -17,6 +17,8 @@ /** * Class UiComponentFactory + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UiComponentFactory extends DataObject { @@ -152,9 +154,9 @@ public function create($identifier, $name = null, array $arguments = []) $className = $componentArguments['config']['class']; } if (!isset($componentArguments['context'])) { - $componentArguments['context'] = $this->contextFactory->create([ - 'namespace' => $identifier - ]); + $componentArguments['context'] = $this->contextFactory->create( + ['namespace' => $identifier] + ); } $reverseMerge = isset($componentArguments['data']['reverseMetadataMerge']) @@ -292,7 +294,7 @@ protected function mergeMetadataElement(array $bundleComponents, $name, array $d } else { foreach ($bundleComponents as &$childData) { if (isset($childData['attributes']['class']) - && is_a($childData['attributes']['class'], 'Magento\Ui\Component\Container', true) + && is_a($childData['attributes']['class'], \Magento\Ui\Component\Container::class, true) && isset($childData['children']) && is_array($childData['children']) ) { list($childData['children'], $isMerged) = $this->mergeMetadataElement( diff --git a/lib/internal/Magento/Framework/View/File/Factory.php b/lib/internal/Magento/Framework/View/File/Factory.php index dc55a289c0896..789f81ca3b800 100644 --- a/lib/internal/Magento/Framework/View/File/Factory.php +++ b/lib/internal/Magento/Framework/View/File/Factory.php @@ -43,7 +43,7 @@ public function __construct(ObjectManagerInterface $objectManager) public function create($filename, $module = '', ThemeInterface $theme = null, $isBase = false) { return $this->objectManager->create( - 'Magento\Framework\View\File', + \Magento\Framework\View\File::class, ['filename' => $filename, 'module' => $module, 'theme' => $theme, 'isBase' => $isBase] ); } diff --git a/lib/internal/Magento/Framework/View/File/FileList/Factory.php b/lib/internal/Magento/Framework/View/File/FileList/Factory.php index 53de5e30421b2..feba471b0634f 100644 --- a/lib/internal/Magento/Framework/View/File/FileList/Factory.php +++ b/lib/internal/Magento/Framework/View/File/FileList/Factory.php @@ -16,7 +16,7 @@ class Factory /** * Default file list collator */ - const FILE_LIST_COLLATOR = 'Magento\Framework\View\File\FileList\Collator'; + const FILE_LIST_COLLATOR = \Magento\Framework\View\File\FileList\Collator::class; /** * Object manager @@ -48,6 +48,6 @@ public function create($instanceName = self::FILE_LIST_COLLATOR) if (!$collator instanceof CollateInterface) { throw new \UnexpectedValueException("$instanceName has to implement the collate interface."); } - return $this->objectManager->create('Magento\Framework\View\File\FileList', ['collator' => $collator]); + return $this->objectManager->create(\Magento\Framework\View\File\FileList::class, ['collator' => $collator]); } } diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php index 5e73497438423..3334967c8da83 100755 --- a/lib/internal/Magento/Framework/View/Layout.php +++ b/lib/internal/Magento/Framework/View/Layout.php @@ -195,7 +195,7 @@ public function __construct( Logger $logger, $cacheable = true ) { - $this->_elementClass = 'Magento\Framework\View\Layout\Element'; + $this->_elementClass = \Magento\Framework\View\Layout\Element::class; $this->_renderingOutput = new \Magento\Framework\DataObject(); $this->_processorFactory = $processorFactory; @@ -952,7 +952,7 @@ public function getMessagesBlock() if ($block) { return $block; } - return $this->createBlock('Magento\Framework\View\Element\Messages', 'messages'); + return $this->createBlock(\Magento\Framework\View\Element\Messages::class, 'messages'); } /** diff --git a/lib/internal/Magento/Framework/View/Layout/BuilderFactory.php b/lib/internal/Magento/Framework/View/Layout/BuilderFactory.php index 812455f3519d6..c39a67619dd4f 100644 --- a/lib/internal/Magento/Framework/View/Layout/BuilderFactory.php +++ b/lib/internal/Magento/Framework/View/Layout/BuilderFactory.php @@ -26,8 +26,8 @@ class BuilderFactory * @var array */ protected $typeMap = [ - self::TYPE_LAYOUT => 'Magento\Framework\View\Layout\Builder', - self::TYPE_PAGE => 'Magento\Framework\View\Page\Builder', + self::TYPE_LAYOUT => \Magento\Framework\View\Layout\Builder::class, + self::TYPE_PAGE => \Magento\Framework\View\Page\Builder::class, ]; /** diff --git a/lib/internal/Magento/Framework/View/Layout/Generator/ContextFactory.php b/lib/internal/Magento/Framework/View/Layout/Generator/ContextFactory.php index 452e5694230a0..cedb37939838e 100644 --- a/lib/internal/Magento/Framework/View/Layout/Generator/ContextFactory.php +++ b/lib/internal/Magento/Framework/View/Layout/Generator/ContextFactory.php @@ -28,6 +28,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Layout\Generator\Context', $data); + return $this->objectManager->create(\Magento\Framework\View\Layout\Generator\Context::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/Layout/Generator/UiComponent.php b/lib/internal/Magento/Framework/View/Layout/Generator/UiComponent.php index e56477b4f4019..24804ba20a5db 100644 --- a/lib/internal/Magento/Framework/View/Layout/Generator/UiComponent.php +++ b/lib/internal/Magento/Framework/View/Layout/Generator/UiComponent.php @@ -31,7 +31,7 @@ class UiComponent implements GeneratorInterface /** * Block container for components */ - const CONTAINER = 'Magento\Framework\View\Element\UiComponent\ContainerInterface'; + const CONTAINER = \Magento\Framework\View\Element\UiComponent\ContainerInterface::class; /** * @var UiComponentFactory @@ -115,14 +115,18 @@ protected function generateComponent(DataStructure $structure, $elementName, $da $structure->addToParentGroup($elementName, $attributes['group']); } - $context = $this->contextFactory->create([ - 'namespace' => $elementName, - 'pageLayout' => $layout - ]); - - $component = $this->uiComponentFactory->create($elementName, null, [ - 'context' => $context - ]); + $context = $this->contextFactory->create( + [ + 'namespace' => $elementName, + 'pageLayout' => $layout + ] + ); + + $component = $this->uiComponentFactory->create( + $elementName, + null, + ['context' => $context] + ); $this->prepareComponent($component); /** @var ContainerInterface $blockContainer */ diff --git a/lib/internal/Magento/Framework/View/Layout/Pool.php b/lib/internal/Magento/Framework/View/Layout/Pool.php index 532ed131680ed..57c925471da97 100644 --- a/lib/internal/Magento/Framework/View/Layout/Pool.php +++ b/lib/internal/Magento/Framework/View/Layout/Pool.php @@ -13,7 +13,7 @@ */ class Pool { - const DEFAULT_CLASS = 'Magento\Framework\View\Layout\Generic'; + const DEFAULT_CLASS = \Magento\Framework\View\Layout\Generic::class; /** * Layouts pool diff --git a/lib/internal/Magento/Framework/View/Layout/ProcessorFactory.php b/lib/internal/Magento/Framework/View/Layout/ProcessorFactory.php index 16a2536f49119..16d80ca77e5a1 100644 --- a/lib/internal/Magento/Framework/View/Layout/ProcessorFactory.php +++ b/lib/internal/Magento/Framework/View/Layout/ProcessorFactory.php @@ -32,7 +32,7 @@ class ProcessorFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Layout\ProcessorInterface' + $instanceName = \Magento\Framework\View\Layout\ProcessorInterface::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Layout/Proxy.php b/lib/internal/Magento/Framework/View/Layout/Proxy.php index 3cb2a273d168e..efaef44d6636c 100644 --- a/lib/internal/Magento/Framework/View/Layout/Proxy.php +++ b/lib/internal/Magento/Framework/View/Layout/Proxy.php @@ -48,7 +48,7 @@ class Proxy extends \Magento\Framework\View\Layout implements \Magento\Framework */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = '\\Magento\\Framework\\View\\Layout', + $instanceName = \Magento\Framework\View\Layout::class, $shared = true ) { $this->_objectManager = $objectManager; diff --git a/lib/internal/Magento/Framework/View/Layout/Reader/ContextFactory.php b/lib/internal/Magento/Framework/View/Layout/Reader/ContextFactory.php index 16a6e579ac8c9..5e795c3b2ee63 100644 --- a/lib/internal/Magento/Framework/View/Layout/Reader/ContextFactory.php +++ b/lib/internal/Magento/Framework/View/Layout/Reader/ContextFactory.php @@ -28,6 +28,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $data = []) { - return $this->objectManager->create('Magento\Framework\View\Layout\Reader\Context', $data); + return $this->objectManager->create(\Magento\Framework\View\Layout\Reader\Context::class, $data); } } diff --git a/lib/internal/Magento/Framework/View/LayoutFactory.php b/lib/internal/Magento/Framework/View/LayoutFactory.php index 3960372c0b03d..2890ec5cb8a15 100644 --- a/lib/internal/Magento/Framework/View/LayoutFactory.php +++ b/lib/internal/Magento/Framework/View/LayoutFactory.php @@ -32,7 +32,7 @@ class LayoutFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\LayoutInterface' + $instanceName = \Magento\Framework\View\LayoutInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Model/Layout/Merge.php b/lib/internal/Magento/Framework/View/Model/Layout/Merge.php index 72568b235b799..90220320952af 100644 --- a/lib/internal/Magento/Framework/View/Model/Layout/Merge.php +++ b/lib/internal/Magento/Framework/View/Model/Layout/Merge.php @@ -490,7 +490,7 @@ public function asSimplexml() */ protected function _loadXmlString($xmlString) { - return simplexml_load_string($xmlString, 'Magento\Framework\View\Layout\Element'); + return simplexml_load_string($xmlString, \Magento\Framework\View\Layout\Element::class); } /** diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php index e862c764d74c4..2301dd14ddb9f 100644 --- a/lib/internal/Magento/Framework/View/Page/Config.php +++ b/lib/internal/Magento/Framework/View/Page/Config.php @@ -133,7 +133,7 @@ private function getAreaResolver() { if ($this->areaResolver === null) { $this->areaResolver = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\App\State'); + ->get(\Magento\Framework\App\State::class); } return $this->areaResolver; } diff --git a/lib/internal/Magento/Framework/View/Page/Config/RendererFactory.php b/lib/internal/Magento/Framework/View/Page/Config/RendererFactory.php index 7c576e8a24274..d293569a1427a 100644 --- a/lib/internal/Magento/Framework/View/Page/Config/RendererFactory.php +++ b/lib/internal/Magento/Framework/View/Page/Config/RendererFactory.php @@ -33,7 +33,7 @@ class RendererFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Page\Config\Renderer' + $instanceName = \Magento\Framework\View\Page\Config\Renderer::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Page/ConfigFactory.php b/lib/internal/Magento/Framework/View/Page/ConfigFactory.php index 2b39611db34db..d0fed31c244d9 100644 --- a/lib/internal/Magento/Framework/View/Page/ConfigFactory.php +++ b/lib/internal/Magento/Framework/View/Page/ConfigFactory.php @@ -33,7 +33,7 @@ class ConfigFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Page\Config' + $instanceName = \Magento\Framework\View\Page\Config::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Result/LayoutFactory.php b/lib/internal/Magento/Framework/View/Result/LayoutFactory.php index 22bca7c3f9dfc..67b3b90c88b1f 100644 --- a/lib/internal/Magento/Framework/View/Result/LayoutFactory.php +++ b/lib/internal/Magento/Framework/View/Result/LayoutFactory.php @@ -26,7 +26,7 @@ class LayoutFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Result\Layout' + $instanceName = \Magento\Framework\View\Result\Layout::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Result/PageFactory.php b/lib/internal/Magento/Framework/View/Result/PageFactory.php index e82ef0cb66137..68329e9ddb4d4 100644 --- a/lib/internal/Magento/Framework/View/Result/PageFactory.php +++ b/lib/internal/Magento/Framework/View/Result/PageFactory.php @@ -31,7 +31,7 @@ class PageFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\Result\Page' + $instanceName = \Magento\Framework\View\Result\Page::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/ResultFactory.php b/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/ResultFactory.php index f430736480f12..3955d18c889d8 100644 --- a/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/ResultFactory.php +++ b/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/ResultFactory.php @@ -36,7 +36,7 @@ class ResultFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\TemplateEngine\Xhtml\ResultInterface' + $instanceName = \Magento\Framework\View\TemplateEngine\Xhtml\ResultInterface::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/TemplateFactory.php b/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/TemplateFactory.php index 3d5d027ab08d1..d8a5c4e97e49a 100644 --- a/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/TemplateFactory.php +++ b/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/TemplateFactory.php @@ -36,7 +36,7 @@ class TemplateFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\View\TemplateEngine\Xhtml\Template' + $instanceName = \Magento\Framework\View\TemplateEngine\Xhtml\Template::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php index b73fdec443f4b..cb161a5c204df 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php @@ -32,21 +32,21 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->bundle = $this->getMockBuilder('Magento\Framework\View\Asset\Bundle') + $this->bundle = $this->getMockBuilder(\Magento\Framework\View\Asset\Bundle::class) ->disableOriginalConstructor() ->getMock(); - $this->bundleConfig = $this->getMockBuilder('Magento\Framework\View\Asset\Bundle\ConfigInterface') + $this->bundleConfig = $this->getMockBuilder(\Magento\Framework\View\Asset\Bundle\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->assetConfig = $this->getMockBuilder('Magento\Framework\View\Asset\ConfigInterface') + $this->assetConfig = $this->getMockBuilder(\Magento\Framework\View\Asset\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $this->asset = $this->getMockForAbstractClass( - 'Magento\Framework\View\Asset\LocalInterface', + \Magento\Framework\View\Asset\LocalInterface::class, [], '', false, @@ -55,7 +55,7 @@ protected function setUp() ['getContentType'] ); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); @@ -79,13 +79,13 @@ public function testAddAssetWithInvalidType() public function testAddAssetWithExcludedFile() { - $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $dirRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); - $configView = $this->getMockBuilder('Magento\Framework\Config\View') + $configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->setMockClassName('configView') ->disableOriginalConstructor() ->getMock(); @@ -122,13 +122,13 @@ public function testAddAssetWithExcludedFile() public function testAddAssetWithExcludedDirectory() { - $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $dirRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); - $configView = $this->getMockBuilder('Magento\Framework\Config\View') + $configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->disableOriginalConstructor() ->getMock(); @@ -174,13 +174,13 @@ public function testAddAssetWithExcludedDirectory() public function testAddAsset() { - $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $dirRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); - $configView = $this->getMockBuilder('Magento\Framework\Config\View') + $configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/BundleTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/BundleTest.php index 8b1cdbb74fde1..180cc4ac7e898 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/BundleTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/BundleTest.php @@ -38,13 +38,13 @@ class BundleTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->bundleConfigMock = $this->getMockBuilder('Magento\Framework\View\Asset\Bundle\ConfigInterface') + $this->bundleConfigMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Bundle\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); @@ -76,7 +76,7 @@ public function testMinSuffix() '/js/bundle/bundle0.min.js' ); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); $contextMock @@ -92,7 +92,7 @@ public function testMinSuffix() ->method('getLocale') ->willReturn('locale'); - $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface') + $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\LocalInterface::class) ->setMethods(['getContentType', 'getContext']) ->getMockForAbstractClass(); $assetMock @@ -108,7 +108,7 @@ public function testMinSuffix() ->method('getFilePath') ->willReturn('onefile.js'); - $writeMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $writeMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMockForAbstractClass(); $writeMock ->expects($this->once()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/ConfigTest.php index c87b5682edbe1..bc03655d36a2a 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/ConfigTest.php @@ -35,9 +35,9 @@ class ConfigTest extends \Magento\Framework\TestFramework\Unit\BaseTestCase */ protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); - $this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); $this->model = new Config($this->scopeConfigMock, $this->appStateMock); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php index 0973535ea3640..ca8d10cf8b7a1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php @@ -44,7 +44,7 @@ public function testGetConfigPath( $expectedResult ) { $this->fallbackContext = $this->objectManager->getObject( - 'Magento\Framework\View\Asset\File\FallbackContext', + \Magento\Framework\View\Asset\File\FallbackContext::class, [ 'baseUrl' => $baseUrl, 'areaType' => $areaType, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php index 9d42226ea11fb..1ad1ab80fdef4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php @@ -32,9 +32,9 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->source = $this->getMock('Magento\Framework\View\Asset\Source', [], [], '', false); - $this->context = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\ContextInterface'); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->source = $this->getMock(\Magento\Framework\View\Asset\Source::class, [], [], '', false); + $this->context = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\ContextInterface::class); + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/GroupedCollectionTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/GroupedCollectionTest.php index 4d81a2d4db042..590d7f3fa884b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/GroupedCollectionTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/GroupedCollectionTest.php @@ -20,7 +20,7 @@ class GroupedCollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $factory = $this->getMock( - 'Magento\Framework\View\Asset\PropertyGroupFactory', + \Magento\Framework\View\Asset\PropertyGroupFactory::class, [], [], '', @@ -68,7 +68,7 @@ protected function _assertGroups(array $expectedGroups, array $actualGroupObject $actualGroups = []; /** @var $actualGroup \Magento\Framework\View\Asset\PropertyGroup */ foreach ($actualGroupObjects as $actualGroup) { - $this->assertInstanceOf('Magento\Framework\View\Asset\PropertyGroup', $actualGroup); + $this->assertInstanceOf(\Magento\Framework\View\Asset\PropertyGroup::class, $actualGroup); $actualGroups[] = ['properties' => $actualGroup->getProperties(), 'assets' => $actualGroup->getAll()]; } $this->assertEquals($expectedGroups, $actualGroups); @@ -91,7 +91,7 @@ public function testGetGroups() { $cssAsset = new \Magento\Framework\View\Asset\Remote('http://127.0.0.1/style.css', 'css'); $jsAsset = new \Magento\Framework\View\Asset\Remote('http://127.0.0.1/script.js', 'js'); - $jsAssetAllowingMerge = $this->getMockForAbstractClass('Magento\Framework\View\Asset\MergeableInterface'); + $jsAssetAllowingMerge = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeableInterface::class); $jsAssetAllowingMerge->expects($this->any())->method('getContentType')->will($this->returnValue('js')); // assets with identical properties should be grouped together diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php index 91666d0838cea..b28c45eefc320 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php @@ -41,7 +41,7 @@ protected function setUp() { $this->fileName = DirectoryList::TMP . DIRECTORY_SEPARATOR . self::LOCK_NAME . LockerProcess::LOCK_EXTENSION; - $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); @@ -107,7 +107,6 @@ protected function getTmpDirectoryMockTrue() ->with($this->fileName) ->willReturn(time() - 25); - $tmpDirectoryMock->expects(self::once()) ->method('writeFile') ->with($this->fileName, self::matchesRegularExpression('#\d+#')); @@ -147,7 +146,7 @@ protected function getTmpDirectoryMockFalse($exactly = 0) */ private function getTmpDirectoryMock() { - $tmpDirectoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $tmpDirectoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMockForAbstractClass(); return $tmpDirectoryMock; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php index f7ebf899fe950..5a329de9e0d38 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php @@ -39,17 +39,17 @@ class MergeServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->_config = $this->getMock('Magento\Framework\View\Asset\ConfigInterface', [], [], '', false); - $this->_filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_config = $this->getMock(\Magento\Framework\View\Asset\ConfigInterface::class, [], [], '', false); + $this->_filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->_directory = $this->getMock( - '\Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, [], [], '', false ); - $this->_state = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->_state = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->_filesystem->expects( $this->any() )->method( @@ -84,7 +84,7 @@ public function testGetMergedAssetsWrongContentType() */ public function testGetMergedAssets(array $assets, $contentType, $appMode, $mergeStrategy) { - $mergedAsset = $this->getMock('Magento\Framework\View\Asset\AssetInterface'); + $mergedAsset = $this->getMock(\Magento\Framework\View\Asset\AssetInterface::class); $this->_config->expects($this->once())->method('isMergeCssFiles')->will($this->returnValue(true)); $this->_config->expects($this->once())->method('isMergeJsFiles')->will($this->returnValue(true)); @@ -95,7 +95,7 @@ public function testGetMergedAssets(array $assets, $contentType, $appMode, $merg )->method( 'create' )->with( - 'Magento\Framework\View\Asset\Merged', + \Magento\Framework\View\Asset\Merged::class, ['assets' => $assets, 'mergeStrategy' => $mergeStrategyMock] )->will( $this->returnValue($mergedAsset) @@ -129,37 +129,37 @@ public static function getMergedAssetsDataProvider() $jsAssets, 'js', \Magento\Framework\App\State::MODE_PRODUCTION, - 'Magento\Framework\View\Asset\MergeStrategy\FileExists', + \Magento\Framework\View\Asset\MergeStrategy\FileExists::class, ], 'css production mode' => [ $cssAssets, 'css', \Magento\Framework\App\State::MODE_PRODUCTION, - 'Magento\Framework\View\Asset\MergeStrategy\FileExists', + \Magento\Framework\View\Asset\MergeStrategy\FileExists::class, ], 'js default mode' => [ $jsAssets, 'js', \Magento\Framework\App\State::MODE_DEFAULT, - 'Magento\Framework\View\Asset\MergeStrategy\Checksum', + \Magento\Framework\View\Asset\MergeStrategy\Checksum::class, ], 'css default mode' => [ $cssAssets, 'js', \Magento\Framework\App\State::MODE_DEFAULT, - 'Magento\Framework\View\Asset\MergeStrategy\Checksum', + \Magento\Framework\View\Asset\MergeStrategy\Checksum::class, ], 'js developer mode' => [ $jsAssets, 'js', \Magento\Framework\App\State::MODE_DEVELOPER, - 'Magento\Framework\View\Asset\MergeStrategy\Checksum', + \Magento\Framework\View\Asset\MergeStrategy\Checksum::class, ], 'css developer mode' => [ $cssAssets, 'css', \Magento\Framework\App\State::MODE_DEVELOPER, - 'Magento\Framework\View\Asset\MergeStrategy\Checksum', + \Magento\Framework\View\Asset\MergeStrategy\Checksum::class, ] ]; } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/ChecksumTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/ChecksumTest.php index c109afa91b912..9c7859116c4cb 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/ChecksumTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/ChecksumTest.php @@ -38,10 +38,12 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mergerMock = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\MergeStrategyInterface'); - $this->sourceDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->targetDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); - $filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); + $this->mergerMock = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeStrategyInterface::class); + $this->sourceDir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); + $this->targetDir = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class + ); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem->expects($this->once()) ->method('getDirectoryRead') ->with(DirectoryList::ROOT) @@ -51,7 +53,7 @@ protected function setUp() ->with(DirectoryList::STATIC_VIEW) ->will($this->returnValue($this->targetDir)); $this->checksum = new Checksum($this->mergerMock, $filesystem); - $this->resultAsset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $this->resultAsset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); } public function testMergeNoAssets() @@ -111,9 +113,9 @@ public function testMergeMtimeUnchanged() */ private function getAssetsToMerge() { - $one = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $one = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $one->expects($this->once())->method('getSourceFile')->will($this->returnValue('/dir/file/one.txt')); - $two = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $two = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $two->expects($this->once())->method('getSourceFile')->will($this->returnValue('/dir/file/two.txt')); $this->sourceDir->expects($this->exactly(2)) ->method('getRelativePath') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/DirectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/DirectTest.php index fb8c93ca642cf..23041feb2b8c6 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/DirectTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/DirectTest.php @@ -33,14 +33,14 @@ class DirectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cssUrlResolver = $this->getMock('\Magento\Framework\View\Url\CssResolver'); - $filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); - $this->writeDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->cssUrlResolver = $this->getMock(\Magento\Framework\View\Url\CssResolver::class); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->writeDir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $filesystem->expects($this->any()) ->method('getDirectoryWrite') ->with(DirectoryList::STATIC_VIEW) ->will($this->returnValue($this->writeDir)); - $this->resultAsset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $this->resultAsset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $this->object = new Direct($filesystem, $this->cssUrlResolver); } @@ -87,7 +87,7 @@ private function prepareAssetsToMerge(array $data) { $result = []; foreach ($data as $content) { - $asset = $this->getMockForAbstractClass('Magento\Framework\View\Asset\LocalInterface'); + $asset = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\LocalInterface::class); $asset->expects($this->once())->method('getContent')->will($this->returnValue($content)); $result[] = $asset; } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/FileExistsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/FileExistsTest.php index 993dcc48671b4..2354411700ce8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/FileExistsTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/FileExistsTest.php @@ -33,15 +33,15 @@ class FileExistsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mergerMock = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\MergeStrategyInterface'); - $this->dirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); - $filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); + $this->mergerMock = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeStrategyInterface::class); + $this->dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem->expects($this->once()) ->method('getDirectoryRead') ->with(DirectoryList::STATIC_VIEW) ->will($this->returnValue($this->dirMock)); $this->fileExists = new FileExists($this->mergerMock, $filesystem); - $this->resultAsset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $this->resultAsset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $this->resultAsset->expects($this->once())->method('getPath')->will($this->returnValue('foo/file')); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergedTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergedTest.php index 84c2973c907a8..c0dfadc7e9362 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergedTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergedTest.php @@ -42,22 +42,22 @@ class MergedTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_assetJsOne = $this->getMockForAbstractClass('Magento\Framework\View\Asset\MergeableInterface'); + $this->_assetJsOne = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeableInterface::class); $this->_assetJsOne->expects($this->any())->method('getContentType')->will($this->returnValue('js')); $this->_assetJsOne->expects($this->any())->method('getPath') ->will($this->returnValue('script_one.js')); - $this->_assetJsTwo = $this->getMockForAbstractClass('Magento\Framework\View\Asset\MergeableInterface'); + $this->_assetJsTwo = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeableInterface::class); $this->_assetJsTwo->expects($this->any())->method('getContentType')->will($this->returnValue('js')); $this->_assetJsTwo->expects($this->any())->method('getPath') ->will($this->returnValue('script_two.js')); - $this->_logger = $this->getMock('Psr\Log\LoggerInterface'); + $this->_logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->_mergeStrategy = $this->getMock('Magento\Framework\View\Asset\MergeStrategyInterface'); + $this->_mergeStrategy = $this->getMock(\Magento\Framework\View\Asset\MergeStrategyInterface::class); - $this->_assetRepo = $this->getMock( - '\Magento\Framework\View\Asset\Repository', [], [], '', false + $this->_assetRepo = $this->getMock( + \Magento\Framework\View\Asset\Repository::class, [], [], '', false ); } @@ -91,7 +91,7 @@ public function testConstructorRequireMergeInterface() */ public function testConstructorIncompatibleContentTypes() { - $assetCss = $this->getMockForAbstractClass('Magento\Framework\View\Asset\MergeableInterface'); + $assetCss = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeableInterface::class); $assetCss->expects($this->any())->method('getContentType')->will($this->returnValue('css')); new \Magento\Framework\View\Asset\Merged( $this->_logger, @@ -111,7 +111,7 @@ public function testIteratorInterfaceMerge() $this->_assetRepo, $assets ); - $mergedAsset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); + $mergedAsset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $this->_mergeStrategy ->expects($this->once()) ->method('merge') @@ -127,7 +127,7 @@ public function testIteratorInterfaceMerge() public function testIteratorInterfaceMergeFailure() { $mergeError = new \Exception('File not found'); - $assetBroken = $this->getMockForAbstractClass('Magento\Framework\View\Asset\MergeableInterface'); + $assetBroken = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\MergeableInterface::class); $assetBroken->expects($this->any())->method('getContentType')->will($this->returnValue('js')); $assetBroken->expects($this->any())->method('getPath') ->will($this->throwException($mergeError)); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php index ad031ec1a06db..21a27f33cad18 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php @@ -35,10 +35,10 @@ class MinificationTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/ModuleTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/ModuleTest.php index 8a699c48072c0..0ba45a729d916 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/ModuleTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/ModuleTest.php @@ -27,8 +27,8 @@ class ModuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); - $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); + $this->asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); + $this->assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); $this->object = new \Magento\Framework\View\Asset\NotationResolver\Module($this->assetRepo); } @@ -53,7 +53,7 @@ public function testConvertModuleNotationToPathNoModularSeparator() public function testConvertModuleNotationToPathModularSeparator( $assetRelPath, $relatedFieldId, $similarRelPath, $expectedResult ) { - $similarAsset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); + $similarAsset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $similarAsset->expects($this->any()) ->method('getPath') ->will($this->returnValue($similarRelPath)); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/VariableTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/VariableTest.php index 61e9203ea06e2..77b81faf359aa 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/VariableTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/NotationResolver/VariableTest.php @@ -32,12 +32,12 @@ protected function setUp() $path = 'frontend/Magento/blank/en_US'; $this->context = $this->getMock( - '\Magento\Framework\View\Asset\File\Context', + \Magento\Framework\View\Asset\File\Context::class, null, [$baseUrl, DirectoryList::STATIC_VIEW, $path] ); - $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); + $this->assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); $this->assetRepo->expects($this->any()) ->method('getStaticViewFileContext') ->will($this->returnValue($this->context)); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php index 7a5c3417e3562..a4a2930143f81 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php @@ -168,7 +168,7 @@ public function testProcess() { $alternatives = [ 'processor' => [ - AlternativeSource::PROCESSOR_CLASS => 'Magento\Framework\View\Asset\ContentProcessorInterface' + AlternativeSource::PROCESSOR_CLASS => \Magento\Framework\View\Asset\ContentProcessorInterface::class ] ]; @@ -216,7 +216,7 @@ public function testProcess() $this->objectManagerMock->expects(self::once()) ->method('get') - ->with('Magento\Framework\View\Asset\ContentProcessorInterface') + ->with(\Magento\Framework\View\Asset\ContentProcessorInterface::class) ->willReturn($this->getProcessorMock($assetMock)); $alternativeSource = new AlternativeSource( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/ChainTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/ChainTest.php index f3e4fb3b3e3a5..52bea4e87e9e9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/ChainTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/ChainTest.php @@ -27,7 +27,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->asset = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\LocalInterface'); + $this->asset = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\LocalInterface::class); $this->asset->expects($this->once())->method('getContentType')->will($this->returnValue('assetType')); $this->object = new Chain($this->asset, 'origContent', 'origType', 'origPath'); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/MinifyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/MinifyTest.php index 4cdf98872414f..76a5ed5fc1c72 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/MinifyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/MinifyTest.php @@ -33,11 +33,11 @@ class MinifyTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->adapterMock = $this->getMockBuilder('Magento\Framework\Code\Minifier\AdapterInterface') + $this->adapterMock = $this->getMockBuilder(\Magento\Framework\Code\Minifier\AdapterInterface::class) ->setMethods(['minify']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); @@ -58,7 +58,7 @@ protected function setUp() */ public function testProcess($targetPath, $originalPath, $minifyCalls, $setContentCalls, $isEnabled) { - $chainMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Chain') + $chainMock = $this->getMockBuilder(\Magento\Framework\View\Asset\PreProcessor\Chain::class) ->disableOriginalConstructor() ->getMock(); $chainMock diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php index f65aba6b3ee5b..8269cc14eddb0 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php @@ -23,7 +23,7 @@ class PoolTest extends \PHPUnit_Framework_TestCase const CONTENT_TYPE = 'test-type'; - const PREPROCESSOR_CLASS = 'Magento\Framework\View\Asset\PreProcessorInterface'; + const PREPROCESSOR_CLASS = \Magento\Framework\View\Asset\PreProcessorInterface::class; /** * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject @@ -42,10 +42,11 @@ class PoolTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') - ->getMockForAbstractClass(); - $this->sorterMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Helper\SortInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMockForAbstractClass(); + $this->sorterMock = $this->getMockBuilder( + \Magento\Framework\View\Asset\PreProcessor\Helper\SortInterface::class + )->getMockForAbstractClass(); } /** @@ -54,7 +55,7 @@ protected function setUp() private function getChainMock($type) { /** @var Chain|\PHPUnit_Framework_MockObject_MockObject $chainMock */ - $chainMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Chain') + $chainMock = $this->getMockBuilder(\Magento\Framework\View\Asset\PreProcessor\Chain::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/RepositoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/RepositoryTest.php index cadb00c259fff..e3c5084397658 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/RepositoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/RepositoryTest.php @@ -10,6 +10,8 @@ /** * Unit test for Magento\Framework\View\Asset\Repository + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class RepositoryTest extends \PHPUnit_Framework_TestCase { @@ -68,33 +70,35 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->urlMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $this->urlMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $this->designMock = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->listMock = $this->getMockBuilder('Magento\Framework\View\Design\Theme\ListInterface') + $this->listMock = $this->getMockBuilder(\Magento\Framework\View\Design\Theme\ListInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->sourceMock = $this->getMockBuilder('Magento\Framework\View\Asset\Source') + $this->sourceMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Source::class) ->disableOriginalConstructor() ->getMock(); - $this->httpMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->httpMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\Asset\FileFactory') + $this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Asset\FileFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->fallbackFactoryMock = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContextFactory') + $this->fallbackFactoryMock = $this->getMockBuilder( + \Magento\Framework\View\Asset\File\FallbackContextFactory::class + ) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->contextFactoryMock = $this->getMockBuilder('Magento\Framework\View\Asset\File\ContextFactory') + $this->contextFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File\ContextFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->remoteFactoryMock = $this->getMockBuilder('Magento\Framework\View\Asset\RemoteFactory') + $this->remoteFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Asset\RemoteFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -170,7 +174,7 @@ public function testCreateAsset() ->method('getThemeByFullPath') ->willReturnArgument(0); - $fallbackContextMock = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContex') + $fallbackContextMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContex::class) ->disableOriginalConstructor() ->getMock(); $this->fallbackFactoryMock @@ -187,7 +191,7 @@ public function testCreateAsset() ) ->willReturn($fallbackContextMock); - $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class) ->disableOriginalConstructor() ->getMock(); @@ -216,7 +220,7 @@ public function testCreateAsset() */ public function testGetStaticViewFileContext() { - $themeMock = $this->getMock('Magento\Framework\View\Design\ThemeInterface', [], [], '', false); + $themeMock = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class, [], [], '', false); $this->designMock ->expects($this->any()) ->method('getDesignParams') @@ -236,7 +240,7 @@ public function testGetStaticViewFileContext() ->method('isSecure') ->willReturn(false); - $fallbackContextMock = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContex') + $fallbackContextMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContex::class) ->disableOriginalConstructor() ->getMock(); $this->fallbackFactoryMock @@ -268,11 +272,11 @@ public function testGetStaticViewFileContext() */ public function testCreateRelated($filePath, $resultFilePath, $module) { - $originalContextMock = $this->getMockBuilder('Magento\Framework\View\Asset\ContextInterface') + $originalContextMock = $this->getMockBuilder(\Magento\Framework\View\Asset\ContextInterface::class) ->disableOriginalConstructor() ->getMock(); - $originalAssetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + $originalAssetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class) ->disableOriginalConstructor() ->setMethods(['getModule', 'getContext']) ->getMock(); @@ -281,7 +285,7 @@ public function testCreateRelated($filePath, $resultFilePath, $module) ->method('getContext') ->willReturn($originalContextMock); - $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class) ->disableOriginalConstructor() ->getMock(); @@ -321,7 +325,7 @@ public function createRelatedDataProvider() */ public function testCreateArbitrary() { - $contextMock = $this->getMockBuilder('Magento\Framework\View\Asset\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Asset\ContextInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -337,7 +341,7 @@ public function testCreateArbitrary() ) ->willReturn($contextMock); - $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class) ->disableOriginalConstructor() ->getMock(); @@ -373,7 +377,7 @@ public function testCreateRemoteAsset() */ public function testGetUrl() { - $themeMock = $this->getMock('Magento\Framework\View\Design\ThemeInterface', [], [], '', false); + $themeMock = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class, [], [], '', false); $this->designMock ->expects($this->any()) ->method('getDesignParams') @@ -385,7 +389,7 @@ public function testGetUrl() ] ); - $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class) ->disableOriginalConstructor() ->getMock(); $assetMock diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php index 99e4b76ac0db8..66e33e4fe3140 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php @@ -76,18 +76,19 @@ class SourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->preProcessorPool = $this->getMock( - 'Magento\Framework\View\Asset\PreProcessor\Pool', [], [], '', false + $this->preProcessorPool = $this->getMock( + \Magento\Framework\View\Asset\PreProcessor\Pool::class, [], [], '', false ); - $this->viewFileResolution = $this->getMock( - 'Magento\Framework\View\Design\FileResolution\Fallback\StaticFile', [], [], '', false + $this->viewFileResolution = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile::class, [], [], '', false ); - $this->theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $this->theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); /** @var \Magento\Framework\App\Config\ScopeConfigInterface $config */ - $this->chainFactory = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\ChainFactoryInterface') + $this->chainFactory = $this->getMockBuilder( + \Magento\Framework\View\Asset\PreProcessor\ChainFactoryInterface::class) ->getMock(); - $this->chain = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Chain') + $this->chain = $this->getMockBuilder(\Magento\Framework\View\Asset\PreProcessor\Chain::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -95,13 +96,19 @@ protected function setUp() ->method('create') ->willReturn($this->chain); - $themeList = $this->getMockForAbstractClass('Magento\Framework\View\Design\Theme\ListInterface'); + $themeList = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Theme\ListInterface::class); $themeList->expects($this->any()) ->method('getThemeByFullPath') ->with('frontend/magento_theme') ->willReturn($this->theme); - $this->readFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->readFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); $this->initFilesystem(); @@ -127,7 +134,7 @@ protected function setUp() public function testGetFile($origFile, $origPath, $origContent, $isMaterialization, $isExist) { $filePath = 'some/file.ext'; - $read = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $read = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $read->expects($this->at(0))->method('readFile')->with($origPath)->willReturn($origContent); $this->readFactory->expects($this->atLeastOnce())->method('create')->willReturn($read); $this->viewFileResolution->expects($this->once()) @@ -221,10 +228,14 @@ public function getFileDataProvider() protected function initFilesystem() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->rootDirRead = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->staticDirRead = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->varDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->rootDirRead = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\ReadInterface::class + ); + $this->staticDirRead = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\ReadInterface::class + ); + $this->varDir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $readDirMap = [ [DirectoryList::ROOT, DriverPool::FILE, $this->rootDirRead], @@ -264,7 +275,7 @@ protected function getAsset($isFallback = true) ); } - $asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); + $asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $asset->expects($this->any()) ->method('getContext') ->willReturn($context); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTest.php index 7c0a12c452504..b93e9b7a0e045 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTest.php @@ -28,7 +28,7 @@ class BlockPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->blockFactory = $this->getMockBuilder('Magento\Framework\View\Element\BlockFactory') + $this->blockFactory = $this->getMockBuilder(\Magento\Framework\View\Element\BlockFactory::class) ->disableOriginalConstructor() ->setMethods(['createBlock']) ->getMock(); @@ -38,10 +38,10 @@ protected function setUp() public function testAdd() { $blockName = 'testName'; - $blockClass = '\Magento\Framework\View\BlockPoolTestBlock'; + $blockClass = \Magento\Framework\View\Test\Unit\BlockPoolTestBlock::class; $arguments = ['key' => 'value']; - $block = $this->getMock('Magento\Framework\View\BlockPoolTestBlock'); + $block = $this->getMock(\Magento\Framework\View\Test\Unit\BlockPoolTestBlock::class); $this->blockFactory->expects($this->atLeastOnce()) ->method('createBlock') @@ -64,19 +64,3 @@ public function testAddWithException() $this->blockPool->add('BlockPoolTestBlock', 'NotExistingBlockClass'); } } - -/** - * Class BlockPoolTestBlock mock - */ -class BlockPoolTestBlock implements \Magento\Framework\View\Element\BlockInterface -{ - /** - * Produce and return block's html output - * - * @return string - */ - public function toHtml() - { - return ''; - } -} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTestBlock.php b/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTestBlock.php new file mode 100644 index 0000000000000..4dd282f29487e --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/BlockPoolTestBlock.php @@ -0,0 +1,22 @@ +repositoryMock = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->viewConfigFactoryMock = $this->getMock('Magento\Framework\Config\ViewFactory', [], [], '', false); + $this->repositoryMock = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->viewConfigFactoryMock = $this->getMock(\Magento\Framework\Config\ViewFactory::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->config = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Config', + \Magento\Framework\View\Config::class, [ 'assetRepo' => $this->repositoryMock, 'viewConfigFactory' => $this->viewConfigFactoryMock @@ -43,7 +43,7 @@ public function testGetViewConfig() $themeCode = 2; $themeMock = $this->getMock( - 'Magento\Theme\Model\Theme', + \Magento\Theme\Model\Theme::class, ['getCode'], [], '', @@ -60,12 +60,12 @@ public function testGetViewConfig() ->method('updateDesignParams') ->with($this->equalTo($params)) ->will($this->returnSelf()); - $configViewMock = $this->getMock('Magento\Framework\Config\View', [], [], '', false); + $configViewMock = $this->getMock(\Magento\Framework\Config\View::class, [], [], '', false); $this->viewConfigFactoryMock->expects($this->once()) ->method('create') ->willReturn($configViewMock); - $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params)); + $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params)); // lazy load test - $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params)); + $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params)); } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php b/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php index 8eabe913b4062..59e5b0e7a43f8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php @@ -11,6 +11,9 @@ use \Magento\Framework\View\Context; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ContextTest extends \PHPUnit_Framework_TestCase { /** @@ -35,97 +38,106 @@ class ContextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->appState = $this->getMockBuilder('Magento\Framework\App\State') + $this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->design = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $this->design = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->context = $objectManager->getObject('Magento\Framework\View\Context', [ - 'appState' => $this->appState, - 'request' => $this->request, - 'design' => $this->design - ]); + $this->context = $objectManager->getObject( + \Magento\Framework\View\Context::class, + [ + 'appState' => $this->appState, + 'request' => $this->request, + 'design' => $this->design + ] + ); } public function testGetCache() { - $this->assertInstanceOf('\Magento\Framework\App\CacheInterface', $this->context->getCache()); + $this->assertInstanceOf(\Magento\Framework\App\CacheInterface::class, $this->context->getCache()); } public function testGetDesignPackage() { - $this->assertInstanceOf('\Magento\Framework\View\DesignInterface', $this->context->getDesignPackage()); + $this->assertInstanceOf(\Magento\Framework\View\DesignInterface::class, $this->context->getDesignPackage()); } public function testGetEventManager() { - $this->assertInstanceOf('\Magento\Framework\Event\ManagerInterface', $this->context->getEventManager()); + $this->assertInstanceOf(\Magento\Framework\Event\ManagerInterface::class, $this->context->getEventManager()); } public function testGetFrontController() { $this->assertInstanceOf( - '\Magento\Framework\App\FrontControllerInterface', + \Magento\Framework\App\FrontControllerInterface::class, $this->context->getFrontController() ); } public function testGetLayout() { - $this->assertInstanceOf('\Magento\Framework\View\LayoutInterface', $this->context->getLayout()); + $this->assertInstanceOf(\Magento\Framework\View\LayoutInterface::class, $this->context->getLayout()); } public function testGetRequest() { - $this->assertInstanceOf('\Magento\Framework\App\Request\Http', $this->context->getRequest()); + $this->assertInstanceOf(\Magento\Framework\App\Request\Http::class, $this->context->getRequest()); } public function testGetSession() { - $this->assertInstanceOf('\Magento\Framework\Session\SessionManagerInterface', $this->context->getSession()); + $this->assertInstanceOf( + \Magento\Framework\Session\SessionManagerInterface::class, + $this->context->getSession() + ); } public function testGetScopeConfig() { - $this->assertInstanceOf('\Magento\Framework\App\Config\ScopeConfigInterface', $this->context->getScopeConfig()); + $this->assertInstanceOf( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + $this->context->getScopeConfig() + ); } public function testGetTranslator() { - $this->assertInstanceOf('\Magento\Framework\TranslateInterface', $this->context->getTranslator()); + $this->assertInstanceOf(\Magento\Framework\TranslateInterface::class, $this->context->getTranslator()); } public function testGetUrlBuilder() { - $this->assertInstanceOf('\Magento\Framework\UrlInterface', $this->context->getUrlBuilder()); + $this->assertInstanceOf(\Magento\Framework\UrlInterface::class, $this->context->getUrlBuilder()); } public function testGetViewConfig() { - $this->assertInstanceOf('\Magento\Framework\View\ConfigInterface', $this->context->getViewConfig()); + $this->assertInstanceOf(\Magento\Framework\View\ConfigInterface::class, $this->context->getViewConfig()); } public function testGetCacheState() { - $this->assertInstanceOf('\Magento\Framework\App\Cache\StateInterface', $this->context->getCacheState()); + $this->assertInstanceOf(\Magento\Framework\App\Cache\StateInterface::class, $this->context->getCacheState()); } public function testGetLogger() { - $this->assertInstanceOf('\Psr\Log\LoggerInterface', $this->context->getLogger()); + $this->assertInstanceOf(\Psr\Log\LoggerInterface::class, $this->context->getLogger()); } public function testGetAppState() { - $this->assertInstanceOf('\Magento\Framework\App\State', $this->context->getAppState()); + $this->assertInstanceOf(\Magento\Framework\App\State::class, $this->context->getAppState()); } public function testGetArea() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php index 2aa32df72f48c..ca74870a715ab 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php @@ -27,12 +27,13 @@ class DataSourcePoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->blockFactory = $this->getMockBuilder('Magento\Framework\View\Element\BlockFactory') + $this->blockFactory = $this->getMockBuilder(\Magento\Framework\View\Element\BlockFactory::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->dataSourcePool = $objectManager->getObject('Magento\Framework\View\DataSourcePool', [ + $this->dataSourcePool = $objectManager->getObject( + \Magento\Framework\View\DataSourcePool::class, [ 'blockFactory' => $this->blockFactory ]); } @@ -48,7 +49,7 @@ public function testAddWithException() protected function createBlock($blockClass) { - $block = $this->getMock('Magento\Framework\View\Element\BlockInterface'); + $block = $this->getMock(\Magento\Framework\View\Element\BlockInterface::class); $this->blockFactory->expects($this->once()) ->method('createBlock') @@ -60,7 +61,7 @@ protected function createBlock($blockClass) public function testAdd() { $blockName = 'DataSourcePoolTestBlock'; - $blockClass = 'Magento\Framework\View\Test\Unit\DataSourcePoolTestBlock'; + $blockClass = \Magento\Framework\View\Test\Unit\DataSourcePoolTestBlock::class; $block = $this->createBlock($blockClass); @@ -70,7 +71,7 @@ public function testAdd() public function testGet() { $blockName = 'DataSourcePoolTestBlock'; - $blockClass = 'Magento\Framework\View\Test\Unit\DataSourcePoolTestBlock'; + $blockClass = \Magento\Framework\View\Test\Unit\DataSourcePoolTestBlock::class; $block = $this->createBlock($blockClass); $this->dataSourcePool->add($blockName, $blockClass); @@ -88,7 +89,7 @@ public function testGetEmpty() public function testAssignAndGetNamespaceData() { $blockName = 'DataSourcePoolTestBlock'; - $blockClass = 'Magento\Framework\View\Test\Unit\DataSourcePoolTestBlock'; + $blockClass = \Magento\Framework\View\Test\Unit\DataSourcePoolTestBlock::class; $block = $this->createBlock($blockClass); $this->dataSourcePool->add($blockName, $blockClass); @@ -101,19 +102,3 @@ public function testAssignAndGetNamespaceData() $this->assertEquals([], $this->dataSourcePool->getNamespaceData('WrongNamespace')); } } - -/** - * Class DataSourcePoolTestBlock mock - */ -class DataSourcePoolTestBlock implements \Magento\Framework\View\Element\BlockInterface -{ - /** - * Produce and return block's html output - * - * @return string - */ - public function toHtml() - { - return ''; - } -} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTestBlock.php b/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTestBlock.php new file mode 100644 index 0000000000000..3165a7d63ff47 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTestBlock.php @@ -0,0 +1,22 @@ + 'value_one', 'param_two' => 'value_two']; - $ruleOne = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Fallback\Rule\RuleInterface'); + $ruleOne = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class); $ruleOne->expects( $this->once() )->method( @@ -37,7 +37,7 @@ public function testGetPatternDirs() $this->returnValue(['rule_one/path/one', 'rule_one/path/two']) ); - $ruleTwo = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Fallback\Rule\RuleInterface'); + $ruleTwo = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class); $ruleTwo->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModularSwitchTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModularSwitchTest.php index 3ac796caf2fe5..2359543779c9e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModularSwitchTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModularSwitchTest.php @@ -27,10 +27,10 @@ class ModularSwitchTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->ruleNonModular = $this->getMockForAbstractClass( - '\Magento\Framework\View\Design\Fallback\Rule\RuleInterface' + \Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class ); $this->ruleModular = $this->getMockForAbstractClass( - '\Magento\Framework\View\Design\Fallback\Rule\RuleInterface' + \Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class ); $this->object = new ModularSwitch($this->ruleNonModular, $this->ruleModular); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModuleTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModuleTest.php index f8cfeac4accd0..ffe6b2df79e95 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModuleTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ModuleTest.php @@ -29,9 +29,9 @@ class ModuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->rule = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Fallback\Rule\RuleInterface'); + $this->rule = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class); $this->componentRegistrar = $this->getMockForAbstractClass( - '\Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->model = new Module($this->rule, $this->componentRegistrar); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ThemeTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ThemeTest.php index ff0395da6a6d2..5d4c1656e154d 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ThemeTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/Rule/ThemeTest.php @@ -29,12 +29,13 @@ class ThemeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->rule = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Fallback\Rule\RuleInterface'); + $this->rule = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class); $this->componentRegistrar = $this->getMockForAbstractClass( - '\Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->model = new Theme($this->rule, $this->componentRegistrar); } + /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Parameter "theme" should be specified and should implement the theme interface @@ -46,10 +47,10 @@ public function testGetPatternDirsException() public function testGetPatternDirs() { - $parentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $parentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $parentTheme->expects($this->any())->method('getFullPath')->will($this->returnValue('package/parent_theme')); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any())->method('getFullPath')->will($this->returnValue('package/current_theme')); $theme->expects($this->any())->method('getParentTheme')->will($this->returnValue($parentTheme)); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php index ac4d8014da735..a45849ad501f3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php @@ -7,7 +7,6 @@ namespace Magento\Framework\View\Test\Unit\Design\Fallback; use \Magento\Framework\View\Design\Fallback\RulePool; - use Magento\Framework\Filesystem; class RulePoolTest extends \PHPUnit_Framework_TestCase @@ -19,11 +18,11 @@ class RulePoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystemMock->expects($this->any()) ->method('getDirectoryRead') ->will($this->returnCallback(function ($code) { - $dirMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); + $dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $dirMock->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnCallback(function ($path) use ($code) { @@ -33,22 +32,40 @@ protected function setUp() return $dirMock; })); - $simpleFactory = $this->getMock('Magento\Framework\View\Design\Fallback\Rule\SimpleFactory', [], [], '', false); - $rule = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Fallback\Rule\RuleInterface'); + $simpleFactory = $this->getMock( + \Magento\Framework\View\Design\Fallback\Rule\SimpleFactory::class, + [], + [], + '', + false + ); + $rule = $this->getMockForAbstractClass(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class); $simpleFactory->expects($this->any()) ->method('create') ->will($this->returnValue($rule)); - $themeFactory = $this->getMock('Magento\Framework\View\Design\Fallback\Rule\ThemeFactory', [], [], '', false); + $themeFactory = $this->getMock( + \Magento\Framework\View\Design\Fallback\Rule\ThemeFactory::class, + [], + [], + '', + false + ); $themeFactory->expects($this->any()) ->method('create') ->will($this->returnValue($rule)); - $moduleFactory = $this->getMock('Magento\Framework\View\Design\Fallback\Rule\ModuleFactory', [], [], '', false); + $moduleFactory = $this->getMock( + \Magento\Framework\View\Design\Fallback\Rule\ModuleFactory::class, + [], + [], + '', + false + ); $moduleFactory->expects($this->any()) ->method('create') ->will($this->returnValue($rule)); $moduleSwitchFactory = $this->getMock( - 'Magento\Framework\View\Design\Fallback\Rule\ModularSwitchFactory', + \Magento\Framework\View\Design\Fallback\Rule\ModularSwitchFactory::class, [], [], '', @@ -65,10 +82,10 @@ protected function setUp() $moduleSwitchFactory ); - $parentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $parentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $parentTheme->expects($this->any())->method('getThemePath')->will($this->returnValue('parent_theme_path')); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any())->method('getThemePath')->will($this->returnValue('current_theme_path')); $theme->expects($this->any())->method('getParentTheme')->will($this->returnValue($parentTheme)); } @@ -86,7 +103,7 @@ protected function tearDown() public function testGetRule($type) { $actualResult = $this->model->getRule($type); - $this->assertInstanceOf('\Magento\Framework\View\Design\Fallback\Rule\RuleInterface', $actualResult); + $this->assertInstanceOf(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class, $actualResult); $this->assertSame($actualResult, $this->model->getRule($type)); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/FileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/FileTest.php index 0740a550eb6d0..67579cbc0d679 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/FileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/FileTest.php @@ -24,13 +24,15 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolver = $this->getMock('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface'); + $this->resolver = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface::class + ); $this->object = new File($this->resolver); } public function testGetFile() { - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $expected = 'some/file.ext'; $this->resolver->expects($this->once()) ->method('resolve') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/LocaleFileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/LocaleFileTest.php index ecf106c9de5b3..58a9017f6a26f 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/LocaleFileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/LocaleFileTest.php @@ -24,13 +24,15 @@ class LocaleFileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolver = $this->getMock('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface'); + $this->resolver = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface::class + ); $this->object = new LocaleFile($this->resolver); } public function testGetFile() { - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $expected = 'some/file.ext'; $this->resolver->expects($this->once()) ->method('resolve') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php index 002290e1b92bf..98946634477cb 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php @@ -31,15 +31,19 @@ class AlternativeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directory = $this->getMock('\Magento\Framework\Filesystem\Directory\Read', [], [], '', false); - $readFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->directory = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); + $readFactory = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false); $readFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->directory)); $this->rule = $this->getMock( - '\Magento\Framework\View\Design\Fallback\Rule\RuleInterface', [], [], '', false + \Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class, + [], + [], + '', + false ); - $rulePool = $this->getMock('Magento\Framework\View\Design\Fallback\RulePool', [], [], '', false); + $rulePool = $this->getMock(\Magento\Framework\View\Design\Fallback\RulePool::class, [], [], '', false); $rulePool->expects($this->any()) ->method('getRule') ->with('type') @@ -57,8 +61,8 @@ public function testConstructorException(array $alternativeExtensions) $this->setExpectedException('\InvalidArgumentException', "\$alternativeExtensions must be an array with format:" . " array('ext1' => array('ext1', 'ext2'), 'ext3' => array(...)]"); - $readFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); - $rulePool = $this->getMock('Magento\Framework\View\Design\Fallback\RulePool', [], [], '', false); + $readFactory = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false); + $rulePool = $this->getMock(\Magento\Framework\View\Design\Fallback\RulePool::class, [], [], '', false); new Alternative($readFactory, $rulePool, $alternativeExtensions); } @@ -78,7 +82,7 @@ public function testResolve() $requestedFile = 'file.css'; $expected = 'some/dir/file.less'; - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any()) ->method('getFullPath') ->will($this->returnValue('magento_theme')); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php index 663976302a281..3f461f1602247 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php @@ -35,11 +35,11 @@ class MinificationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->resolverMock = $this - ->getMockBuilder('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface') + ->getMockBuilder(\Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->assetMinificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->assetMinificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/SimpleTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/SimpleTest.php index 96e25f6d34f00..ae2f4877e6ba9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/SimpleTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/SimpleTest.php @@ -291,7 +291,7 @@ public function testResolveNonexistentFile() */ private function getMockForTheme($themePath) { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any()) ->method('getThemePath') ->willReturn($themePath); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/StaticFileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/StaticFileTest.php index 145751b43545f..bc2ef10d24972 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/StaticFileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/StaticFileTest.php @@ -24,13 +24,15 @@ class StaticFileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolver = $this->getMock('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface'); + $this->resolver = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface::class + ); $this->object = new StaticFile($this->resolver); } public function testGetFile() { - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $expected = 'some/file.ext'; $this->resolver->expects($this->once()) ->method('resolve') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php index ecea3aa48fbd0..841b03e177f7c 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php @@ -40,11 +40,15 @@ class TemplateFileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolver = $this->getMock('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface'); - $this->minifier = $this->getMock('Magento\Framework\View\Template\Html\MinifierInterface'); - $this->state = $this->getMockBuilder('Magento\Framework\App\State')->disableOriginalConstructor()->getMock(); + $this->resolver = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface::class + ); + $this->minifier = $this->getMock(\Magento\Framework\View\Template\Html\MinifierInterface::class); + $this->state = $this->getMockBuilder( + \Magento\Framework\App\State::class + )->disableOriginalConstructor()->getMock(); $this->assetConfig = $this->getMockForAbstractClass( - 'Magento\Framework\View\Asset\ConfigInterface', + \Magento\Framework\View\Asset\ConfigInterface::class, [], '', false @@ -62,7 +66,7 @@ public function testGetFileWhenStateDeveloper() ->method('isMinifyHtml') ->willReturn(true); - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $expected = 'some/file.ext'; $this->state->expects($this->once()) @@ -90,7 +94,7 @@ public function testGetFileWhenModifiedNeeded($mode, $method) ->method('isMinifyHtml') ->willReturn(true); - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $expected = 'some/file.ext'; $expectedMinified = '/path/to/minified/some/file.ext'; @@ -117,7 +121,7 @@ public function testGetFileIfMinificationIsDisabled() ->method('isMinifyHtml') ->willReturn(false); - $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $expected = 'some/file.ext'; $this->resolver->expects($this->once()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/AbstractFileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/AbstractFileTest.php index bec54d5e7042c..702017363e359 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/AbstractFileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/AbstractFileTest.php @@ -36,23 +36,23 @@ class AbstractFileTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_customizationPath = $this->getMock( - 'Magento\Framework\View\Design\Theme\Customization\Path', + \Magento\Framework\View\Design\Theme\Customization\Path::class, [], [], '', false ); $this->_fileFactory = $this->getMock( - 'Magento\Framework\View\Design\Theme\FileFactory', + \Magento\Framework\View\Design\Theme\FileFactory::class, ['create'], [], '', false ); - $this->_filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->_filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->_modelBuilder = $this->getMockBuilder( - 'Magento\Framework\View\Design\Theme\Customization\AbstractFile' + \Magento\Framework\View\Design\Theme\Customization\AbstractFile::class )->setMethods( ['getType', 'getContentType'] )->setConstructorArgs( @@ -75,7 +75,7 @@ protected function tearDown() public function testCreate() { $model = $this->_modelBuilder->getMock(); - $file = $this->getMock('Magento\Theme\Model\Theme\File', [], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, [], [], '', false); $file->expects($this->once())->method('setCustomizationService')->with($model); $this->_fileFactory->expects($this->once())->method('create')->will($this->returnValue($file)); /** @var $model \Magento\Framework\View\Design\Theme\Customization\AbstractFile */ @@ -88,8 +88,8 @@ public function testCreate() public function testGetFullPath() { $model = $this->_modelBuilder->getMock(); - $theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false); - $file = $this->getMock('Magento\Theme\Model\Theme\File', [], [], '', false); + $theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, [], [], '', false); $file->expects($this->any())->method('getTheme')->will($this->returnValue($theme)); $file->expects($this->once())->method('getData')->with('file_path')->will($this->returnValue('file.path')); @@ -122,12 +122,12 @@ public function testPrepareFile($type, $fileContent, $expectedContent, $existedF $files = []; foreach ($existedFiles as $fileData) { - $file = $this->getMock('Magento\Theme\Model\Theme\File', ['__wakeup', 'save'], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, ['__wakeup', 'save'], [], '', false); $file->setData($fileData); $files[] = $file; } $customization = $this->getMock( - 'Magento\Framework\View\Design\Theme\Customization', + \Magento\Framework\View\Design\Theme\Customization::class, [], [], '', @@ -143,11 +143,11 @@ public function testPrepareFile($type, $fileContent, $expectedContent, $existedF $this->returnValue($files) ); - $theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false); + $theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false); $theme->expects($this->any())->method('getCustomization')->will($this->returnValue($customization)); $file = $this->getMock( - 'Magento\Theme\Model\Theme\File', + \Magento\Theme\Model\Theme\File::class, ['__wakeup', 'getTheme', 'save'], [], '', @@ -211,7 +211,7 @@ public function testSave() { $model = $this->_modelBuilder->setMethods(['getFullPath', 'getType', 'getContentType'])->getMock(); - $file = $this->getMock('Magento\Theme\Model\Theme\File', ['__wakeup'], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, ['__wakeup'], [], '', false); $file->setData( [ 'file_type' => 'js', @@ -224,7 +224,7 @@ public function testSave() $model->expects($this->once())->method('getFullPath')->with($file)->will($this->returnValue('test_path')); $directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, ['writeFile', 'delete', 'getRelativePath'], [], '', @@ -254,7 +254,7 @@ public function testSave() public function testDelete() { $model = $this->_modelBuilder->setMethods(['getFullPath', 'getType', 'getContentType'])->getMock(); - $file = $this->getMock('Magento\Theme\Model\Theme\File', ['__wakeup'], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, ['__wakeup'], [], '', false); $file->setData( [ 'file_type' => 'js', @@ -265,7 +265,7 @@ public function testDelete() ] ); $directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, ['touch', 'delete', 'getRelativePath'], [], '', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/PathTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/PathTest.php index b988842fd8df1..a70558060ab21 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/PathTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Customization/PathTest.php @@ -35,14 +35,14 @@ class PathTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); + $this->_theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); /** @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject $filesystem */ - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->_directory = $this->getMock('\Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->_directory = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $filesystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->_directory)); $this->_directory->expects($this->any())->method('getAbsolutePath')->will($this->returnArgument(0)); $this->componentRegistrar = $this->getMockForAbstractClass( - '\Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->_model = new \Magento\Framework\View\Design\Theme\Customization\Path( $filesystem, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/CustomizationTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/CustomizationTest.php index fa31c0f4aa644..9f2725f9db4d6 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/CustomizationTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/CustomizationTest.php @@ -36,14 +36,14 @@ class CustomizationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fileProvider = $this->getMock( - 'Magento\Framework\View\Design\Theme\FileProviderInterface', + \Magento\Framework\View\Design\Theme\FileProviderInterface::class, [], [], '', false ); $collectionFactory = $this->getMock( - 'Magento\Theme\Model\ResourceModel\Theme\File\CollectionFactory', + \Magento\Theme\Model\ResourceModel\Theme\File\CollectionFactory::class, ['create'], [], '', @@ -51,14 +51,14 @@ protected function setUp() ); $collectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->fileProvider)); $this->customizationPath = $this->getMock( - 'Magento\Framework\View\Design\Theme\Customization\Path', + \Magento\Framework\View\Design\Theme\Customization\Path::class, [], [], '', false ); $this->theme = $this->getMock( - 'Magento\Theme\Model\Theme', + \Magento\Theme\Model\Theme::class, ['__wakeup', 'save', 'load'], [], '', @@ -118,7 +118,7 @@ public function testGetFilesByType() */ public function testGenerationOfFileInfo() { - $file = $this->getMock('Magento\Theme\Model\Theme\File', ['__wakeup', 'getFileInfo'], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, ['__wakeup', 'getFileInfo'], [], '', false); $file->expects($this->once())->method('getFileInfo')->will($this->returnValue(['sample-generation'])); $this->assertEquals([['sample-generation']], $this->model->generateFileInfo([$file])); } @@ -199,7 +199,7 @@ public function testReorder($sequence, $filesContent) $files = []; $type = 'sample-type'; foreach ($filesContent as $fileContent) { - $file = $this->getMock('Magento\Theme\Model\Theme\File', ['__wakeup', 'save'], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, ['__wakeup', 'save'], [], '', false); $file->expects($fileContent['isCalled'])->method('save')->will($this->returnSelf()); $file->setData($fileContent['content']); $files[] = $file; @@ -215,7 +215,7 @@ public function testReorder($sequence, $filesContent) $this->returnValue($files) ); $this->assertInstanceOf( - 'Magento\Framework\View\Design\Theme\CustomizationInterface', + \Magento\Framework\View\Design\Theme\CustomizationInterface::class, $this->model->reorder($type, $sequence) ); } @@ -271,7 +271,7 @@ public function customFileContent() */ public function testDelete() { - $file = $this->getMock('Magento\Theme\Model\Theme\File', ['__wakeup', 'delete'], [], '', false); + $file = $this->getMock(\Magento\Theme\Model\Theme\File::class, ['__wakeup', 'delete'], [], '', false); $file->expects($this->once())->method('delete')->will($this->returnSelf()); $file->setData( [ @@ -293,7 +293,7 @@ public function testDelete() ); $this->assertInstanceOf( - 'Magento\Framework\View\Design\Theme\CustomizationInterface', + \Magento\Framework\View\Design\Theme\CustomizationInterface::class, $this->model->delete([1]) ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php index 132b41fed2cfa..c9cb30391a104 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php @@ -16,7 +16,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ public function testCreate() { - $themeMock = $this->getMock('Magento\Theme\Model\Theme', ['__wakeup', 'getType'], [], '', false); + $themeMock = $this->getMock(\Magento\Theme\Model\Theme::class, ['__wakeup', 'getType'], [], '', false); $themeMock->expects( $this->any() )->method( @@ -25,15 +25,15 @@ public function testCreate() $this->returnValue(\Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL) ); - $newThemeMock = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false); + $newThemeMock = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager->expects( $this->once() )->method( 'create' )->with( - 'Magento\Framework\View\Design\Theme\Domain\VirtualInterface', + \Magento\Framework\View\Design\Theme\Domain\VirtualInterface::class, ['theme' => $themeMock] )->will( $this->returnValue($newThemeMock) @@ -49,15 +49,15 @@ public function testCreate() public function testCreateWithWrongThemeType() { $wrongThemeType = 'wrong_theme_type'; - $themeMock = $this->getMock('Magento\Theme\Model\Theme', ['__wakeup', 'getType'], [], '', false); + $themeMock = $this->getMock(\Magento\Theme\Model\Theme::class, ['__wakeup', 'getType'], [], '', false); $themeMock->expects($this->any())->method('getType')->will($this->returnValue($wrongThemeType)); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $themeDomainFactory = new \Magento\Framework\View\Design\Theme\Domain\Factory($objectManager); $this->setExpectedException( - 'Magento\Framework\Exception\LocalizedException', + \Magento\Framework\Exception\LocalizedException::class, sprintf('Invalid type of theme domain model "%s"', $wrongThemeType) ); $themeDomainFactory->create($themeMock); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/FlyweightFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/FlyweightFactoryTest.php index 5f75fa2c0615d..e98ce7e666182 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/FlyweightFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/FlyweightFactoryTest.php @@ -21,7 +21,7 @@ class FlyweightFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->themeProviderMock = $this->getMock('Magento\Framework\View\Design\Theme\ThemeProviderInterface'); + $this->themeProviderMock = $this->getMock(\Magento\Framework\View\Design\Theme\ThemeProviderInterface::class); $this->factory = new FlyweightFactory($this->themeProviderMock); } @@ -33,7 +33,7 @@ protected function setUp() */ public function testCreateById($path, $expectedId) { - $theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false); + $theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false); $theme->expects($this->exactly(3))->method('getId')->will($this->returnValue($expectedId)); $theme->expects($this->once())->method('getFullPath')->will($this->returnValue(null)); @@ -69,7 +69,7 @@ public function testCreateByPath() { $path = 'frontend/Magento/luma'; $themeId = 7; - $theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false); + $theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false); $theme->expects($this->exactly(3))->method('getId')->will($this->returnValue($themeId)); $theme->expects($this->once())->method('getFullPath')->will($this->returnValue($path)); @@ -94,7 +94,7 @@ public function testCreateByPath() public function testCreateDummy() { $themeId = 0; - $theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false); + $theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false); $theme->expects($this->once())->method('getId')->will($this->returnValue($themeId)); $this->themeProviderMock->expects( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Image/UploaderTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Image/UploaderTest.php index c12063fabd2ef..7a33830bc8cfb 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Image/UploaderTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Image/UploaderTest.php @@ -38,11 +38,11 @@ class UploaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->_transferAdapterMock = $this->getMock('Zend_File_Transfer_Adapter_Http', [], [], '', false); - $this->_fileUploader = $this->getMock('Magento\Framework\File\Uploader', [], [], '', false); + $this->_filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->_transferAdapterMock = $this->getMock(\Zend_File_Transfer_Adapter_Http::class, [], [], '', false); + $this->_fileUploader = $this->getMock(\Magento\Framework\File\Uploader::class, [], [], '', false); - $adapterFactory = $this->getMock('Magento\Framework\HTTP\Adapter\FileTransferFactory'); + $adapterFactory = $this->getMock(\Magento\Framework\HTTP\Adapter\FileTransferFactory::class); $adapterFactory->expects( $this->once() )->method( @@ -52,7 +52,7 @@ protected function setUp() ); $uploaderFactory = $this->getMock( - 'Magento\Framework\File\UploaderFactory', + \Magento\Framework\File\UploaderFactory::class, ['create'], [], '', @@ -102,7 +102,7 @@ public function uploadDataProvider() 'checkAllowedExtension' => true, 'save' => true, 'result' => false, - 'exception' => 'Magento\Framework\Exception\LocalizedException' + 'exception' => \Magento\Framework\Exception\LocalizedException::class ], [ 'isUploaded' => true, @@ -110,7 +110,7 @@ public function uploadDataProvider() 'checkAllowedExtension' => false, 'save' => true, 'result' => false, - 'exception' => 'Magento\Framework\Exception\LocalizedException' + 'exception' => \Magento\Framework\Exception\LocalizedException::class ], [ 'isUploaded' => true, @@ -118,7 +118,7 @@ public function uploadDataProvider() 'checkAllowedExtension' => true, 'save' => false, 'result' => false, - 'exception' => 'Magento\Framework\Exception\LocalizedException' + 'exception' => \Magento\Framework\Exception\LocalizedException::class ] ]; } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ImageTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ImageTest.php index 30bb16c1858ec..82bd042feb93e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ImageTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ImageTest.php @@ -13,6 +13,9 @@ use Magento\Framework\App\Filesystem\DirectoryList; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ImageTest extends \PHPUnit_Framework_TestCase { /** @@ -58,7 +61,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_mediaDirectoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, ['isExist', 'copyFile', 'getRelativePath', 'delete'], [], '', @@ -66,11 +69,11 @@ protected function setUp() false ); $this->_rootDirectoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, ['isExist', 'copyFile', 'getRelativePath', 'delete'], [], '', false, false ); $this->_filesystemMock = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryWrite', '__wakeup'], [], '', @@ -85,14 +88,14 @@ protected function setUp() ->method('getDirectoryWrite') ->with(DirectoryList::ROOT) ->will($this->returnValue($this->_rootDirectoryMock)); - $imageFactory = $this->getMock('Magento\Framework\Image\Factory', [], [], '', false, false); - $this->_imageMock = $this->getMock('Magento\Framework\Image', [], [], '', false, false); + $imageFactory = $this->getMock(\Magento\Framework\Image\Factory::class, [], [], '', false, false); + $this->_imageMock = $this->getMock(\Magento\Framework\Image::class, [], [], '', false, false); $imageFactory->expects($this->any())->method('create')->will($this->returnValue($this->_imageMock)); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->_themeMock = $this->getMock('Magento\Theme\Model\Theme', ['__wakeup'], [], '', false, false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->_themeMock = $this->getMock(\Magento\Theme\Model\Theme::class, ['__wakeup'], [], '', false, false); $this->_uploaderMock = $this->getMock( - 'Magento\Framework\View\Design\Theme\Image\Uploader', + \Magento\Framework\View\Design\Theme\Image\Uploader::class, [], [], '', @@ -103,7 +106,8 @@ protected function setUp() $this->imagePathMock = $this->_getImagePathMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Framework\View\Design\Theme\Image', [ + $this->_model = $objectManager->getObject( + \Magento\Framework\View\Design\Theme\Image::class, [ 'filesystem' => $this->_filesystemMock, 'imageFactory' => $imageFactory, 'uploader' => $this->_uploaderMock, @@ -127,7 +131,7 @@ protected function tearDown() */ protected function _getImagePathMock() { - $imagePathMock = $this->getMock('Magento\Theme\Model\Theme\Image\Path', [], [], '', false); + $imagePathMock = $this->getMock(\Magento\Theme\Model\Theme\Image\Path::class, [], [], '', false); $testBaseUrl = 'http://localhost/media_path/'; $imagePathMock->expects($this->any())->method('getPreviewImageDefaultUrl') @@ -218,7 +222,7 @@ public function testCreatePreviewImageCopy() ->with($relativePath, $this->anything()) ->will($this->returnValue(true)); - $themeImageMock = $this->getMockBuilder('Magento\Framework\View\Design\Theme\Image') + $themeImageMock = $this->getMockBuilder(\Magento\Framework\View\Design\Theme\Image::class) ->disableOriginalConstructor() ->setMethods(['getPreviewImagePath']) ->getMock(); @@ -226,7 +230,7 @@ public function testCreatePreviewImageCopy() ->method('getPreviewImagePath') ->will($this->returnValue($previewImage)); - $themeMock = $this->getMockBuilder('Magento\Theme\Model\Theme') + $themeMock = $this->getMockBuilder(\Magento\Theme\Model\Theme::class) ->disableOriginalConstructor() ->setMethods(['getThemeImage', 'getPreviewImage', '__wakeup']) ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/LabelTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/LabelTest.php index f6935209d4e0b..21f9671b1cd5e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/LabelTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/LabelTest.php @@ -22,7 +22,7 @@ class LabelTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->labelList = $this->getMockBuilder('Magento\Framework\View\Design\Theme\Label\ListInterface') + $this->labelList = $this->getMockBuilder(\Magento\Framework\View\Design\Theme\Label\ListInterface::class) ->getMockForAbstractClass(); $this->model = new Label( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ThemePackageListTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ThemePackageListTest.php index 50e66fdf5007b..bce773e5e1aca 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ThemePackageListTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/ThemePackageListTest.php @@ -27,8 +27,16 @@ class ThemePackageListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registrar = $this->getMockForAbstractClass('\Magento\Framework\Component\ComponentRegistrarInterface'); - $this->factory = $this->getMock('Magento\Framework\View\Design\Theme\ThemePackageFactory', [], [], '', false); + $this->registrar = $this->getMockForAbstractClass( + \Magento\Framework\Component\ComponentRegistrarInterface::class + ); + $this->factory = $this->getMock( + \Magento\Framework\View\Design\Theme\ThemePackageFactory::class, + [], + [], + '', + false + ); $this->object = new ThemePackageList($this->registrar, $this->factory); } @@ -56,7 +64,7 @@ public function testGetTheme() ->method('getPath') ->with(ComponentRegistrar::THEME, $themeKey) ->willReturn($themePath); - $themePackage = $this->getMock('\Magento\Framework\View\Design\Theme\ThemePackage', [], [], '', false); + $themePackage = $this->getMock(\Magento\Framework\View\Design\Theme\ThemePackage::class, [], [], '', false); $this->factory->expects($this->once()) ->method('create') ->with($themeKey, $themePath) @@ -70,7 +78,7 @@ public function testGetThemes() ->method('getPaths') ->with(ComponentRegistrar::THEME) ->willReturn(['theme1' => 'path1', 'theme2' => 'path2']); - $themePackage = $this->getMock('\Magento\Framework\View\Design\Theme\ThemePackage', [], [], '', false); + $themePackage = $this->getMock(\Magento\Framework\View\Design\Theme\ThemePackage::class, [], [], '', false); $this->factory->expects($this->exactly(2)) ->method('create') ->withConsecutive( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/DesignExceptionsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/DesignExceptionsTest.php index d91f049e3452d..6223c7909da69 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/DesignExceptionsTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/DesignExceptionsTest.php @@ -30,12 +30,12 @@ class DesignExceptionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->designExceptions = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\DesignExceptions', + \Magento\Framework\View\DesignExceptions::class, [ 'scopeConfig' => $this->scopeConfigMock, 'exceptionConfigPath' => $this->exceptionConfigPath, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php b/lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php index 0aae78ad4653e..58331e32deda4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php @@ -32,9 +32,9 @@ class DesignLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_areaListMock = $this->getMock('\Magento\Framework\App\AreaList', [], [], '', false); - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->_areaListMock = $this->getMock(\Magento\Framework\App\AreaList::class, [], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->_model = new \Magento\Framework\View\DesignLoader( $this->_requestMock, $this->_areaListMock, @@ -44,7 +44,7 @@ protected function setUp() public function testLoad() { - $area = $this->getMock('Magento\Framework\App\Area', [], [], '', false); + $area = $this->getMock(\Magento\Framework\App\Area::class, [], [], '', false); $this->appState->expects($this->once())->method('getAreaCode')->will($this->returnValue('area')); $this->_areaListMock->expects($this->once())->method('getArea')->with('area')->will($this->returnValue($area)); $area->expects($this->at(0))->method('load') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/BlockFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/BlockFactoryTest.php index ea63368b46dee..c430e8a31f756 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/BlockFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/BlockFactoryTest.php @@ -21,19 +21,20 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->blockFactory = $objectManagerHelper->getObject('Magento\Framework\View\Element\BlockFactory', [ - 'objectManager' => $this->objectManagerMock - ]); + $this->blockFactory = $objectManagerHelper->getObject( + \Magento\Framework\View\Element\BlockFactory::class, + ['objectManager' => $this->objectManagerMock] + ); } public function testCreateBlock() { - $className = 'Magento\Framework\View\Element\Template'; + $className = \Magento\Framework\View\Element\Template::class; $argumentsResult = ['arg1', 'arg2']; - $templateMock = $this->getMockBuilder('Magento\Framework\View\Element\Template') + $templateMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock->expects($this->once()) @@ -42,7 +43,7 @@ public function testCreateBlock() ->will($this->returnValue($templateMock)); $this->assertInstanceOf( - 'Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, $this->blockFactory->createBlock($className, $argumentsResult) ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/FormKeyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/FormKeyTest.php index d4828ecbe1c62..8f3273ec2fd8b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/FormKeyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/FormKeyTest.php @@ -16,7 +16,7 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $formKeyMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey') + $formKeyMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey::class) ->setMethods(['getFormKey'])->disableOriginalConstructor()->getMock(); $formKeyMock->expects($this->any()) @@ -24,7 +24,7 @@ protected function setUp() ->will($this->returnValue('form_key')); $this->formKeyElement = $objectManagerHelper->getObject( - 'Magento\Framework\View\Element\FormKey', + \Magento\Framework\View\Element\FormKey::class, ['formKey' => $formKeyMock] ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/CalendarTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/CalendarTest.php index d6dc3d5abb8de..a4aead039c292 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/CalendarTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/CalendarTest.php @@ -24,12 +24,12 @@ class CalendarTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); /** @var \Magento\Framework\View\Element\Template\Context $context */ $this->context = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [ 'localeDate' => $this->localeDate, ] @@ -37,7 +37,7 @@ protected function setUp() /** @var \Magento\Framework\View\Element\Html\Links $block */ $this->block = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Element\Html\Calendar', + \Magento\Framework\View\Element\Html\Calendar::class, ['context' => $this->context] ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php index e7dce020656ec..bbe1ba8047b14 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php @@ -30,9 +30,9 @@ class CurrentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_urlBuilderMock = $this->getMock('\Magento\Framework\UrlInterface'); - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->_defaultPathMock = $this->getMock('\Magento\Framework\App\DefaultPathInterface'); + $this->_urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->_defaultPathMock = $this->getMock(\Magento\Framework\App\DefaultPathInterface::class); } public function testGetUrl() @@ -44,7 +44,7 @@ public function testGetUrl() /** @var \Magento\Framework\View\Element\Html\Link\Current $link */ $link = $this->_objectManager->getObject( - 'Magento\Framework\View\Element\Html\Link\Current', + \Magento\Framework\View\Element\Html\Link\Current::class, ['urlBuilder' => $this->_urlBuilderMock] ); @@ -55,7 +55,7 @@ public function testGetUrl() public function testIsCurrentIfIsset() { /** @var \Magento\Framework\View\Element\Html\Link\Current $link */ - $link = $this->_objectManager->getObject('Magento\Framework\View\Element\Html\Link\Current'); + $link = $this->_objectManager->getObject(\Magento\Framework\View\Element\Html\Link\Current::class); $link->setCurrent(true); $this->assertTrue($link->IsCurrent()); } @@ -76,7 +76,7 @@ public function testIsCurrent() $this->_requestMock->expects($this->once())->method('getControllerName')->will($this->returnValue('b')); /** @var \Magento\Framework\View\Element\Html\Link\Current $link */ $link = $this->_objectManager->getObject( - 'Magento\Framework\View\Element\Html\Link\Current', + \Magento\Framework\View\Element\Html\Link\Current::class, [ 'urlBuilder' => $this->_urlBuilderMock, 'request' => $this->_requestMock, @@ -94,7 +94,7 @@ public function testIsCurrentFalse() /** @var \Magento\Framework\View\Element\Html\Link\Current $link */ $link = $this->_objectManager->getObject( - 'Magento\Framework\View\Element\Html\Link\Current', + \Magento\Framework\View\Element\Html\Link\Current::class, ['urlBuilder' => $this->_urlBuilderMock, 'request' => $this->_requestMock] ); $this->assertFalse($link->isCurrent()); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php index d686ed7a035f6..06bb48426fc1f 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php @@ -39,30 +39,30 @@ public function getLinkAttributesDataProvider() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $escaperMock = $this->getMockBuilder('Magento\Framework\Escaper') + $escaperMock = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->setMethods(['escapeHtml'])->disableOriginalConstructor()->getMock(); $escaperMock->expects($this->any()) ->method('escapeHtml') ->will($this->returnArgument(0)); - $urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->setMethods(['getUrl'])->disableOriginalConstructor()->getMockForAbstractClass(); $urlBuilderMock->expects($this->any()) ->method('getUrl') ->will($this->returnArgument('http://site.com/link.html')); - $validtorMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\File\Validator') + $validtorMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Validator::class) ->setMethods(['isValid'])->disableOriginalConstructor()->getMock(); - $scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config') + $scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->setMethods(['isSetFlag'])->disableOriginalConstructor()->getMock(); - $resolverMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\File\Resolver') + $resolverMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class) ->setMethods([])->disableOriginalConstructor()->getMock(); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->setMethods(['getEscaper', 'getUrlBuilder', 'getValidator', 'getResolver', 'getScopeConfig']) ->disableOriginalConstructor() ->getMock(); @@ -89,12 +89,12 @@ public function getLinkAttributesDataProvider() /** @var \Magento\Framework\View\Element\Html\Link $linkWithAttributes */ $linkWithAttributes = $objectManagerHelper->getObject( - 'Magento\Framework\View\Element\Html\Link', + \Magento\Framework\View\Element\Html\Link::class, ['context' => $contextMock] ); /** @var \Magento\Framework\View\Element\Html\Link $linkWithoutAttributes */ $linkWithoutAttributes = $objectManagerHelper->getObject( - 'Magento\Framework\View\Element\Html\Link', + \Magento\Framework\View\Element\Html\Link::class, ['context' => $contextMock] ); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php index 07472a1b75102..d9ef656c98eaa 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinksTest.php @@ -27,7 +27,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManager($this); /** @var Context $context */ - $this->context = $this->objectManagerHelper->getObject('Magento\Framework\View\Element\Template\Context'); + $this->context = $this->objectManagerHelper->getObject(\Magento\Framework\View\Element\Template\Context::class); $this->block = new Links($this->context); } @@ -46,7 +46,7 @@ public function testGetLinks() public function testSetActive() { - $link = $this->getMock('Magento\Framework\View\Element\Html\Link', [], [], '', false); + $link = $this->getMock(\Magento\Framework\View\Element\Html\Link::class, [], [], '', false); $link ->expects($this->at(1)) ->method('__call') @@ -79,7 +79,7 @@ public function testRenderLink() ->willReturn($blockHtml); /** @var \Magento\Framework\View\Element\AbstractBlock $link */ - $link = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $link = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->disableOriginalConstructor() ->getMock(); $link diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php index 9d4e381f06cc8..6e10998105654 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php @@ -16,18 +16,18 @@ class SelectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $escaper = $this->getMockBuilder('Magento\Framework\Escaper') + $escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->getMock(); $escaper->expects($this->any()) ->method('escapeHtml') ->will($this->returnArgument(0)); - $context = $this->getMockBuilder('Magento\Framework\View\Element\Context') + $context = $this->getMockBuilder(\Magento\Framework\View\Element\Context::class) ->disableOriginalConstructor() ->getMock(); $context->expects($this->once()) @@ -41,9 +41,10 @@ protected function setUp() ->will($this->returnValue($scopeConfig)); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->select = $objectManagerHelper->getObject('Magento\Framework\View\Element\Html\Select', [ - 'context' => $context - ]); + $this->select = $objectManagerHelper->getObject( + \Magento\Framework\View\Element\Html\Select::class, + ['context' => $context] + ); } public function testAddOptionAndSetOptionsAndGetOptions() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php index 2149d94ab8eaf..a5b24d8c0c323 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php @@ -29,20 +29,20 @@ class CookieTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionConfigMock = $this->getMockBuilder('Magento\Framework\Session\Config') + $this->sessionConfigMock = $this->getMockBuilder(\Magento\Framework\Session\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->ipValidatorMock = $this->getMockBuilder('Magento\Framework\Validator\Ip') + $this->ipValidatorMock = $this->getMockBuilder(\Magento\Framework\Validator\Ip::class) ->disableOriginalConstructor() ->getMock(); - $validtorMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\File\Validator') + $validtorMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Validator::class) ->setMethods(['isValid'])->disableOriginalConstructor()->getMock(); - $scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config') + $scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->setMethods(['isSetFlag'])->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->any()) @@ -63,7 +63,7 @@ protected function setUp() public function testInstanceOf() { - $this->assertInstanceOf('Magento\Framework\View\Element\Js\Cookie', $this->model); + $this->assertInstanceOf(\Magento\Framework\View\Element\Js\Cookie::class, $this->model); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationMediatorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationMediatorTest.php index 7411d3aaef64a..faafd76ef6e60 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationMediatorTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationMediatorTest.php @@ -29,12 +29,12 @@ class InterpretationMediatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->interpretationStrategy = $this->getMockBuilder( - 'Magento\Framework\View\Element\Message\InterpretationStrategy' + \Magento\Framework\View\Element\Message\InterpretationStrategy::class ) ->disableOriginalConstructor() ->getMock(); $this->messageMock = $this->getMock( - 'Magento\Framework\Message\MessageInterface' + \Magento\Framework\Message\MessageInterface::class ); $this->interpretationMediator = new InterpretationMediator( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationStrategyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationStrategyTest.php index bff282ff71938..8cd8ffd0e787b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationStrategyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/InterpretationStrategyTest.php @@ -41,20 +41,20 @@ class InterpretationStrategyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->renderersPool = $this->getMockBuilder( - 'Magento\Framework\View\Element\Message\Renderer\RenderersPool' + \Magento\Framework\View\Element\Message\Renderer\RenderersPool::class ) ->disableOriginalConstructor() ->getMock(); $this->messageConfigurationsPool = $this->getMockBuilder( - 'Magento\Framework\View\Element\Message\MessageConfigurationsPool' + \Magento\Framework\View\Element\Message\MessageConfigurationsPool::class ) ->disableOriginalConstructor() ->getMock(); $this->messageMock = $this->getMock( - 'Magento\Framework\Message\MessageInterface' + \Magento\Framework\Message\MessageInterface::class ); $this->renderer = $this->getMock( - 'Magento\Framework\View\Element\Message\Renderer\RendererInterface' + \Magento\Framework\View\Element\Message\Renderer\RendererInterface::class ); $this->interpretationStrategy = new InterpretationStrategy( @@ -75,7 +75,7 @@ public function testInterpret() $renderedMessage = 'Script'; $renderer = $this->getMock( - 'Magento\Framework\View\Element\Message\Renderer\RendererInterface' + \Magento\Framework\View\Element\Message\Renderer\RendererInterface::class ); $this->messageMock->expects(static::once()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRenderer/TemplateTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRenderer/TemplateTest.php index fc7a5990b872e..1600e8ed3424a 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRenderer/TemplateTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRenderer/TemplateTest.php @@ -13,15 +13,15 @@ class TemplateTest extends \PHPUnit_Framework_TestCase public function testGetCacheKeyInfo() { $helper = new ObjectManager($this); - $storeMock = $this->getMock('Magento\Store\Api\Data\StoreInterface'); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects(static::once()) ->method('getStore') ->willReturn($storeMock); /** @var Template $template */ $template = $helper->getObject( - 'Magento\Framework\View\Element\Message\Renderer\BlockRenderer\Template', + \Magento\Framework\View\Element\Message\Renderer\BlockRenderer\Template::class, [ 'storeManager' => $storeManager ] diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php index 4cc19720504ee..ba89ef5b64685 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php @@ -24,7 +24,7 @@ class BlockRendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->blockTemplate = $this->getMockBuilder( - 'Magento\Framework\View\Element\Message\Renderer\BlockRenderer\Template' + \Magento\Framework\View\Element\Message\Renderer\BlockRenderer\Template::class ) ->disableOriginalConstructor() ->getMock(); @@ -35,7 +35,7 @@ protected function setUp() public function testRender() { /** @var MessageInterface | \PHPUnit_Framework_MockObject_MockObject $message */ - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $messageData = [ 'painting' => 'The Last Supper', 'apostles_cnt' => 28, @@ -77,7 +77,7 @@ public function testRender() public function testRenderNoTemplate() { /** @var MessageInterface | \PHPUnit_Framework_MockObject_MockObject $message */ - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $messageData = [ 'who' => 'Brian', 'is' => 'a Very Naughty Boy' diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/EscapeRendererTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/EscapeRendererTest.php index 23578ac662bc9..c15426422d899 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/EscapeRendererTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/EscapeRendererTest.php @@ -18,12 +18,12 @@ public function testInterpret() /** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaper */ $escaper = $this->getMockBuilder( - 'Magento\Framework\Escaper' + \Magento\Framework\Escaper::class ) ->disableOriginalConstructor() ->getMock(); /** @var MessageInterface | \PHPUnit_Framework_MockObject_MockObject $message */ - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $message->expects(static::once()) ->method('getText') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/RenderersPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/RenderersPoolTest.php index ba98ca8df4d4f..b7007225738f3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/RenderersPoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/RenderersPoolTest.php @@ -13,13 +13,13 @@ public function testGetRenderer() { $renderers = [ 'renderer_1' => $this->getMock( - 'Magento\Framework\View\Element\Message\Renderer\RendererInterface' + \Magento\Framework\View\Element\Message\Renderer\RendererInterface::class ), 'renderer_2' => $this->getMock( - 'Magento\Framework\View\Element\Message\Renderer\RendererInterface' + \Magento\Framework\View\Element\Message\Renderer\RendererInterface::class ), 'renderer_3' => $this->getMock( - 'Magento\Framework\View\Element\Message\Renderer\RendererInterface' + \Magento\Framework\View\Element\Message\Renderer\RendererInterface::class ) ]; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php index c899bc91067ef..086c491d65287 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/MessagesTest.php @@ -40,24 +40,27 @@ class MessagesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->collectionFactory = $this->getMockBuilder('Magento\Framework\Message\CollectionFactory') + $this->collectionFactory = $this->getMockBuilder(\Magento\Framework\Message\CollectionFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->messageFactory = $this->getMockBuilder('Magento\Framework\Message\Factory') + $this->messageFactory = $this->getMockBuilder(\Magento\Framework\Message\Factory::class) ->disableOriginalConstructor() ->getMock(); $this->messageInterpretationStrategy = $this->getMock( - 'Magento\Framework\View\Element\Message\InterpretationStrategyInterface' + \Magento\Framework\View\Element\Message\InterpretationStrategyInterface::class ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messages = $objectManager->getObject('Magento\Framework\View\Element\Messages', [ - 'collectionFactory' => $this->collectionFactory, - 'messageFactory' => $this->messageFactory, - 'interpretationStrategy' => $this->messageInterpretationStrategy - ]); + $this->messages = $objectManager->getObject( + \Magento\Framework\View\Element\Messages::class, + [ + 'collectionFactory' => $this->collectionFactory, + 'messageFactory' => $this->messageFactory, + 'interpretationStrategy' => $this->messageInterpretationStrategy + ] + ); } /** @@ -65,7 +68,7 @@ protected function setUp() */ protected function initMessageCollection() { - $collection = $this->getMockBuilder('Magento\Framework\Message\Collection') + $collection = $this->getMockBuilder(\Magento\Framework\Message\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -77,7 +80,7 @@ protected function initMessageCollection() public function testSetMessages() { - $collection = $this->getMockBuilder('Magento\Framework\Message\Collection') + $collection = $this->getMockBuilder(\Magento\Framework\Message\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -96,8 +99,8 @@ public function testGetMessageCollection() public function testAddMessages() { - $messageOne = $this->getMock('Magento\Framework\Message\MessageInterface'); - $messageTwo = $this->getMock('Magento\Framework\Message\MessageInterface'); + $messageOne = $this->getMock(\Magento\Framework\Message\MessageInterface::class); + $messageTwo = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $arrayMessages = [$messageOne, $messageTwo]; @@ -110,7 +113,7 @@ public function testAddMessages() ->method('addMessage') ->with($messageTwo); - $collectionForAdd = $this->getMockBuilder('Magento\Framework\Message\Collection') + $collectionForAdd = $this->getMockBuilder(\Magento\Framework\Message\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -123,7 +126,7 @@ public function testAddMessages() public function testAddMessage() { - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $collection = $this->initMessageCollection(); @@ -138,7 +141,7 @@ public function testAddError() { $messageText = 'Some message error text'; - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $this->messageFactory->expects($this->once()) ->method('create') @@ -157,7 +160,7 @@ public function testAddWarning() { $messageText = 'Some message warning text'; - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $this->messageFactory->expects($this->once()) ->method('create') @@ -176,7 +179,7 @@ public function testAddNotice() { $messageText = 'Some message notice text'; - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $this->messageFactory->expects($this->once()) ->method('create') @@ -195,7 +198,7 @@ public function testAddSuccess() { $messageText = 'Some message success text'; - $message = $this->getMock('Magento\Framework\Message\MessageInterface'); + $message = $this->getMock(\Magento\Framework\Message\MessageInterface::class); $this->messageFactory->expects($this->once()) ->method('create') @@ -213,7 +216,7 @@ public function testAddSuccess() public function testGetMessagesByType() { $messageType = MessageInterface::TYPE_SUCCESS; - $resultMessages = [$this->getMock('Magento\Framework\Message\MessageInterface')]; + $resultMessages = [$this->getMock(\Magento\Framework\Message\MessageInterface::class)]; $collection = $this->initMessageCollection(); $collection->expects($this->once()) @@ -282,13 +285,13 @@ public function testGetGroupedHtml() $resultHtml .= ''; $resultHtml .= ''; - $errorMock = $this->getMockBuilder('Magento\Framework\Message\MessageInterface') + $errorMock = $this->getMockBuilder(\Magento\Framework\Message\MessageInterface::class) ->getMockForAbstractClass(); - $warningMock = $this->getMockBuilder('Magento\Framework\Message\MessageInterface') + $warningMock = $this->getMockBuilder(\Magento\Framework\Message\MessageInterface::class) ->getMockForAbstractClass(); - $noticeMock = $this->getMockBuilder('Magento\Framework\Message\MessageInterface') + $noticeMock = $this->getMockBuilder(\Magento\Framework\Message\MessageInterface::class) ->getMockForAbstractClass(); - $successMock = $this->getMockBuilder('Magento\Framework\Message\MessageInterface') + $successMock = $this->getMockBuilder(\Magento\Framework\Message\MessageInterface::class) ->getMockForAbstractClass(); $this->messageInterpretationStrategy->expects(static::any()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/RendererListTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/RendererListTest.php index 08384c9592338..62b40c3017d2f 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/RendererListTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/RendererListTest.php @@ -31,18 +31,18 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $this->blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->setMethods(['setRenderedBlock', 'getTemplate', 'setTemplate'])->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->setMethods(['getBlock', 'getChildName'])->disableOriginalConstructor()->getMockForAbstractClass(); $this->layoutMock->expects($this->any()) ->method('getBlock') ->will($this->returnValue($this->blockMock)); - $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Context::class) ->setMethods(['getLayout'])->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->any()) @@ -50,7 +50,7 @@ protected function setUp() ->will($this->returnValue($this->layoutMock)); $this->renderList = $objectManagerHelper->getObject( - 'Magento\Framework\View\Element\RendererList', + \Magento\Framework\View\Element\RendererList::class, ['context' => $this->contextMock] ); } @@ -75,12 +75,12 @@ public function testGetRenderer() /** During the first call cache will be generated */ $this->assertInstanceOf( - '\Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, $this->renderList->getRenderer('type', null, null) ); /** Cached value should be returned during second call */ $this->assertInstanceOf( - '\Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, $this->renderList->getRenderer('type', null, 'renderer_template') ); } @@ -91,7 +91,7 @@ public function testGetRenderer() public function testGetRendererWithException() { $this->assertInstanceOf( - '\Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, $this->renderList->getRenderer(null) ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ResolverTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ResolverTest.php index 320f5bc04d849..491f6d6d4378e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ResolverTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ResolverTest.php @@ -32,7 +32,7 @@ class ResolverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_viewFileSystemMock = $this->getMock('\Magento\Framework\View\FileSystem', [], [], '', false); + $this->_viewFileSystemMock = $this->getMock(\Magento\Framework\View\FileSystem::class, [], [], '', false); $this->_resolver = new \Magento\Framework\View\Element\Template\File\Resolver( $this->_viewFileSystemMock ); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ValidatorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ValidatorTest.php index c66ee1ceba1d9..f9333918afbbc 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ValidatorTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Template/File/ValidatorTest.php @@ -62,10 +62,10 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_fileSystemMock = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); - $this->_scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); - $this->rootDirectoryMock = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->compiledDirectoryMock = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $this->_fileSystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->rootDirectoryMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); + $this->compiledDirectoryMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->_fileSystemMock->expects($this->any()) ->method('getDirectoryRead') @@ -80,7 +80,13 @@ protected function setUp() ->method('getAbsolutePath') ->will($this->returnValue('/magento/var/compiled')); - $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); + $this->componentRegistrar = $this->getMock( + \Magento\Framework\Component\ComponentRegistrar::class, + [], + [], + '', + false + ); $this->componentRegistrar->expects($this->any()) ->method('getPaths') ->will( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php index b21449a99d264..b98890fe7261d 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php @@ -8,6 +8,9 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem\DriverPool; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class TemplateTest extends \PHPUnit_Framework_TestCase { /** @@ -48,7 +51,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->resolver = $this->getMock( - 'Magento\Framework\View\Element\Template\File\Resolver', + \Magento\Framework\View\Element\Template\File\Resolver::class, [], [], '', @@ -56,39 +59,39 @@ protected function setUp() ); $this->validator = $this->getMock( - 'Magento\Framework\View\Element\Template\File\Validator', + \Magento\Framework\View\Element\Template\File\Validator::class, [], [], '', false ); - $this->rootDirMock = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $this->rootDirMock = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $this->rootDirMock->expects($this->any()) ->method('getRelativePath') ->willReturnArgument(0); - $this->filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->filesystem->expects($this->any()) ->method('getDirectoryRead') ->with(DirectoryList::ROOT, DriverPool::FILE) ->willReturn($this->rootDirMock); $this->templateEngine = $this->getMock( - 'Magento\Framework\View\TemplateEnginePool', + \Magento\Framework\View\TemplateEnginePool::class, ['render', 'get'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->templateEngine->expects($this->any())->method('get')->willReturn($this->templateEngine); - $appState = $this->getMock('Magento\Framework\App\State', ['getAreaCode'], [], '', false); + $appState = $this->getMock(\Magento\Framework\App\State::class, ['getAreaCode'], [], '', false); $appState->expects($this->any())->method('getAreaCode')->willReturn('frontend'); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $helper->getObject( - 'Magento\Framework\View\Element\Template', + \Magento\Framework\View\Element\Template::class, [ 'filesystem' => $this->filesystem, 'enginePool' => $this->templateEngine, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php index 2434eddb2adaa..3b491c90bb772 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php @@ -21,7 +21,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->item = $objectManager->getObject('Magento\Framework\View\Element\Text\TextList\Item'); + $this->item = $objectManager->getObject(\Magento\Framework\View\Element\Text\TextList\Item::class); } public function testSetLink() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php index 108a4e62b9ae8..3f6a165c9c1ea 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php @@ -21,7 +21,7 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->link = $objectManager->getObject('Magento\Framework\View\Element\Text\TextList\Link'); + $this->link = $objectManager->getObject(\Magento\Framework\View\Element\Text\TextList\Link::class); } public function testSetLink() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/TextTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/TextTest.php index 6da7b2b5c0575..d8b2fb48a0b80 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/TextTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/TextTest.php @@ -15,12 +15,12 @@ class TextTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->elementText = $objectManagerHelper->getObject('Magento\Framework\View\Element\Text'); + $this->elementText = $objectManagerHelper->getObject(\Magento\Framework\View\Element\Text::class); } public function testSetText() { - $this->assertInstanceOf('Magento\Framework\View\Element\Text', $this->elementText->setText('example')); + $this->assertInstanceOf(\Magento\Framework\View\Element\Text::class, $this->elementText->setText('example')); } public function testGetText() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ContextTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ContextTest.php index f74004a4ea456..9c0056861a837 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ContextTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ContextTest.php @@ -21,32 +21,32 @@ class ContextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $pageLayout = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')->getMock(); - $request = $this->getMockBuilder('\Magento\Framework\App\Request\Http') + $pageLayout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class)->getMock(); + $request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $buttonProviderFactory = - $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Control\ButtonProviderFactory') + $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Control\ButtonProviderFactory::class) ->disableOriginalConstructor() ->getMock(); $actionPoolFactory = - $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Control\ActionPoolFactory') + $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Control\ActionPoolFactory::class) ->disableOriginalConstructor() ->getMock(); $contentTypeFactory = - $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContentType\ContentTypeFactory') + $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContentType\ContentTypeFactory::class) ->disableOriginalConstructor() ->getMock(); - $urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMock(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor')->getMock(); + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)->getMock(); + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class)->getMock(); $uiComponentFactory = - $this->getMockBuilder('Magento\Framework\View\Element\UiComponentFactory') + $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentFactory::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->context = $objectManagerHelper->getObject( - 'Magento\Framework\View\Element\UiComponent\Context', + \Magento\Framework\View\Element\UiComponent\Context::class, [ 'pageLayout' => $pageLayout, 'request' => $request, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php index 930163d8ea2ff..6ef4e659de073 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php @@ -32,9 +32,9 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + $this->component = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentInterface::class) ->getMockForAbstractClass(); - $this->observer = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ObserverInterface') + $this->observer = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ObserverInterface::class) ->getMockForAbstractClass(); $this->processor = new Processor(); } @@ -56,7 +56,7 @@ public function testAttachAndNotify() ->method('update') ->with($this->component); /** @var UiComponentInterface $component2 */ - $component2 = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + $component2 = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentInterface::class) ->getMockForAbstractClass(); $component2->expects($this->any()) ->method('getComponentName') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/BaseTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/BaseTest.php index 3e676a770ccb8..25b3bededf04d 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/BaseTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/BaseTest.php @@ -32,14 +32,14 @@ class BaseTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory') + $this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\View\File\Factory::class) ->disableOriginalConstructor() ->getMock(); - $this->themeMock = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface') + $this->themeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class) ->setMethods(['getData']) ->getMockForAbstractClass(); - $this->dirSearch = $this->getMock('Magento\Framework\Component\DirSearch', [], [], '', false); + $this->dirSearch = $this->getMock(\Magento\Framework\Component\DirSearch::class, [], [], '', false); $this->fileCollector = new \Magento\Framework\View\File\Collector\Base( $this->dirSearch, @@ -53,7 +53,7 @@ public function testGetFiles() $files = []; foreach (['shared', 'theme'] as $fileType) { for ($i = 0; $i < 2; $i++) { - $file = $this->getMock('\Magento\Framework\Component\ComponentFile', [], [], '', false); + $file = $this->getMock(\Magento\Framework\Component\ComponentFile::class, [], [], '', false); $file->expects($this->once()) ->method('getFullPath') ->will($this->returnValue("{$fileType}/module/{$i}/path")); @@ -82,10 +82,10 @@ public function testGetFiles() $result = $this->fileCollector->getFiles($this->themeMock, '*.xml'); $this->assertCount(4, $result); - $this->assertInstanceOf('Magento\Framework\View\File', $result[0]); - $this->assertInstanceOf('Magento\Framework\View\File', $result[1]); - $this->assertInstanceOf('Magento\Framework\View\File', $result[2]); - $this->assertInstanceOf('Magento\Framework\View\File', $result[3]); + $this->assertInstanceOf(\Magento\Framework\View\File::class, $result[0]); + $this->assertInstanceOf(\Magento\Framework\View\File::class, $result[1]); + $this->assertInstanceOf(\Magento\Framework\View\File::class, $result[2]); + $this->assertInstanceOf(\Magento\Framework\View\File::class, $result[3]); } /** @@ -95,7 +95,7 @@ public function testGetFiles() */ protected function createFileMock() { - return $this->getMockBuilder('Magento\Framework\View\File') + return $this->getMockBuilder(\Magento\Framework\View\File::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php index d74e6f28bb682..38e585cce7928 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php @@ -27,8 +27,8 @@ class ModuleDependencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileSource = $this->getMockForAbstractClass('Magento\Framework\View\File\CollectorInterface'); - $this->_moduleListMock = $this->getMock('Magento\Framework\Module\ModuleListInterface'); + $this->_fileSource = $this->getMockForAbstractClass(\Magento\Framework\View\File\CollectorInterface::class); + $this->_moduleListMock = $this->getMock(\Magento\Framework\Module\ModuleListInterface::class); $this->_moduleListMock->expects($this->any()) ->method('getNames') ->will($this->returnValue(['Fixture_ModuleB', 'Fixture_ModuleA'])); @@ -45,7 +45,7 @@ protected function setUp() */ public function testGetFiles(array $fixtureFiles, array $expectedFiles, $message) { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->_fileSource ->expects($this->once()) ->method('getFiles') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleOutputTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleOutputTest.php index 19a5e5545b757..83be2ee7ac10e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleOutputTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleOutputTest.php @@ -27,8 +27,8 @@ class ModuleOutputTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileSource = $this->getMockForAbstractClass('Magento\Framework\View\File\CollectorInterface'); - $this->_moduleManager = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); + $this->_fileSource = $this->getMockForAbstractClass(\Magento\Framework\View\File\CollectorInterface::class); + $this->_moduleManager = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); $this->_moduleManager ->expects($this->any()) ->method('isOutputEnabled') @@ -43,7 +43,7 @@ protected function setUp() public function testGetFiles() { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $fileOne = new \Magento\Framework\View\File('1.xml', 'Module_OutputEnabled'); $fileTwo = new \Magento\Framework\View\File('2.xml', 'Module_OutputDisabled'); $fileThree = new \Magento\Framework\View\File('3.xml', 'Module_OutputEnabled', $theme); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/BaseTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/BaseTest.php index 44c2850b1125c..97608caa26069 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/BaseTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/BaseTest.php @@ -45,22 +45,28 @@ class BaseTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->themeDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Read', + \Magento\Framework\Filesystem\Directory\Read::class, ['getAbsolutePath', 'search'], [], '', false ); - $this->pathPatternHelperMock = $this->getMockBuilder('Magento\Framework\View\Helper\PathPattern') + $this->pathPatternHelperMock = $this->getMockBuilder(\Magento\Framework\View\Helper\PathPattern::class) ->disableOriginalConstructor() ->getMock(); - $this->fileFactory = $this->getMock('Magento\Framework\View\File\Factory', [], [], '', false); - $this->readDirFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->fileFactory = $this->getMock(\Magento\Framework\View\File\Factory::class, [], [], '', false); + $this->readDirFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); $this->readDirFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->themeDirectory)); $this->componentRegistrar = $this->getMockForAbstractClass( - 'Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->model = new \Magento\Framework\View\File\Collector\Override\Base( $this->fileFactory, @@ -76,7 +82,7 @@ public function testGetFilesWrongTheme() $this->componentRegistrar->expects($this->once()) ->method('getPath') ->will($this->returnValue('')); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once()) ->method('getFullPath') ->will($this->returnValue('area/Vendor/theme')); @@ -93,7 +99,7 @@ public function testGetFilesWrongTheme() public function testGetFiles($files, $filePath, $pathPattern) { $themePath = 'area/theme/path'; - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once())->method('getFullPath')->willReturn($themePath); $handlePath = 'design/area/theme/path/%s/override/%s'; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php index 979698a79f902..9b80652d8c8e3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php @@ -41,21 +41,27 @@ class ThemeModularTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->themeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $this->themeDirectory = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $this->themeDirectory->expects($this->any()) ->method('getAbsolutePath') ->willReturnArgument(0); - $this->pathPatternHelperMock = $this->getMockBuilder('Magento\Framework\View\Helper\PathPattern') + $this->pathPatternHelperMock = $this->getMockBuilder(\Magento\Framework\View\Helper\PathPattern::class) ->disableOriginalConstructor() ->getMock(); - $this->fileFactory = $this->getMock('Magento\Framework\View\File\Factory', [], [], '', false); - $this->readDirFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->fileFactory = $this->getMock(\Magento\Framework\View\File\Factory::class, [], [], '', false); + $this->readDirFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); $this->readDirFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->themeDirectory)); $this->componentRegistrar = $this->getMockForAbstractClass( - 'Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->model = new \Magento\Framework\View\File\Collector\Override\ThemeModular( $this->fileFactory, @@ -71,7 +77,7 @@ public function testGetFilesWrongTheme() $this->componentRegistrar->expects($this->once()) ->method('getPath') ->will($this->returnValue('')); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once()) ->method('getFullPath') ->will($this->returnValue('area/Vendor/theme')); @@ -82,14 +88,14 @@ public function testGetFiles() { $themePath = 'area/theme_path'; $inputPath = '*.xml'; - $grandparentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $grandparentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $grandparentTheme->expects($this->once())->method('getCode')->willReturn('vendor/grand_parent_theme'); - $parentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $parentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $parentTheme->expects($this->once())->method('getCode')->willReturn('vendor/parent_theme'); $parentTheme->expects($this->once())->method('getParentTheme')->willReturn($grandparentTheme); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once())->method('getFullPath')->willReturn($themePath); $theme->expects($this->once())->method('getParentTheme')->willReturn($parentTheme); @@ -104,8 +110,8 @@ public function testGetFiles() ->with($inputPath) ->willReturn('[^/]*\\.xml'); - $fileOne = $this->getMock('Magento\Framework\View\File', [], [], '', false); - $fileTwo = $this->getMock('Magento\Framework\View\File', [], [], '', false); + $fileOne = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); + $fileTwo = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); $this->fileFactory ->expects($this->exactly(2)) ->method('create') @@ -127,14 +133,14 @@ public function testGetFilesWithPreset() { $themePath = 'area/theme_path'; $inputPath = 'preset/3.xml'; - $grandparentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $grandparentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $grandparentTheme->expects($this->once())->method('getCode')->willReturn('vendor/grand_parent_theme'); - $parentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $parentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $parentTheme->expects($this->once())->method('getCode')->willReturn('vendor/parent_theme'); $parentTheme->expects($this->once())->method('getParentTheme')->willReturn($grandparentTheme); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once())->method('getFullPath')->willReturn($themePath); $theme->expects($this->once())->method('getParentTheme')->willReturn($parentTheme); @@ -144,7 +150,7 @@ public function testGetFilesWithPreset() ->with('*_*/override/theme/*/*/preset/3.xml') ->willReturn([$filePathOne]); - $fileOne = $this->getMock('Magento\Framework\View\File', [], [], '', false); + $fileOne = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); $this->fileFactory ->expects($this->once()) ->method('create') @@ -169,9 +175,9 @@ public function testGetFilesWrongAncestor() $filePath = 'design/area/theme_path/Module_One/override/theme/vendor/parent_theme/1.xml'; $expectedMessage = "Trying to override modular view file '$filePath' for theme 'vendor/parent_theme'" . ", which is not ancestor of theme 'vendor/theme_path'"; - $this->setExpectedException('Magento\Framework\Exception\LocalizedException', $expectedMessage); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class, $expectedMessage); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once())->method('getFullPath')->willReturn($themePath); $theme->expects($this->once())->method('getParentTheme')->willReturn(null); $theme->expects($this->once())->method('getCode')->willReturn('vendor/theme_path'); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeModularTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeModularTest.php index 87a7e00dcaee2..5175eaee18a52 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeModularTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeModularTest.php @@ -45,22 +45,28 @@ class ThemeModularTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->themeDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Read', + \Magento\Framework\Filesystem\Directory\Read::class, ['getAbsolutePath', 'search'], [], '', false ); - $this->pathPatternHelperMock = $this->getMockBuilder('Magento\Framework\View\Helper\PathPattern') + $this->pathPatternHelperMock = $this->getMockBuilder(\Magento\Framework\View\Helper\PathPattern::class) ->disableOriginalConstructor() ->getMock(); - $this->fileFactory = $this->getMock('Magento\Framework\View\File\Factory', [], [], '', false); - $this->readDirFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->fileFactory = $this->getMock(\Magento\Framework\View\File\Factory::class, [], [], '', false); + $this->readDirFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); $this->readDirFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->themeDirectory)); $this->componentRegistrar = $this->getMockForAbstractClass( - 'Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->model = new \Magento\Framework\View\File\Collector\ThemeModular( $this->fileFactory, @@ -76,7 +82,7 @@ public function testGetFilesWrongTheme() $this->componentRegistrar->expects($this->once()) ->method('getPath') ->will($this->returnValue('')); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once()) ->method('getFullPath') ->will($this->returnValue('area/Vendor/theme')); @@ -92,7 +98,7 @@ public function testGetFilesWrongTheme() */ public function testGetFiles($files, $filePath, $pathPattern) { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $themePath = 'area/theme/path'; $theme->expects($this->once())->method('getFullPath')->willReturn($themePath); @@ -120,7 +126,7 @@ public function testGetFiles($files, $filePath, $pathPattern) $checkResult = []; foreach ($files as $key => $file) { $checkResult[$key] = new \Magento\Framework\View\File($file['handle'], $file['module'], $theme); - $checkResult[$key] = $this->getMock('Magento\Framework\View\File', [], [], '', false); + $checkResult[$key] = $this->getMock(\Magento\Framework\View\File::class, [], [], '', false); $this->fileFactory ->expects($this->at($key)) ->method('create') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeTest.php index 218ae10dc48f9..eff156b55b498 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/ThemeTest.php @@ -55,23 +55,29 @@ class ThemeTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->themeDirectoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $this->themeDirectoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->getMock(); - $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory') + $this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\View\File\Factory::class) ->disableOriginalConstructor() ->getMock(); - $this->themeMock = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface') + $this->themeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class) ->getMock(); $this->themeMock->expects($this->once()) ->method('getFullPath') ->will($this->returnValue($this->themePath)); - $this->readDirFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->readDirFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); $this->readDirFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->themeDirectoryMock)); $this->componentRegistrar = $this->getMockForAbstractClass( - 'Magento\Framework\Component\ComponentRegistrarInterface' + \Magento\Framework\Component\ComponentRegistrarInterface::class ); $this->themeFileCollector = new Theme( $this->fileFactoryMock, @@ -112,7 +118,7 @@ public function testGetFilesSingle() ->method('getPath') ->with(ComponentRegistrar::THEME, $this->themePath) ->will($this->returnValue(self::FULL_THEME_PATH)); - $fileMock = $this->getMockBuilder('Magento\Framework\View\File') + $fileMock = $this->getMockBuilder(\Magento\Framework\View\File::class) ->disableOriginalConstructor() ->getMock(); @@ -142,7 +148,7 @@ public function testGetFilesMultiple() ->method('getPath') ->with(ComponentRegistrar::THEME, $this->themePath) ->will($this->returnValue(self::FULL_THEME_PATH)); - $fileMock = $this->getMockBuilder('Magento\Framework\View\File') + $fileMock = $this->getMockBuilder(\Magento\Framework\View\File::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/FactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/FactoryTest.php index d8bba6b1e047b..5853e16f96dda 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/FactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/FactoryTest.php @@ -20,20 +20,20 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Framework\View\File\Factory($this->_objectManager); } public function testCreate() { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $file = new \Magento\Framework\View\File(__FILE__, 'Fixture_Module', $theme); $isBase = true; $this->_objectManager ->expects($this->once()) ->method('create') ->with( - 'Magento\Framework\View\File', + \Magento\Framework\View\File::class, $this->identicalTo([ 'filename' => __FILE__, 'module' => 'Fixture_Module', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/CollatorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/CollatorTest.php index 910c086b22968..1dd1a2b840383 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/CollatorTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/CollatorTest.php @@ -53,7 +53,7 @@ protected function _createViewFile($filename, $module, $themeFullPath = null) { $theme = null; if ($themeFullPath !== null) { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath)); } return new \Magento\Framework\View\File($filename, $module, $theme); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/FactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/FactoryTest.php index 0548e1786b113..79a6be6b59499 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/FactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/FileList/FactoryTest.php @@ -20,7 +20,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Framework\View\File\FileList\Factory($this->objectManager); } @@ -28,7 +28,7 @@ public function testCreate() { $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $collator = $helperObjectManager->getObject(\Magento\Framework\View\File\FileList\Factory::FILE_LIST_COLLATOR); - $list = $helperObjectManager->getObject('Magento\Framework\View\File\FileList'); + $list = $helperObjectManager->getObject(\Magento\Framework\View\File\FileList::class); $this->objectManager ->expects($this->once()) @@ -40,7 +40,7 @@ public function testCreate() ->expects($this->once()) ->method('create') ->with( - $this->equalTo('Magento\Framework\View\File\FileList'), + $this->equalTo(\Magento\Framework\View\File\FileList::class), $this->equalTo(['collator' => $collator]) ) ->will($this->returnValue($list)); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/FileListTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/FileListTest.php index 9940e2ea09584..7cf14156d5656 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/FileListTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/FileListTest.php @@ -34,7 +34,7 @@ protected function setUp() { $this->_baseFile = $this->_createViewFile('fixture.xml', 'Fixture_TestModule'); $this->_themeFile = $this->_createViewFile('fixture.xml', 'Fixture_TestModule', 'area/theme/path'); - $this->collator = $this->getMock('Magento\Framework\View\File\FileList\Collator', ['collate']); + $this->collator = $this->getMock(\Magento\Framework\View\File\FileList\Collator::class, ['collate']); $this->_model = new \Magento\Framework\View\File\FileList($this->collator); $this->_model->add([$this->_baseFile, $this->_themeFile]); } @@ -51,7 +51,7 @@ protected function _createViewFile($filename, $module, $themeFullPath = null) { $theme = null; if ($themeFullPath !== null) { - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath)); } return new \Magento\Framework\View\File($filename, $module, $theme); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/FileSystemTest.php b/lib/internal/Magento/Framework/View/Test/Unit/FileSystemTest.php index 331615b7b5f86..7ab094d7b3f3f 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/FileSystemTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/FileSystemTest.php @@ -50,22 +50,24 @@ class FileSystemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileResolution = $this->getMock('Magento\Framework\View\Design\FileResolution\Fallback\File', [], + $this->_fileResolution = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\File::class, [], [], '', false ); - $this->_templateFileResolution = $this->getMock( - 'Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile', [], [], '', false + $this->_templateFileResolution = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile::class, [], [], '', false ); - $this->_localeFileResolution = $this->getMock( - 'Magento\Framework\View\Design\FileResolution\Fallback\LocaleFile', [], [], '', false + $this->_localeFileResolution = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\LocaleFile::class, [], [], '', false ); - $this->_staticFileResolution = $this->getMock( - 'Magento\Framework\View\Design\FileResolution\Fallback\StaticFile', [], [], '', false + $this->_staticFileResolution = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile::class, [], [], '', false ); - $this->_emailTemplateFileResolution = $this->getMock( - 'Magento\Framework\View\Design\FileResolution\Fallback\EmailTemplateFile', [], [], '', false + $this->_emailTemplateFileResolution = $this->getMock( + \Magento\Framework\View\Design\FileResolution\Fallback\EmailTemplateFile::class, [], [], '', false ); - $this->_assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', + $this->_assetRepo = $this->getMock( + \Magento\Framework\View\Asset\Repository::class, ['extractScope', 'updateDesignParams', 'createAsset'], [], '', false ); @@ -83,8 +85,8 @@ public function testGetFilename() { $params = [ 'area' => 'some_area', - 'themeModel' => $this->getMock( - 'Magento\Framework\View\Design\ThemeInterface', [], [], '', false, false + 'themeModel' => $this->getMock( + \Magento\Framework\View\Design\ThemeInterface::class, [], [], '', false, false ), 'module' => 'Some_Module', //It should be set in \Magento\Framework\View\Asset\Repository::extractScope // but PHPUnit has troubles with passing arguments by reference @@ -110,8 +112,8 @@ public function testGetTemplateFileName() { $params = [ 'area' => 'some_area', - 'themeModel' => $this->getMock( - 'Magento\Framework\View\Design\ThemeInterface', [], [], '', false, false + 'themeModel' => $this->getMock( + \Magento\Framework\View\Design\ThemeInterface::class, [], [], '', false, false ), 'module' => 'Some_Module', //It should be set in \Magento\Framework\View\Asset\Repository::extractScope // but PHPUnit has troubles with passing arguments by reference @@ -137,8 +139,8 @@ public function testGetLocaleFileName() { $params = [ 'area' => 'some_area', - 'themeModel' => $this->getMock( - 'Magento\Framework\View\Design\ThemeInterface', + 'themeModel' => $this->getMock( + \Magento\Framework\View\Design\ThemeInterface::class, [], [], '', @@ -163,8 +165,8 @@ public function testGetViewFile() { $params = [ 'area' => 'some_area', - 'themeModel' => $this->getMock( - 'Magento\Framework\View\Design\ThemeInterface', + 'themeModel' => $this->getMock( + \Magento\Framework\View\Design\ThemeInterface::class, [], [], '', @@ -261,8 +263,8 @@ public function testGetEmailTemplateFile() $locale = \Magento\Setup\Module\I18n\Locale::DEFAULT_SYSTEM_LOCALE; $params = [ 'area' => 'some_area', - 'themeModel' => $this->getMock( - 'Magento\Framework\View\Design\ThemeInterface', [], [], '', false, false + 'themeModel' => $this->getMock( + \Magento\Framework\View\Design\ThemeInterface::class, [], [], '', false, false ), 'module' => 'Some_Module', 'locale' => $locale diff --git a/lib/internal/Magento/Framework/View/Test/Unit/FileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/FileTest.php index 2a0177aaaff91..890e1672435b9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/FileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/FileTest.php @@ -19,7 +19,7 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $this->_theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->_model = new \Magento\Framework\View\File(__FILE__, 'Fixture_TestModule', $this->_theme, true); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Helper/PathPatternTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Helper/PathPatternTest.php index c25062c443a73..e844351fc4244 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Helper/PathPatternTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Helper/PathPatternTest.php @@ -23,7 +23,7 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->pathPatternHelper = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Helper\PathPattern' + \Magento\Framework\View\Helper\PathPattern::class ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/Decorator/UpdaterTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/Decorator/UpdaterTest.php index 1ab3ff733d6e8..7457106f901b2 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/Decorator/UpdaterTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/Decorator/UpdaterTest.php @@ -26,8 +26,10 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->_interpreter = $this->getMockForAbstractClass('Magento\Framework\Data\Argument\InterpreterInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_interpreter = $this->getMockForAbstractClass( + \Magento\Framework\Data\Argument\InterpreterInterface::class + ); $this->_model = new Updater($this->_objectManager, $this->_interpreter); } @@ -35,7 +37,7 @@ public function testEvaluate() { $input = [ 'value' => 'some text', - 'updater' => ['Magento\Framework\View\Layout\Argument\UpdaterInterface'], + 'updater' => [\Magento\Framework\View\Layout\Argument\UpdaterInterface::class], ]; $evaluatedValue = 'some text (new)'; $updatedValue = 'some text (updated)'; @@ -50,7 +52,7 @@ public function testEvaluate() $this->returnValue($evaluatedValue) ); - $updater = $this->getMockForAbstractClass('Magento\Framework\View\Layout\Argument\UpdaterInterface'); + $updater = $this->getMockForAbstractClass(\Magento\Framework\View\Layout\Argument\UpdaterInterface::class); $updater->expects( $this->once() )->method( @@ -66,7 +68,7 @@ public function testEvaluate() )->method( 'get' )->with( - 'Magento\Framework\View\Layout\Argument\UpdaterInterface' + \Magento\Framework\View\Layout\Argument\UpdaterInterface::class )->will( $this->returnValue($updater) ); @@ -114,8 +116,8 @@ public function testEvaluateWrongUpdaterClass() $input = [ 'value' => 'some text', 'updater' => [ - 'Magento\Framework\View\Layout\Argument\UpdaterInterface', - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\View\Layout\Argument\UpdaterInterface::class, + \Magento\Framework\ObjectManagerInterface::class, ], ]; $self = $this; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php index a80f55c9a1514..3a9eca119e177 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php @@ -26,9 +26,9 @@ class HelperMethodTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_interpreter = $this->getMock( - 'Magento\Framework\View\Layout\Argument\Interpreter\NamedParams', + \Magento\Framework\View\Layout\Argument\Interpreter\NamedParams::class, [], [], '', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php index 50a6073adeff5..14ae6805d90d7 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php @@ -21,7 +21,9 @@ class NamedParamsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_interpreter = $this->getMockForAbstractClass('Magento\Framework\Data\Argument\InterpreterInterface'); + $this->_interpreter = $this->getMockForAbstractClass( + \Magento\Framework\Data\Argument\InterpreterInterface::class + ); $this->_model = new NamedParams($this->_interpreter); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php index 761c56f6d7747..a8f2374cc0ce1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php @@ -9,7 +9,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase { - const EXPECTED_CLASS = 'Magento\Framework\View\Test\Unit\Layout\Argument\Interpreter\ObjectTest'; + const EXPECTED_CLASS = \Magento\Framework\View\Test\Unit\Layout\Argument\Interpreter\ObjectTest::class; /** * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject @@ -28,7 +28,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new DataObject($this->_objectManager, self::EXPECTED_CLASS); } @@ -72,7 +72,7 @@ public function evaluateWrongClassDataProvider() return [ 'no class' => [[], '\InvalidArgumentException', 'Object class name is missing'], 'unexpected class' => [ - ['value' => 'Magento\Framework\ObjectManagerInterface'], + ['value' => \Magento\Framework\ObjectManagerInterface::class], '\UnexpectedValueException', 'Instance of ' . self::EXPECTED_CLASS . ' is expected', ] diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php index 41e49fea61db2..87bdef315a5c8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php @@ -26,13 +26,13 @@ class OptionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new Options($this->_objectManager); } public function testEvaluate() { - $modelClass = 'Magento\Framework\Data\OptionSourceInterface'; + $modelClass = \Magento\Framework\Data\OptionSourceInterface::class; $model = $this->getMockForAbstractClass($modelClass); $model->expects( $this->once() @@ -76,7 +76,7 @@ public function evaluateWrongModelDataProvider() return [ 'no model' => [[], '\InvalidArgumentException', 'Options source model class is missing'], 'wrong model class' => [ - ['model' => 'Magento\Framework\View\Test\Unit\Layout\Argument\Interpreter\OptionsTest'], + ['model' => \Magento\Framework\View\Test\Unit\Layout\Argument\Interpreter\OptionsTest::class], '\UnexpectedValueException', 'Instance of the options source model is expected', ] diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/UrlTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/UrlTest.php index 508d214e63ac2..2bfa538f5f1f1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/UrlTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/UrlTest.php @@ -26,9 +26,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_urlResolver = $this->getMock('Magento\Framework\UrlInterface'); + $this->_urlResolver = $this->getMock(\Magento\Framework\UrlInterface::class); $this->_interpreter = $this->getMock( - 'Magento\Framework\View\Layout\Argument\Interpreter\NamedParams', + \Magento\Framework\View\Layout\Argument\Interpreter\NamedParams::class, [], [], '', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php index cf7992a62a98e..6afd0ca712149 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php @@ -29,16 +29,16 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->buildFactory = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Layout\BuilderFactory', + \Magento\Framework\View\Layout\BuilderFactory::class, [ 'objectManager' => $this->objectManagerMock, 'typeMap' => [ [ 'type' => 'invalid_type', - 'class' => 'Magento\Framework\View\Layout\BuilderFactory', + 'class' => \Magento\Framework\View\Layout\BuilderFactory::class, ], ] ] @@ -53,7 +53,7 @@ protected function setUp() */ public function testCreate($type, $arguments, $layoutBuilderClass) { - $layoutBuilderMock = $this->getMockBuilder('Magento\Framework\View\Layout\Builder') + $layoutBuilderMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Builder::class) ->disableOriginalConstructor() ->getMock(); @@ -71,7 +71,7 @@ public function createDataProvider() 'layout_type' => [ 'type' => \Magento\Framework\View\Layout\BuilderFactory::TYPE_LAYOUT, 'arguments' => ['key' => 'val'], - 'layoutBuilderClass' => 'Magento\Framework\View\Layout\Builder', + 'layoutBuilderClass' => \Magento\Framework\View\Layout\Builder::class, ] ]; } @@ -89,7 +89,7 @@ public function testCreateInvalidData() */ public function testCreateWithNonBuilderClass() { - $wrongClass = $this->getMockBuilder('Magento\Framework\View\Layout\BuilderFactory') + $wrongClass = $this->getMockBuilder(\Magento\Framework\View\Layout\BuilderFactory::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderTest.php index 9ff96adaa6527..238326a8b4588 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderTest.php @@ -18,7 +18,7 @@ */ class BuilderTest extends \PHPUnit_Framework_TestCase { - const CLASS_NAME = 'Magento\Framework\View\Layout\Builder'; + const CLASS_NAME = \Magento\Framework\View\Layout\Builder::class; /** * @covers \Magento\Framework\View\Layout\Builder::build() @@ -28,16 +28,16 @@ public function testBuild() $fullActionName = 'route_controller_action'; /** @var Http|\PHPUnit_Framework_MockObject_MockObject */ - $request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $request->expects($this->exactly(3))->method('getFullActionName')->will($this->returnValue($fullActionName)); /** @var ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject $processor */ - $processor = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + $processor = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false); $processor->expects($this->once())->method('load'); /** @var Layout|\PHPUnit_Framework_MockObject_MockObject */ $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, $this->getLayoutMockMethods(), [], '', @@ -49,7 +49,7 @@ public function testBuild() $data = ['full_action_name' => $fullActionName, 'layout' => $layout]; /** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */ - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $eventManager->expects($this->at(0))->method('dispatch')->with('layout_load_before', $data); $eventManager->expects($this->at(1))->method('dispatch')->with('layout_generate_blocks_before', $data); $eventManager->expects($this->at(2))->method('dispatch')->with('layout_generate_blocks_after', $data); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php index a5f00f0824026..227535f94f601 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php @@ -35,12 +35,12 @@ class StructureTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->stateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->dataStructure = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Layout\Data\Structure', + \Magento\Framework\View\Layout\Data\Structure::class, [ 'logger' => $this->loggerMock, 'state' => $this->stateMock diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/File/Collector/AggregateTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/File/Collector/AggregateTest.php index d07c68802532f..eca2306b5b5c6 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/File/Collector/AggregateTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/File/Collector/AggregateTest.php @@ -39,17 +39,17 @@ class AggregateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileList = $this->getMock('Magento\Framework\View\File\FileList', [], [], '', false); - $this->_baseFiles = $this->getMockForAbstractClass('Magento\Framework\View\File\CollectorInterface'); - $this->_themeFiles = $this->getMockForAbstractClass('Magento\Framework\View\File\CollectorInterface'); + $this->_fileList = $this->getMock(\Magento\Framework\View\File\FileList::class, [], [], '', false); + $this->_baseFiles = $this->getMockForAbstractClass(\Magento\Framework\View\File\CollectorInterface::class); + $this->_themeFiles = $this->getMockForAbstractClass(\Magento\Framework\View\File\CollectorInterface::class); $this->_overridingBaseFiles = $this->getMockForAbstractClass( - 'Magento\Framework\View\File\CollectorInterface' + \Magento\Framework\View\File\CollectorInterface::class ); $this->_overridingThemeFiles = $this->getMockForAbstractClass( - 'Magento\Framework\View\File\CollectorInterface' + \Magento\Framework\View\File\CollectorInterface::class ); $fileListFactory = $this->getMock( - 'Magento\Framework\View\File\FileList\Factory', + \Magento\Framework\View\File\FileList\Factory::class, [], [], '', @@ -71,8 +71,8 @@ protected function setUp() */ public function testGetFiles() { - $parentTheme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); - $theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $parentTheme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); + $theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php index e60ed749e7c01..2dfe9f607dd32 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php @@ -7,6 +7,7 @@ /** * @covers \Magento\Framework\View\Layout\Generator\Block + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class BlockTest extends \PHPUnit_Framework_TestCase { @@ -46,7 +47,13 @@ public function testProcess( $argumentData = ['argument' => 'value']; $class = 'test_class'; - $scheduleStructure = $this->getMock('Magento\Framework\View\Layout\ScheduledStructure', [], [], '', false); + $scheduleStructure = $this->getMock( + \Magento\Framework\View\Layout\ScheduledStructure::class, + [], + [], + '', + false + ); $scheduleStructure->expects($this->once())->method('getElements')->will( $this->returnValue( [ @@ -90,18 +97,18 @@ public function testProcess( /** * @var \Magento\Framework\View\Layout\Reader\Context|\PHPUnit_Framework_MockObject_MockObject $readerContext */ - $readerContext = $this->getMock('Magento\Framework\View\Layout\Reader\Context', [], [], '', false); + $readerContext = $this->getMock(\Magento\Framework\View\Layout\Reader\Context::class, [], [], '', false); $readerContext->expects($this->once())->method('getScheduledStructure') ->will($this->returnValue($scheduleStructure)); - $layout = $this->getMock('Magento\Framework\View\LayoutInterface', [], [], '', false); + $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); /** * @var \Magento\Framework\View\Element\AbstractBlock|\PHPUnit_Framework_MockObject_MockObject $blockInstance */ // explicitly set mocked methods for successful expectation of magic methods $blockInstance = $this->getMock( - 'Magento\Framework\View\Element\AbstractBlock', + \Magento\Framework\View\Element\AbstractBlock::class, ['setType', 'setTemplate', 'setTtl', $methodName, 'setNameInLayout', 'addData', 'setLayout'], [], '', @@ -117,13 +124,13 @@ public function testProcess( $layout->expects($this->once())->method('setBlock')->with($elementName, $blockInstance); - $structure = $this->getMock('Magento\Framework\View\Layout\Data\Structure', [], [], '', false); + $structure = $this->getMock(\Magento\Framework\View\Layout\Data\Structure::class, [], [], '', false); $structure->expects($addToParentGroupCount)->method('addToParentGroup')->with($elementName, $testGroup); /** * @var \PHPUnit_Framework_MockObject_MockObject $generatorContext */ - $generatorContext = $this->getMock('Magento\Framework\View\Layout\Generator\Context', [], [], '', false); + $generatorContext = $this->getMock(\Magento\Framework\View\Layout\Generator\Context::class, [], [], '', false); $generatorContext->expects($this->once())->method('getLayout')->will($this->returnValue($layout)); $generatorContext->expects($this->once())->method('getStructure')->will($this->returnValue($structure)); @@ -131,7 +138,7 @@ public function testProcess( * @var \PHPUnit_Framework_MockObject_MockObject $argumentInterpreter */ $argumentInterpreter = $this->getMock( - 'Magento\Framework\Data\Argument\InterpreterInterface', + \Magento\Framework\Data\Argument\InterpreterInterface::class, [], [], '', @@ -149,29 +156,29 @@ public function testProcess( } /** @var \Magento\Framework\View\Element\BlockFactory|\PHPUnit_Framework_MockObject_MockObject $blockFactory */ - $blockFactory = $this->getMock('Magento\Framework\View\Element\BlockFactory', [], [], '', false); + $blockFactory = $this->getMock(\Magento\Framework\View\Element\BlockFactory::class, [], [], '', false); $blockFactory->expects($this->any()) ->method('createBlock') ->with($class, ['data' => $argumentData]) ->will($this->returnValue($blockInstance)); /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */ - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $eventManager->expects($this->once())->method('dispatch') ->with('core_layout_block_create_after', [$literal => $blockInstance]); - $scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); $scopeConfigMock->expects($this->once())->method('isSetFlag') ->with('config_path', 'scope', 'default')->willReturn($testIsFlag); - $scopeResolverMock = $this->getMock('Magento\Framework\App\ScopeResolverInterface', [], [], '', false); + $scopeResolverMock = $this->getMock(\Magento\Framework\App\ScopeResolverInterface::class, [], [], '', false); $scopeResolverMock->expects($this->once())->method('getScope') ->willReturn('default'); /** @var \Magento\Framework\View\Layout\Generator\Block $block */ $block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject( - 'Magento\Framework\View\Layout\Generator\Block', + \Magento\Framework\View\Layout\Generator\Block::class, [ 'argumentInterpreter' => $argumentInterpreter, 'blockFactory' => $blockFactory, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php index ecbeb99c8d0e9..5f637825abfa0 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php @@ -48,25 +48,27 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->scheduledStructureMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure') + $this->scheduledStructureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure::class) ->disableOriginalConstructor()->getMock(); - $this->structureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure') + $this->structureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Data\Structure::class) ->disableOriginalConstructor()->getMock(); - $this->generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $this->generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor()->getMock(); $this->generatorContextMock->expects($this->any()) ->method('getStructure') ->willReturn($this->structureMock); - $this->readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor()->getMock(); $this->readerContextMock->expects($this->any()) ->method('getScheduledStructure') ->willReturn($this->scheduledStructureMock); - $this->container = $this->objectManagerHelper->getObject('Magento\Framework\View\Layout\Generator\Container'); + $this->container = $this->objectManagerHelper->getObject( + \Magento\Framework\View\Layout\Generator\Container::class + ); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/UiComponentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/UiComponentTest.php index 3cefd5a5cc4d1..c774b82f9e3fa 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/UiComponentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/UiComponentTest.php @@ -12,6 +12,9 @@ use Magento\Framework\View\Layout\ScheduledStructure; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class UiComponentTest extends \PHPUnit_Framework_TestCase { /** @@ -57,21 +60,22 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->argumentInterpreterMock = $this->getMockBuilder('Magento\Framework\Data\Argument\InterpreterInterface') - ->disableOriginalConstructor()->getMockForAbstractClass(); - $this->uiComponentFactoryMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentFactory') + $this->argumentInterpreterMock = $this->getMockBuilder( + \Magento\Framework\Data\Argument\InterpreterInterface::class + )->disableOriginalConstructor()->getMockForAbstractClass(); + $this->uiComponentFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentFactory::class) ->disableOriginalConstructor()->getMock(); - $this->scheduledStructureMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure') + $this->scheduledStructureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure::class) ->disableOriginalConstructor()->getMock(); $this->contextFactoryMock = $this->getMock( - 'Magento\Framework\View\Element\UiComponent\ContextFactory', + \Magento\Framework\View\Element\UiComponent\ContextFactory::class, [], [], '', false ); $this->blockFactoryMock = $this->getMock( - 'Magento\Framework\View\Element\BlockFactory', + \Magento\Framework\View\Element\BlockFactory::class, [], [], '', @@ -79,7 +83,7 @@ protected function setUp() ); $this->uiComponent = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Layout\Generator\UiComponent', + \Magento\Framework\View\Layout\Generator\UiComponent::class, [ 'uiComponentFactory' => $this->uiComponentFactoryMock, 'blockFactory' => $this->blockFactoryMock, @@ -92,17 +96,17 @@ public function testProcess() { $this->prepareScheduledStructure(); - $this->readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor()->getMock(); $this->readerContextMock->expects($this->any()) ->method('getScheduledStructure') ->willReturn($this->scheduledStructureMock); - $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor()->getMock(); - $structureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure') + $structureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Data\Structure::class) ->disableOriginalConstructor()->getMock(); $structureMock->expects($this->once()) @@ -110,7 +114,7 @@ public function testProcess() ->with(UiComponent::TYPE, 'new_group') ->willReturnSelf(); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')->getMockForAbstractClass(); + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class)->getMockForAbstractClass(); $generatorContextMock->expects($this->any()) ->method('getStructure') @@ -125,7 +129,7 @@ public function testProcess() ->willReturnSelf(); $componentMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponentInterface', + \Magento\Framework\View\Element\UiComponentInterface::class, [], '', false, @@ -135,13 +139,13 @@ public function testProcess() ); $contextMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', + \Magento\Framework\View\Element\UiComponent\ContextInterface::class, [], '', false ); $blockMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, [], '', false diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php index 2eaba50b1ebd1..330b640812ca5 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php @@ -51,7 +51,7 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { // ScheduledStructure - $this->readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor() ->getMock(); $this->scheduledStructure = new ScheduledStructure(); @@ -59,23 +59,23 @@ protected function setUp() ->willReturn($this->scheduledStructure); // DataStructure - $this->generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $this->generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->structureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure') + $this->structureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Data\Structure::class) ->disableOriginalConstructor() ->setMethods(['reorderChildElement']) ->getMock(); $this->generatorContextMock->expects($this->any())->method('getStructure') ->willReturn($this->structureMock); - $this->helperMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure\Helper') + $this->helperMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure\Helper::class) ->disableOriginalConstructor() ->getMock(); $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $helperObjectManager->getObject( - 'Magento\Framework\View\Layout\GeneratorPool', + \Magento\Framework\View\Layout\GeneratorPool::class, [ 'helper' => $this->helperMock, 'generators' => $this->getGeneratorsMocks() @@ -88,11 +88,11 @@ protected function setUp() */ protected function getGeneratorsMocks() { - $firstGenerator = $this->getMock('Magento\Framework\View\Layout\GeneratorInterface'); + $firstGenerator = $this->getMock(\Magento\Framework\View\Layout\GeneratorInterface::class); $firstGenerator->expects($this->any())->method('getType')->willReturn('first_generator'); $firstGenerator->expects($this->atLeastOnce())->method('process'); - $secondGenerator = $this->getMock('Magento\Framework\View\Layout\GeneratorInterface'); + $secondGenerator = $this->getMock(\Magento\Framework\View\Layout\GeneratorInterface::class); $secondGenerator->expects($this->any())->method('getType')->willReturn('second_generator'); $secondGenerator->expects($this->atLeastOnce())->method('process'); return [$firstGenerator, $secondGenerator]; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php index 28de4f208641c..24bbd93918074 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php @@ -44,7 +44,7 @@ protected function getElement($xml, $elementType) . $xml . ''; - $xml = simplexml_load_string($xml, 'Magento\Framework\View\Layout\Element'); + $xml = simplexml_load_string($xml, \Magento\Framework\View\Layout\Element::class); return $xml->{$elementType}; } @@ -69,7 +69,7 @@ protected function prepareReaderPool($xml, $elementType) protected function getBlock(array $arguments) { return (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\View\Layout\Reader\Block', $arguments); + ->getObject(\Magento\Framework\View\Layout\Reader\Block::class, $arguments); } /** @@ -79,14 +79,14 @@ protected function getBlock(array $arguments) protected function setUp() { $this->scheduledStructure = $this->getMock( - 'Magento\Framework\View\Layout\ScheduledStructure', + \Magento\Framework\View\Layout\ScheduledStructure::class, [], [], '', false ); - $this->context = $this->getMock('Magento\Framework\View\Layout\Reader\Context', [], [], '', false); - $this->readerPool = $this->getMock('Magento\Framework\View\Layout\ReaderPool', [], [], '', false); + $this->context = $this->getMock(\Magento\Framework\View\Layout\Reader\Context::class, [], [], '', false); + $this->readerPool = $this->getMock(\Magento\Framework\View\Layout\ReaderPool::class, [], [], '', false); } /** @@ -140,7 +140,7 @@ public function testProcessBlock( ] ); - $helper = $this->getMock('Magento\Framework\View\Layout\ScheduledStructure\Helper', [], [], '', false); + $helper = $this->getMock(\Magento\Framework\View\Layout\ScheduledStructure\Helper::class, [], [], '', false); $helper->expects($scheduleStructureCount)->method('scheduleStructure')->will($this->returnValue($literal)); $this->prepareReaderPool( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php index 458b0eb78e113..4e10a5a6a0841 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php @@ -37,13 +37,13 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->helperMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure\Helper') + $this->helperMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure\Helper::class) ->disableOriginalConstructor()->getMock(); - $this->readerPoolMock = $this->getMockBuilder('Magento\Framework\View\Layout\ReaderPool') + $this->readerPoolMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ReaderPool::class) ->disableOriginalConstructor()->getMock(); $this->container = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Layout\Reader\Container', + \Magento\Framework\View\Layout\Reader\Container::class, [ 'helper' => $this->helperMock, 'readerPool' => $this->readerPoolMock @@ -72,7 +72,7 @@ public function testProcess( $setRemoveCondition ) { /** @var ScheduledStructure|\PHPUnit_Framework_MockObject_MockObject $scheduledStructureMock */ - $scheduledStructureMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure') + $scheduledStructureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure::class) ->disableOriginalConstructor()->getMock(); $scheduledStructureMock->expects($getStructureCondition) ->method('getStructureElementData') @@ -87,7 +87,7 @@ public function testProcess( ->with($containerName); /** @var \Magento\Framework\View\Layout\Reader\Context|\PHPUnit_Framework_MockObject_MockObject $contextMock */ - $contextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor()->getMock(); $contextMock->expects($this->any()) ->method('getScheduledStructure') @@ -233,7 +233,7 @@ protected function getElement($xml, $elementType) { $xml = simplexml_load_string( '' . $xml . '', - 'Magento\Framework\View\Layout\Element' + \Magento\Framework\View\Layout\Element::class ); return $xml->{$elementType}; } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php index b2ca8e3fca932..a91ac3b38709d 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php @@ -15,16 +15,16 @@ public function testCreateInvalidArgument() $className = 'class_name'; $data = ['data']; - $object = (new ObjectManager($this))->getObject('Magento\Framework\DataObject'); + $object = (new ObjectManager($this))->getObject(\Magento\Framework\DataObject::class); /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManager */ - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager->expects($this->once())->method('create')->with($className, $data) ->will($this->returnValue($object)); /** @var \Magento\Framework\View\Layout\ReaderFactory|\PHPUnit_Framework_MockObject_MockObject $factory */ $factory = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\View\Layout\ReaderFactory', ['objectManager' => $objectManager]); + ->getObject(\Magento\Framework\View\Layout\ReaderFactory::class, ['objectManager' => $objectManager]); $this->setExpectedException( '\InvalidArgumentException', @@ -39,16 +39,16 @@ public function testCreateValidArgument() $data = ['data']; /** @var \Magento\Framework\View\Layout\ReaderInterface|\PHPUnit_Framework_MockObject_MockObject $object */ - $object = $this->getMock('Magento\Framework\View\Layout\ReaderInterface', [], [], '', false); + $object = $this->getMock(\Magento\Framework\View\Layout\ReaderInterface::class, [], [], '', false); /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManager */ - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManager->expects($this->once())->method('create')->with($className, $data) ->will($this->returnValue($object)); /** @var \Magento\Framework\View\Layout\ReaderFactory|\PHPUnit_Framework_MockObject_MockObject $factory */ $factory = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\View\Layout\ReaderFactory', ['objectManager' => $objectManager]); + ->getObject(\Magento\Framework\View\Layout\ReaderFactory::class, ['objectManager' => $objectManager]); $this->assertSame($object, $factory->create($className, $data)); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/MoveTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/MoveTest.php index 8867856e0982c..34d8be322935b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/MoveTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/MoveTest.php @@ -37,16 +37,16 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->scheduledStructureMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure') + $this->scheduledStructureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure::class) ->disableOriginalConstructor()->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->any()) ->method('getScheduledStructure') ->willReturn($this->scheduledStructureMock); - $this->move = $this->objectManagerHelper->getObject('Magento\Framework\View\Layout\Reader\Move'); + $this->move = $this->objectManagerHelper->getObject(\Magento\Framework\View\Layout\Reader\Move::class); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php index 3c585307c1689..9560c04fe9c89 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php @@ -30,11 +30,11 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->helper = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure\Helper') + $this->helper = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure\Helper::class) ->setMethods(['scheduleStructure']) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->setMethods(['getScheduledStructure', 'setElementToIfconfigList']) ->disableOriginalConstructor() ->getMock(); @@ -55,7 +55,13 @@ public function testGetSupportedNodes() */ public function testInterpret($element) { - $scheduleStructure = $this->getMock('\Magento\Framework\View\Layout\ScheduledStructure', [], [], '', false); + $scheduleStructure = $this->getMock( + \Magento\Framework\View\Layout\ScheduledStructure::class, + [], + [], + '', + false + ); $this->context->expects($this->any())->method('getScheduledStructure')->will( $this->returnValue($scheduleStructure) ); @@ -98,7 +104,7 @@ protected function getElement($xml, $elementType) { $xml = simplexml_load_string( '' . $xml . '', - 'Magento\Framework\View\Layout\Element' + \Magento\Framework\View\Layout\Element::class ); return $xml->{$elementType}; } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ReaderPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ReaderPoolTest.php index f4029c99984ce..9dddead0e2af8 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ReaderPoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ReaderPoolTest.php @@ -22,14 +22,14 @@ class ReaderPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->readerFactoryMock = $this->getMockBuilder('Magento\Framework\View\Layout\ReaderFactory') + $this->readerFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ReaderFactory::class) ->disableOriginalConstructor()->getMock(); $this->pool = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Layout\ReaderPool', + \Magento\Framework\View\Layout\ReaderPool::class, [ 'readerFactory' => $this->readerFactoryMock, - 'readers' => ['move' => 'Magento\Framework\View\Layout\Reader\Move'] + 'readers' => ['move' => \Magento\Framework\View\Layout\Reader\Move::class] ] ); } @@ -37,7 +37,7 @@ protected function setUp() public function testInterpret() { /** @var Reader\Context $contextMock */ - $contextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor()->getMock(); $currentElement = new \Magento\Framework\View\Layout\Element( @@ -47,7 +47,7 @@ public function testInterpret() /** * @var \Magento\Framework\View\Layout\Reader\Move|\PHPUnit_Framework_MockObject_MockObject $moveReaderMock */ - $moveReaderMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Move') + $moveReaderMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Move::class) ->disableOriginalConstructor()->getMock(); $moveReaderMock->expects($this->exactly(2))->method('interpret') ->willReturn($this->returnSelf()); @@ -56,7 +56,7 @@ public function testInterpret() $this->readerFactoryMock->expects($this->once()) ->method('create') - ->willReturnMap([['Magento\Framework\View\Layout\Reader\Move', [], $moveReaderMock]]); + ->willReturnMap([[\Magento\Framework\View\Layout\Reader\Move::class, [], $moveReaderMock]]); $this->pool->interpret($contextMock, $currentElement); $this->pool->interpret($contextMock, $currentElement); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php index 6cb3a5cfdca83..f19d1b9c260b1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php @@ -45,18 +45,18 @@ class HelperTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->scheduledStructureMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure') + $this->scheduledStructureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ScheduledStructure::class) ->disableOriginalConstructor() ->getMock(); - $this->dataStructureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure') + $this->dataStructureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Data\Structure::class) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->stateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->helper = $helperObjectManager->getObject( - 'Magento\Framework\View\Layout\ScheduledStructure\Helper', + \Magento\Framework\View\Layout\ScheduledStructure\Helper::class, [ 'logger' => $this->loggerMock, 'state' => $this->stateMock diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructureTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructureTest.php index 371268adf5f34..d0a55ddd3eb62 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructureTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructureTest.php @@ -70,7 +70,7 @@ protected function setUp() $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $helperObjectManager->getObject( - 'Magento\Framework\View\Layout\ScheduledStructure', + \Magento\Framework\View\Layout\ScheduledStructure::class, ['data' => $this->scheduledData] ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/LayoutFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/LayoutFactoryTest.php index 17baba3417935..e6a0c0a14bd5e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/LayoutFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/LayoutFactoryTest.php @@ -21,11 +21,11 @@ class LayoutFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->layoutFactory = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\LayoutFactory', + \Magento\Framework\View\LayoutFactory::class, [ 'objectManager' => $this->objectManagerMock ] @@ -34,7 +34,7 @@ protected function setUp() public function testCreate() { - $instance = 'Magento\Framework\View\LayoutInterface'; + $instance = \Magento\Framework\View\LayoutInterface::class; $layoutMock = $this->getMock($instance, [], [], '', false); $data = ['some' => 'data']; $this->objectManagerMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php index 9104b70753a87..413b1e4cd1ac8 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php @@ -98,36 +98,36 @@ class LayoutTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->structureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure') + $this->structureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Data\Structure::class) ->disableOriginalConstructor() ->getMock(); $this->processorFactoryMock = $this->getMock( - 'Magento\Framework\View\Layout\ProcessorFactory', + \Magento\Framework\View\Layout\ProcessorFactory::class, ['create'], [], '', false ); $this->themeResolverMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Design\Theme\ResolverInterface' + \Magento\Framework\View\Design\Theme\ResolverInterface::class ); - $this->processorMock = $this->getMock('Magento\Framework\View\Model\Layout\Merge', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->generatorBlockMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Block') + $this->processorMock = $this->getMock(\Magento\Framework\View\Model\Layout\Merge::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->generatorBlockMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Block::class) ->disableOriginalConstructor()->getMock(); - $this->generatorContainerMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Container') + $this->generatorContainerMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Container::class) ->disableOriginalConstructor()->getMock(); - $this->cacheMock = $this->getMockBuilder('Magento\Framework\Cache\FrontendInterface') + $this->cacheMock = $this->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->readerPoolMock = $this->getMockBuilder('Magento\Framework\View\Layout\ReaderPool') + $this->readerPoolMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ReaderPool::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->generatorPoolMock = $this->getMockBuilder('Magento\Framework\View\Layout\GeneratorPool') + $this->generatorPoolMock = $this->getMockBuilder(\Magento\Framework\View\Layout\GeneratorPool::class) ->disableOriginalConstructor()->getMock(); $this->generatorPoolMock->expects($this->any()) ->method('getGenerator') @@ -138,21 +138,21 @@ protected function setUp() ]) ); - $this->readerContextFactoryMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\ContextFactory') - ->disableOriginalConstructor() - ->getMock(); - $this->readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->readerContextFactoryMock = $this->getMockBuilder( + \Magento\Framework\View\Layout\Reader\ContextFactory::class + )->disableOriginalConstructor()->getMock(); + $this->readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor() ->getMock(); $this->generatorContextFactoryMock = $this->getMockBuilder( - 'Magento\Framework\View\Layout\Generator\ContextFactory' + \Magento\Framework\View\Layout\Generator\ContextFactory::class ) ->disableOriginalConstructor() ->getMock(); - $this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); $this->model = new \Magento\Framework\View\Layout( @@ -174,7 +174,7 @@ protected function setUp() public function testCreateBlockSuccess() { - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->structureMock->expects($this->once()) @@ -182,18 +182,21 @@ public function testCreateBlockSuccess() ->with( 'blockname', \Magento\Framework\View\Layout\Element::TYPE_BLOCK, - 'Magento\Framework\View\Element\AbstractBlock' + \Magento\Framework\View\Element\AbstractBlock::class )->willReturn('blockname'); $this->generatorBlockMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock)); - $this->model->createBlock('Magento\Framework\View\Element\AbstractBlock', 'blockname', []); - $this->assertInstanceOf('Magento\Framework\View\Element\AbstractBlock', $this->model->getBlock('blockname')); + $this->model->createBlock(\Magento\Framework\View\Element\AbstractBlock::class, 'blockname', []); + $this->assertInstanceOf( + \Magento\Framework\View\Element\AbstractBlock::class, + $this->model->getBlock('blockname') + ); $this->assertFalse($this->model->getBlock('not_exist')); } public function testGetUpdate() { - $themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $themeMock = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->themeResolverMock->expects($this->once()) ->method('get') @@ -210,7 +213,7 @@ public function testGetUpdate() public function testGenerateXml() { - $themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $themeMock = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->themeResolverMock->expects($this->once()) ->method('get') @@ -223,7 +226,7 @@ public function testGenerateXml() $xmlString = '' . '123'; - $xml = simplexml_load_string($xmlString, 'Magento\Framework\View\Layout\Element'); + $xml = simplexml_load_string($xmlString, \Magento\Framework\View\Layout\Element::class); $this->processorMock->expects($this->once()) ->method('asSimplexml') ->will($this->returnValue($xml)); @@ -242,7 +245,7 @@ public function testGetChildBlock() $customBlockParentName = 'custom_block_parent'; $customBlockAlias = 'custom_block_alias'; - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\Template') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template::class) ->disableOriginalConstructor() ->getMock(); @@ -263,7 +266,7 @@ public function testGetChildBlock() $this->model->setBlock($customBlockName, $blockMock); $this->assertInstanceOf( - 'Magento\Framework\View\Element\AbstractBlock', + \Magento\Framework\View\Element\AbstractBlock::class, $this->model->getChildBlock($customBlockParentName, $customBlockAlias) ); } @@ -320,7 +323,7 @@ public function testGetChildBlocks() ->with($this->equalTo($parentName)) ->will($this->returnValue($childrenArray)); - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->structureMock->expects($this->once()) @@ -328,13 +331,13 @@ public function testGetChildBlocks() ->with( 'block_name', \Magento\Framework\View\Layout\Element::TYPE_BLOCK, - 'Magento\Framework\View\Element\AbstractBlock' + \Magento\Framework\View\Element\AbstractBlock::class )->willReturn('block_name'); $this->generatorBlockMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock)); $this->assertSame( $blockMock, - $this->model->createBlock('Magento\Framework\View\Element\AbstractBlock', 'block_name', []) + $this->model->createBlock(\Magento\Framework\View\Element\AbstractBlock::class, 'block_name', []) ); $this->assertSame(['value1' => $blockMock], $this->model->getChildBlocks($parentName)); } @@ -478,7 +481,7 @@ public function isManipulationAllowedDataProvider() public function testSetGetBlock() { $blockName = 'some_name'; - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->assertSame($this->model, $this->model->setBlock($blockName, $blockMock)); @@ -495,7 +498,7 @@ public function testRenameElement() { $oldName = 'old_name'; $newName = 'new_name'; - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -576,8 +579,7 @@ public function getBlockSingletonDataProvider() { return [ [ - 'some_type', - 'Magento\Framework\View\Element\Template', + 'some_type', \Magento\Framework\View\Element\Template::class, true, ], ]; @@ -672,7 +674,7 @@ public function getRendererOptionsDataProvider() */ public function testIsCacheable($xmlString, $result) { - $xml = simplexml_load_string($xmlString, 'Magento\Framework\View\Layout\Element'); + $xml = simplexml_load_string($xmlString, \Magento\Framework\View\Layout\Element::class); $this->assertSame($this->model, $this->model->setXml($xml)); $this->assertSame($result, $this->model->isCacheable()); } @@ -704,10 +706,10 @@ public function testGenerateElementsWithoutCache() $layoutCacheId = 'layout_cache_id'; $handles = ['default', 'another']; /** @var \Magento\Framework\View\Layout\Element $xml */ - $xml = simplexml_load_string('', 'Magento\Framework\View\Layout\Element'); + $xml = simplexml_load_string('', \Magento\Framework\View\Layout\Element::class); $this->model->setXml($xml); - $themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $themeMock = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->themeResolverMock->expects($this->once()) ->method('get') ->willReturn($themeMock); @@ -738,7 +740,7 @@ public function testGenerateElementsWithoutCache() ->with(serialize($this->readerContextMock), 'structure_' . $layoutCacheId, $handles) ->willReturn(true); - $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor() ->getMock(); $this->generatorContextFactoryMock->expects($this->once()) @@ -769,10 +771,10 @@ public function testGenerateElementsWithCache() { $layoutCacheId = 'layout_cache_id'; /** @var \Magento\Framework\View\Layout\Element $xml */ - $xml = simplexml_load_string('', 'Magento\Framework\View\Layout\Element'); + $xml = simplexml_load_string('', \Magento\Framework\View\Layout\Element::class); $this->model->setXml($xml); - $themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); + $themeMock = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class); $this->themeResolverMock->expects($this->once()) ->method('get') ->willReturn($themeMock); @@ -785,7 +787,7 @@ public function testGenerateElementsWithCache() ->method('getCacheId') ->willReturn($layoutCacheId); - $readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor() ->getMock(); @@ -799,7 +801,7 @@ public function testGenerateElementsWithCache() $this->cacheMock->expects($this->never()) ->method('save'); - $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor() ->getMock(); $this->generatorContextFactoryMock->expects($this->once()) @@ -865,7 +867,7 @@ public function testRenderElementDisplay($displayValue) ->with($name) ->willReturn($children); - $block = $this->getMock('Magento\Framework\View\Element\AbstractBlock', [], [], '', false); + $block = $this->getMock(\Magento\Framework\View\Element\AbstractBlock::class, [], [], '', false); $block->expects($this->once())->method('toHtml')->willReturn($blockHtml); $renderingOutput = new \Magento\Framework\DataObject(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/TranslatorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/TranslatorTest.php index ce5f3a8a0e771..57d4a73ce2ee1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/TranslatorTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/TranslatorTest.php @@ -45,7 +45,7 @@ protected function setUp() XML; - $this->_xmlDocument = simplexml_load_string($string, 'Magento\Framework\Simplexml\Element'); + $this->_xmlDocument = simplexml_load_string($string, \Magento\Framework\Simplexml\Element::class); $this->_object = new \Magento\Framework\View\Model\Layout\Translator(); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/Update/ValidatorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/Update/ValidatorTest.php index 50a314426523f..5fed45d8be458 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/Update/ValidatorTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Model/Layout/Update/ValidatorTest.php @@ -27,7 +27,7 @@ protected function setUp() protected function _createValidator($layoutUpdate, $isSchemaValid = true) { $domConfigFactory = $this->getMockBuilder( - 'Magento\Framework\Config\DomFactory' + \Magento\Framework\Config\DomFactory::class )->disableOriginalConstructor()->getMock(); $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); @@ -49,9 +49,9 @@ protected function _createValidator($layoutUpdate, $isSchemaValid = true) new \Magento\Framework\Config\Dom\ValidationException($exceptionMessage) ) ); - $urnResolver = $this->_objectHelper->getObject('Magento\Framework\Config\Dom\UrnResolver'); + $urnResolver = $this->_objectHelper->getObject(\Magento\Framework\Config\Dom\UrnResolver::class); $model = $this->_objectHelper->getObject( - 'Magento\Framework\View\Model\Layout\Update\Validator', + \Magento\Framework\View\Model\Layout\Update\Validator::class, ['domConfigFactory' => $domConfigFactory, 'urnResolver' => $urnResolver] ); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/BuilderTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/BuilderTest.php index 6c102df03528b..3daa3ac97ede8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/BuilderTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/BuilderTest.php @@ -14,7 +14,7 @@ */ class BuilderTest extends \Magento\Framework\View\Test\Unit\Layout\BuilderTest { - const CLASS_NAME = 'Magento\Framework\View\Page\Builder'; + const CLASS_NAME = \Magento\Framework\View\Page\Builder::class; /** * @param array $arguments @@ -22,18 +22,24 @@ class BuilderTest extends \Magento\Framework\View\Test\Unit\Layout\BuilderTest */ protected function getBuilder($arguments) { - $arguments['pageConfig'] = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $arguments['pageConfig'] = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $arguments['pageConfig']->expects($this->once())->method('setBuilder'); $arguments['pageConfig']->expects($this->once())->method('getPageLayout') ->will($this->returnValue('test_layout')); - $readerContext = $this->getMock('Magento\Framework\View\Layout\Reader\Context', [], [], '', false); + $readerContext = $this->getMock(\Magento\Framework\View\Layout\Reader\Context::class, [], [], '', false); /** @var \PHPUnit_Framework_MockObject_MockObject $layout */ $layout = & $arguments['layout']; $layout->expects($this->once())->method('getReaderContext')->will($this->returnValue($readerContext)); - $arguments['pageLayoutReader'] = $this->getMock('Magento\Framework\View\Page\Layout\Reader', [], [], '', false); + $arguments['pageLayoutReader'] = $this->getMock( + \Magento\Framework\View\Page\Layout\Reader::class, + [], + [], + '', + false + ); $arguments['pageLayoutReader']->expects($this->once())->method('read')->with($readerContext, 'test_layout'); return parent::getBuilder($arguments); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php index 376a8f9754dae..51bdd1ce17c53 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php @@ -27,13 +27,13 @@ class BodyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->bodyGenerator = $objectManagerHelper->getObject( - 'Magento\Framework\View\Page\Config\Generator\Body', + \Magento\Framework\View\Page\Config\Generator\Body::class, [ 'pageConfig' => $this->pageConfigMock, ] @@ -42,15 +42,15 @@ protected function setUp() public function testProcess() { - $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor() ->getMock(); - $structureMock = $this->getMockBuilder('Magento\Framework\View\Page\Config\Structure') + $structureMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config\Structure::class) ->disableOriginalConstructor() ->getMock(); - $readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor() ->getMock(); $readerContextMock->expects($this->any()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php index dca137f44f206..d017a2e69c4a0 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php @@ -33,16 +33,16 @@ class HeadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->title = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->title = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->headGenerator = $objectManagerHelper->getObject( - 'Magento\Framework\View\Page\Config\Generator\Head', + \Magento\Framework\View\Page\Config\Generator\Head::class, [ 'pageConfig' => $this->pageConfigMock, ] @@ -51,15 +51,15 @@ protected function setUp() public function testProcess() { - $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') + $generatorContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Generator\Context::class) ->disableOriginalConstructor() ->getMock(); $this->title->expects($this->any())->method('set')->with()->will($this->returnSelf()); - $structureMock = $this->getMockBuilder('Magento\Framework\View\Page\Config\Structure') + $structureMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config\Structure::class) ->disableOriginalConstructor() ->getMock(); - $readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor() ->getMock(); $readerContextMock->expects($this->any()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Reader/HeadTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Reader/HeadTest.php index 737ae264645fe..7a8e77121d076 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Reader/HeadTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Reader/HeadTest.php @@ -24,10 +24,10 @@ protected function setUp() public function testInterpret() { - $readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $readerContextMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->disableOriginalConstructor() ->getMock(); - $structureMock = $this->getMockBuilder('Magento\Framework\View\Page\Config\Structure') + $structureMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config\Structure::class) ->disableOriginalConstructor() ->getMock(); $readerContextMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php index ed77622ba3828..0f5b9ffff61c6 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php @@ -75,45 +75,45 @@ class RendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->assetMergeServiceMock = $this->getMockBuilder('Magento\Framework\View\Asset\MergeService') + $this->assetMergeServiceMock = $this->getMockBuilder(\Magento\Framework\View\Asset\MergeService::class) ->disableOriginalConstructor() ->getMock(); - $this->urlBuilderMock = $this->getMockForAbstractClass('Magento\Framework\UrlInterface'); + $this->urlBuilderMock = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class); - $this->escaperMock = $this->getMockBuilder('Magento\Framework\Escaper') + $this->escaperMock = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->getMock(); $this->escaperMock->expects($this->any()) ->method('escapeHtml') ->willReturnArgument(0); - $this->stringMock = $this->getMockBuilder('Magento\Framework\Stdlib\StringUtils') + $this->stringMock = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); - $this->assetsCollection = $this->getMockBuilder('Magento\Framework\View\Asset\GroupedCollection') + $this->assetsCollection = $this->getMockBuilder(\Magento\Framework\View\Asset\GroupedCollection::class) ->setMethods(['getGroups']) ->disableOriginalConstructor() ->getMock(); - $this->assetInterfaceMock = $this->getMockForAbstractClass('Magento\Framework\View\Asset\AssetInterface'); + $this->assetInterfaceMock = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\AssetInterface::class); - $this->titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->setMethods(['set', 'get']) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManager($this); $this->renderer = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Page\Config\Renderer', + \Magento\Framework\View\Page\Config\Renderer::class, [ 'pageConfig' => $this->pageConfigMock, 'assetMergeService' => $this->assetMergeServiceMock, @@ -261,14 +261,14 @@ public function testRenderAssets($groupOne, $groupTwo, $expectedResult) $exception = new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('my message')); - $assetMockOne = $this->getMock('Magento\Framework\View\Asset\AssetInterface'); + $assetMockOne = $this->getMock(\Magento\Framework\View\Asset\AssetInterface::class); $assetMockOne->expects($this->exactly(2)) ->method('getUrl') ->willReturn($assetUrl); $groupAssetsOne = [$assetMockOne, $assetMockOne]; - $groupMockOne = $this->getMockBuilder('Magento\Framework\View\Asset\PropertyGroup') + $groupMockOne = $this->getMockBuilder(\Magento\Framework\View\Asset\PropertyGroup::class) ->disableOriginalConstructor() ->getMock(); $groupMockOne->expects($this->once()) @@ -283,14 +283,14 @@ public function testRenderAssets($groupOne, $groupTwo, $expectedResult) ['ie_condition', $groupOne['condition']], ]); - $assetMockTwo = $this->getMock('Magento\Framework\View\Asset\AssetInterface'); + $assetMockTwo = $this->getMock(\Magento\Framework\View\Asset\AssetInterface::class); $assetMockTwo->expects($this->once()) ->method('getUrl') ->willThrowException($exception); $groupAssetsTwo = [$assetMockTwo]; - $groupMockTwo = $this->getMockBuilder('Magento\Framework\View\Asset\PropertyGroup') + $groupMockTwo = $this->getMockBuilder(\Magento\Framework\View\Asset\PropertyGroup::class) ->disableOriginalConstructor() ->getMock(); $groupMockTwo->expects($this->once()) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php index c4856d753f449..347d0ed38ff8e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php @@ -24,7 +24,7 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->structure = $objectManagerHelper->getObject( - 'Magento\Framework\View\Page\Config\Structure' + \Magento\Framework\View\Page\Config\Structure::class ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php index 2e73629c03888..9714a6ef7c1a9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php @@ -71,21 +71,27 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->pageAssets = $this->getMock('Magento\Framework\View\Asset\GroupedCollection', [], [], '', false); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); - $this->favicon = $this->getMock('Magento\Framework\View\Page\FaviconInterface', [], [], '', false); - $this->builder = $this->getMock('Magento\Framework\View\Layout\BuilderInterface', [], [], '', false); - $this->asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); - $this->remoteAsset = $this->getMock('\Magento\Framework\View\Asset\Remote', [], [], '', false); - $this->title = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $locale = $this->getMockForAbstractClass('Magento\Framework\Locale\ResolverInterface', [], '', false); + $this->assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->pageAssets = $this->getMock(\Magento\Framework\View\Asset\GroupedCollection::class, [], [], '', false); + $this->scopeConfig = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + [], + [], + '', + false + ); + $this->favicon = $this->getMock(\Magento\Framework\View\Page\FaviconInterface::class, [], [], '', false); + $this->builder = $this->getMock(\Magento\Framework\View\Layout\BuilderInterface::class, [], [], '', false); + $this->asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); + $this->remoteAsset = $this->getMock(\Magento\Framework\View\Asset\Remote::class, [], [], '', false); + $this->title = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $locale = $this->getMockForAbstractClass(\Magento\Framework\Locale\ResolverInterface::class, [], '', false); $locale->expects($this->any()) ->method('getLocale') ->willReturn(Resolver::DEFAULT_LOCALE); $this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject( - 'Magento\Framework\View\Page\Config', + \Magento\Framework\View\Page\Config::class, [ 'assetRepo' => $this->assetRepo, 'pageAssets' => $this->pageAssets, @@ -95,7 +101,7 @@ protected function setUp() ] ); - $this->areaResolverMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->areaResolverMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $areaResolverReflection = (new \ReflectionClass(get_class($this->model)))->getProperty('areaResolver'); $areaResolverReflection->setAccessible(true); $areaResolverReflection->setValue($this->model, $this->areaResolverMock); @@ -104,7 +110,7 @@ protected function setUp() public function testSetBuilder() { $this->assertInstanceOf( - 'Magento\Framework\View\Page\Config', + \Magento\Framework\View\Page\Config::class, $this->model->setBuilder($this->builder) ); } @@ -113,14 +119,14 @@ public function testBuild() { $this->model->setBuilder($this->builder); $this->builder->expects($this->once())->method('build')->will( - $this->returnValue('Magento\Framework\View\LayoutInterface') + $this->returnValue(\Magento\Framework\View\LayoutInterface::class) ); $this->model->publicBuild(); } public function testGetTitle() { - $this->assertInstanceOf('\Magento\Framework\View\Page\Title', $this->model->getTitle()); + $this->assertInstanceOf(\Magento\Framework\View\Page\Title::class, $this->model->getTitle()); } public function testMetadata() @@ -247,7 +253,10 @@ public function testRobotsAdminhtml() public function testGetAssetCollection() { - $this->assertInstanceOf('Magento\Framework\View\Asset\GroupedCollection', $this->model->getAssetCollection()); + $this->assertInstanceOf( + \Magento\Framework\View\Asset\GroupedCollection::class, + $this->model->getAssetCollection() + ); } /** @@ -265,7 +274,7 @@ public function testAddPageAsset($file, $properties, $name, $expectedName) ); $this->pageAssets->expects($this->once())->method('add')->with($expectedName, $this->asset, $properties); $this->assertInstanceOf( - 'Magento\Framework\View\Page\Config', + \Magento\Framework\View\Page\Config::class, $this->model->addPageAsset($file, $properties, $name) ); } @@ -304,7 +313,7 @@ public function testAddRemotePageAsset($url, $contentType, $properties, $name, $ ); $this->pageAssets->expects($this->once())->method('add')->with($expectedName, $this->remoteAsset, $properties); $this->assertInstanceOf( - 'Magento\Framework\View\Page\Config', + \Magento\Framework\View\Page\Config::class, $this->model->addRemotePageAsset($url, $contentType, $properties, $name) ); } @@ -342,13 +351,13 @@ public function testAddRss() $this->remoteAsset, $expected ); - $this->assertInstanceOf('Magento\Framework\View\Page\Config', $this->model->addRss($title, $href)); + $this->assertInstanceOf(\Magento\Framework\View\Page\Config::class, $this->model->addRss($title, $href)); } public function testAddBodyClass() { $className = 'test class'; - $this->assertInstanceOf('Magento\Framework\View\Page\Config', $this->model->addBodyClass($className)); + $this->assertInstanceOf(\Magento\Framework\View\Page\Config::class, $this->model->addBodyClass($className)); $this->assertEquals('test-class', $this->model->getElementAttribute('body', 'class')); } @@ -395,7 +404,10 @@ public function elementAttributeDataProvider() */ public function testElementAttributeException($elementType, $attribute, $value) { - $this->setExpectedException('\Magento\Framework\Exception\LocalizedException', $elementType . " isn't allowed"); + $this->setExpectedException( + \Magento\Framework\Exception\LocalizedException::class, + $elementType . " isn't allowed" + ); $this->model->setElementAttribute($elementType, $attribute, $value); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Layout/ReaderTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Layout/ReaderTest.php index 59e5a21c4637b..7e5a4323de3f6 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Layout/ReaderTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Layout/ReaderTest.php @@ -54,39 +54,39 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->processorInterface = $this->getMock( - 'Magento\Framework\View\Layout\ProcessorInterface', + \Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false ); - $this->themeInterface = $this->getMock('Magento\Framework\View\Design\ThemeInterface', [], [], '', false); + $this->themeInterface = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class, [], [], '', false); $this->processorFactory = $this->getMock( - 'Magento\Framework\View\Layout\ProcessorFactory', + \Magento\Framework\View\Layout\ProcessorFactory::class, ['create'], [], '', false ); $this->themeResolver = $this->getMock( - 'Magento\Framework\View\Design\Theme\ResolverInterface', + \Magento\Framework\View\Design\Theme\ResolverInterface::class, [], [], '', false ); - $this->pageLayoutFileSource = $this->getMockBuilder('Magento\Framework\View\File\CollectorInterface') + $this->pageLayoutFileSource = $this->getMockBuilder(\Magento\Framework\View\File\CollectorInterface::class) ->getMock(); - $this->readerPool = $this->getMockBuilder('Magento\Framework\View\Layout\ReaderPool') + $this->readerPool = $this->getMockBuilder(\Magento\Framework\View\Layout\ReaderPool::class) ->disableOriginalConstructor() ->getMock(); - $this->readerContext = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') + $this->readerContext = $this->getMockBuilder(\Magento\Framework\View\Layout\Reader\Context::class) ->setMethods(['getScheduledStructure']) ->disableOriginalConstructor() ->getMock(); $this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject( - 'Magento\Framework\View\Page\Layout\Reader', + \Magento\Framework\View\Page\Layout\Reader::class, [ 'themeResolver' => $this->themeResolver, 'processorFactory' => $this->processorFactory, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php index 34ffb54ba60e9..0247e080662f8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php @@ -28,13 +28,13 @@ class TitleTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->title = $objectManagerHelper->getObject( - 'Magento\Framework\View\Page\Title', + \Magento\Framework\View\Page\Title::class, ['scopeConfig' => $this->scopeConfigMock] ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php index 9d7d017240c98..82c0bf30c3782 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php @@ -18,15 +18,21 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); - $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolverMock->expects($this->once()) ->method('getRealPath') ->with('urn:magento:framework:View/PageLayout/etc/layouts.xsd') ->willReturn($urnResolver->getRealPath('urn:magento:framework:View/PageLayout/etc/layouts.xsd')); - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); - $domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $domFactoryMock = $this->getMock(\Magento\Framework\Config\DomFactory::class, [], [], '', false); $domFactoryMock->expects($this->once()) ->method('createDom') ->willReturnCallback( @@ -45,7 +51,7 @@ function ($arguments) use ($validationStateMock) { ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Framework\View\PageLayout\Config', + \Magento\Framework\View\PageLayout\Config::class, [ 'urnResolver' => $urnResolverMock, 'configFiles' => [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Render/RenderFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Render/RenderFactoryTest.php index 010b12ca692e4..0ae4cf420a4ec 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Render/RenderFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Render/RenderFactoryTest.php @@ -21,11 +21,11 @@ class RenderFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->renderFactory = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Render\RenderFactory', + \Magento\Framework\View\Render\RenderFactory::class, [ 'objectManager' => $this->objectManagerMock ] @@ -34,12 +34,12 @@ protected function setUp() public function testGet() { - $instance = 'Magento\Framework\View\RenderInterface'; + $instance = \Magento\Framework\View\RenderInterface::class; $renderMock = $this->getMock($instance, [], [], '', false); $data = 'RenderInterface'; $this->objectManagerMock->expects($this->once()) ->method('get') - ->with($this->equalTo('Magento\Framework\View\Render\RenderInterface')) + ->with($this->equalTo(\Magento\Framework\View\Render\RenderInterface::class)) ->will($this->returnValue($renderMock)); $this->assertInstanceOf($instance, $this->renderFactory->get($data)); } @@ -52,7 +52,7 @@ public function testGetException() { $this->objectManagerMock->expects($this->once()) ->method('get') - ->with($this->equalTo('Magento\Framework\View\Render\RenderInterface')) + ->with($this->equalTo(\Magento\Framework\View\Render\RenderInterface::class)) ->will($this->returnValue(new \stdClass())); $this->renderFactory->get('RenderInterface'); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php index 0b8bfba8f3439..ab97670dd6105 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php @@ -41,19 +41,19 @@ class LayoutTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $this->translateInline = $this->getMock('Magento\Framework\Translate\InlineInterface'); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout)); $context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $context->expects($this->any())->method('getEventManager')->will($this->returnValue($this->eventManager)); $this->resultLayout = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject( - 'Magento\Framework\View\Result\Layout', + ->getObject( + \Magento\Framework\View\Result\Layout::class, ['context' => $context, 'translateInline' => $this->translateInline] ); } @@ -77,7 +77,7 @@ public function testGetDefaultLayoutHandle() public function testAddHandle() { - $processor = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + $processor = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false); $processor->expects($this->once())->method('addHandle')->with('module_controller_action'); $this->layout->expects($this->once())->method('getUpdate')->will($this->returnValue($processor)); @@ -87,7 +87,7 @@ public function testAddHandle() public function testAddUpdate() { - $processor = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + $processor = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false); $processor->expects($this->once())->method('addUpdate')->with('handle_name'); $this->layout->expects($this->once())->method('getUpdate')->will($this->returnValue($processor)); @@ -125,7 +125,7 @@ public function testRenderResult( ->willReturnSelf(); /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject $response */ - $response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $response->expects($setHttpResponseCodeCount)->method('setHttpResponseCode')->with($httpCode); $response->expects($setHeaderCount)->method('setHeader')->with($headerName, $headerValue, $replaceHeader); $response->expects($this->once())->method('appendBody')->with($layoutOutput); @@ -152,7 +152,7 @@ public function renderResultDataProvider() public function testAddDefaultHandle() { - $processor = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + $processor = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false); $processor->expects($this->once())->method('addHandle')->with('module_controller_action'); $this->layout->expects($this->once())->method('getUpdate')->will($this->returnValue($processor)); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Result/PageFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Result/PageFactoryTest.php index 7355dffa1f381..244a6671a89cd 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Result/PageFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Result/PageFactoryTest.php @@ -24,22 +24,24 @@ class PageFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->pageFactory = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Result\PageFactory', + \Magento\Framework\View\Result\PageFactory::class, [ 'objectManager' => $this->objectManagerMock ] ); - $this->page = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->page = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); } public function testCreate() { - $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\Framework\View\Result\Page') + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with(\Magento\Framework\View\Result\Page::class) ->will($this->returnValue($this->page)); $this->assertSame($this->page, $this->pageFactory->create()); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Result/PageTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Result/PageTest.php index 6825a8b85f64f..6fcb407b54bf9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Result/PageTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Result/PageTest.php @@ -64,16 +64,16 @@ class PageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layout = $this->getMockBuilder('Magento\Framework\View\Layout') + $this->layout = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->setMethods(['addHandle', 'getUpdate', 'isLayoutDefined']) ->disableOriginalConstructor() ->getMock(); - $this->layoutFactory = $this->getMockBuilder('Magento\Framework\View\LayoutFactory') + $this->layoutFactory = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class) ->disableOriginalConstructor() ->getMock(); $this->layoutFactory->expects($this->any())->method('create')->will($this->returnValue($this->layout)); - $this->layoutMerge = $this->getMockBuilder('Magento\Framework\View\Model\Layout\Merge') + $this->layoutMerge = $this->getMockBuilder(\Magento\Framework\View\Model\Layout\Merge::class) ->disableOriginalConstructor() ->getMock(); @@ -81,33 +81,36 @@ protected function setUp() ->method('getUpdate') ->will($this->returnValue($this->layoutMerge)); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfig = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfig = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->viewFileSystem = $this->getMockBuilder('Magento\Framework\View\FileSystem') + $this->viewFileSystem = $this->getMockBuilder(\Magento\Framework\View\FileSystem::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->context = $objectManagerHelper->getObject('Magento\Framework\View\Element\Template\Context', [ - 'layout' => $this->layout, - 'request' => $this->request, - 'viewFileSystem' => $this->viewFileSystem, - 'pageConfig' => $this->pageConfig - ]); + $this->context = $objectManagerHelper->getObject( + \Magento\Framework\View\Element\Template\Context::class, + [ + 'layout' => $this->layout, + 'request' => $this->request, + 'viewFileSystem' => $this->viewFileSystem, + 'pageConfig' => $this->pageConfig + ] + ); - $this->translateInline = $this->getMock('Magento\Framework\Translate\InlineInterface'); + $this->translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class); - $this->pageConfigRenderer = $this->getMockBuilder('Magento\Framework\View\Page\Config\Renderer') + $this->pageConfigRenderer = $this->getMockBuilder(\Magento\Framework\View\Page\Config\Renderer::class) ->disableOriginalConstructor() ->getMock(); - $pageConfigRendererFactory = $this->getMockBuilder('Magento\Framework\View\Page\Config\RendererFactory') + $pageConfigRendererFactory = $this->getMockBuilder(\Magento\Framework\View\Page\Config\RendererFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -118,7 +121,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->page = $objectManagerHelper->getObject( - 'Magento\Framework\View\Result\Page', + \Magento\Framework\View\Result\Page::class, [ 'isIsolated' => true, 'layoutFactory' => $this->layoutFactory, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php index 94fa61e04cbe5..5b52a1a5e85e1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php @@ -204,7 +204,7 @@ public function testGetMinified() $file = '/absolute/path/to/phtml/template/file'; $relativeGeneratedPath = 'absolute/path/to/phtml/template/file'; - $htmlDriver = $this->getMock('Magento\Framework\Filesystem\DriverInterface', [], [], '', false); + $htmlDriver = $this->getMock(\Magento\Framework\Filesystem\DriverInterface::class, [], [], '', false); $htmlDriver ->expects($this->once()) ->method('getRealPathSafety') diff --git a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php index 1c81b34d752bd..c51223eae1cef 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php @@ -22,7 +22,7 @@ class PhpTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_helperFactoryMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_helperFactoryMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_phpEngine = new \Magento\Framework\View\TemplateEngine\Php($this->_helperFactoryMock); } @@ -34,7 +34,7 @@ protected function setUp() public function testRender() { $blockMock = $this->getMockBuilder( - 'Magento\Framework\View\Element\Template' + \Magento\Framework\View\Element\Template::class )->setMethods( ['testMethod'] )->disableOriginalConstructor()->getMock(); @@ -60,7 +60,7 @@ public function testRender() public function testRenderException() { $blockMock = $this->getMockBuilder( - 'Magento\Framework\View\Element\Template' + \Magento\Framework\View\Element\Template::class )->setMethods( ['testMethod'] )->disableOriginalConstructor()->getMock(); @@ -74,7 +74,7 @@ public function testRenderException() */ public function testHelperWithInvalidClass() { - $class = 'Magento\Framework\DataObject'; + $class = \Magento\Framework\DataObject::class; $object = $this->getMock($class, [], [], '', false); $this->_helperFactoryMock->expects( $this->once() @@ -90,7 +90,7 @@ public function testHelperWithInvalidClass() public function testHelperWithValidClass() { - $class = 'Magento\Framework\App\Helper\AbstractHelper'; + $class = \Magento\Framework\App\Helper\AbstractHelper::class; $object = $this->getMockForAbstractClass($class, [], '', false); $this->_helperFactoryMock->expects( $this->once() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngineFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngineFactoryTest.php index 06096482a4fa5..bfc0562644129 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngineFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngineFactoryTest.php @@ -20,22 +20,22 @@ class TemplateEngineFactoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_factory = new TemplateEngineFactory( $this->_objectManagerMock, - ['test' => 'Fixture\Module\Model\TemplateEngine'] + ['test' => \Fixture\Module\Model\TemplateEngine::class] ); } public function testCreateKnownEngine() { - $engine = $this->getMock('Magento\Framework\View\TemplateEngineInterface'); + $engine = $this->getMock(\Magento\Framework\View\TemplateEngineInterface::class); $this->_objectManagerMock->expects( $this->once() )->method( 'create' )->with( - 'Fixture\Module\Model\TemplateEngine' + \Fixture\Module\Model\TemplateEngine::class )->will( $this->returnValue($engine) ); @@ -63,7 +63,7 @@ public function testCreateInvalidEngine() )->method( 'create' )->with( - 'Fixture\Module\Model\TemplateEngine' + \Fixture\Module\Model\TemplateEngine::class )->will( $this->returnValue(new \stdClass()) ); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEnginePoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEnginePoolTest.php index 48feff47dd4f9..413c0bc946f80 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEnginePoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEnginePoolTest.php @@ -21,13 +21,13 @@ class TemplateEnginePoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_factory = $this->getMock('Magento\Framework\View\TemplateEngineFactory', [], [], '', false); + $this->_factory = $this->getMock(\Magento\Framework\View\TemplateEngineFactory::class, [], [], '', false); $this->_model = new TemplateEnginePool($this->_factory); } public function testGet() { - $engine = $this->getMock('Magento\Framework\View\TemplateEngineInterface'); + $engine = $this->getMock(\Magento\Framework\View\TemplateEngineInterface::class); $this->_factory->expects($this->once())->method('create')->with('test')->will($this->returnValue($engine)); $this->assertSame($engine, $this->_model->get('test')); // Make sure factory is invoked only once and the same instance is returned afterwards diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Url/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Url/ConfigTest.php index a5a0b5b1c13a1..1d6f31fafdee4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Url/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Url/ConfigTest.php @@ -20,7 +20,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_scopeConfig = $this->getMockBuilder( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class )->disableOriginalConstructor()->getMock(); $this->_model = new \Magento\Framework\View\Url\Config($this->_scopeConfig); } diff --git a/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php b/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php index b3e01634347d2..14be2dbb313e3 100644 --- a/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php @@ -306,7 +306,7 @@ public function apiShutdownFunction() */ protected function _saveFatalErrorReport($reportData) { - $this->directoryWrite->create('report/api'); + $this->directoryWrite->create(\report/api::class); $reportId = abs(intval(microtime(true) * rand(100, 1000))); $this->directoryWrite->writeFile('report/api/' . $reportId, serialize($reportData)); return $reportId; diff --git a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php index 47052ad62de4d..47bedb4992710 100644 --- a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php @@ -26,7 +26,7 @@ */ class ServiceInputProcessor implements ServicePayloadConverterInterface { - const EXTENSION_ATTRIBUTES_TYPE = '\Magento\Framework\Api\ExtensionAttributesInterface'; + const EXTENSION_ATTRIBUTES_TYPE = \Magento\Framework\Api\ExtensionAttributesInterface::class; /** @var \Magento\Framework\Reflection\TypeProcessor */ protected $typeProcessor; diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php index 0fb6cc8db21da..6d9c972557687 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php @@ -31,18 +31,18 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** Set up mocks for SUT. */ - $this->encoderMock = $this->getMockBuilder('Magento\Framework\Json\Encoder') + $this->encoderMock = $this->getMockBuilder(\Magento\Framework\Json\Encoder::class) ->disableOriginalConstructor() ->setMethods(['encode']) ->getMock(); - $this->_appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->_appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->_loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->_loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); - $filesystemMock = $this->getMockBuilder('\Magento\Framework\Filesystem') + $filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); @@ -194,7 +194,7 @@ public function testMaskExceptionInDeveloperMode() $logicalException = new \LogicException($errorMessage); /** Assert that Logic exception is converted to WebapiException without message obfuscation. */ $maskedException = $this->_errorProcessor->maskException($logicalException); - $this->assertInstanceOf('Magento\Framework\Webapi\Exception', $maskedException); + $this->assertInstanceOf(\Magento\Framework\Webapi\Exception::class, $maskedException); $this->assertEquals( $errorMessage, $maskedException->getMessage(), @@ -313,7 +313,7 @@ public function assertMaskedException( $expectedDetails ) { /** All masked exceptions must be WebapiException */ - $expectedType = 'Magento\Framework\Webapi\Exception'; + $expectedType = \Magento\Framework\Webapi\Exception::class; $this->assertInstanceOf( $expectedType, $maskedException, diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php index e606898068fd1..21001fff8db2c 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php @@ -14,7 +14,7 @@ protected function setUp() { /** Initialize SUT. */ $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->request = $objectManager->getObject('Magento\Framework\Webapi\Request'); + $this->request = $objectManager->getObject(\Magento\Framework\Webapi\Request::class); } protected function tearDown() diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php index 9abac64ca5938..2fee65e7cd564 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php @@ -24,11 +24,11 @@ class JsonTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** Prepare mocks for SUT constructor. */ - $this->decoderMock = $this->getMockBuilder('Magento\Framework\Json\Decoder') + $this->decoderMock = $this->getMockBuilder(\Magento\Framework\Json\Decoder::class) ->disableOriginalConstructor() ->setMethods(['decode']) ->getMock(); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->_appStateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); /** Initialize SUT. */ $this->_jsonDeserializer = new \Magento\Framework\Webapi\Rest\Request\Deserializer\Json( $this->decoderMock, @@ -90,7 +90,7 @@ public function testDeserializeInvalidEncodedBodyExceptionDeveloperModeOff() $this->_jsonDeserializer->deserialize($inputInvalidJson); $this->fail("Exception is expected to be raised"); } catch (\Magento\Framework\Webapi\Exception $e) { - $this->assertInstanceOf('Magento\Framework\Webapi\Exception', $e, 'Exception type is invalid'); + $this->assertInstanceOf(\Magento\Framework\Webapi\Exception::class, $e, 'Exception type is invalid'); $this->assertEquals('Decoding error.', $e->getMessage(), 'Exception message is invalid'); $this->assertEquals( \Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, @@ -121,7 +121,7 @@ public function testDeserializeInvalidEncodedBodyExceptionDeveloperModeOn() $this->_jsonDeserializer->deserialize($inputInvalidJson); $this->fail("Exception is expected to be raised"); } catch (\Magento\Framework\Webapi\Exception $e) { - $this->assertInstanceOf('Magento\Framework\Webapi\Exception', $e, 'Exception type is invalid'); + $this->assertInstanceOf(\Magento\Framework\Webapi\Exception::class, $e, 'Exception type is invalid'); $this->assertContains('Decoding error:', $e->getMessage(), 'Exception message is invalid'); $this->assertEquals( \Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php index 3fb5257ed360f..0c76b25f2a868 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php @@ -19,8 +19,8 @@ class XmlTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** Prepare mocks for SUT constructor. */ - $this->_xmlParserMock = $this->getMock('Magento\Framework\Xml\Parser', ['xmlToArray', 'loadXML']); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->_xmlParserMock = $this->getMock(\Magento\Framework\Xml\Parser::class, ['xmlToArray', 'loadXML']); + $this->_appStateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); /** Initialize SUT. */ $this->_xmlDeserializer = new \Magento\Framework\Webapi\Rest\Request\Deserializer\Xml( $this->_xmlParserMock, @@ -100,7 +100,7 @@ public function testDeserializeMagentoWebapiExceptionDeveloperModeOn() $this->fail("Exception is expected to be raised"); } catch (\Magento\Framework\Webapi\Exception $e) { $exceptionMessage = 'Decoding Error: End tag for "key1" was omitted.'; - $this->assertInstanceOf('Magento\Framework\Webapi\Exception', $e, 'Exception type is invalid'); + $this->assertInstanceOf(\Magento\Framework\Webapi\Exception::class, $e, 'Exception type is invalid'); $this->assertEquals($exceptionMessage, $e->getMessage(), 'Exception message is invalid'); $this->assertEquals( \Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, @@ -125,7 +125,7 @@ public function testDeserializeMagentoWebapiExceptionDeveloperModeOff() $this->_xmlDeserializer->deserialize($invalidXml); $this->fail("Exception is expected to be raised"); } catch (\Magento\Framework\Webapi\Exception $e) { - $this->assertInstanceOf('Magento\Framework\Webapi\Exception', $e, 'Exception type is invalid'); + $this->assertInstanceOf(\Magento\Framework\Webapi\Exception::class, $e, 'Exception type is invalid'); $this->assertEquals('Decoding error.', $e->getMessage(), 'Exception message is invalid'); $this->assertEquals( \Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php index 984091832030a..40529b73a9166 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php @@ -13,7 +13,7 @@ public function testGetLogicExceptionEmptyRequestAdapter() { $this->setExpectedException('LogicException', 'Request deserializer adapter is not set.'); $interpreterFactory = new \Magento\Framework\Webapi\Rest\Request\DeserializerFactory( - $this->getMock('Magento\Framework\ObjectManagerInterface'), + $this->getMock(\Magento\Framework\ObjectManagerInterface::class), [] ); $interpreterFactory->get('contentType'); @@ -23,10 +23,10 @@ public function testGet() { $expectedMetadata = ['text_xml' => ['type' => 'text/xml', 'model' => 'Xml']]; $validInterpreterMock = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Request\Deserializer\Xml' + \Magento\Framework\Webapi\Rest\Request\Deserializer\Xml::class )->disableOriginalConstructor()->getMock(); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($validInterpreterMock)); $interpreterFactory = new \Magento\Framework\Webapi\Rest\Request\DeserializerFactory( @@ -40,11 +40,11 @@ public function testGetMagentoWebapiException() { $expectedMetadata = ['text_xml' => ['type' => 'text/xml', 'model' => 'Xml']]; $this->setExpectedException( - 'Magento\Framework\Webapi\Exception', + \Magento\Framework\Webapi\Exception::class, 'Server cannot understand Content-Type HTTP header media type text_xml' ); $interpreterFactory = new \Magento\Framework\Webapi\Rest\Request\DeserializerFactory( - $this->getMock('Magento\Framework\ObjectManagerInterface'), + $this->getMock(\Magento\Framework\ObjectManagerInterface::class), $expectedMetadata ); $interpreterFactory->get('text_xml'); @@ -54,14 +54,14 @@ public function testGetLogicExceptionInvalidRequestDeserializer() { $expectedMetadata = ['text_xml' => ['type' => 'text/xml', 'model' => 'Xml']]; $invalidInterpreter = $this->getMockBuilder( - 'Magento\Framework\Webapi\Response\Rest\Renderer\Json' + \Magento\Framework\Webapi\Response\Rest\Renderer\Json::class )->disableOriginalConstructor()->getMock(); $this->setExpectedException( 'LogicException', 'The deserializer must implement "Magento\Framework\Webapi\Rest\Request\DeserializerInterface".' ); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($invalidInterpreter)); $interpreterFactory = new \Magento\Framework\Webapi\Rest\Request\DeserializerFactory( diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/RequestTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/RequestTest.php index 3d7561bc7949c..74eef3d093f1d 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/RequestTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/RequestTest.php @@ -28,22 +28,22 @@ protected function setUp() { /** Prepare mocks for request constructor arguments. */ $this->_deserializerFactory = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Request\DeserializerFactory' + \Magento\Framework\Webapi\Rest\Request\DeserializerFactory::class )->setMethods( ['deserialize', 'get'] )->disableOriginalConstructor()->getMock(); - $areaListMock = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); - $configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); + $areaListMock = $this->getMock(\Magento\Framework\App\AreaList::class, [], [], '', false); + $configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); $areaListMock->expects($this->once())->method('getFrontName')->will($this->returnValue('rest')); /** Instantiate request. */ // TODO: Get rid of SUT mocks. - $this->_cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); - $converterMock = $this->getMockBuilder('Magento\Framework\Stdlib\StringUtils') + $this->_cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); + $converterMock = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class) ->disableOriginalConstructor() ->setMethods(['cleanString']) ->getMock(); $this->_request = $this->getMock( - 'Magento\Framework\Webapi\Rest\Request', + \Magento\Framework\Webapi\Rest\Request::class, ['getHeader', 'getMethod', 'isGet', 'isPost', 'isPut', 'isDelete', 'getContent'], [$this->_cookieManagerMock, $converterMock, $areaListMock, $configScopeMock, $this->_deserializerFactory] ); @@ -109,7 +109,7 @@ protected function _prepareSutForGetBodyParamsTest($params) $this->returnValue($contentType) ); $deserializer = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Request\Deserializer\Json' + \Magento\Framework\Webapi\Rest\Request\Deserializer\Json::class )->disableOriginalConstructor()->setMethods( ['deserialize'] )->getMock(); diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/FieldsFilterTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/FieldsFilterTest.php index d59bcb77846b4..1ce545c0282bb 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/FieldsFilterTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/FieldsFilterTest.php @@ -31,7 +31,7 @@ class FieldsFilterTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->requestMock = $this->getMock('Magento\Framework\Webapi\Rest\Request', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\Webapi\Rest\Request::class, [], [], '', false); $this->processor = new FieldsFilter($this->requestMock); $this->sampleResponseValue = [ 'customer' => [ diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/Renderer/JsonTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/Renderer/JsonTest.php index dd7fea6bb7cfa..a4be393c638dc 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/Renderer/JsonTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/Renderer/JsonTest.php @@ -18,7 +18,7 @@ class JsonTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** Prepare mocks and objects for SUT constructor. */ - $this->encoderMock = $this->getMockBuilder('Magento\Framework\Json\Encoder') + $this->encoderMock = $this->getMockBuilder(\Magento\Framework\Json\Encoder::class) ->disableOriginalConstructor() ->setMethods(['encode']) ->getMock(); diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php index 0a8050439ebc1..ec5bc846e8042 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php @@ -20,16 +20,16 @@ class RendererFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_requestMock = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Request' + \Magento\Framework\Webapi\Rest\Request::class )->disableOriginalConstructor()->getMock(); $renders = [ - 'default' => ['type' => '*/*', 'model' => 'Magento\Framework\Webapi\Rest\Response\Renderer\Json'], + 'default' => ['type' => '*/*', 'model' => \Magento\Framework\Webapi\Rest\Response\Renderer\Json::class], 'application_json' => [ 'type' => 'application/json', - 'model' => 'Magento\Framework\Webapi\Rest\Response\Renderer\Json', + 'model' => \Magento\Framework\Webapi\Rest\Response\Renderer\Json::class, ], ]; @@ -51,7 +51,7 @@ public function testGet() $this->_requestMock->expects($this->once())->method('getAcceptTypes')->will($this->returnValue($acceptTypes)); /** Mock renderer. */ $rendererMock = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Response\Renderer\Json' + \Magento\Framework\Webapi\Rest\Response\Renderer\Json::class )->disableOriginalConstructor()->getMock(); /** Mock object to return mocked renderer. */ $this->_objectManagerMock->expects( @@ -59,7 +59,7 @@ public function testGet() )->method( 'get' )->with( - 'Magento\Framework\Webapi\Rest\Response\Renderer\Json' + \Magento\Framework\Webapi\Rest\Response\Renderer\Json::class )->will( $this->returnValue($rendererMock) ); @@ -79,7 +79,7 @@ public function testGetWithWrongAcceptHttpHeader() } catch (\Magento\Framework\Webapi\Exception $e) { $exceptionMessage = 'Server cannot match any of the given Accept HTTP header media type(s) '. 'from the request: "" with media types from the config of response renderer.'; - $this->assertInstanceOf('Magento\Framework\Webapi\Exception', $e, 'Exception type is invalid'); + $this->assertInstanceOf(\Magento\Framework\Webapi\Exception::class, $e, 'Exception type is invalid'); $this->assertEquals($exceptionMessage, $e->getMessage(), 'Exception message is invalid'); $this->assertEquals( \Magento\Framework\Webapi\Exception::HTTP_NOT_ACCEPTABLE, @@ -103,7 +103,7 @@ public function testGetWithWrongRendererClass() )->method( 'get' )->with( - 'Magento\Framework\Webapi\Rest\Response\Renderer\Json' + \Magento\Framework\Webapi\Rest\Response\Renderer\Json::class )->will( $this->returnValue(new \Magento\Framework\DataObject()) ); diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/ResponseTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/ResponseTest.php index 5acec6cbd4c81..7535f950a0ed0 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/ResponseTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/ResponseTest.php @@ -27,15 +27,15 @@ protected function setUp() { /** Mock all objects required for SUT. */ $this->rendererMock = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Response\Renderer\Json' + \Magento\Framework\Webapi\Rest\Response\Renderer\Json::class )->disableOriginalConstructor()->getMock(); $rendererFactoryMock = $this->getMockBuilder( - 'Magento\Framework\Webapi\Rest\Response\RendererFactory' + \Magento\Framework\Webapi\Rest\Response\RendererFactory::class )->disableOriginalConstructor()->getMock(); $rendererFactoryMock->expects($this->any())->method('get')->will($this->returnValue($this->rendererMock)); - $this->errorProcessorMock = $this->getMockBuilder('Magento\Framework\Webapi\ErrorProcessor') + $this->errorProcessorMock = $this->getMockBuilder(\Magento\Framework\Webapi\ErrorProcessor::class) ->disableOriginalConstructor()->getMock(); - $this->appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->appStateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); /** Init SUP. */ $this->responseRest = new \Magento\Framework\Webapi\Rest\Response( @@ -70,7 +70,7 @@ public function testSetWebapiExceptionException() $this->responseRest->setException($apiException); /** Assert that \Magento\Framework\Webapi\Exception was set and presented in the list. */ $this->assertTrue( - $this->responseRest->hasExceptionOfType('Magento\Framework\Webapi\Exception'), + $this->responseRest->hasExceptionOfType(\Magento\Framework\Webapi\Exception::class), 'Magento\Framework\Webapi\Exception was not set.' ); } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index 6e592647e4b4e..77bca657b1a86 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -22,6 +22,9 @@ use Magento\Webapi\Test\Unit\Service\Entity\SimpleData; use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase { /** @var ServiceInputProcessor */ @@ -45,7 +48,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectManagerMock = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->any()) @@ -57,35 +60,36 @@ function ($className) use ($objectManager) { ); /** @var \Magento\Framework\Reflection\TypeProcessor $typeProcessor */ - $typeProcessor = $objectManager->getObject('Magento\Framework\Reflection\TypeProcessor'); - $cache = $this->getMockBuilder('Magento\Framework\App\Cache\Type\Reflection') + $typeProcessor = $objectManager->getObject(\Magento\Framework\Reflection\TypeProcessor::class); + $cache = $this->getMockBuilder(\Magento\Framework\App\Cache\Type\Reflection::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->any())->method('load')->willReturn(false); - $this->customAttributeTypeLocator = $this->getMockBuilder('Magento\Eav\Model\EavCustomAttributeTypeLocator') + $this->customAttributeTypeLocator = $this->getMockBuilder( + \Magento\Eav\Model\EavCustomAttributeTypeLocator::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Framework\Api\AttributeDataBuilder */ - $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); $this->attributeValueFactoryMock->expects($this->any()) ->method('create') ->willReturnCallback( function () use ($objectManager) { - return $objectManager->getObject('Magento\Framework\Api\AttributeValue'); + return $objectManager->getObject(\Magento\Framework\Api\AttributeValue::class); } ); - $this->fieldNamer = $this->getMockBuilder('Magento\Framework\Reflection\FieldNamer') + $this->fieldNamer = $this->getMockBuilder(\Magento\Framework\Reflection\FieldNamer::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $this->methodsMap = $objectManager->getObject( - 'Magento\Framework\Reflection\MethodsMap', + \Magento\Framework\Reflection\MethodsMap::class, [ 'cache' => $cache, 'typeProcessor' => $typeProcessor, @@ -95,7 +99,7 @@ function () use ($objectManager) { ); $this->serviceInputProcessor = $objectManager->getObject( - 'Magento\Framework\Webapi\ServiceInputProcessor', + \Magento\Framework\Webapi\ServiceInputProcessor::class, [ 'typeProcessor' => $typeProcessor, 'objectManager' => $this->objectManagerMock, @@ -110,7 +114,7 @@ public function testSimpleProperties() { $data = ['entityId' => 15, 'name' => 'Test']; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'simple', $data ); @@ -123,7 +127,7 @@ public function testNonExistentPropertiesWithDefaultArgumentValue() { $data = []; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'simpleDefaultValue', $data ); @@ -139,7 +143,7 @@ public function testNonExistentPropertiesWithoutDefaultArgumentValue() { $data = []; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'simple', $data ); @@ -150,7 +154,7 @@ public function testNestedDataProperties() { $data = ['nested' => ['details' => ['entityId' => 15, 'name' => 'Test']]]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'nestedData', $data ); @@ -174,7 +178,7 @@ public function testSimpleArrayProperties() { $data = ['ids' => [1, 2, 3, 4]]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'simpleArray', $data ); @@ -192,7 +196,7 @@ public function testAssociativeArrayProperties() { $data = ['associativeArray' => ['key' => 'value', 'key_two' => 'value_two']]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'associativeArray', $data ); @@ -210,7 +214,7 @@ public function testAssociativeArrayPropertiesWithItem() { $data = ['associativeArray' => ['item' => 'value']]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'associativeArray', $data ); @@ -227,7 +231,7 @@ public function testAssociativeArrayPropertiesWithItemArray() { $data = ['associativeArray' => ['item' => ['value1','value2']]]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'associativeArray', $data ); @@ -250,7 +254,7 @@ public function testArrayOfDataObjectProperties() ], ]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'dataArray', $data ); @@ -276,7 +280,7 @@ public function testNestedSimpleArrayProperties() { $data = ['arrayData' => ['ids' => [1, 2, 3, 4]]]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'nestedSimpleArray', $data ); @@ -299,7 +303,7 @@ public function testNestedAssociativeArrayProperties() 'associativeArrayData' => ['associativeArray' => ['key' => 'value', 'key2' => 'value2']], ]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'nestedAssociativeArray', $data ); @@ -324,7 +328,7 @@ public function testNestedArrayOfDataObjectProperties() ], ]; $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'nestedDataArray', $data ); @@ -362,7 +366,7 @@ public function testCustomAttributesProperties($customAttributeType, $inputData, $this->customAttributeTypeLocator->expects($this->any())->method('getType')->willReturn($customAttributeType); $result = $this->serviceInputProcessor->process( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService::class, 'ObjectWithCustomAttributesMethod', $inputData ); @@ -408,7 +412,7 @@ public function customAttributesDataProvider() 'expectedObject'=> $this->getObjectWithCustomAttributes('integer', TestService::DEFAULT_VALUE), ], 'customAttributeObject' => [ - 'customAttributeType' => 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray', + 'customAttributeType' => \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray::class, 'inputData' => [ 'param' => [ 'customAttributes' => [ @@ -450,7 +454,7 @@ public function customAttributesDataProvider() 'expectedObject'=> $this->getObjectWithCustomAttributes('emptyData') ], 'customAttributeObjectNonExistentCustomAttributeCodeValue' => [ - 'customAttributeType' => 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray', + 'customAttributeType' => \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray::class, 'inputData' => [ 'param' => [ 'customAttributes' => [ @@ -480,35 +484,35 @@ protected function getObjectWithCustomAttributes($type, $value = []) break; case 'SimpleArray': $customAttributeValue = $objectManager->getObject( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray::class, ['data' => $value] ); break; case 'Simple[]': $dataObjectSimple1 = $objectManager->getObject( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple::class, ['data' => $value[0]] ); $dataObjectSimple2 = $objectManager->getObject( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple::class, ['data' => $value[1]] ); $customAttributeValue = [$dataObjectSimple1, $dataObjectSimple2]; break; case 'emptyData': return $objectManager->getObject( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes::class, ['data' => []] ); default: return null; } return $objectManager->getObject( - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes', + \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes::class, ['data' => [ 'custom_attributes' => [ TestService::CUSTOM_ATTRIBUTE_CODE => $objectManager->getObject( - 'Magento\Framework\Api\AttributeValue', + \Magento\Framework\Api\AttributeValue::class, ['data' => [ 'attribute_code' => TestService::CUSTOM_ATTRIBUTE_CODE, From ef8fa86e81a4d2fe800299a14f433277aaabe308 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:17:20 +0300 Subject: [PATCH 04/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Code/Generator/Converter.php | 2 +- .../ObjectManager/Code/Generator/Factory.php | 2 +- .../Code/Generator/Persistor.php | 6 +- .../ObjectManager/Code/Generator/Proxy.php | 34 ++-- .../Code/Generator/Repository.php | 7 +- .../ObjectManager/Config/Compiled.php | 2 +- .../ObjectManager/Config/Reader/Dom.php | 2 +- .../Config/Reader/DomFactory.php | 2 +- .../ObjectManager/DefinitionFactory.php | 4 +- .../ObjectManager/InterceptableValidator.php | 2 +- .../Framework/ObjectManager/ObjectManager.php | 2 +- .../Profiler/Code/Generator/Logger.php | 4 +- .../Profiler/FactoryDecorator.php | 2 +- .../Unit/Code/Generator/ConverterTest.php | 32 ++-- .../Test/Unit/Code/Generator/FactoryTest.php | 10 +- .../Code/Generator/GenerateRepositoryTest.php | 10 +- .../Test/Unit/Code/Generator/ProxyTest.php | 11 +- .../Unit/Code/Generator/RepositoryTest.php | 13 +- .../Test/Unit/Config/ConfigTest.php | 4 +- .../Test/Unit/Config/Mapper/DomTest.php | 6 +- .../Unit/Config/Reader/DomFactoryTest.php | 6 +- .../Test/Unit/Config/Reader/DomTest.php | 8 +- .../Test/Unit/Config/SchemaLocatorTest.php | 2 +- .../Test/Unit/Definition/CompiledStub.php | 25 +++ .../Test/Unit/Definition/CompiledTest.php | 22 +-- .../Test/Unit/DefinitionFactoryTest.php | 16 +- .../Test/Unit/Factory/CompiledTest.php | 36 ++-- .../Test/Unit/Factory/FactoryTest.php | 61 +++++-- .../Test/Unit/Helper/CompositeTest.php | 4 +- .../Test/Unit/InterceptableValidatorTest.php | 4 +- .../Test/Unit/ObjectManagerTest.php | 167 +++++++++--------- .../Unit/Profiler/FactoryDecoratorTest.php | 10 +- .../Test/Unit/Relations/RuntimeTest.php | 16 +- .../ObjectManager/Test/Unit/TMapTest.php | 4 +- .../Adapter/Mysql/AggregationFactory.php | 9 +- .../Search/Adapter/Mysql/DocumentFactory.php | 7 +- .../Adapter/Mysql/Field/FieldFactory.php | 2 +- .../Mysql/Query/MatchContainerFactory.php | 2 +- .../Mysql/Query/QueryContainerFactory.php | 2 +- .../Search/Adapter/Mysql/ResponseFactory.php | 2 +- .../Adapter/Mysql/ScoreBuilderFactory.php | 2 +- .../Adapter/Mysql/TemporaryStorageFactory.php | 2 +- .../Search/Dynamic/EntityStorageFactory.php | 2 +- .../Framework/Search/Request/Builder.php | 6 +- .../Request/Config/FilesystemReader.php | 2 +- .../Framework/Search/Request/Mapper.php | 24 +-- .../Search/SearchEngine/Config/Reader.php | 2 +- .../Test/Unit/Adapter/Mysql/AdapterTest.php | 32 ++-- .../Aggregation/Builder/ContainerTest.php | 2 +- .../Mysql/Aggregation/Builder/MetricsTest.php | 6 +- .../Mysql/Aggregation/Builder/RangeTest.php | 18 +- .../Mysql/Aggregation/Builder/TermTest.php | 12 +- .../Adapter/Mysql/Aggregation/BuilderTest.php | 27 +-- .../Aggregation/DataProviderContainerTest.php | 2 +- .../Adapter/Mysql/ConditionManagerTest.php | 6 +- .../Mysql/Filter/Builder/RangeTest.php | 6 +- .../Adapter/Mysql/Filter/Builder/TermTest.php | 6 +- .../Mysql/Filter/Builder/WildcardTest.php | 6 +- .../Unit/Adapter/Mysql/Filter/BuilderTest.php | 21 ++- .../Test/Unit/Adapter/Mysql/MapperTest.php | 50 +++--- .../Adapter/Mysql/Query/Builder/MatchTest.php | 16 +- .../Mysql/Query/QueryContainerTest.php | 8 +- .../Adapter/Mysql/ResponseFactoryTest.php | 8 +- .../Unit/Adapter/Mysql/ScoreBuilderTest.php | 2 +- .../Adapter/Mysql/TemporaryStorageTest.php | 18 +- .../Search/Test/Unit/DocumentTest.php | 4 +- .../Test/Unit/Dynamic/IntervalFactoryTest.php | 8 +- .../Unit/Request/Aggregation/StatusTest.php | 4 +- .../Search/Test/Unit/Request/BinderTest.php | 2 +- .../Search/Test/Unit/Request/BuilderTest.php | 16 +- .../Search/Test/Unit/Request/CleanerTest.php | 4 +- .../Unit/Request/Config/SchemaLocatorTest.php | 2 +- .../Search/Test/Unit/Request/MapperTest.php | 103 +++++------ .../Test/Unit/Response/AggregationTest.php | 4 +- .../Test/Unit/Response/QueryResponseTest.php | 8 +- .../SearchEngine/Config/SchemaLocatorTest.php | 2 +- .../Test/Unit/SearchResponseBuilderTest.php | 18 +- .../Framework/Search/Test/Unit/SearchTest.php | 42 +++-- .../Stdlib/Cookie/CookieMetadataFactory.php | 6 +- .../Stdlib/DateTime/DateTimeFormatter.php | 2 +- .../Test/Unit/Cookie/CookieScopeTest.php | 18 +- .../Test/Unit/Cookie/PhpCookieManagerTest.php | 34 ++-- .../Unit/Cookie/PublicCookieMetadataTest.php | 2 +- .../Cookie/SensitiveCookieMetadataTest.php | 10 +- .../Unit/DateTime/DateTimeFormatterTest.php | 6 +- .../Test/Unit/DateTime/DateTimeTest.php | 2 +- .../Test/Unit/DateTime/Filter/DateTest.php | 4 +- .../Unit/DateTime/Filter/DateTimeTest.php | 4 +- .../Test/Unit/App/Scope/SourceTest.php | 6 +- .../Framework/Test/Unit/AuthorizationTest.php | 4 +- .../Framework/Test/Unit/CurrencyTest.php | 6 +- .../Framework/Test/Unit/EventFactoryTest.php | 6 +- .../Magento/Framework/Test/Unit/EventTest.php | 4 +- .../Framework/Test/Unit/FilesystemTest.php | 10 +- .../Magento/Framework/Test/Unit/FlagTest.php | 18 +- .../Framework/Test/Unit/ObjectTest.php | 6 +- .../Framework/Test/Unit/PhraseTest.php | 4 +- .../Framework/Test/Unit/ProfilerTest.php | 38 ++-- .../Framework/Test/Unit/RegistryTest.php | 4 +- .../Magento/Framework/Test/Unit/ShellTest.php | 2 +- .../Framework/Test/Unit/TranslateTest.php | 34 ++-- .../Magento/Framework/Test/Unit/UrlTest.php | 42 ++--- .../Test/Unit/ValidatorFactoryTest.php | 9 +- .../Framework/Test/Unit/ValidatorTest.php | 20 ++- .../View/Design/Theme/Label/OptionsTest.php | 2 +- 105 files changed, 727 insertions(+), 641 deletions(-) create mode 100644 lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/CompiledStub.php diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php index 82b6ed9efdd02..b1d74de6b6518 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php @@ -107,7 +107,7 @@ protected function _getClassMethods() 'parameters' => [ [ 'name' => $paramName, - 'type' => '\Magento\Framework\Api\AbstractExtensibleObject', + 'type' => \Magento\Framework\Api\AbstractExtensibleObject::class, ], ], 'body' => $body, diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php index 51c3ae378bec7..51c9bf58bef03 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php @@ -43,7 +43,7 @@ protected function _getDefaultConstructorDefinition() return [ 'name' => '__construct', 'parameters' => [ - ['name' => 'objectManager', 'type' => '\Magento\Framework\ObjectManagerInterface'], + ['name' => 'objectManager', 'type' => '\\' . \Magento\Framework\ObjectManagerInterface::class], ['name' => 'instanceName', 'defaultValue' => $this->getSourceClassName()], ], 'body' => "\$this->_objectManager = \$objectManager;\n\$this->_instanceName = \$instanceName;", diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php index 5c7e80e7b3467..80218546f2642 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php @@ -60,7 +60,7 @@ protected function _getClassProperties() 'tags' => [ [ 'name' => 'var', - 'description' => '\Magento\Framework\App\ResourceConnection', + 'description' => '\\' . \Magento\Framework\App\ResourceConnection::class, ], ], ] @@ -73,7 +73,7 @@ protected function _getClassProperties() 'tags' => [ [ 'name' => 'var', - 'description' => '\Magento\Framework\DB\Adapter\AdapterInterface', + 'description' => '\\' . \Magento\Framework\DB\Adapter\AdapterInterface::class, ], ], ] @@ -182,7 +182,7 @@ protected function _getDefaultConstructorDefinition() ], [ 'name' => 'resource', - 'type' => '\Magento\Framework\App\ResourceConnection' + 'type' => '\\' . \Magento\Framework\App\ResourceConnection::class ], ], 'body' => "\$this->" diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php index ef8fb2c47854c..3563c883ac70d 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php @@ -17,7 +17,7 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract /** * Marker interface */ - const NON_INTERCEPTABLE_INTERFACE = '\Magento\Framework\ObjectManager\NoninterceptableInterface'; + const NON_INTERCEPTABLE_INTERFACE = \Magento\Framework\ObjectManager\NoninterceptableInterface::class; /** * @param string $modelClassName @@ -99,11 +99,11 @@ protected function _getClassMethods() 'name' => '_getSubject', 'visibility' => 'protected', 'body' => "if (!\$this->_subject) {\n" . - " \$this->_subject = true === \$this->_isShared\n" . - " ? \$this->_objectManager->get(\$this->_instanceName)\n" . - " : \$this->_objectManager->create(\$this->_instanceName);\n" . - "}\n" . - "return \$this->_subject;", + " \$this->_subject = true === \$this->_isShared\n" . + " ? \$this->_objectManager->get(\$this->_instanceName)\n" . + " : \$this->_objectManager->create(\$this->_instanceName);\n" . + "}\n" . + "return \$this->_subject;", 'docblock' => [ 'shortDescription' => 'Get proxied instance', 'tags' => [['name' => 'return', 'description' => $this->getSourceClassName()]], @@ -113,12 +113,12 @@ protected function _getClassMethods() $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($publicMethods as $method) { if (!($method->isConstructor() || - $method->isFinal() || - $method->isStatic() || - $method->isDestructor()) && !in_array( - $method->getName(), - ['__sleep', '__wakeup', '__clone'] - ) + $method->isFinal() || + $method->isStatic() || + $method->isDestructor()) && !in_array( + $method->getName(), + ['__sleep', '__wakeup', '__clone'] + ) ) { $methods[] = $this->_getMethodInfo($method); } @@ -136,10 +136,10 @@ protected function _generateCode() $reflection = new \ReflectionClass($typeName); if ($reflection->isInterface()) { - $this->_classGenerator->setImplementedInterfaces([$typeName, self::NON_INTERCEPTABLE_INTERFACE]); + $this->_classGenerator->setImplementedInterfaces([$typeName, '\\' . self::NON_INTERCEPTABLE_INTERFACE]); } else { $this->_classGenerator->setExtendedClass($typeName); - $this->_classGenerator->setImplementedInterfaces([self::NON_INTERCEPTABLE_INTERFACE]); + $this->_classGenerator->setImplementedInterfaces(['\\' . self::NON_INTERCEPTABLE_INTERFACE]); } return parent::_generateCode(); } @@ -186,13 +186,13 @@ protected function _getDefaultConstructorDefinition() return [ 'name' => '__construct', 'parameters' => [ - ['name' => 'objectManager', 'type' => '\Magento\Framework\ObjectManagerInterface'], + ['name' => 'objectManager', 'type' => '\\' . \Magento\Framework\ObjectManagerInterface::class], ['name' => 'instanceName', 'defaultValue' => $this->getSourceClassName()], ['name' => 'shared', 'defaultValue' => true], ], 'body' => "\$this->_objectManager = \$objectManager;" . - "\n\$this->_instanceName = \$instanceName;" . - "\n\$this->_isShared = \$shared;", + "\n\$this->_instanceName = \$instanceName;" . + "\n\$this->_isShared = \$shared;", 'docblock' => [ 'shortDescription' => ucfirst(static::ENTITY_TYPE) . ' constructor', 'tags' => [ diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php index 00e6bf473e113..c520835f09f8c 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php @@ -81,7 +81,8 @@ protected function _getClassProperties() 'tags' => [ [ 'name' => 'var', - 'description' => '\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + 'description' => + '\\' . \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, ], ], ] @@ -153,7 +154,7 @@ protected function _getDefaultConstructorDefinition() ], [ 'name' => 'extensionAttributesJoinProcessor', - 'type' => '\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + 'type' => '\\' . \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, ], ], 'body' => "\$this->" @@ -178,7 +179,7 @@ protected function _getDefaultConstructorDefinition() ], [ 'name' => 'param', - 'description' => '\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface' + 'description' => '\\' . \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class . " \$extensionAttributesJoinProcessor" ], ], diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php b/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php index 227b9444b6061..a3ed3b941844e 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php @@ -76,7 +76,7 @@ public function getArguments($type) } return $this->arguments[$type]; } else { - return [['_i_' => 'Magento\Framework\ObjectManagerInterface']]; + return [['_i_' => \Magento\Framework\ObjectManagerInterface::class]]; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php b/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php index 59c68b2163c86..c0be553334f8d 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php @@ -40,7 +40,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'di.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Reader/DomFactory.php b/lib/internal/Magento/Framework/ObjectManager/Config/Reader/DomFactory.php index 0338e89d0de92..6ac554142feab 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Reader/DomFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Reader/DomFactory.php @@ -34,7 +34,7 @@ class DomFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\ObjectManager\Config\Reader\Dom' + $instanceName = \Magento\Framework\ObjectManager\Config\Reader\Dom::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index 4d76aa2c69b1f..40959aa196694 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -63,8 +63,8 @@ class DefinitionFactory * @var array */ protected static $definitionClasses = [ - Binary::MODE_NAME => '\Magento\Framework\ObjectManager\Definition\Compiled\Binary', - Serialized::MODE_NAME => '\Magento\Framework\ObjectManager\Definition\Compiled\Serialized', + Binary::MODE_NAME => \Magento\Framework\ObjectManager\Definition\Compiled\Binary::class, + Serialized::MODE_NAME => \Magento\Framework\ObjectManager\Definition\Compiled\Serialized::class, ]; /** diff --git a/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php b/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php index 7054239f76f9f..e8de47a13aae9 100644 --- a/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php +++ b/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php @@ -39,7 +39,7 @@ private function isInterceptable($instanceName) { return !is_subclass_of( $instanceName, - \Magento\Framework\ObjectManager\Code\Generator\Proxy::NON_INTERCEPTABLE_INTERFACE + '\\' . \Magento\Framework\ObjectManager\Code\Generator\Proxy::NON_INTERCEPTABLE_INTERFACE ); } diff --git a/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php b/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php index 1eb1dcd227cf7..f8be1abe0d1f1 100644 --- a/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php +++ b/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php @@ -41,7 +41,7 @@ public function __construct(FactoryInterface $factory, ConfigInterface $config, $this->_config = $config; $this->_factory = $factory; $this->_sharedInstances = &$sharedInstances; - $this->_sharedInstances['Magento\Framework\ObjectManagerInterface'] = $this; + $this->_sharedInstances[\Magento\Framework\ObjectManagerInterface::class] = $this; } /** diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php index 4cb677c631fc0..cdb5a39618276 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php @@ -36,7 +36,7 @@ protected function _getClassProperties() 'docblock' => [ 'shortDescription' => 'Object Manager factory log', 'tags' => [ - ['name' => 'var', 'description' => '\Magento\Framework\ObjectManager\Factory\Log'], + ['name' => 'var', 'description' => '\\' . \Magento\Framework\ObjectManager\Factory\Log::class], ], ], ], @@ -46,7 +46,7 @@ protected function _getClassProperties() 'docblock' => [ 'shortDescription' => 'Object Manager instance', 'tags' => [ - ['name' => 'var', 'description' => '\Magento\Framework\ObjectManagerInterface'], + ['name' => 'var', 'description' => '\\' . \Magento\Framework\ObjectManagerInterface::class], ], ], ], diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php index 8ff2e2f8ef2b3..d4eaefc041196 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php @@ -11,7 +11,7 @@ class FactoryDecorator implements \Magento\Framework\ObjectManager\FactoryInterf /** * Name of the class that generates logging wrappers */ - const GENERATOR_NAME = 'Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger'; + const GENERATOR_NAME = \Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger::class; /** * @var \Magento\Framework\ObjectManager\FactoryInterface diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ConverterTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ConverterTest.php index 64ba9230fe58a..9b3c1e3701e4e 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ConverterTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ConverterTest.php @@ -14,8 +14,15 @@ */ class ConverterTest extends \PHPUnit_Framework_TestCase { - const SOURCE_CLASS_NAME = '\Magento\Framework\ObjectManager\Code\Generator\Sample'; - const RESULT_CLASS_NAME = '\Magento\Framework\ObjectManager\Code\Generator\SampleConverter'; + /** + * @var string + */ + private $sourceClassName; + + /** + * @var string + */ + private $resultClassName; /** * @var Io | \PHPUnit_Framework_MockObject_MockObject @@ -39,30 +46,33 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->sourceClassName = '\\' . \Magento\Framework\ObjectManager\Code\Generator\Sample::class; + $this->resultClassName = '\\' . \Magento\Framework\ObjectManager\Code\Generator\SampleConverter::class; + $this->ioObjectMock = $this->getMock( - 'Magento\Framework\Code\Generator\Io', + \Magento\Framework\Code\Generator\Io::class, [], [], '', false ); $this->classGenerator = $this->getMock( - 'Magento\Framework\Code\Generator\ClassGenerator', + \Magento\Framework\Code\Generator\ClassGenerator::class, [], [], '', false ); - $this->definedClassesMock = $this->getMockBuilder('Magento\Framework\Code\Generator\DefinedClasses') + $this->definedClassesMock = $this->getMockBuilder(\Magento\Framework\Code\Generator\DefinedClasses::class) ->disableOriginalConstructor()->getMock(); $objectManager = new ObjectManager($this); $this->generator = $objectManager->getObject( - 'Magento\Framework\ObjectManager\Code\Generator\Converter', + \Magento\Framework\ObjectManager\Code\Generator\Converter::class, [ - 'sourceClassName' => self::SOURCE_CLASS_NAME, - 'resultClassName' => self::RESULT_CLASS_NAME, + 'sourceClassName' => $this->sourceClassName, + 'resultClassName' => $this->resultClassName, 'ioObject' => $this->ioObjectMock, 'classGenerator' => $this->classGenerator, 'definedClasses' => $this->definedClassesMock @@ -82,13 +92,13 @@ public function testGenerate() $this->ioObjectMock->expects($this->once()) ->method('makeResultFileDirectory') - ->with(self::RESULT_CLASS_NAME) + ->with($this->resultClassName) ->will($this->returnValue(true)); //Mocking _generateCode call $this->classGenerator->expects($this->once()) ->method('setName') - ->with(self::RESULT_CLASS_NAME) + ->with($this->resultClassName) ->willReturnSelf(); $this->classGenerator->expects($this->once()) ->method('addProperties') @@ -106,7 +116,7 @@ public function testGenerate() //Mocking generation $this->ioObjectMock->expects($this->any()) ->method('generateResultFileName') - ->with(self::RESULT_CLASS_NAME) + ->with($this->resultClassName) ->will($this->returnValue($resultFileName)); $this->ioObjectMock->expects($this->once()) ->method('writeResultFile') diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/FactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/FactoryTest.php index 00fb0ae393b57..f7ce4a7cb902c 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/FactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/FactoryTest.php @@ -15,27 +15,27 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ioObjectMock = $this->getMock('\Magento\Framework\Code\Generator\Io', [], [], '', false); + $this->ioObjectMock = $this->getMock(\Magento\Framework\Code\Generator\Io::class, [], [], '', false); } public function testGenerate() { require_once __DIR__ . '/_files/Sample.php'; $model = $this->getMock( - '\Magento\Framework\ObjectManager\Code\Generator\Factory', + \Magento\Framework\ObjectManager\Code\Generator\Factory::class, ['_validateData'], [ - '\Magento\Framework\ObjectManager\Code\Generator\Sample', + \Magento\Framework\ObjectManager\Code\Generator\Sample::class, null, $this->ioObjectMock, null, null, - $this->getMock('Magento\Framework\Filesystem\FileResolver') + $this->getMock(\Magento\Framework\Filesystem\FileResolver::class) ] ); $this->ioObjectMock->expects($this->once())->method('generateResultFileName') - ->with('\Magento\Framework\ObjectManager\Code\Generator\SampleFactory') + ->with('\\' . \Magento\Framework\ObjectManager\Code\Generator\SampleFactory::class) ->will($this->returnValue('sample_file.php')); $factoryCode = file_get_contents(__DIR__ . '/_files/SampleFactory.txt'); $this->ioObjectMock->expects($this->once())->method('writeResultFile') diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/GenerateRepositoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/GenerateRepositoryTest.php index 3080bd731900e..21ba8defc06c9 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/GenerateRepositoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/GenerateRepositoryTest.php @@ -23,7 +23,7 @@ class GenerateRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->ioObjectMock = $this->getMock( - '\Magento\Framework\Code\Generator\Io', + \Magento\Framework\Code\Generator\Io::class, [], [], '', @@ -39,23 +39,23 @@ public function testGenerate() require_once __DIR__ . '/_files/Sample.php'; /** @var \PHPUnit_Framework_MockObject_MockObject $model */ $model = $this->getMock( - 'Magento\Framework\ObjectManager\Code\Generator\Repository', + \Magento\Framework\ObjectManager\Code\Generator\Repository::class, [ '_validateData' ], [ - '\Magento\Framework\ObjectManager\Code\Generator\Sample', + \Magento\Framework\ObjectManager\Code\Generator\Sample::class, null, $this->ioObjectMock, null, null, - $this->getMock('Magento\Framework\Filesystem\FileResolver') + $this->getMock(\Magento\Framework\Filesystem\FileResolver::class) ] ); $this->ioObjectMock->expects($this->once()) ->method('generateResultFileName') - ->with('\Magento\Framework\ObjectManager\Code\Generator\SampleRepository') + ->with('\\' . \Magento\Framework\ObjectManager\Code\Generator\SampleRepository::class) ->willReturn('SampleRepository.php'); $repositoryCode = file_get_contents(__DIR__ . '/_files/SampleRepository.txt'); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ProxyTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ProxyTest.php index 3dc358a42c582..db15ba92d1cd2 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ProxyTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/ProxyTest.php @@ -15,27 +15,28 @@ class ProxyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ioObjectMock = $this->getMock('\Magento\Framework\Code\Generator\Io', [], [], '', false); + $this->ioObjectMock = $this->getMock(\Magento\Framework\Code\Generator\Io::class, [], [], '', false); } public function testGenerate() { require_once __DIR__ . '/_files/Sample.php'; $model = $this->getMock( - '\Magento\Framework\ObjectManager\Code\Generator\Proxy', + \Magento\Framework\ObjectManager\Code\Generator\Proxy::class, ['_validateData'], - ['\Magento\Framework\ObjectManager\Code\Generator\Sample', + [ + \Magento\Framework\ObjectManager\Code\Generator\Sample::class, null, $this->ioObjectMock, null, null, - $this->getMock('Magento\Framework\Filesystem\FileResolver') + $this->getMock(\Magento\Framework\Filesystem\FileResolver::class) ] ); $sampleProxyCode = file_get_contents(__DIR__ . '/_files/SampleProxy.txt'); $this->ioObjectMock->expects($this->once())->method('generateResultFileName') - ->with('\Magento\Framework\ObjectManager\Code\Generator\Sample_Proxy') + ->with('\\' . \Magento\Framework\ObjectManager\Code\Generator\Sample_Proxy::class) ->will($this->returnValue('sample_file.php')); $this->ioObjectMock->expects($this->once())->method('writeResultFile') ->with('sample_file.php', $sampleProxyCode); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php index b3b9619d8723c..32bbc4ac8e317 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php @@ -13,29 +13,24 @@ */ class RepositoryTest extends EntityChildTestAbstract { - const SOURCE_CLASS_NAME = '\Magento\Framework\ObjectManager\Code\Generator\Sample'; - const RESULT_CLASS_NAME = '\Magento\Framework\ObjectManager\Code\Generator\Sample\Repository'; - const GENERATOR_CLASS_NAME = 'Magento\Framework\ObjectManager\Code\Generator\Repository'; - const OUTPUT_FILE_NAME = 'SampleConverter.php'; - protected function getSourceClassName() { - return self::SOURCE_CLASS_NAME; + return '\\' . \Magento\Framework\ObjectManager\Code\Generator\Sample::class; } protected function getResultClassName() { - return self::RESULT_CLASS_NAME; + return '\\' . \Magento\Framework\ObjectManager\Code\Generator\Sample\Repository::class; } protected function getGeneratorClassName() { - return self::GENERATOR_CLASS_NAME; + return '\\' . \Magento\Framework\ObjectManager\Code\Generator\Repository::class; } protected function getOutputFileName() { - return self::OUTPUT_FILE_NAME; + return 'SampleConverter.php'; } protected function mockDefinedClassesCall() diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php index 0876f2f365f8c..844d5fa94a627 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php @@ -35,10 +35,10 @@ private function _assertFooTypeArguments(Config $config) public function testExtendWithCacheMock() { - $definitions = $this->getMock('Magento\Framework\ObjectManager\DefinitionInterface'); + $definitions = $this->getMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); $definitions->expects($this->once())->method('getClasses')->will($this->returnValue(['FooType'])); - $cache = $this->getMock('Magento\Framework\ObjectManager\ConfigCacheInterface'); + $cache = $this->getMock(\Magento\Framework\ObjectManager\ConfigCacheInterface::class); $cache->expects($this->once())->method('get')->will($this->returnValue(false)); $config = new Config(null, $definitions); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/DomTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/DomTest.php index 8ca486230a4ad..25dc156080cfc 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/DomTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/DomTest.php @@ -21,7 +21,7 @@ class DomTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $argumentParser = $this->getMock('\Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser'); + $argumentParser = $this->getMock(\Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser::class); $argumentParser->expects( $this->any() )->method( @@ -30,7 +30,7 @@ protected function setUp() $this->returnCallback([$this, 'parserMockCallback']) ); - $booleanUtils = $this->getMock('\Magento\Framework\Stdlib\BooleanUtils'); + $booleanUtils = $this->getMock(\Magento\Framework\Stdlib\BooleanUtils::class); $booleanUtils->expects( $this->any() )->method( @@ -39,7 +39,7 @@ protected function setUp() $this->returnValueMap([['true', true], ['false', false]]) ); - $this->argumentInterpreter = $this->getMock('Magento\Framework\Data\Argument\InterpreterInterface'); + $this->argumentInterpreter = $this->getMock(\Magento\Framework\Data\Argument\InterpreterInterface::class); $this->argumentInterpreter->expects( $this->any() )->method( diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomFactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomFactoryTest.php index 4532c8ce77a49..2f5c6027d0f1f 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomFactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomFactoryTest.php @@ -27,9 +27,9 @@ class DomFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_object = $this->getMock('Magento\Framework\ObjectManager\Config\Reader\Dom', [], [], '', false); + $this->_object = $this->getMock(\Magento\Framework\ObjectManager\Config\Reader\Dom::class, [], [], '', false); $this->_objectManager = $this->getMock( - '\Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', @@ -42,7 +42,7 @@ public function testCreate() { $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\ObjectManager\Config\Reader\Dom') + ->with(\Magento\Framework\ObjectManager\Config\Reader\Dom::class) ->will($this->returnValue($this->_object)); $this->_factory->create([1]); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomTest.php index 30766bbf05259..01bca1c688266 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/DomTest.php @@ -37,23 +37,23 @@ class DomTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fileResolverMock = $this->getMock('\Magento\Framework\Config\FileResolverInterface'); + $this->fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); $this->converterMock = $this->getMock( - '\Magento\Framework\ObjectManager\Config\Mapper\Dom', + \Magento\Framework\ObjectManager\Config\Mapper\Dom::class, [], [], '', false ); $this->schemaLocatorMock = $this->getMock( - '\Magento\Framework\ObjectManager\Config\SchemaLocator', + \Magento\Framework\ObjectManager\Config\SchemaLocator::class, [], [], '', false ); $this->validationStateMock = $this->getMock( - '\Magento\Framework\Config\ValidationStateInterface', + \Magento\Framework\Config\ValidationStateInterface::class, [], [], '', diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/SchemaLocatorTest.php index a1a42021276df..84adc07177028 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/SchemaLocatorTest.php @@ -21,7 +21,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->model = new \Magento\Framework\ObjectManager\Config\SchemaLocator($this->urnResolverMock); $property = new \ReflectionProperty($this->model, 'urnResolver'); $property->setAccessible(true); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/CompiledStub.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/CompiledStub.php new file mode 100644 index 0000000000000..16b8436a0c41a --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/CompiledStub.php @@ -0,0 +1,25 @@ +getMock( - '\Magento\Framework\Code\Reader\ClassReader', + \Magento\Framework\Code\Reader\ClassReader::class, ['getConstructor'], [], '', @@ -26,7 +26,7 @@ public function testGetParametersWithUndefinedDefinition() ->with($className) ->willReturn($undefinedDefinitionSignature); $model = $objectManager->getObject( - 'Magento\Framework\ObjectManager\Test\Unit\Definition\CompiledStub', + \Magento\Framework\ObjectManager\Test\Unit\Definition\CompiledStub::class, [ 'definitions' => [[], []], 'reader' => $readerMock @@ -35,21 +35,3 @@ public function testGetParametersWithUndefinedDefinition() $this->assertEquals($undefinedDefinitionSignature, $model->getParameters($className)); } } - -/** - * Stub class for abstract Magento\Framework\ObjectManager\DefinitionInterface - */ -class CompiledStub extends Compiled -{ - - /** - * Unpack signature - * - * @param string $signature - * @return mixed - */ - protected function _unpack($signature) - { - return unserialize($signature); - } -} diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/DefinitionFactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/DefinitionFactoryTest.php index 15c42a8e83aa6..468e01ce80aba 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/DefinitionFactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/DefinitionFactoryTest.php @@ -29,7 +29,7 @@ protected function setUp() { $this->sampleContent = serialize([1, 2, 3]); $this->filesystemDriverMock = $this->getMock( - 'Magento\Framework\Filesystem\Driver\File', + \Magento\Framework\Filesystem\Driver\File::class, [], [], '', @@ -46,7 +46,7 @@ protected function setUp() public function testCreateClassDefinitionFromString() { $this->assertInstanceOf( - '\Magento\Framework\ObjectManager\Definition\Compiled\Serialized', + \Magento\Framework\ObjectManager\Definition\Compiled\Serialized::class, $this->model->createClassDefinition($this->sampleContent) ); } @@ -73,13 +73,11 @@ public function createPluginsAndRelationsReadableDataProvider() return [ 'relations' => [ 'DefinitionDir/relations.ser', - 'createRelations', - '\Magento\Framework\ObjectManager\Relations\Compiled', + 'createRelations', \Magento\Framework\ObjectManager\Relations\Compiled::class, ], 'plugins' => [ 'DefinitionDir/plugins.ser', - 'createPluginDefinition', - '\Magento\Framework\Interception\Definition\Compiled', + 'createPluginDefinition', \Magento\Framework\Interception\Definition\Compiled::class, ], ]; } @@ -103,13 +101,11 @@ public function createPluginsAndRelationsNotReadableDataProvider() return [ 'relations' => [ 'DefinitionDir/relations.ser', - 'createRelations', - '\Magento\Framework\ObjectManager\Relations\Runtime', + 'createRelations', \Magento\Framework\ObjectManager\Relations\Runtime::class, ], 'plugins' => [ 'DefinitionDir/plugins.ser', - 'createPluginDefinition', - '\Magento\Framework\Interception\Definition\Runtime', + 'createPluginDefinition', \Magento\Framework\Interception\Definition\Runtime::class, ], ]; } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php index dd0d2de147f82..dbf7da6bb5eab 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php @@ -36,11 +36,11 @@ class CompiledTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->setMethods([]) ->getMock(); - $this->config = $this->getMockBuilder('Magento\Framework\ObjectManager\ConfigInterface') + $this->config = $this->getMockBuilder(\Magento\Framework\ObjectManager\ConfigInterface::class) ->setMethods([]) ->getMock(); @@ -54,9 +54,10 @@ public function testCreateSimple() $expectedConfig = $this->getSimpleConfig(); $requestedType = 'requestedType'; - $type = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting'; - $sharedType = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting'; - $nonSharedType = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting'; + $type = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting::class; + $sharedType = + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting::class; + $nonSharedType = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting::class; $this->config->expects($this->any()) ->method('getArguments') @@ -87,7 +88,7 @@ public function testCreateSimple() $result = $this->factory->create($requestedType, []); $this->assertInstanceOf( - 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting', + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting::class, $result ); $this->assertInstanceOf($sharedType, $result->getSharedDependency()); @@ -102,10 +103,11 @@ public function testCreateSimpleConfiguredArguments() { $expectedConfig = $this->getSimpleNestedConfig(); - $type = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting'; + $type = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting::class; $requestedType = 'requestedType'; - $sharedType = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting'; - $nonSharedType = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting'; + $sharedType = + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting::class; + $nonSharedType = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting::class; $this->config->expects($this->any()) ->method('getArguments') @@ -137,7 +139,7 @@ public function testCreateSimpleConfiguredArguments() $result = $this->factory->create($requestedType, []); $this->assertInstanceOf( - 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting', + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\SimpleClassTesting::class, $result ); $this->assertInstanceOf($sharedType, $result->getSharedDependency()); @@ -170,10 +172,11 @@ private function getSimpleConfig() { return [ 'nonSharedDependency' => [ - '_ins_' => 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting', + '_ins_' => \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting::class, ], 'sharedDependency' => [ - '_i_' => 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting', + '_i_' => + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting::class, ], 'value' => [ '_v_' => 'value', @@ -200,10 +203,11 @@ private function getSimpleNestedConfig() { return [ 'nonSharedDependency' => [ - '_ins_' => 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting', + '_ins_' => \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencyTesting::class, ], 'sharedDependency' => [ - '_i_' => 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting', + '_i_' => + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Compiled\DependencySharedTesting::class, ], 'value' => [ '_v_' => 'value', @@ -212,13 +216,13 @@ private function getSimpleNestedConfig() '_vac_' => [ 'array_value' => 'value', 'array_configured_instance' => [ - '_i_' => 'Magento\Framework\ObjectManager\Test\Unit' + '_i_' => \Magento\Framework\ObjectManager\Test\Unit::class . '\Factory\Fixture\Compiled\DependencySharedTesting', ], 'array_configured_array' => [ 'array_array_value' => 'value', 'array_array_configured_instance' => [ - '_ins_' => 'Magento\Framework\ObjectManager' + '_ins_' => \Magento\Framework\ObjectManager::class . '\Test\Unit\Factory\Fixture\Compiled\DependencyTesting', ], ], diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php index 157b4468a27f9..91fbe465862f1 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php @@ -37,7 +37,7 @@ protected function setUp() public function testCreateNoArgs() { - $this->assertInstanceOf('StdClass', $this->factory->create('StdClass')); + $this->assertInstanceOf('StdClass', $this->factory->create(\StdClass::class)); } /** @@ -46,13 +46,13 @@ public function testCreateNoArgs() */ public function testResolveArgumentsException() { - $configMock = $this->getMock('\Magento\Framework\ObjectManager\Config\Config', [], [], '', false); + $configMock = $this->getMock(\Magento\Framework\ObjectManager\Config\Config::class, [], [], '', false); $configMock->expects($this->once())->method('getArguments') ->will($this->returnValue([ 'firstParam' => 1, ])); - $definitionsMock = $this->getMock('Magento\Framework\ObjectManager\DefinitionInterface'); + $definitionsMock = $this->getMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); $definitionsMock->expects($this->once())->method('getParameters') ->will($this->returnValue([[ 'firstParam', 'string', true, 'default_val', @@ -65,17 +65,20 @@ public function testResolveArgumentsException() ); $this->objectManager = new ObjectManager($this->factory, $this->config); $this->factory->setObjectManager($this->objectManager); - $this->factory->create('Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar', ['foo' => 'bar']); + $this->factory->create( + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, + ['foo' => 'bar'] + ); } public function testCreateOneArg() { /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar $result */ $result = $this->factory->create( - 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar', + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, ['foo' => 'bar'] ); - $this->assertInstanceOf('\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar', $result); + $this->assertInstanceOf(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, $result); $this->assertEquals('bar', $result->getFoo()); } @@ -84,15 +87,18 @@ public function testCreateWithInjectable() // let's imitate that One is injectable by providing DI configuration for it $this->config->extend( [ - 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar' => [ + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class => [ 'arguments' => ['foo' => 'bar'], ], ] ); /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two $result */ - $result = $this->factory->create('Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two'); - $this->assertInstanceOf('\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two', $result); - $this->assertInstanceOf('\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar', $result->getOne()); + $result = $this->factory->create(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two::class); + $this->assertInstanceOf(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two::class, $result); + $this->assertInstanceOf( + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, + $result->getOne() + ); $this->assertEquals('bar', $result->getOne()->getFoo()); $this->assertEquals('optional', $result->getBaz()); } @@ -126,20 +132,37 @@ public function circularDataProvider() public function testCreateUsingReflection() { - $type = 'Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Polymorphous'; - $definitions = $this->getMock('Magento\Framework\ObjectManager\DefinitionInterface'); + $type = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Polymorphous::class; + $definitions = $this->getMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); // should be more than defined in "switch" of create() method $definitions->expects($this->once())->method('getParameters')->with($type)->will($this->returnValue([ - ['one', null, false, null], ['two', null, false, null], ['three', null, false, null], - ['four', null, false, null], ['five', null, false, null], ['six', null, false, null], - ['seven', null, false, null], ['eight', null, false, null], ['nine', null, false, null], + ['one', null, false, null], + ['two', null, false, null], + ['three', null, false, null], + ['four', null, false, null], + ['five', null, false, null], + ['six', null, false, null], + ['seven', null, false, null], + ['eight', null, false, null], + ['nine', null, false, null], ['ten', null, false, null], ])); $factory = new Developer($this->config, null, $definitions); - $result = $factory->create($type, [ - 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, - 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10, - ]); + $result = $factory->create( + $type, + [ + 'one' => 1, + 'two' => 2, + 'three' => 3, + 'four' => 4, + 'five' => 5, + 'six' => 6, + 'seven' => 7, + 'eight' => 8, + 'nine' => 9, + 'ten' => 10, + ] + ); $this->assertSame(10, $result->getArg(9)); } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Helper/CompositeTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Helper/CompositeTest.php index c3c6e19816dcb..42119448d87a9 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Helper/CompositeTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Helper/CompositeTest.php @@ -26,7 +26,9 @@ class CompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->compositeHelper = $this->objectManager->getObject('Magento\Framework\ObjectManager\Helper\Composite'); + $this->compositeHelper = $this->objectManager->getObject( + \Magento\Framework\ObjectManager\Helper\Composite::class + ); } public function testFilterAndSortDeclaredComponents() diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/InterceptableValidatorTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/InterceptableValidatorTest.php index 0853c7f755106..f17cffc584a5f 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/InterceptableValidatorTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/InterceptableValidatorTest.php @@ -14,12 +14,12 @@ public function testValidate() $interceptableValidator = new \Magento\Framework\ObjectManager\InterceptableValidator(); $this->assertFalse( $interceptableValidator->validate( - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Interceptor' + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Interceptor::class ) ); $this->assertFalse( $interceptableValidator->validate( - 'Magento\Test\Di\Proxy' + \Magento\Test\Di\Proxy::class ) ); } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManagerTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManagerTest.php index 609060e9444f8..710db13efd1f1 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManagerTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManagerTest.php @@ -39,19 +39,19 @@ protected function setUp() public function testCreateCreatesNewInstanceEveryTime() { - $objectA = $this->_object->create('Magento\Test\Di\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $objectA); - $objectB = $this->_object->create('Magento\Test\Di\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $objectB); + $objectA = $this->_object->create(\Magento\Test\Di\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $objectA); + $objectB = $this->_object->create(\Magento\Test\Di\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $objectB); $this->assertNotSame($objectA, $objectB); } public function testGetCreatesNewInstanceOnlyOnce() { - $objectA = $this->_object->get('Magento\Test\Di\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $objectA); - $objectB = $this->_object->get('Magento\Test\Di\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $objectB); + $objectA = $this->_object->get(\Magento\Test\Di\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $objectA); + $objectB = $this->_object->get(\Magento\Test\Di\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $objectB); $this->assertSame($objectA, $objectB); } @@ -60,17 +60,17 @@ public function testCreateCreatesPreferredImplementation() $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child::class, ], ] ); - $interface = $this->_object->create('Magento\Test\Di\DiInterface'); - $parent = $this->_object->create('Magento\Test\Di\DiParent'); - $child = $this->_object->create('Magento\Test\Di\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $interface); - $this->assertInstanceOf('Magento\Test\Di\Child', $parent); - $this->assertInstanceOf('Magento\Test\Di\Child', $child); + $interface = $this->_object->create(\Magento\Test\Di\DiInterface::class); + $parent = $this->_object->create(\Magento\Test\Di\DiParent::class); + $child = $this->_object->create(\Magento\Test\Di\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $interface); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $parent); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $child); $this->assertNotSame($interface, $parent); $this->assertNotSame($interface, $child); } @@ -80,17 +80,17 @@ public function testGetCreatesPreferredImplementation() $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child::class, ], ] ); - $interface = $this->_object->get('Magento\Test\Di\DiInterface'); - $parent = $this->_object->get('Magento\Test\Di\DiParent'); - $child = $this->_object->get('Magento\Test\Di\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $interface); - $this->assertInstanceOf('Magento\Test\Di\Child', $parent); - $this->assertInstanceOf('Magento\Test\Di\Child', $child); + $interface = $this->_object->get(\Magento\Test\Di\DiInterface::class); + $parent = $this->_object->get(\Magento\Test\Di\DiParent::class); + $child = $this->_object->get(\Magento\Test\Di\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $interface); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $parent); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $child); $this->assertSame($interface, $parent); $this->assertSame($interface, $child); } @@ -104,12 +104,12 @@ public function testCreateThrowsExceptionIfRequiredConstructorParameterIsNotProv $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child::class, ], ] ); - $this->_object->create('Magento\Test\Di\Aggregate\AggregateParent'); + $this->_object->create(\Magento\Test\Di\Aggregate\AggregateParent::class); } public function testCreateResolvesScalarParametersAutomatically() @@ -117,23 +117,23 @@ public function testCreateResolvesScalarParametersAutomatically() $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child::class, ], - 'Magento\Test\Di\Aggregate\AggregateParent' => [ + \Magento\Test\Di\Aggregate\AggregateParent::class => [ 'arguments' => [ - 'child' => ['instance' => 'Magento\Test\Di\Child\A'], + 'child' => ['instance' => \Magento\Test\Di\Child\A::class], 'scalar' => 'scalarValue', ], ], ] ); /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ - $result = $this->_object->create('Magento\Test\Di\Aggregate\AggregateParent'); - $this->assertInstanceOf('Magento\Test\Di\Aggregate\AggregateParent', $result); - $this->assertInstanceOf('Magento\Test\Di\Child', $result->interface); - $this->assertInstanceOf('Magento\Test\Di\Child', $result->parent); - $this->assertInstanceOf('Magento\Test\Di\Child\A', $result->child); + $result = $this->_object->create(\Magento\Test\Di\Aggregate\AggregateParent::class); + $this->assertInstanceOf(\Magento\Test\Di\Aggregate\AggregateParent::class, $result); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $result->interface); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $result->parent); + $this->assertInstanceOf(\Magento\Test\Di\Child\A::class, $result->child); $this->assertEquals('scalarValue', $result->scalar); $this->assertEquals('1', $result->optionalScalar); } @@ -143,21 +143,21 @@ public function testGetCreatesSharedInstancesEveryTime() $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child::class, ], - 'Magento\Test\Di\DiInterface' => ['shared' => 0], - 'Magento\Test\Di\Aggregate\AggregateParent' => [ + \Magento\Test\Di\DiInterface::class => ['shared' => 0], + \Magento\Test\Di\Aggregate\AggregateParent::class => [ 'arguments' => ['scalar' => 'scalarValue'], ], ] ); /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ - $result = $this->_object->create('Magento\Test\Di\Aggregate\AggregateParent'); - $this->assertInstanceOf('Magento\Test\Di\Aggregate\AggregateParent', $result); - $this->assertInstanceOf('Magento\Test\Di\Child', $result->interface); - $this->assertInstanceOf('Magento\Test\Di\Child', $result->parent); - $this->assertInstanceOf('Magento\Test\Di\Child', $result->child); + $result = $this->_object->create(\Magento\Test\Di\Aggregate\AggregateParent::class); + $this->assertInstanceOf(\Magento\Test\Di\Aggregate\AggregateParent::class, $result); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $result->interface); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $result->parent); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $result->child); $this->assertNotSame($result->interface, $result->parent); $this->assertNotSame($result->interface, $result->child); $this->assertSame($result->parent, $result->child); @@ -173,17 +173,17 @@ public function testGetDetectsCircularDependency() $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child\Circular', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child\Circular::class, ], ] ); - $this->_object->create('Magento\Test\Di\Aggregate\AggregateParent'); + $this->_object->create(\Magento\Test\Di\Aggregate\AggregateParent::class); } public function testCreateIgnoresOptionalArguments() { - $instance = $this->_object->create('Magento\Test\Di\Aggregate\WithOptional'); + $instance = $this->_object->create(\Magento\Test\Di\Aggregate\WithOptional::class); $this->assertNull($instance->parent); $this->assertNull($instance->child); } @@ -193,11 +193,11 @@ public function testCreateCreatesPreconfiguredInstance() $this->_object->configure( [ 'preferences' => [ - 'Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent', - 'Magento\Test\Di\DiParent' => 'Magento\Test\Di\Child', + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class, + \Magento\Test\Di\DiParent::class => \Magento\Test\Di\Child::class, ], 'customChildType' => [ - 'type' => 'Magento\Test\Di\Aggregate\Child', + 'type' => \Magento\Test\Di\Aggregate\Child::class, 'arguments' => [ 'scalar' => 'configuredScalar', 'secondScalar' => 'configuredSecondScalar', @@ -207,7 +207,7 @@ public function testCreateCreatesPreconfiguredInstance() ] ); $customChild = $this->_object->get('customChildType'); - $this->assertInstanceOf('Magento\Test\Di\Aggregate\Child', $customChild); + $this->assertInstanceOf(\Magento\Test\Di\Aggregate\Child::class, $customChild); $this->assertEquals('configuredScalar', $customChild->scalar); $this->assertEquals('configuredSecondScalar', $customChild->secondScalar); $this->assertEquals(1, $customChild->optionalScalar); @@ -220,9 +220,9 @@ public function testParameterShareabilityConfigurationIsApplied() $this->_object->configure( [ 'customChildType' => [ - 'type' => 'Magento\Test\Di\Aggregate\Child', + 'type' => \Magento\Test\Di\Aggregate\Child::class, 'arguments' => [ - 'interface' => ['instance' => 'Magento\Test\Di\DiParent'], + 'interface' => ['instance' => \Magento\Test\Di\DiParent::class], 'scalar' => 'configuredScalar', 'secondScalar' => 'configuredSecondScalar', ], @@ -239,7 +239,7 @@ public function testParameterShareabilityConfigurationIsApplied() 'customChildType' => [ 'arguments' => [ 'interface' => [ - 'instance' => 'Magento\Test\Di\DiParent', + 'instance' => \Magento\Test\Di\DiParent::class, 'shared' => false, ], ], @@ -257,9 +257,9 @@ public function testTypeShareabilityConfigurationIsApplied() $this->_object->configure( [ 'customChildType' => [ - 'type' => 'Magento\Test\Di\Aggregate\Child', + 'type' => \Magento\Test\Di\Aggregate\Child::class, 'arguments' => [ - 'interface' => ['instance' => 'Magento\Test\Di\DiParent'], + 'interface' => ['instance' => \Magento\Test\Di\DiParent::class], 'scalar' => 'configuredScalar', 'secondScalar' => 'configuredSecondScalar', ], @@ -271,10 +271,10 @@ public function testTypeShareabilityConfigurationIsApplied() $this->assertNotSame($childA, $childB); $this->assertSame($childA->interface, $childB->interface); - $this->_object->configure(['Magento\Test\Di\DiParent' => ['shared' => false]]); + $this->_object->configure([\Magento\Test\Di\DiParent::class => ['shared' => false]]); - $parent1 = $this->_object->create('Magento\Test\Di\DiParent'); - $parent2 = $this->_object->create('Magento\Test\Di\DiParent'); + $parent1 = $this->_object->create(\Magento\Test\Di\DiParent::class); + $parent2 = $this->_object->create(\Magento\Test\Di\DiParent::class); $this->assertNotSame($parent1, $parent2); $childA = $this->_object->create('customChildType'); @@ -286,11 +286,11 @@ public function testParameterShareabilityConfigurationOverridesTypeShareability( { $this->_object->configure( [ - 'Magento\Test\Di\DiParent' => ['shared' => false], + \Magento\Test\Di\DiParent::class => ['shared' => false], 'customChildType' => [ - 'type' => 'Magento\Test\Di\Aggregate\Child', + 'type' => \Magento\Test\Di\Aggregate\Child::class, 'arguments' => [ - 'interface' => ['instance' => 'Magento\Test\Di\DiParent'], + 'interface' => ['instance' => \Magento\Test\Di\DiParent::class], 'scalar' => 'configuredScalar', 'secondScalar' => 'configuredSecondScalar', ], @@ -307,7 +307,7 @@ public function testParameterShareabilityConfigurationOverridesTypeShareability( 'customChildType' => [ 'arguments' => [ 'interface' => [ - 'instance' => 'Magento\Test\Di\DiParent', + 'instance' => \Magento\Test\Di\DiParent::class, 'shared' => true, ], ], @@ -324,8 +324,10 @@ public function testGlobalArgumentsCanBeConfigured() { $this->_object->configure( [ - 'preferences' => ['Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent'], - 'Magento\Test\Di\Aggregate\AggregateParent' => [ + 'preferences' => [ + \Magento\Test\Di\DiInterface::class => \Magento\Test\Di\DiParent::class + ], + \Magento\Test\Di\Aggregate\AggregateParent::class => [ 'arguments' => [ 'scalar' => ['argument' => 'first_param'], 'optionalScalar' => ['argument' => 'second_param'], @@ -334,7 +336,7 @@ public function testGlobalArgumentsCanBeConfigured() ] ); /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ - $result = $this->_object->create('Magento\Test\Di\Aggregate\AggregateParent'); + $result = $this->_object->create(\Magento\Test\Di\Aggregate\AggregateParent::class); $this->assertEquals('first_param_value', $result->scalar); $this->assertEquals('second_param_value', $result->optionalScalar); } @@ -342,15 +344,13 @@ public function testGlobalArgumentsCanBeConfigured() public function testConfiguredArgumentsAreInherited() { $this->_object->configure( - [ - 'Magento\Test\Di\Aggregate\AggregateParent' => [ + [\Magento\Test\Di\Aggregate\AggregateParent::class => [ 'arguments' => [ - 'interface' => ['instance' => 'Magento\Test\Di\DiParent'], + 'interface' => ['instance' => \Magento\Test\Di\DiParent::class], 'scalar' => ['argument' => 'first_param'], 'optionalScalar' => 'parentOptionalScalar', ], - ], - 'Magento\Test\Di\Aggregate\Child' => [ + ], \Magento\Test\Di\Aggregate\Child::class => [ 'arguments' => [ 'secondScalar' => 'childSecondScalar', ], @@ -359,8 +359,8 @@ public function testConfiguredArgumentsAreInherited() ); /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ - $result = $this->_object->create('Magento\Test\Di\Aggregate\Child'); - $this->assertInstanceOf('Magento\Test\Di\DiParent', $result->interface); + $result = $this->_object->create(\Magento\Test\Di\Aggregate\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\DiParent::class, $result->interface); $this->assertEquals('first_param_value', $result->scalar); $this->assertEquals('childSecondScalar', $result->secondScalar); $this->assertEquals('parentOptionalScalar', $result->optionalScalar); @@ -370,16 +370,16 @@ public function testConfiguredArgumentsOverrideInheritedArguments() { $this->_object->configure( [ - 'Magento\Test\Di\Aggregate\AggregateParent' => [ + \Magento\Test\Di\Aggregate\AggregateParent::class => [ 'arguments' => [ - 'interface' => ['instance' => 'Magento\Test\Di\DiParent'], + 'interface' => ['instance' => \Magento\Test\Di\DiParent::class], 'scalar' => ['argument' => 'first_param'], 'optionalScalar' => 'parentOptionalScalar', ], ], - 'Magento\Test\Di\Aggregate\Child' => [ + \Magento\Test\Di\Aggregate\Child::class => [ 'arguments' => [ - 'interface' => ['instance' => 'Magento\Test\Di\Child'], + 'interface' => ['instance' => \Magento\Test\Di\Child::class], 'scalar' => ['argument' => 'second_param'], 'secondScalar' => 'childSecondScalar', 'optionalScalar' => 'childOptionalScalar', @@ -389,8 +389,8 @@ public function testConfiguredArgumentsOverrideInheritedArguments() ); /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ - $result = $this->_object->create('Magento\Test\Di\Aggregate\Child'); - $this->assertInstanceOf('Magento\Test\Di\Child', $result->interface); + $result = $this->_object->create(\Magento\Test\Di\Aggregate\Child::class); + $this->assertInstanceOf(\Magento\Test\Di\Child::class, $result->interface); $this->assertEquals('second_param_value', $result->scalar); $this->assertEquals('childSecondScalar', $result->secondScalar); $this->assertEquals('childOptionalScalar', $result->optionalScalar); @@ -398,6 +398,9 @@ public function testConfiguredArgumentsOverrideInheritedArguments() public function testGetIgnoresFirstSlash() { - $this->assertSame($this->_object->get('Magento\Test\Di\Child'), $this->_object->get('Magento\Test\Di\Child')); + $this->assertSame( + $this->_object->get(\Magento\Test\Di\Child::class), + $this->_object->get(\Magento\Test\Di\Child::class) + ); } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php index 082712ff73ee4..ccac7cbb35809 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Profiler/FactoryDecoratorTest.php @@ -11,17 +11,17 @@ class FactoryDecoratorTest extends \PHPUnit_Framework_TestCase /** * Name of the base class to wrap in logger */ - const CLASS_NAME = 'Magento\Test\Di\WrappedClass'; + const CLASS_NAME = \Magento\Test\Di\WrappedClass::class; /** * Name of the wrapper class that does logging */ - const LOGGER_NAME = 'Magento\Test\Di\WrappedClass\Logger'; + const LOGGER_NAME = \Magento\Test\Di\WrappedClass\Logger::class; /** * Name of the class that generates wrappers - should not be wrapped by logger */ - const GENERATOR_NAME = 'Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger'; + const GENERATOR_NAME = \Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger::class; /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\ObjectManager\FactoryInterface*/ private $objectManagerMock; @@ -34,13 +34,13 @@ protected function setUp() require_once __DIR__ . '/../_files/logger_classes.php'; $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\FactoryInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManager\FactoryInterface::class) ->disableOriginalConstructor() ->getMock(); // Instantiate SUT $this->model = $objectManager->getObject( - 'Magento\Framework\ObjectManager\Profiler\FactoryDecorator', + \Magento\Framework\ObjectManager\Profiler\FactoryDecorator::class, ['subject' => $this->objectManagerMock] ); } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php index 8b643f4e78a78..cb274f845b668 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php @@ -34,9 +34,9 @@ public function testGetParents($type, $parents) public function getParentsDataProvider() { return [ - ['Magento\Test\Di\DiInterface', []], - ['Magento\Test\Di\DiParent', [null, 'Magento\Test\Di\DiInterface']], - ['Magento\Test\Di\Child', ['Magento\Test\Di\DiParent', 'Magento\Test\Di\ChildInterface']] + [\Magento\Test\Di\DiInterface::class, []], + [\Magento\Test\Di\DiParent::class, [null, \Magento\Test\Di\DiInterface::class]], + [\Magento\Test\Di\Child::class, [\Magento\Test\Di\DiParent::class, \Magento\Test\Di\ChildInterface::class]] ]; } @@ -52,11 +52,11 @@ public function testHasIfNonExists($entity) public function nonExistentGeneratorsDataProvider() { return [ - ['Magento\Test\Module\Model\Item\Factory'], - ['Magento\Test\Module\Model\Item\Proxy'], - ['Magento\Test\Module\Model\Item\Interceptor'], - ['Magento\Test\Module\Model\Item\Mapper'], - ['Magento\Test\Module\Model\Item\SearchResults'] + [\Magento\Test\Module\Model\Item\Factory::class], + [\Magento\Test\Module\Model\Item\Proxy::class], + [\Magento\Test\Module\Model\Item\Interceptor::class], + [\Magento\Test\Module\Model\Item\Mapper::class], + [\Magento\Test\Module\Model\Item\SearchResults::class] ]; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php index db217e6f9314f..3f80775c5f9bf 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php @@ -25,10 +25,10 @@ class TMapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->om = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->om = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMockForAbstractClass(); - $this->omConfig = $this->getMockBuilder('Magento\Framework\ObjectManager\ConfigInterface') + $this->omConfig = $this->getMockBuilder(\Magento\Framework\ObjectManager\ConfigInterface::class) ->getMockForAbstractClass(); } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php index c80fa2e4f9ed7..e7fcbff98e5ed 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php @@ -37,14 +37,17 @@ public function create(array $rawAggregation) foreach ($rawAggregation as $rawBucketName => $rawBucket) { /** @var \Magento\Framework\Search\Response\Bucket[] $buckets */ $buckets[$rawBucketName] = $this->objectManager->create( - 'Magento\Framework\Search\Response\Bucket', + \Magento\Framework\Search\Response\Bucket::class, [ 'name' => $rawBucketName, 'values' => $this->prepareValues((array)$rawBucket) ] ); } - return $this->objectManager->create('Magento\Framework\Search\Response\Aggregation', ['buckets' => $buckets]); + return $this->objectManager->create( + \Magento\Framework\Search\Response\Aggregation::class, + ['buckets' => $buckets] + ); } /** @@ -58,7 +61,7 @@ private function prepareValues(array $values) $valuesObjects = []; foreach ($values as $name => $value) { $valuesObjects[] = $this->objectManager->create( - 'Magento\Framework\Search\Response\Aggregation\Value', + \Magento\Framework\Search\Response\Aggregation\Value::class, [ 'value' => $name, 'metrics' => $value, diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php index cebcc973ce8fa..0c2c91b515e98 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php @@ -51,11 +51,14 @@ public function create($rawDocument) if ($fieldName === $entityId) { $documentId = $rawField['value']; } else { - $fields[$fieldName] = $this->objectManager->create('Magento\Framework\Search\DocumentField', $rawField); + $fields[$fieldName] = $this->objectManager->create( + \Magento\Framework\Search\DocumentField::class, + $rawField + ); } } return $this->objectManager->create( - 'Magento\Framework\Search\Document', + \Magento\Framework\Search\Document::class, ['documentFields' => $fields, 'documentId' => $documentId] ); } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php index 18326ac36ea69..66cbe02334fa1 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php @@ -31,7 +31,7 @@ class FieldFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Search\Adapter\Mysql\Field\FieldInterface' + $instanceName = \Magento\Framework\Search\Adapter\Mysql\Field\FieldInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php index a96c7545241ba..f106b0a7bee45 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php @@ -32,7 +32,7 @@ class MatchContainerFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Search\Adapter\Mysql\Query\MatchContainer' + $instanceName = \Magento\Framework\Search\Adapter\Mysql\Query\MatchContainer::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php index a4a825d00b01e..8b2a4bdce3a8d 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php @@ -32,7 +32,7 @@ class QueryContainerFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer' + $instanceName = \Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php index 369e79fd2da2c..1e3ccd165ad2f 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php @@ -63,7 +63,7 @@ public function create($rawResponse) /** @var \Magento\Framework\Search\Response\Aggregation $aggregations */ $aggregations = $this->aggregationFactory->create($rawResponse['aggregations']); return $this->objectManager->create( - 'Magento\Framework\Search\Response\QueryResponse', + \Magento\Framework\Search\Response\QueryResponse::class, [ 'documents' => $documents, 'aggregations' => $aggregations diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php index 96671e613bf34..28cd19bda70ef 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php @@ -32,7 +32,7 @@ class ScoreBuilderFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Search\Adapter\Mysql\ScoreBuilder' + $instanceName = \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php index da9e08abea9ab..282d7ee4b53a8 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php @@ -36,7 +36,7 @@ class TemporaryStorageFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Search\Adapter\Mysql\TemporaryStorage' + $instanceName = \Magento\Framework\Search\Adapter\Mysql\TemporaryStorage::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Search/Dynamic/EntityStorageFactory.php b/lib/internal/Magento/Framework/Search/Dynamic/EntityStorageFactory.php index 32333b2646dd4..4bfde016bf868 100644 --- a/lib/internal/Magento/Framework/Search/Dynamic/EntityStorageFactory.php +++ b/lib/internal/Magento/Framework/Search/Dynamic/EntityStorageFactory.php @@ -34,7 +34,7 @@ class EntityStorageFactory */ public function __construct( ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Framework\Search\Dynamic\EntityStorage' + $instanceName = \Magento\Framework\Search\Dynamic\EntityStorage::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/lib/internal/Magento/Framework/Search/Request/Builder.php b/lib/internal/Magento/Framework/Search/Request/Builder.php index 8020545c6f6e8..720cce7ea8faa 100644 --- a/lib/internal/Magento/Framework/Search/Request/Builder.php +++ b/lib/internal/Magento/Framework/Search/Request/Builder.php @@ -166,7 +166,7 @@ private function convert($data) { /** @var Mapper $mapper */ $mapper = $this->objectManager->create( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'rootQueryName' => $data['query'], @@ -176,7 +176,7 @@ private function convert($data) ] ); return $this->objectManager->create( - 'Magento\Framework\Search\Request', + \Magento\Framework\Search\Request::class, [ 'name' => $data['query'], 'indexName' => $data['index'], @@ -198,7 +198,7 @@ private function buildDimensions(array $dimensionsData) $dimensions = []; foreach ($dimensionsData as $dimensionData) { $dimensions[$dimensionData['name']] = $this->objectManager->create( - 'Magento\Framework\Search\Request\Dimension', + \Magento\Framework\Search\Request\Dimension::class, $dimensionData ); } diff --git a/lib/internal/Magento/Framework/Search/Request/Config/FilesystemReader.php b/lib/internal/Magento/Framework/Search/Request/Config/FilesystemReader.php index bce411bc27354..dbc99aeb57d08 100644 --- a/lib/internal/Magento/Framework/Search/Request/Config/FilesystemReader.php +++ b/lib/internal/Magento/Framework/Search/Request/Config/FilesystemReader.php @@ -41,7 +41,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'search_request.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php index c2bf6658eacac..59008aac5983a 100644 --- a/lib/internal/Magento/Framework/Search/Request/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php @@ -121,7 +121,7 @@ private function mapQuery($queryName) switch ($query['type']) { case QueryInterface::TYPE_MATCH: $query = $this->objectManager->create( - 'Magento\Framework\Search\Request\Query\Match', + \Magento\Framework\Search\Request\Query\Match::class, [ 'name' => $query['name'], 'value' => $query['value'], @@ -141,7 +141,7 @@ private function mapQuery($queryName) throw new \Exception('Reference is not provided'); } $query = $this->objectManager->create( - 'Magento\Framework\Search\Request\Query\Filter', + \Magento\Framework\Search\Request\Query\Filter::class, [ 'name' => $query['name'], 'boost' => isset($query['boost']) ? $query['boost'] : 1, @@ -153,7 +153,7 @@ private function mapQuery($queryName) case QueryInterface::TYPE_BOOL: $aggregatedByType = $this->aggregateQueriesByType($query['queryReference']); $query = $this->objectManager->create( - 'Magento\Framework\Search\Request\Query\BoolExpression', + \Magento\Framework\Search\Request\Query\BoolExpression::class, array_merge( ['name' => $query['name'], 'boost' => isset($query['boost']) ? $query['boost'] : 1], $aggregatedByType @@ -190,7 +190,7 @@ private function mapFilter($filterName) switch ($filter['type']) { case FilterInterface::TYPE_TERM: $filter = $this->objectManager->create( - 'Magento\Framework\Search\Request\Filter\Term', + \Magento\Framework\Search\Request\Filter\Term::class, [ 'name' => $filter['name'], 'field' => $filter['field'], @@ -200,7 +200,7 @@ private function mapFilter($filterName) break; case FilterInterface::TYPE_RANGE: $filter = $this->objectManager->create( - 'Magento\Framework\Search\Request\Filter\Range', + \Magento\Framework\Search\Request\Filter\Range::class, [ 'name' => $filter['name'], 'field' => $filter['field'], @@ -211,7 +211,7 @@ private function mapFilter($filterName) break; case FilterInterface::TYPE_WILDCARD: $filter = $this->objectManager->create( - 'Magento\Framework\Search\Request\Filter\Wildcard', + \Magento\Framework\Search\Request\Filter\Wildcard::class, [ 'name' => $filter['name'], 'field' => $filter['field'], @@ -222,7 +222,7 @@ private function mapFilter($filterName) case FilterInterface::TYPE_BOOL: $aggregatedByType = $this->aggregateFiltersByType($filter['filterReference']); $filter = $this->objectManager->create( - 'Magento\Framework\Search\Request\Filter\BoolExpression', + \Magento\Framework\Search\Request\Filter\BoolExpression::class, array_merge( ['name' => $filter['name']], $aggregatedByType @@ -327,13 +327,13 @@ public function getBuckets() switch ($bucketData['type']) { case BucketInterface::TYPE_TERM: $bucket = $this->objectManager->create( - 'Magento\Framework\Search\Request\Aggregation\TermBucket', + \Magento\Framework\Search\Request\Aggregation\TermBucket::class, $arguments ); break; case BucketInterface::TYPE_RANGE: $bucket = $this->objectManager->create( - 'Magento\Framework\Search\Request\Aggregation\RangeBucket', + \Magento\Framework\Search\Request\Aggregation\RangeBucket::class, array_merge( $arguments, ['ranges' => $this->mapRanges($bucketData)] @@ -342,7 +342,7 @@ public function getBuckets() break; case BucketInterface::TYPE_DYNAMIC: $bucket = $this->objectManager->create( - 'Magento\Framework\Search\Request\Aggregation\DynamicBucket', + \Magento\Framework\Search\Request\Aggregation\DynamicBucket::class, array_merge( $arguments, ['method' => $bucketData['method']] @@ -371,7 +371,7 @@ private function mapMetrics(array $bucketData) $metrics = $bucketData['metric']; foreach ($metrics as $metric) { $metricObjects[] = $this->objectManager->create( - 'Magento\Framework\Search\Request\Aggregation\Metric', + \Magento\Framework\Search\Request\Aggregation\Metric::class, [ 'type' => $metric['type'] ] @@ -394,7 +394,7 @@ private function mapRanges(array $bucketData) $ranges = $bucketData['range']; foreach ($ranges as $range) { $rangeObjects[] = $this->objectManager->create( - 'Magento\Framework\Search\Request\Aggregation\Range', + \Magento\Framework\Search\Request\Aggregation\Range::class, [ 'from' => $range['from'], 'to' => $range['to'] diff --git a/lib/internal/Magento/Framework/Search/SearchEngine/Config/Reader.php b/lib/internal/Magento/Framework/Search/SearchEngine/Config/Reader.php index 6965bf5216202..72a5e1ccd0180 100644 --- a/lib/internal/Magento/Framework/Search/SearchEngine/Config/Reader.php +++ b/lib/internal/Magento/Framework/Search/SearchEngine/Config/Reader.php @@ -33,7 +33,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'search_engine.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/AdapterTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/AdapterTest.php index 99eba9e3db105..8c325580bea17 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/AdapterTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/AdapterTest.php @@ -10,6 +10,9 @@ use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AdapterTest extends \PHPUnit_Framework_TestCase { /** @@ -71,20 +74,20 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\Search\RequestInterface::class) ->setMethods(['getAggregation']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->setMethods(['getConnection']) ->disableOriginalConstructor() ->getMock(); - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); - $this->connectionAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionAdapter = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->setMethods(['fetchAssoc']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -92,31 +95,32 @@ protected function setUp() ->method('getConnection') ->will($this->returnValue($this->connectionAdapter)); - $this->mapper = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Mapper') + $this->mapper = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Mapper::class) ->setMethods(['buildQuery']) ->disableOriginalConstructor() ->getMock(); - $this->responseFactory = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\ResponseFactory') + $this->responseFactory = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ResponseFactory::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); - $this->aggregatioBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder') - ->setMethods(['build']) + $this->aggregatioBuilder = $this->getMockBuilder( + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder::class + )->setMethods(['build']) ->disableOriginalConstructor() ->getMock(); - $this->bucket = $this->getMockBuilder('Magento\Framework\Search\Request\BucketInterface') + $this->bucket = $this->getMockBuilder(\Magento\Framework\Search\Request\BucketInterface::class) ->setMethods(['getType', 'getName']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->temporaryStorage = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\TemporaryStorage') + $this->temporaryStorage = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\TemporaryStorage::class) ->disableOriginalConstructor() ->getMock(); - $temporaryStorageFactoryName = 'Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory'; + $temporaryStorageFactoryName = \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory::class; $temporaryStorageFactory = $this->getMockBuilder($temporaryStorageFactoryName) ->setMethods(['create']) ->disableOriginalConstructor() @@ -126,7 +130,7 @@ protected function setUp() ->willReturn($this->temporaryStorage); $this->adapter = $this->objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Adapter', + \Magento\Framework\Search\Adapter\Mysql\Adapter::class, [ 'mapper' => $this->mapper, 'responseFactory' => $this->responseFactory, @@ -154,14 +158,14 @@ public function testQuery() ], ]; - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $this->connectionAdapter->expects($this->once()) ->method('select') ->willReturn($select); - $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/ContainerTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/ContainerTest.php index d494a7a076a2c..ea4592101251b 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/ContainerTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/ContainerTest.php @@ -25,7 +25,7 @@ public function testGet() $bucketValue = 'dataProvider'; /** @var \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Container $provider */ $provider = $this->objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Container', + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Container::class, ['buckets' => [$bucketName => $bucketValue]] ); $this->assertEquals($bucketValue, $provider->get($bucketName)); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/MetricsTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/MetricsTest.php index 465ed98b1ba1f..9a405453d5cfc 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/MetricsTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/MetricsTest.php @@ -29,17 +29,17 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->requestBucket = $this->getMockBuilder('Magento\Framework\Search\Request\BucketInterface') + $this->requestBucket = $this->getMockBuilder(\Magento\Framework\Search\Request\BucketInterface::class) ->setMethods(['getMetrics']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->metric = $this->getMockBuilder('Magento\Framework\Search\Request\Aggregation\Metric') + $this->metric = $this->getMockBuilder(\Magento\Framework\Search\Request\Aggregation\Metric::class) ->setMethods(['getType']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->metrics = $helper->getObject('Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Metrics'); + $this->metrics = $helper->getObject(\Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Metrics::class); } public function testBuild() diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/RangeTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/RangeTest.php index 986a5eac41beb..91eac77290267 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/RangeTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/RangeTest.php @@ -59,17 +59,17 @@ protected function setUp() $helper = new ObjectManager($this); $this->metricsBuilder = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Metrics' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Metrics::class ) ->setMethods(['build']) ->disableOriginalConstructor() ->getMock(); - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->setMethods(['fetchAssoc', 'select', 'getCaseSql']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -77,32 +77,32 @@ protected function setUp() ->method('select') ->willReturn($this->select); - $this->resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->any()) ->method('getConnection') ->willReturn($this->connectionMock); - $this->bucket = $this->getMockBuilder('Magento\Framework\Search\Request\BucketInterface') + $this->bucket = $this->getMockBuilder(\Magento\Framework\Search\Request\BucketInterface::class) ->setMethods(['getName', 'getRanges']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->range = $this->getMockBuilder('Magento\Framework\Search\Request\Aggregation\Range') + $this->range = $this->getMockBuilder(\Magento\Framework\Search\Request\Aggregation\Range::class) ->setMethods(['getFrom', 'getTo']) ->disableOriginalConstructor() ->getMock(); $this->dataProvider = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface::class ) ->setMethods(['getDataSet', 'execute']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->builder = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Range', + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Range::class, ['metricsBuilder' => $this->metricsBuilder, 'resource' => $this->resource] ); } @@ -154,7 +154,7 @@ public function testBuild() $this->dataProvider->expects($this->once())->method('execute')->willReturn($this->select); /** @var \Magento\Framework\DB\Ddl\Table|\PHPUnit_Framework_MockObject_MockObject $table */ - $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/TermTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/TermTest.php index eae130fa69b53..61a73de1844c8 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/TermTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/Builder/TermTest.php @@ -46,30 +46,30 @@ protected function setUp() $helper = new ObjectManager($this); $this->metricsBuilder = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Metrics' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Metrics::class ) ->setMethods(['build']) ->disableOriginalConstructor() ->getMock(); - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods(['where', 'columns', 'group']) ->disableOriginalConstructor() ->getMock(); - $this->bucket = $this->getMockBuilder('Magento\Framework\Search\Request\BucketInterface') + $this->bucket = $this->getMockBuilder(\Magento\Framework\Search\Request\BucketInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->dataProvider = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface::class ) ->setMethods(['getDataSet', 'execute']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->term = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Term', + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Term::class, ['metricsBuilder' => $this->metricsBuilder] ); } @@ -96,7 +96,7 @@ public function testBuild() $this->dataProvider->expects($this->once())->method('execute')->willReturn($this->select); /** @var \Magento\Framework\DB\Ddl\Table|\PHPUnit_Framework_MockObject_MockObject $table */ - $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/BuilderTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/BuilderTest.php index f3ed7e7b863e8..1fd7f055e449c 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/BuilderTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/BuilderTest.php @@ -10,6 +10,9 @@ use Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class BuilderTest extends \PHPUnit_Framework_TestCase { /** @@ -74,67 +77,67 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->entityMetadata = $this->getMockBuilder('Magento\Framework\Search\EntityMetadata') + $this->entityMetadata = $this->getMockBuilder(\Magento\Framework\Search\EntityMetadata::class) ->setMethods(['getEntityId']) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\Search\RequestInterface::class) ->setMethods(['getAggregation']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->bucket = $this->getMockBuilder('Magento\Framework\Search\Request\BucketInterface') + $this->bucket = $this->getMockBuilder(\Magento\Framework\Search\Request\BucketInterface::class) ->setMethods(['getName']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $this->bucketBuilder = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\BucketInterface' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\BucketInterface::class ) ->setMethods(['build']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->aggregationContainer = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Container' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\Container::class ) ->setMethods(['get']) ->disableOriginalConstructor() ->getMock(); $this->aggregationContainer->expects($this->any())->method('get')->willReturn($this->bucketBuilder); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->setMethods(['fetchAssoc']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->dataProvider = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface::class ) ->setMethods(['getDataSet']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->dataProviderContainer = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderContainer' + \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderContainer::class ) ->setMethods(['get']) ->disableOriginalConstructor() ->getMock(); $this->dataProviderContainer->expects($this->any())->method('get')->willReturn($this->dataProvider); - $this->resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); $this->builder = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder', + \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder::class, [ 'entityMetadata' => $this->entityMetadata, 'dataProviderContainer' => $this->dataProviderContainer, @@ -152,7 +155,7 @@ public function testBuild() $fetchResult = ['name' => ['some', 'result']]; /** @var \Magento\Framework\DB\Ddl\Table|\PHPUnit_Framework_MockObject_MockObject $table */ - $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/DataProviderContainerTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/DataProviderContainerTest.php index f0f6f3af39a63..0a04eefd7d08f 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/DataProviderContainerTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Aggregation/DataProviderContainerTest.php @@ -25,7 +25,7 @@ public function testGet() $bucketValue = 'dataProvider'; /** @var \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderContainer $provider */ $provider = $this->objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderContainer', + \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderContainer::class, ['dataProviders' => [$bucketName => $bucketValue]] ); $this->assertEquals($bucketValue, $provider->get($bucketName)); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ConditionManagerTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ConditionManagerTest.php index d5c5eab769be2..4c65d9105a965 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ConditionManagerTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ConditionManagerTest.php @@ -27,7 +27,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->connectionMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->setMethods(['quote', 'quoteIdentifier']) ->getMockForAbstractClass(); @@ -50,7 +50,7 @@ function ($value) { ) ); - $this->resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->once()) @@ -58,7 +58,7 @@ function ($value) { ->will($this->returnValue($this->connectionMock)); $this->conditionManager = $objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\ConditionManager', + \Magento\Framework\Search\Adapter\Mysql\ConditionManager::class, [ 'resource' => $this->resource ] diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/RangeTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/RangeTest.php index 49cba33a7f5f1..abab93a2f633e 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/RangeTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/RangeTest.php @@ -31,12 +31,12 @@ class RangeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + $this->requestFilter = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Range::class) ->setMethods(['getField', 'getFrom', 'getTo']) ->disableOriginalConstructor() ->getMock(); - $this->conditionManager = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\ConditionManager') + $this->conditionManager = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ConditionManager::class) ->disableOriginalConstructor() ->setMethods(['generateCondition']) ->getMock(); @@ -51,7 +51,7 @@ function ($field, $operator, $value) { ); $this->filter = $objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range', + \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range::class, [ 'conditionManager' => $this->conditionManager, ] diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/TermTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/TermTest.php index 08b2fcf46c9cd..1aefd9e804586 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/TermTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/TermTest.php @@ -31,12 +31,12 @@ class TermTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + $this->requestFilter = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Term::class) ->setMethods(['getField', 'getValue']) ->disableOriginalConstructor() ->getMock(); - $this->conditionManager = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\ConditionManager') + $this->conditionManager = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ConditionManager::class) ->disableOriginalConstructor() ->setMethods(['generateCondition']) ->getMock(); @@ -56,7 +56,7 @@ function ($field, $operator, $value) { ); $this->filter = $objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term', + \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term::class, [ 'conditionManager' => $this->conditionManager, ] diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/WildcardTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/WildcardTest.php index 9b4db75657eaa..fb9fbde2beb78 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/WildcardTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/Builder/WildcardTest.php @@ -31,12 +31,12 @@ class WildcardTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + $this->requestFilter = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Term::class) ->setMethods(['getField', 'getValue']) ->disableOriginalConstructor() ->getMock(); - $this->conditionManager = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\ConditionManager') + $this->conditionManager = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ConditionManager::class) ->disableOriginalConstructor() ->setMethods(['generateCondition']) ->getMock(); @@ -51,7 +51,7 @@ function ($field, $operator, $value) { ); $this->filter = $objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Wildcard', + \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Wildcard::class, [ 'conditionManager' => $this->conditionManager, ] diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/BuilderTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/BuilderTest.php index 6191d36f07200..048186d7a22be 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/BuilderTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Filter/BuilderTest.php @@ -13,6 +13,9 @@ use Magento\Framework\Search\Request\Query\BoolExpression as RequestBoolQuery; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class BuilderTest extends \PHPUnit_Framework_TestCase { /** @@ -38,7 +41,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->conditionManager = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ConditionManager') + $this->conditionManager = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ConditionManager::class) ->disableOriginalConstructor() ->setMethods(['generateCondition', 'combineQueries', 'wrapBrackets']) ->getMock(); @@ -73,7 +76,7 @@ function ($query) { ) ); - $rangeBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range') + $rangeBuilder = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range::class) ->setMethods(['buildFilter']) ->disableOriginalConstructor() ->getMock(); @@ -109,7 +112,7 @@ function (FilterInterface $filter, $isNegation) { ) ); - $termBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term') + $termBuilder = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term::class) ->setMethods(['buildFilter']) ->disableOriginalConstructor() ->getMock(); @@ -132,7 +135,7 @@ function (FilterInterface $filter, $isNegation) { ); $this->preprocessor = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Filter\PreprocessorInterface' + \Magento\Framework\Search\Adapter\Mysql\Filter\PreprocessorInterface::class ) ->setMethods(['process']) ->disableOriginalConstructor() @@ -144,7 +147,7 @@ function ($filter, $isNegation, $queryString) { ); $this->builder = $objectManager->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder', + \Magento\Framework\Search\Adapter\Mysql\Filter\Builder::class, [ 'range' => $rangeBuilder, 'term' => $termBuilder, @@ -204,7 +207,7 @@ public function buildTermFilterDataProvider() */ private function createTermFilter($field, $value) { - $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + $filter = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Term::class) ->setMethods(['getField', 'getValue']) ->disableOriginalConstructor() ->getMock(); @@ -248,7 +251,7 @@ public function buildRangeFilterDataProvider() */ private function createRangeFilter($field, $from, $to) { - $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + $filter = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Range::class) ->setMethods(['getField', 'getFrom', 'getTo']) ->disableOriginalConstructor() ->getMock(); @@ -382,7 +385,7 @@ public function buildBoolFilterDataProvider() */ private function createBoolFilter(array $must, array $should, array $mustNot) { - $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\BoolExpression') + $filter = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\BoolExpression::class) ->setMethods(['getMust', 'getShould', 'getMustNot']) ->disableOriginalConstructor() ->getMock(); @@ -405,7 +408,7 @@ private function createBoolFilter(array $must, array $should, array $mustNot) public function testUnknownFilterType() { /** @var FilterInterface|\PHPUnit_Framework_MockObject_MockObject $filter */ - $filter = $this->getMockBuilder('Magento\Framework\Search\Request\FilterInterface') + $filter = $this->getMockBuilder(\Magento\Framework\Search\Request\FilterInterface::class) ->setMethods(['getType']) ->getMockForAbstractClass(); $filter->expects($this->any()) diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/MapperTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/MapperTest.php index 8832f4a205118..4f2a931f1b462 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/MapperTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/MapperTest.php @@ -83,18 +83,18 @@ class MapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connectionAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionAdapter = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->setMethods(['select', 'dropTable']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->any())->method('getConnection') ->will($this->returnValue($this->connectionAdapter)); - $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\Search\RequestInterface::class) ->setMethods(['getQuery', 'getIndex', 'getSize']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -102,7 +102,9 @@ protected function setUp() ->method('getIndex') ->will($this->returnValue(self::INDEX_NAME)); - $this->queryContainer = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer') + $this->queryContainer = $this->getMockBuilder( + \Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer::class + ) ->setMethods(['addMatchQuery', 'getMatchQueries']) ->disableOriginalConstructor() ->getMock(); @@ -110,7 +112,7 @@ protected function setUp() ->method('addMatchQuery') ->willReturnArgument(0); - $this->temporaryStorage = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\TemporaryStorage') + $this->temporaryStorage = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\TemporaryStorage::class) ->setMethods(['storeDocumentsFromSelect']) ->disableOriginalConstructor() ->getMock(); @@ -204,7 +206,7 @@ public function testBuildQuery($query, array $derivedQueries = [], $queriesCount $this->filterBuilder->expects($this->any())->method('build')->will($this->returnValue('(1)')); - $table = $this->getMockBuilder('\Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); $this->temporaryStorage->expects($this->any()) @@ -294,7 +296,7 @@ public function testGetUnknownQueryType() { $select = $this->createSelectMock(null, false, false); $this->mockBuilders($select); - $query = $this->getMockBuilder('Magento\Framework\Search\Request\QueryInterface') + $query = $this->getMockBuilder(\Magento\Framework\Search\Request\QueryInterface::class) ->setMethods(['getType']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -332,7 +334,7 @@ protected function addDroppedTables(array $tables) */ private function createMatchQuery() { - $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + $query = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\Match::class) ->setMethods(['getType']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -348,7 +350,7 @@ private function createMatchQuery() */ private function createFilterQuery($referenceType, $reference) { - $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Filter') + $query = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\Filter::class) ->setMethods(['getType', 'getReferenceType', 'getReference']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -370,7 +372,7 @@ private function createFilterQuery($referenceType, $reference) */ private function createBoolQuery(array $must, array $should, array $mustNot) { - $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\BoolExpression') + $query = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\BoolExpression::class) ->setMethods(['getMust', 'getShould', 'getMustNot', 'getType']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -394,7 +396,7 @@ private function createBoolQuery(array $must, array $should, array $mustNot) */ private function createFilter() { - return $this->getMockBuilder('Magento\Framework\Search\Request\FilterInterface') + return $this->getMockBuilder(\Magento\Framework\Search\Request\FilterInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); } @@ -406,7 +408,7 @@ private function createFilter() */ private function createMatchContainer($request, $conditionType) { - $matchContainer = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Query\MatchContainer') + $matchContainer = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Query\MatchContainer::class) ->setMethods(['getRequest', 'getConditionType']) ->disableOriginalConstructor() ->getMock(); @@ -426,28 +428,32 @@ private function mockBuilders(Select $select) { $helper = new ObjectManager($this); - $this->scoreBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder') + $this->scoreBuilder = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ScoreBuilder::class) ->setMethods(['clear']) ->disableOriginalConstructor() ->getMock(); - $this->scoreBuilderFactory = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilderFactory') + $this->scoreBuilderFactory = $this->getMockBuilder( + \Magento\Framework\Search\Adapter\Mysql\ScoreBuilderFactory::class + ) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->scoreBuilderFactory->expects($this->any())->method('create') ->will($this->returnValue($this->scoreBuilder)); - $this->filterBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Filter\Builder') + $this->filterBuilder = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Filter\Builder::class) ->setMethods(['build']) ->disableOriginalConstructor() ->getMock(); - $this->matchBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match') + $this->matchBuilder = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match::class) ->setMethods(['build']) ->disableOriginalConstructor() ->getMock(); $this->matchBuilder->expects($this->any()) ->method('build') ->willReturnArgument(1); - $this->indexBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\IndexBuilderInterface') + $this->indexBuilder = $this->getMockBuilder( + \Magento\Framework\Search\Adapter\Mysql\IndexBuilderInterface::class + ) ->disableOriginalConstructor() ->setMethods(['build']) ->getMockForAbstractClass(); @@ -455,7 +461,7 @@ private function mockBuilders(Select $select) ->method('build') ->will($this->returnValue($select)); $temporaryStorageFactory = $this->getMockBuilder( - '\Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory' + \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory::class ) ->setMethods(['create']) ->disableOriginalConstructor() @@ -464,7 +470,7 @@ private function mockBuilders(Select $select) ->method('create') ->willReturn($this->temporaryStorage); $queryContainerFactory = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Query\QueryContainerFactory' + \Magento\Framework\Search\Adapter\Mysql\Query\QueryContainerFactory::class ) ->setMethods(['create']) ->disableOriginalConstructor() @@ -472,7 +478,7 @@ private function mockBuilders(Select $select) $queryContainerFactory->expects($this->any()) ->method('create') ->willReturn($this->queryContainer); - $entityMetadata = $this->getMockBuilder('\Magento\Framework\Search\EntityMetadata') + $entityMetadata = $this->getMockBuilder(\Magento\Framework\Search\EntityMetadata::class) ->setMethods(['getEntityId']) ->disableOriginalConstructor() ->getMock(); @@ -480,7 +486,7 @@ private function mockBuilders(Select $select) ->method('getEntityId') ->willReturn(self::METADATA_ENTITY_ID); $this->mapper = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Mapper', + \Magento\Framework\Search\Adapter\Mysql\Mapper::class, [ 'resource' => $this->resource, 'scoreBuilderFactory' => $this->scoreBuilderFactory, @@ -504,7 +510,7 @@ private function mockBuilders(Select $select) */ private function createSelectMock(Select $from = null, $isInternal = true, $isGrouped = true) { - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods(['group', 'limit', 'where', 'columns', 'from', 'join', 'joinInner', 'order']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/Builder/MatchTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/Builder/MatchTest.php index f6b04a6fa0414..c677e045f6377 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/Builder/MatchTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/Builder/MatchTest.php @@ -41,27 +41,27 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->scoreBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder') + $this->scoreBuilder = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\ScoreBuilder::class) ->setMethods(['addCondition']) ->disableOriginalConstructor() ->getMock(); - $this->resolver = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Field\ResolverInterface') + $this->resolver = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Field\ResolverInterface::class) ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->fulltextHelper = $this->getMockBuilder('Magento\Framework\DB\Helper\Mysql\Fulltext') + $this->fulltextHelper = $this->getMockBuilder(\Magento\Framework\DB\Helper\Mysql\Fulltext::class) ->disableOriginalConstructor() ->getMock(); - $this->preprocessor = $this->getMockBuilder('Magento\Search\Adapter\Query\Preprocessor\Synonyms') + $this->preprocessor = $this->getMockBuilder(\Magento\Search\Adapter\Query\Preprocessor\Synonyms::class) ->setMethods(['process']) ->disableOriginalConstructor() ->getMock(); $this->match = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match', + \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match::class, [ 'resolver' => $this->resolver, 'fulltextHelper' => $this->fulltextHelper, @@ -73,7 +73,7 @@ protected function setUp() public function testBuild() { /** @var Select|\PHPUnit_Framework_MockObject_MockObject $select */ - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods(['getMatchQuery', 'match', 'where']) ->disableOriginalConstructor() ->getMock(); @@ -95,7 +95,7 @@ public function testBuild() ->willReturnCallback(function ($fieldList) { $resolvedFields = []; foreach ($fieldList as $column) { - $field = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Field\FieldInterface') + $field = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\Field\FieldInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $field->expects($this->any()) @@ -107,7 +107,7 @@ public function testBuild() }); /** @var \Magento\Framework\Search\Request\Query\Match|\PHPUnit_Framework_MockObject_MockObject $query */ - $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + $query = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\Match::class) ->setMethods(['getMatches', 'getValue']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/QueryContainerTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/QueryContainerTest.php index b0767516404d1..8906e023333f0 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/QueryContainerTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/QueryContainerTest.php @@ -30,23 +30,23 @@ protected function setUp() } $helper = new ObjectManager($this); - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $this->matchContainerFactory = $this->getMockBuilder( - 'Magento\Framework\Search\Adapter\Mysql\Query\MatchContainerFactory' + \Magento\Framework\Search\Adapter\Mysql\Query\MatchContainerFactory::class ) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->requestQuery = $this->getMockBuilder('Magento\Framework\Search\Request\QueryInterface') + $this->requestQuery = $this->getMockBuilder(\Magento\Framework\Search\Request\QueryInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->queryContainer = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer', + \Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer::class, [ 'matchContainerFactory' => $this->matchContainerFactory, ] diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ResponseFactoryTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ResponseFactoryTest.php index a4abd04db8eb2..7c7c14e56b575 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ResponseFactoryTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ResponseFactoryTest.php @@ -28,15 +28,15 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->documentFactory = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\DocumentFactory') + $this->documentFactory = $this->getMockBuilder(\Magento\Framework\Search\Adapter\Mysql\DocumentFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->factory = $helper->getObject( - 'Magento\Framework\Search\Adapter\Mysql\ResponseFactory', + \Magento\Framework\Search\Adapter\Mysql\ResponseFactory::class, ['documentFactory' => $this->documentFactory, 'objectManager' => $this->objectManager] ); } @@ -73,7 +73,7 @@ public function testCreate() $this->objectManager->expects($this->once())->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Response\QueryResponse'), + $this->equalTo(\Magento\Framework\Search\Response\QueryResponse::class), $this->equalTo(['documents' => ['document1', 'document2'], 'aggregations' => null]) ) ->will($this->returnValue('QueryResponseObject')); diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ScoreBuilderTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ScoreBuilderTest.php index eb93d12ea4b3b..1276f614d49ef 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ScoreBuilderTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ScoreBuilderTest.php @@ -13,7 +13,7 @@ class ScoreBuilderTest extends \PHPUnit_Framework_TestCase public function testBuild() { /** @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $builder */ - $builder = (new ObjectManager($this))->getObject('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder'); + $builder = (new ObjectManager($this))->getObject(\Magento\Framework\Search\Adapter\Mysql\ScoreBuilder::class); $builder->startQuery(); // start one query diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/TemporaryStorageTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/TemporaryStorageTest.php index e0820534b1549..6435e6cdc89c9 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/TemporaryStorageTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/TemporaryStorageTest.php @@ -30,11 +30,11 @@ protected function setUp() { $this->tableName = 'some_table_name'; - $this->adapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->adapter = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $resource->expects($this->any()) @@ -45,7 +45,7 @@ protected function setUp() ->willReturn($this->tableName); $this->model = (new ObjectManager($this))->getObject( - 'Magento\Framework\Search\Adapter\Mysql\TemporaryStorage', + \Magento\Framework\Search\Adapter\Mysql\TemporaryStorage::class, ['resource' => $resource] ); } @@ -55,7 +55,7 @@ public function testStoreDocumentsFromSelect() $sql = 'some SQL query'; /** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject $select */ - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); @@ -83,14 +83,14 @@ public function testStoreDocuments() $documentId = 312432; $documentValue = 1.235123; - $documentField = $this->getMockBuilder('Magento\Framework\Search\DocumentField') + $documentField = $this->getMockBuilder(\Magento\Framework\Search\DocumentField::class) ->disableOriginalConstructor() ->getMock(); $documentField->expects($this->once()) ->method('getValue') ->willReturn($documentValue); - $document = $this->getMockBuilder('Magento\Framework\Search\Document') + $document = $this->getMockBuilder(\Magento\Framework\Search\Document::class) ->disableOriginalConstructor() ->getMock(); $document->expects($this->once()) @@ -113,14 +113,14 @@ public function testStoreApiDocuments() $documentId = 312432; $documentValue = 1.235123; - $attributeValue = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + $attributeValue = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); $attributeValue->expects($this->once()) ->method('getValue') ->willReturn($documentValue); - $document = $this->getMockBuilder('Magento\Framework\Api\Search\Document') + $document = $this->getMockBuilder(\Magento\Framework\Api\Search\Document::class) ->disableOriginalConstructor() ->getMock(); $document->expects($this->once()) @@ -143,7 +143,7 @@ public function testStoreApiDocuments() */ private function createTemporaryTable() { - $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) ->disableOriginalConstructor() ->getMock(); $table->expects($this->at(1)) diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/DocumentTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/DocumentTest.php index b195b33998636..a7e1d635a83ed 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/DocumentTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/DocumentTest.php @@ -20,7 +20,7 @@ protected function setUp() $documentFields = []; for ($count = 0; $count < 5; $count++) { - $field = $this->getMockBuilder('Magento\Framework\Search\DocumentField') + $field = $this->getMockBuilder(\Magento\Framework\Search\DocumentField::class) ->disableOriginalConstructor() ->getMock(); @@ -30,7 +30,7 @@ protected function setUp() } $this->document = $helper->getObject( - 'Magento\Framework\Search\Document', + \Magento\Framework\Search\Document::class, [ 'documentId' => 42, 'documentFields' => $documentFields, diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php index 2b15258d9676e..58eee8be5daea 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Dynamic/IntervalFactoryTest.php @@ -42,17 +42,17 @@ protected function setUp() { $this->helper = new ObjectManager($this); - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->setMethods(['create', 'get', 'configure']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->setMethods(['getValue']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->interval = $this->getMockBuilder('Magento\Framework\Search\Dynamic\IntervalInterface') + $this->interval = $this->getMockBuilder(\Magento\Framework\Search\Dynamic\IntervalInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); } @@ -115,7 +115,7 @@ private function factoryCreate() { /** @var \Magento\Framework\Search\Dynamic\IntervalFactory $factory */ $factory = $this->helper->getObject( - 'Magento\Framework\Search\Dynamic\IntervalFactory', + \Magento\Framework\Search\Dynamic\IntervalFactory::class, [ 'objectManager' => $this->objectManager, 'scopeConfig' => $this->scopeConfig, diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/Aggregation/StatusTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/Aggregation/StatusTest.php index 3e842ae48f4a9..9bbe8856d3b78 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/Aggregation/StatusTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/Aggregation/StatusTest.php @@ -20,7 +20,9 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->status = $this->objectManagerHelper->getObject('Magento\Framework\Search\Request\Aggregation\Status'); + $this->status = $this->objectManagerHelper->getObject( + \Magento\Framework\Search\Request\Aggregation\Status::class + ); } public function testIsEnabled() diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/BinderTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/BinderTest.php index 599ecd1d3e2d6..195bb63607634 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/BinderTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/BinderTest.php @@ -21,7 +21,7 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->binder = $helper->getObject('Magento\Framework\Search\Request\Binder'); + $this->binder = $helper->getObject(\Magento\Framework\Search\Request\Binder::class); } /** diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/BuilderTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/BuilderTest.php index a7fddb55f58f8..ed86733588534 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/BuilderTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/BuilderTest.php @@ -48,34 +48,34 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->config = $this->getMockBuilder('Magento\Framework\Search\Request\Config') + $this->config = $this->getMockBuilder(\Magento\Framework\Search\Request\Config::class) ->setMethods(['get']) ->disableOriginalConstructor() ->getMock(); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->requestMapper = $this->getMockBuilder('Magento\Framework\Search\Request\Mapper') + $this->requestMapper = $this->getMockBuilder(\Magento\Framework\Search\Request\Mapper::class) ->setMethods(['getRootQuery', 'getBuckets']) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\Search\Request') + $this->request = $this->getMockBuilder(\Magento\Framework\Search\Request::class) ->disableOriginalConstructor() ->getMock(); - $this->binder = $this->getMockBuilder('Magento\Framework\Search\Request\Binder') + $this->binder = $this->getMockBuilder(\Magento\Framework\Search\Request\Binder::class) ->setMethods(['bind']) ->disableOriginalConstructor() ->getMock(); - $this->cleaner = $this->getMockBuilder('Magento\Framework\Search\Request\Cleaner') + $this->cleaner = $this->getMockBuilder(\Magento\Framework\Search\Request\Cleaner::class) ->setMethods(['clean']) ->disableOriginalConstructor() ->getMock(); $this->requestBuilder = $helper->getObject( - 'Magento\Framework\Search\Request\Builder', + \Magento\Framework\Search\Request\Builder::class, [ 'config' => $this->config, 'objectManager' => $this->objectManager, @@ -208,6 +208,6 @@ public function testCreate() $this->objectManager->expects($this->at(2))->method('create')->willReturn($this->request); $this->config->expects($this->once())->method('get')->with($this->equalTo($requestName))->willReturn($data); $result = $this->requestBuilder->create(); - $this->assertInstanceOf('\Magento\Framework\Search\Request', $result); + $this->assertInstanceOf(\Magento\Framework\Search\Request::class, $result); } } diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/CleanerTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/CleanerTest.php index 2d3368345b910..f41c6013c8785 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/CleanerTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/CleanerTest.php @@ -21,13 +21,13 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->status = $this->getMockBuilder('\Magento\Framework\Search\Request\Aggregation\StatusInterface') + $this->status = $this->getMockBuilder(\Magento\Framework\Search\Request\Aggregation\StatusInterface::class) ->disableOriginalConstructor() ->setMethods(['isEnabled']) ->getMockForAbstractClass(); $this->cleaner = $helper->getObject( - 'Magento\Framework\Search\Request\Cleaner', + \Magento\Framework\Search\Request\Cleaner::class, ['aggregationStatus' => $this->status] ); } diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/Config/SchemaLocatorTest.php index bb2e21474bc5c..c0be790a14a84 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/Config/SchemaLocatorTest.php @@ -20,7 +20,7 @@ protected function setUp() { $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ - $this->urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $this->urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $this->schemaLocator = new \Magento\Framework\Search\Request\Config\SchemaLocator($this->urnResolverMock); } diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php index 1cca5c12d24ed..f87f4c95d9a95 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php @@ -10,6 +10,9 @@ use Magento\Framework\Search\Request\Query\Filter; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MapperTest extends \PHPUnit_Framework_TestCase { const ROOT_QUERY = 'someQuery'; @@ -63,33 +66,33 @@ protected function setUp() { $this->helper = new ObjectManager($this); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->queryMatch = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + $this->queryMatch = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\Match::class) ->disableOriginalConstructor() ->getMock(); - $this->queryBool = $this->getMockBuilder('Magento\Framework\Search\Request\Query\BoolExpression') + $this->queryBool = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\BoolExpression::class) ->disableOriginalConstructor() ->getMock(); - $this->queryFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Filter') + $this->queryFilter = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\Filter::class) ->disableOriginalConstructor() ->getMock(); - $this->filterTerm = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + $this->filterTerm = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Term::class) ->disableOriginalConstructor() ->getMock(); - $this->filterRange = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + $this->filterRange = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Range::class) ->disableOriginalConstructor() ->getMock(); - $this->filterBool = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\BoolExpression') + $this->filterBool = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\BoolExpression::class) ->disableOriginalConstructor() ->getMock(); - $this->filterWildcard = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Wildcard') + $this->filterWildcard = $this->getMockBuilder(\Magento\Framework\Search\Request\Filter\Wildcard::class) ->disableOriginalConstructor() ->getMock(); } @@ -103,7 +106,7 @@ public function testGetQueryMatch($queries) $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->once())->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Match::class), $this->equalTo( [ 'name' => $query['name'], @@ -117,7 +120,7 @@ public function testGetQueryMatch($queries) /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -154,7 +157,7 @@ public function testGetQueryNotUsedStateException() $query = $queries['someQuery']; $this->objectManager->expects($this->once())->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Match::class), $this->equalTo( [ 'name' => $query['name'], @@ -168,7 +171,7 @@ public function testGetQueryNotUsedStateException() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -188,7 +191,7 @@ public function testGetQueryUsedStateException() { /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => [ @@ -221,7 +224,7 @@ public function testGetQueryFilterQueryReference($queries) $query = $queries['someQueryMatch']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Match::class), $this->equalTo( [ 'name' => $query['name'], @@ -235,7 +238,7 @@ public function testGetQueryFilterQueryReference($queries) $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Filter::class), $this->equalTo( [ 'name' => $query['name'], @@ -249,7 +252,7 @@ public function testGetQueryFilterQueryReference($queries) /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -270,7 +273,7 @@ public function testGetQueryFilterReferenceException() { /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => [ @@ -296,7 +299,7 @@ public function testGetQueryBool($queries) $query = $queries['someQueryMatch']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Match::class), $this->equalTo( [ 'name' => $query['name'], @@ -310,7 +313,7 @@ public function testGetQueryBool($queries) $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\BoolExpression'), + $this->equalTo(\Magento\Framework\Search\Request\Query\BoolExpression::class), $this->equalTo( [ 'name' => $query['name'], @@ -323,7 +326,7 @@ public function testGetQueryBool($queries) /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -343,7 +346,7 @@ public function testGetQueryInvalidArgumentException() { /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => [ @@ -367,7 +370,7 @@ public function testGetQueryException() { /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => [], @@ -404,7 +407,7 @@ public function testGetFilterTerm() $filter = $filters['someFilter']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Filter\Term'), + $this->equalTo(\Magento\Framework\Search\Request\Filter\Term::class), $this->equalTo( [ 'name' => $filter['name'], @@ -417,7 +420,7 @@ public function testGetFilterTerm() $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Filter::class), $this->equalTo( [ 'name' => $query['name'], @@ -431,7 +434,7 @@ public function testGetFilterTerm() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -469,7 +472,7 @@ public function testGetFilterWildcard() $filter = $filters['someFilter']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Filter\Wildcard'), + $this->equalTo(\Magento\Framework\Search\Request\Filter\Wildcard::class), $this->equalTo( [ 'name' => $filter['name'], @@ -482,7 +485,7 @@ public function testGetFilterWildcard() $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Filter::class), $this->equalTo( [ 'name' => $query['name'], @@ -496,7 +499,7 @@ public function testGetFilterWildcard() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -535,7 +538,7 @@ public function testGetFilterRange() $filter = $filters['someFilter']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Filter\Range'), + $this->equalTo(\Magento\Framework\Search\Request\Filter\Range::class), $this->equalTo( [ 'name' => $filter['name'], @@ -549,7 +552,7 @@ public function testGetFilterRange() $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Filter::class), $this->equalTo( [ 'name' => $query['name'], @@ -563,7 +566,7 @@ public function testGetFilterRange() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -611,7 +614,7 @@ public function testGetFilterBool() $filter = $filters['someFilterTerm']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Filter\Term'), + $this->equalTo(\Magento\Framework\Search\Request\Filter\Term::class), $this->equalTo( [ 'name' => $filter['name'], @@ -624,7 +627,7 @@ public function testGetFilterBool() $filter = $filters['someFilter']; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Filter\BoolExpression'), + $this->equalTo(\Magento\Framework\Search\Request\Filter\BoolExpression::class), $this->equalTo( [ 'name' => $filter['name'], @@ -636,7 +639,7 @@ public function testGetFilterBool() $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(2))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Filter::class), $this->equalTo( [ 'name' => $query['name'], @@ -650,7 +653,7 @@ public function testGetFilterBool() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -697,7 +700,7 @@ public function testGetFilterNotUsedStateException() $filter = $filters['someFilter']; $this->objectManager->expects($this->at(0))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Filter\Term'), + $this->equalTo(\Magento\Framework\Search\Request\Filter\Term::class), $this->equalTo( [ 'name' => $filter['name'], @@ -710,7 +713,7 @@ public function testGetFilterNotUsedStateException() $query = $queries[self::ROOT_QUERY]; $this->objectManager->expects($this->at(1))->method('create') ->with( - $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo(\Magento\Framework\Search\Request\Query\Filter::class), $this->equalTo( [ 'name' => $query['name'], @@ -724,7 +727,7 @@ public function testGetFilterNotUsedStateException() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -744,7 +747,7 @@ public function testGetFilterUsedStateException() { /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => [ @@ -803,7 +806,7 @@ public function testGetFilterInvalidArgumentException() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -837,7 +840,7 @@ public function testGetFilterException() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -992,9 +995,9 @@ public function testGetBucketsTermBucket() ], "type" => "termBucket", ]; - $metricClass = 'Magento\Framework\Search\Request\Aggregation\Metric'; - $bucketClass = 'Magento\Framework\Search\Request\Aggregation\TermBucket'; - $queryClass = 'Magento\Framework\Search\Request\Query\Match'; + $metricClass = \Magento\Framework\Search\Request\Aggregation\Metric::class; + $bucketClass = \Magento\Framework\Search\Request\Aggregation\TermBucket::class; + $queryClass = \Magento\Framework\Search\Request\Query\Match::class; $queryArguments = [ 'name' => $queries[self::ROOT_QUERY]['name'], 'value' => $queries[self::ROOT_QUERY]['value'], @@ -1019,7 +1022,7 @@ public function testGetBucketsTermBucket() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, @@ -1057,10 +1060,10 @@ public function testGetBucketsRangeBucket() ], "type" => "rangeBucket", ]; - $metricClass = 'Magento\Framework\Search\Request\Aggregation\Metric'; - $bucketClass = 'Magento\Framework\Search\Request\Aggregation\RangeBucket'; - $rangeClass = 'Magento\Framework\Search\Request\Aggregation\Range'; - $queryClass = 'Magento\Framework\Search\Request\Query\Match'; + $metricClass = \Magento\Framework\Search\Request\Aggregation\Metric::class; + $bucketClass = \Magento\Framework\Search\Request\Aggregation\RangeBucket::class; + $rangeClass = \Magento\Framework\Search\Request\Aggregation\Range::class; + $queryClass = \Magento\Framework\Search\Request\Query\Match::class; $queryArguments = [ 'name' => $queries[self::ROOT_QUERY]['name'], 'value' => $queries[self::ROOT_QUERY]['value'], @@ -1101,7 +1104,7 @@ public function testGetBucketsRangeBucket() /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->helper->getObject( - 'Magento\Framework\Search\Request\Mapper', + \Magento\Framework\Search\Request\Mapper::class, [ 'objectManager' => $this->objectManager, 'queries' => $queries, diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Response/AggregationTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Response/AggregationTest.php index 887626869b923..3bedf2badaeb5 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Response/AggregationTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Response/AggregationTest.php @@ -19,7 +19,7 @@ protected function setUp() $helper = new ObjectManager($this); $buckets = []; - $bucket = $this->getMockBuilder('Magento\Framework\Search\Response\Bucket') + $bucket = $this->getMockBuilder(\Magento\Framework\Search\Response\Bucket::class) ->disableOriginalConstructor() ->getMock(); @@ -28,7 +28,7 @@ protected function setUp() $buckets[1] = $bucket; $this->aggregation = $helper->getObject( - 'Magento\Framework\Search\Response\Aggregation', + \Magento\Framework\Search\Response\Aggregation::class, [ 'buckets' => $buckets, ] diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Response/QueryResponseTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Response/QueryResponseTest.php index 6c623d3888b93..0756362af2d98 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Response/QueryResponseTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Response/QueryResponseTest.php @@ -29,7 +29,7 @@ protected function setUp() $helper = new ObjectManager($this); for ($count = 0; $count < 5; $count++) { - $document = $this->getMockBuilder('Magento\Framework\Search\Document') + $document = $this->getMockBuilder(\Magento\Framework\Search\Document::class) ->disableOriginalConstructor() ->getMock(); @@ -37,12 +37,12 @@ protected function setUp() $this->documents[] = $document; } - $this->aggregations = $this->getMockBuilder('Magento\Framework\Search\Response\Aggregation') + $this->aggregations = $this->getMockBuilder(\Magento\Framework\Search\Response\Aggregation::class) ->disableOriginalConstructor() ->getMock(); $this->queryResponse = $helper->getObject( - 'Magento\Framework\Search\Response\QueryResponse', + \Magento\Framework\Search\Response\QueryResponse::class, [ 'documents' => $this->documents, 'aggregations' => $this->aggregations, @@ -67,6 +67,6 @@ public function testCount() public function testGetAggregations() { $aggregations = $this->queryResponse->getAggregations(); - $this->assertInstanceOf('Magento\Framework\Search\Response\Aggregation', $aggregations); + $this->assertInstanceOf(\Magento\Framework\Search\Response\Aggregation::class, $aggregations); } } diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/SearchEngine/Config/SchemaLocatorTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/SearchEngine/Config/SchemaLocatorTest.php index b461d5d64e260..d7edd44ef0514 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/SearchEngine/Config/SchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/SearchEngine/Config/SchemaLocatorTest.php @@ -16,7 +16,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $urnResolver = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolver = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); $urnResolver->expects($this->any()) ->method('getRealPath') ->with(SchemaLocator::SEARCH_ENGINE_XSD_PATH) diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/SearchResponseBuilderTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/SearchResponseBuilderTest.php index 6cd5962052af6..30fb064aa39de 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/SearchResponseBuilderTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/SearchResponseBuilderTest.php @@ -28,15 +28,15 @@ class SearchResponseBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->searchResultFactory = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultFactory') + $this->searchResultFactory = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchResultFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->documentFactory = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentFactory') + $this->documentFactory = $this->getMockBuilder(\Magento\Framework\Api\Search\DocumentFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->model = (new ObjectManager($this))->getObject('Magento\Framework\Search\SearchResponseBuilder', [ + $this->model = (new ObjectManager($this))->getObject(\Magento\Framework\Search\SearchResponseBuilder::class, [ 'documentFactory' => $this->documentFactory, 'searchResultFactory' => $this->searchResultFactory, ]); @@ -49,7 +49,7 @@ public function testBuild() $fieldValue = 'fieldValue'; $aggregations = ['aggregations']; - $document = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface') + $document = $this->getMockBuilder(\Magento\Framework\Api\Search\DocumentInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $document->expects($this->once()) @@ -64,7 +64,7 @@ public function testBuild() ->willReturn($document); /** @var SearchResultInterface|\PHPUnit_Framework_MockObject_MockObject $searchResult */ - $searchResult = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultInterface') + $searchResult = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchResultInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $searchResult->expects($this->once()) @@ -78,7 +78,7 @@ public function testBuild() ->method('create') ->willReturn($searchResult); - $field = $this->getMockBuilder('Magento\Framework\Search\DocumentField') + $field = $this->getMockBuilder(\Magento\Framework\Search\DocumentField::class) ->disableOriginalConstructor() ->getMock(); $field->expects($this->once()) @@ -88,7 +88,7 @@ public function testBuild() ->method('getValue') ->willReturn($fieldValue); - $responseDocument = $this->getMockBuilder('Magento\Framework\Search\Document') + $responseDocument = $this->getMockBuilder(\Magento\Framework\Search\Document::class) ->disableOriginalConstructor() ->getMock(); $responseDocument->expects($this->any()) @@ -99,7 +99,7 @@ public function testBuild() ->willReturn($documentId); /** @var QueryResponse|\PHPUnit_Framework_MockObject_MockObject $response */ - $response = $this->getMockBuilder('Magento\Framework\Search\Response\QueryResponse') + $response = $this->getMockBuilder(\Magento\Framework\Search\Response\QueryResponse::class) ->setMethods(['getIterator', 'getAggregations']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -112,6 +112,6 @@ public function testBuild() $result = $this->model->build($response); - $this->assertInstanceOf('Magento\Framework\Api\Search\SearchResultInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Api\Search\SearchResultInterface::class, $result); } } diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php index 89e83e7cc8bf1..e1561e0257a76 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php @@ -7,6 +7,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SearchTest extends \PHPUnit_Framework_TestCase { /** @@ -38,28 +41,31 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestBuilder = $this->getMockBuilder('Magento\Framework\Search\Request\Builder') + $this->requestBuilder = $this->getMockBuilder(\Magento\Framework\Search\Request\Builder::class) ->disableOriginalConstructor() ->getMock(); - $this->searchEngine = $this->getMockBuilder('Magento\Framework\Search\SearchEngineInterface') + $this->searchEngine = $this->getMockBuilder(\Magento\Framework\Search\SearchEngineInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->searchResponseBuilder = $this->getMockBuilder('Magento\Framework\Search\SearchResponseBuilder') + $this->searchResponseBuilder = $this->getMockBuilder(\Magento\Framework\Search\SearchResponseBuilder::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeResolver = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface') + $this->scopeResolver = $this->getMockBuilder(\Magento\Framework\App\ScopeResolverInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->model = $objectManager->getObject('Magento\Framework\Search\Search', [ - 'requestBuilder' => $this->requestBuilder, - 'searchEngine' => $this->searchEngine, - 'searchResponseBuilder' => $this->searchResponseBuilder, - 'scopeResolver' => $this->scopeResolver, - ]); + $this->model = $objectManager->getObject( + \Magento\Framework\Search\Search::class, + [ + 'requestBuilder' => $this->requestBuilder, + 'searchEngine' => $this->searchEngine, + 'searchResponseBuilder' => $this->searchResponseBuilder, + 'scopeResolver' => $this->scopeResolver, + ] + ); } public function testSearch() @@ -74,18 +80,18 @@ public function testSearch() $this->createFilterMock('range_filter', ['from' => 60, 'to' => 82]), ]; - $scope = $this->getMockBuilder('Magento\Framework\App\ScopeInterface') + $scope = $this->getMockBuilder(\Magento\Framework\App\ScopeInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $filterGroup = $this->getMockBuilder('Magento\Framework\Api\Search\FilterGroup') + $filterGroup = $this->getMockBuilder(\Magento\Framework\Api\Search\FilterGroup::class) ->disableOriginalConstructor() ->getMock(); $filterGroup->expects($this->once()) ->method('getFilters') ->willReturn($filters); - $searchCriteria = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaInterface') + $searchCriteria = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchCriteriaInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $searchCriteria->expects($this->once()) @@ -95,15 +101,15 @@ public function testSearch() ->method('getFilterGroups') ->willReturn([$filterGroup]); - $searchResult = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResult') + $searchResult = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchResult::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + $request = $this->getMockBuilder(\Magento\Framework\Search\RequestInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $response = $this->getMockBuilder('Magento\Framework\Search\ResponseInterface') + $response = $this->getMockBuilder(\Magento\Framework\Search\ResponseInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -139,7 +145,7 @@ public function testSearch() $searchResult = $this->model->search($searchCriteria); - $this->assertInstanceOf('Magento\Framework\Api\Search\SearchResultInterface', $searchResult); + $this->assertInstanceOf(\Magento\Framework\Api\Search\SearchResultInterface::class, $searchResult); } /** @@ -149,7 +155,7 @@ public function testSearch() */ private function createFilterMock($field, $value) { - $filter = $this->getMockBuilder('Magento\Framework\Api\Filter') + $filter = $this->getMockBuilder(\Magento\Framework\Api\Filter::class) ->disableOriginalConstructor() ->getMock(); $filter->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php index 83b98c06ad076..e1fcc0c0911f6 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php @@ -36,7 +36,7 @@ public function __construct(ObjectManagerInterface $objectManager) public function createSensitiveCookieMetadata($metadata = []) { return $this->objectManager->create( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, ['metadata' => $metadata] ); } @@ -50,7 +50,7 @@ public function createSensitiveCookieMetadata($metadata = []) public function createPublicCookieMetadata($metadata = []) { return $this->objectManager->create( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, ['metadata' => $metadata] ); } @@ -64,7 +64,7 @@ public function createPublicCookieMetadata($metadata = []) public function createCookieMetadata($metadata = []) { return $this->objectManager->create( - 'Magento\Framework\Stdlib\Cookie\CookieMetadata', + \Magento\Framework\Stdlib\Cookie\CookieMetadata::class, ['metadata' => $metadata] ); } diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/DateTimeFormatter.php b/lib/internal/Magento/Framework/Stdlib/DateTime/DateTimeFormatter.php index 09726721ea4fa..479baa6f4ee4e 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/DateTimeFormatter.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/DateTimeFormatter.php @@ -43,7 +43,7 @@ private function getLocaleResolver() { if ($this->localeResolver === null) { $this->localeResolver = \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Framework\Locale\ResolverInterface' + \Magento\Framework\Locale\ResolverInterface::class ); } return $this->localeResolver; diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/CookieScopeTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/CookieScopeTest.php index a67cd484ea259..28dcd4447b37e 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/CookieScopeTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/CookieScopeTest.php @@ -32,13 +32,13 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMock(); $this->requestMock->expects($this->any()) ->method('isSecure')->willReturn(true); $this->objectManager = new ObjectManager($this); $cookieMetadataFactory = $this - ->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory') + ->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class) ->disableOriginalConstructor()->getMock(); $cookieMetadataFactory->expects($this->any()) ->method('createSensitiveCookieMetadata') @@ -286,7 +286,7 @@ public function testGetCookieMetadataOverrides() protected function createCookieScope($params = []) { $params = array_merge($this->defaultScopeParams, $params); - return $this->objectManager->getObject('Magento\Framework\Stdlib\Cookie\CookieScope', $params); + return $this->objectManager->getObject(\Magento\Framework\Stdlib\Cookie\CookieScope::class, $params); } /** @@ -297,8 +297,8 @@ protected function createCookieScope($params = []) */ public function createSensitiveMetadata($metadata = []) { - return $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + return $this->objectManager->getObject( + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, ['metadata' => $metadata, 'request' => $this->requestMock] ); } @@ -311,8 +311,8 @@ public function createSensitiveMetadata($metadata = []) */ public function createPublicMetadata($metadata = []) { - return $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + return $this->objectManager->getObject( + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, ['metadata' => $metadata] ); } @@ -325,8 +325,8 @@ public function createPublicMetadata($metadata = []) */ public function createCookieMetadata($metadata = []) { - return $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\CookieMetadata', + return $this->objectManager->getObject( + \Magento\Framework\Stdlib\Cookie\CookieMetadata::class, ['metadata' => $metadata] ); } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php index b53f1e4bf3148..ddb3214705c18 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php @@ -108,20 +108,20 @@ protected function setUp() $mockTranslateSetCookie = true; self::$isSetCookieInvoked = false; $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieScopeInterface') + $this->scopeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieScopeInterface::class) ->setMethods(['getPublicCookieMetadata', 'getCookieMetadata', 'getSensitiveCookieMetadata']) ->disableOriginalConstructor() ->getMock(); - $this->readerMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'); + $this->readerMock = $this->getMock(\Magento\Framework\Stdlib\Cookie\CookieReaderInterface::class); $this->cookieManager = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PhpCookieManager', + \Magento\Framework\Stdlib\Cookie\PhpCookieManager::class, [ 'scope' => $this->scopeMock, 'reader' => $this->readerMock, ] ); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); } @@ -156,9 +156,9 @@ public function testDeleteCookie() { self::$isSetCookieInvoked = false; - /** @var \Magento\Framework\Stdlib\Cookie\CookieMetaData $cookieMetadata */ + /** @var \Magento\Framework\Stdlib\Cookie\CookieMetadata $cookieMetadata */ $cookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\CookieMetaData', + \Magento\Framework\Stdlib\Cookie\CookieMetadata::class, [ 'metadata' => [ 'domain' => 'magento.url', @@ -182,7 +182,7 @@ public function testDeleteCookieWithNoCookieMetadata() { self::$isSetCookieInvoked = false; - $cookieMetadata = $this->objectManager->getObject('Magento\Framework\Stdlib\Cookie\CookieMetaData'); + $cookieMetadata = $this->objectManager->getObject(\Magento\Framework\Stdlib\Cookie\CookieMetadata::class); $this->scopeMock->expects($this->once()) ->method('getCookieMetadata') ->with() @@ -198,7 +198,7 @@ public function testDeleteCookieWithFailureToSendException() { self::$isSetCookieInvoked = false; - $cookieMetadata = $this->objectManager->getObject('Magento\Framework\Stdlib\Cookie\CookieMetaData'); + $cookieMetadata = $this->objectManager->getObject(\Magento\Framework\Stdlib\Cookie\CookieMetadata::class); $this->scopeMock->expects($this->once()) ->method('getCookieMetadata') ->with() @@ -229,7 +229,7 @@ public function testSetSensitiveCookieNoMetadata($cookieName, $secure) /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ $sensitiveCookieMetadata = $this->objectManager ->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock ] @@ -266,7 +266,7 @@ public function testSetSensitiveCookieNullDomainAndPath() /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ $sensitiveCookieMetadata = $this->objectManager ->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock, 'metadata' => [ @@ -301,7 +301,7 @@ public function testSetSensitiveCookieWithPathAndDomain() /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ $sensitiveCookieMetadata = $this->objectManager ->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock, 'metadata' => [ @@ -335,7 +335,7 @@ public function testSetPublicCookieNoMetadata() self::$isSetCookieInvoked = false; /** @var PublicCookieMetadata $publicCookieMetadata */ $publicCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class ); $this->scopeMock->expects($this->once()) @@ -356,7 +356,7 @@ public function testSetPublicCookieDefaultValues() { /** @var PublicCookieMetadata $publicCookieMetadata */ $publicCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, [ 'metadata' => [ 'domain' => null, @@ -388,7 +388,7 @@ public function testSetPublicCookieSomeFieldsSet() self::$isSetCookieInvoked = false; /** @var PublicCookieMetadata $publicCookieMetadata */ $publicCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, [ 'metadata' => [ 'domain' => 'magento.url', @@ -417,7 +417,7 @@ public function testSetCookieBadName() { /** @var \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata $publicCookieMetadata */ $publicCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, [ 'metadata' => [ 'domain' => null, @@ -457,7 +457,7 @@ public function testSetCookieSizeTooLarge() { /** @var PublicCookieMetadata $publicCookieMetadata */ $publicCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, [ 'metadata' => [ 'domain' => null, @@ -500,7 +500,7 @@ public function testSetTooManyCookies() { /** @var PublicCookieMetadata $publicCookieMetadata */ $publicCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class ); $cookieValue = 'some_value'; diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PublicCookieMetadataTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PublicCookieMetadataTest.php index 7473eeb45da50..f02ca0f64677f 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PublicCookieMetadataTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PublicCookieMetadataTest.php @@ -23,7 +23,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); $this->publicCookieMetadata = $objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class ); } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php index 4f5f0ff22e1b2..9940500ca91ee 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php @@ -27,11 +27,11 @@ class SensitiveCookieMetadataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $this->sensitiveCookieMetadata = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock, ] @@ -47,7 +47,7 @@ public function testConstructorAndGetHttpOnly($metadata, $httpOnly) { /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ $object = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock, 'metadata' => $metadata, @@ -95,7 +95,7 @@ public function testGetSecure($isSecure, $metadata, $expected, $callNum = 1) /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ $object = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock, 'metadata' => $metadata, @@ -151,7 +151,7 @@ public function testToArray($isSecure, $metadata, $expected, $callNum = 1) /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ $object = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class, [ 'request' => $this->requestMock, 'metadata' => $metadata, diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php index 690feab510483..af62ec1812943 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php @@ -25,7 +25,7 @@ protected function setUp() $this->markTestSkipped('Skip this test for hhvm due to problem with \IntlDateFormatter::formatObject'); } $this->objectManager = new ObjectManager($this); - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); $this->localeResolverMock->expects($this->any()) @@ -44,7 +44,7 @@ protected function setUp() public function testFormatObject($object, $format = null, $locale = null, $useIntlFormatObject = false) { $dateTimeFormatter = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\DateTime\DateTimeFormatter', + \Magento\Framework\Stdlib\DateTime\DateTimeFormatter::class, [ 'useIntlFormatObject' => $useIntlFormatObject, ] @@ -124,7 +124,7 @@ public function dataProviderFormatObject() public function testFormatObjectIfPassedWrongFormat() { $dateTimeFormatter = $this->objectManager->getObject( - 'Magento\Framework\Stdlib\DateTime\DateTimeFormatter', + \Magento\Framework\Stdlib\DateTime\DateTimeFormatter::class, [ 'useIntlFormatObject' => false, ] diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php index 1798381d1c864..af5c5067002ee 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeTest.php @@ -17,7 +17,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase */ public function testGmtTimestamp() { - $timezone = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')->getMock(); + $timezone = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)->getMock(); $timezone->expects($this->any()) ->method('date') ->willReturn(new \DateTime('2015-04-02 21:03:00')); diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTest.php index 08075da4d2d81..1d593356a0395 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTest.php @@ -17,7 +17,7 @@ class DateTest extends \PHPUnit_Framework_TestCase */ public function testFilter($inputData, $expectedDate) { - $localeMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $localeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); $localeMock->expects( $this->once() )->method( @@ -51,7 +51,7 @@ public function testFilterWithException($inputData) { $this->setExpectedException('\Exception'); - $localeMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $localeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); $localeMock->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTimeTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTimeTest.php index 5ca6f9c52ee78..6dc7df7f312d6 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTimeTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/Filter/DateTimeTest.php @@ -17,7 +17,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase */ public function testFilter($inputData, $expectedDate) { - $localeMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $localeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); $localeMock->expects( $this->once() )->method( @@ -52,7 +52,7 @@ public function testFilterWithException($inputData) { $this->setExpectedException('\Exception'); - $localeMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $localeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); $localeMock->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/Test/Unit/App/Scope/SourceTest.php b/lib/internal/Magento/Framework/Test/Unit/App/Scope/SourceTest.php index 722f8cedb5c1b..37c8c98805c21 100644 --- a/lib/internal/Magento/Framework/Test/Unit/App/Scope/SourceTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/App/Scope/SourceTest.php @@ -23,7 +23,7 @@ class SourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeResolverPoolMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverPool') + $this->scopeResolverPoolMock = $this->getMockBuilder(\Magento\Framework\App\ScopeResolverPool::class) ->disableOriginalConstructor() ->getMock(); @@ -41,11 +41,11 @@ public function testToOptionArray() $result = [$scopeData, $scopeData]; /** @var ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject $scopeResolverMock */ - $scopeResolverMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface') + $scopeResolverMock = $this->getMockBuilder(\Magento\Framework\App\ScopeResolverInterface::class) ->getMockForAbstractClass(); /** @var ScopeInterface|\PHPUnit_Framework_MockObject_MockObject $scopeMock */ - $scopeMock = $this->getMockBuilder('Magento\Framework\App\ScopeInterface') + $scopeMock = $this->getMockBuilder(\Magento\Framework\App\ScopeInterface::class) ->getMockForAbstractClass(); $this->scopeResolverPoolMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Test/Unit/AuthorizationTest.php b/lib/internal/Magento/Framework/Test/Unit/AuthorizationTest.php index e622b8b016f06..5cbd9296cd6d5 100644 --- a/lib/internal/Magento/Framework/Test/Unit/AuthorizationTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/AuthorizationTest.php @@ -25,8 +25,8 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_policyMock = $this->getMock('Magento\Framework\Authorization\PolicyInterface'); - $roleLocatorMock = $this->getMock('Magento\Framework\Authorization\RoleLocatorInterface'); + $this->_policyMock = $this->getMock(\Magento\Framework\Authorization\PolicyInterface::class); + $roleLocatorMock = $this->getMock(\Magento\Framework\Authorization\RoleLocatorInterface::class); $roleLocatorMock->expects($this->any())->method('getAclRoleId')->will($this->returnValue('U1')); $this->_model = new \Magento\Framework\Authorization($this->_policyMock, $roleLocatorMock); } diff --git a/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php b/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php index f62a9a47e61f5..fffefc252894d 100644 --- a/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php @@ -14,10 +14,10 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase { public function testConstruct() { - $frontendCache = $this->getMock('Magento\Framework\Cache\FrontendInterface', [], [], '', false, false); - $lowLevelFrontend = $this->getMock('Zend_Cache_Core', [], [], '', false, false); + $frontendCache = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class, [], [], '', false, false); + $lowLevelFrontend = $this->getMock(\Zend_Cache_Core::class, [], [], '', false, false); /** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject $appCache */ - $appCache = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false, false); + $appCache = $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false, false); $frontendCache->expects($this->once())->method('getLowLevelFrontend')->willReturn($lowLevelFrontend); $appCache->expects($this->once()) ->method('getFrontend') diff --git a/lib/internal/Magento/Framework/Test/Unit/EventFactoryTest.php b/lib/internal/Magento/Framework/Test/Unit/EventFactoryTest.php index 604dcce7f6b85..5b8af515ab86a 100644 --- a/lib/internal/Magento/Framework/Test/Unit/EventFactoryTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/EventFactoryTest.php @@ -24,9 +24,9 @@ class EventFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Framework\EventFactory($this->_objectManagerMock); - $this->_expectedObject = $this->getMockBuilder('Magento\Framework\Event')->getMock(); + $this->_expectedObject = $this->getMockBuilder(\Magento\Framework\Event::class)->getMock(); } public function testCreate() @@ -37,7 +37,7 @@ public function testCreate() )->method( 'create' )->with( - 'Magento\Framework\Event', + \Magento\Framework\Event::class, $arguments )->will( $this->returnValue($this->_expectedObject) diff --git a/lib/internal/Magento/Framework/Test/Unit/EventTest.php b/lib/internal/Magento/Framework/Test/Unit/EventTest.php index c50f7cef0bf64..bd92132491637 100644 --- a/lib/internal/Magento/Framework/Test/Unit/EventTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/EventTest.php @@ -72,14 +72,14 @@ public function testRemoveObserverByName() 'name' => 'ObserverName', ]; $this->event->addObserver($this->observer); - $expected = 'Magento\Framework\Event\Observer\Collection'; + $expected = \Magento\Framework\Event\Observer\Collection::class; $actual = $this->event->getObservers()->removeObserverByName($data['name']); $this->assertInstanceOf($expected, $actual); } public function testDispatch() { - $this->assertInstanceOf('Magento\Framework\Event', $this->event->dispatch()); + $this->assertInstanceOf(\Magento\Framework\Event::class, $this->event->dispatch()); } public function testGetName() diff --git a/lib/internal/Magento/Framework/Test/Unit/FilesystemTest.php b/lib/internal/Magento/Framework/Test/Unit/FilesystemTest.php index fd1d6afd40cac..d172540502c1d 100644 --- a/lib/internal/Magento/Framework/Test/Unit/FilesystemTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/FilesystemTest.php @@ -26,21 +26,21 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_dirReadFactoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\ReadFactory', + \Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false ); $this->_directoryListMock = $this->getMock( - 'Magento\Framework\App\Filesystem\DirectoryList', + \Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false ); $this->_dirWriteFactoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\WriteFactory', + \Magento\Framework\Filesystem\Directory\WriteFactory::class, [], [], '', @@ -56,7 +56,7 @@ protected function setUp() public function testGetDirectoryRead() { /** @var \Magento\Framework\Filesystem\Directory\ReadInterface $dirReadMock */ - $dirReadMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadInterface'); + $dirReadMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->_dirReadFactoryMock->expects($this->once())->method('create')->will($this->returnValue($dirReadMock)); $this->assertEquals($dirReadMock, $this->_filesystem->getDirectoryRead(DirectoryList::ROOT)); } @@ -64,7 +64,7 @@ public function testGetDirectoryRead() public function testGetDirectoryWrite() { /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $dirWriteMock */ - $dirWriteMock = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface'); + $dirWriteMock = $this->getMock(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->_dirWriteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($dirWriteMock)); $this->assertEquals($dirWriteMock, $this->_filesystem->getDirectoryWrite(DirectoryList::ROOT)); } diff --git a/lib/internal/Magento/Framework/Test/Unit/FlagTest.php b/lib/internal/Magento/Framework/Test/Unit/FlagTest.php index 819119e682b6a..82ac648e85bba 100644 --- a/lib/internal/Magento/Framework/Test/Unit/FlagTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/FlagTest.php @@ -25,15 +25,15 @@ protected function setUp() protected function createInstance(array $data = []) { - $eventManager = $this->getMock('Magento\Framework\Event\Manager', ['dispatch'], [], '', false, false); - $context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false, false); + $eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, ['dispatch'], [], '', false, false); + $context = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false, false); $context->expects($this->once()) ->method('getEventDispatcher') ->will($this->returnValue($eventManager)); - $registry = $this->getMock('Magento\Framework\Registry', [], [], '', false, false); + $registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false, false); $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Adapter', + \Magento\Framework\DB\Adapter\Adapter::class, ['beginTransaction'], [], '', @@ -44,7 +44,7 @@ protected function createInstance(array $data = []) ->method('beginTransaction') ->will($this->returnSelf()); $appResource = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -55,10 +55,10 @@ protected function createInstance(array $data = []) ->method('getConnection') ->will($this->returnValue($connection)); - $dbContextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $dbContextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $dbContextMock->expects($this->once())->method('getResources')->willReturn($appResource); $resource = $this->getMock( - '\Magento\Framework\Flag\FlagResource', + \Magento\Framework\Flag\FlagResource::class, ['__wakeup', 'load', 'save', 'addCommitCallback', 'commit', 'rollBack'], ['context' => $dbContextMock], '', @@ -68,7 +68,7 @@ protected function createInstance(array $data = []) ->method('addCommitCallback') ->will($this->returnSelf()); - $resourceCollection = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $resourceCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -114,7 +114,7 @@ public function testSetFlagData() public function testLoadSelf() { - $this->assertInstanceOf('Magento\Framework\Flag', $this->flag->loadSelf()); + $this->assertInstanceOf(\Magento\Framework\Flag::class, $this->flag->loadSelf()); } /** diff --git a/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php b/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php index 96ecb2d8d27a8..c11eea303c2e5 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php @@ -162,7 +162,7 @@ public function testGetDataByKey() */ public function testSetGetDataUsingMethod() { - $mock = $this->getMock('Magento\Framework\DataObject', ['setTestData', 'getTestData']); + $mock = $this->getMock(\Magento\Framework\DataObject::class, ['setTestData', 'getTestData']); $mock->expects($this->once())->method('setTestData')->with($this->equalTo('data')); $mock->expects($this->once())->method('getTestData'); @@ -346,8 +346,8 @@ public function testOffset() $this->assertTrue($this->_object->offsetExists('key1')); $this->assertFalse($this->_object->offsetExists('key2')); - $this->assertEquals('value1', $this->_object->offsetGet('key1')); - $this->assertNull($this->_object->offsetGet('key2')); + $this->assertEquals('value1', $this->_object->offsetget(\key1::class)); + $this->assertNull($this->_object->offsetget(\key2::class)); $this->_object->offsetUnset('key1'); $this->assertFalse($this->_object->offsetExists('key1')); } diff --git a/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php b/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php index 6138467252ae2..77adb8f0bc08d 100644 --- a/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php @@ -27,7 +27,7 @@ class PhraseTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->defaultRenderer = Phrase::getRenderer(); - $this->rendererMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') + $this->rendererMock = $this->getMockBuilder(\Magento\Framework\Phrase\RendererInterface::class) ->getMock(); } @@ -143,6 +143,6 @@ public function testToStringWithExceptionOnRender() */ public function testDefaultRenderer() { - $this->assertInstanceOf('Magento\Framework\Phrase\Renderer\Placeholder', Phrase::getRenderer()); + $this->assertInstanceOf(\Magento\Framework\Phrase\Renderer\Placeholder::class, Phrase::getRenderer()); } } diff --git a/lib/internal/Magento/Framework/Test/Unit/ProfilerTest.php b/lib/internal/Magento/Framework/Test/Unit/ProfilerTest.php index f0d6f4efbb93e..f0bb948b19d48 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ProfilerTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ProfilerTest.php @@ -30,7 +30,7 @@ public function testSetDefaultTags() { $expected = ['some_key' => 'some_value']; \Magento\Framework\Profiler::setDefaultTags($expected); - $this->assertAttributeEquals($expected, '_defaultTags', 'Magento\Framework\Profiler'); + $this->assertAttributeEquals($expected, '_defaultTags', \Magento\Framework\Profiler::class); } public function testAddTagFilter() @@ -40,8 +40,8 @@ public function testAddTagFilter() \Magento\Framework\Profiler::addTagFilter('tag1', 'value_1.2'); $expected = ['tag1' => ['value_1.1', 'value_1.2'], 'tag2' => ['value_2.1']]; - $this->assertAttributeEquals($expected, '_tagFilters', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals(true, '_hasTagFilters', 'Magento\Framework\Profiler'); + $this->assertAttributeEquals($expected, '_tagFilters', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals(true, '_hasTagFilters', \Magento\Framework\Profiler::class); } public function testAdd() @@ -52,7 +52,7 @@ public function testAdd() $this->assertTrue(\Magento\Framework\Profiler::isEnabled()); $expected = [$mock]; - $this->assertAttributeEquals($expected, '_drivers', 'Magento\Framework\Profiler'); + $this->assertAttributeEquals($expected, '_drivers', \Magento\Framework\Profiler::class); } /** @@ -61,7 +61,7 @@ public function testAdd() protected function _getDriverMock() { return $this->getMockBuilder( - 'Magento\Framework\Profiler\DriverInterface' + \Magento\Framework\Profiler\DriverInterface::class )->setMethods( ['start', 'stop', 'clear'] )->getMockForAbstractClass(); @@ -223,13 +223,13 @@ public function testResetProfiler() \Magento\Framework\Profiler::add($driver); \Magento\Framework\Profiler::reset(); - $this->assertAttributeEquals([], '_currentPath', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals([], '_tagFilters', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals([], '_defaultTags', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals([], '_drivers', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals(false, '_hasTagFilters', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals(0, '_pathCount', 'Magento\Framework\Profiler'); - $this->assertAttributeEquals([], '_pathIndex', 'Magento\Framework\Profiler'); + $this->assertAttributeEquals([], '_currentPath', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals([], '_tagFilters', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals([], '_defaultTags', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals([], '_drivers', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals(false, '_hasTagFilters', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals(0, '_pathCount', \Magento\Framework\Profiler::class); + $this->assertAttributeEquals([], '_pathIndex', \Magento\Framework\Profiler::class); } /** @@ -287,10 +287,10 @@ public function passedFilterDataProvider() public function testApplyConfig() { - $mockDriver = $this->getMock('Magento\Framework\Profiler\DriverInterface'); + $mockDriver = $this->getMock(\Magento\Framework\Profiler\DriverInterface::class); $driverConfig = ['type' => 'foo']; $mockDriverFactory = $this->getMockBuilder( - 'Magento\Framework\Profiler\Driver\Factory' + \Magento\Framework\Profiler\Driver\Factory::class )->disableOriginalConstructor()->getMock(); $config = [ 'drivers' => [$driverConfig], @@ -309,13 +309,13 @@ public function testApplyConfig() ); \Magento\Framework\Profiler::applyConfig($config, ''); - $this->assertAttributeEquals([$mockDriver], '_drivers', 'Magento\Framework\Profiler'); + $this->assertAttributeEquals([$mockDriver], '_drivers', \Magento\Framework\Profiler::class); $this->assertAttributeEquals( ['tagName' => ['tagValue']], '_tagFilters', - 'Magento\Framework\Profiler' + \Magento\Framework\Profiler::class ); - $this->assertAttributeEquals(true, '_enabled', 'Magento\Framework\Profiler'); + $this->assertAttributeEquals(true, '_enabled', \Magento\Framework\Profiler::class); } /** @@ -326,7 +326,7 @@ public function testApplyConfig() */ public function testParseConfig($data, $isAjax, $expected) { - $method = new \ReflectionMethod('Magento\Framework\Profiler', '_parseConfig'); + $method = new \ReflectionMethod(\Magento\Framework\Profiler::class, '_parseConfig'); $method->setAccessible(true); $this->assertEquals($expected, $method->invoke(null, $data, '', $isAjax)); } @@ -338,7 +338,7 @@ public function testParseConfig($data, $isAjax, $expected) public function parseConfigDataProvider() { $driverFactory = new \Magento\Framework\Profiler\Driver\Factory(); - $otherDriverFactory = $this->getMock('Magento\Framework\Profiler\Driver\Factory'); + $otherDriverFactory = $this->getMock(\Magento\Framework\Profiler\Driver\Factory::class); return [ 'Empty configuration' => [ [], diff --git a/lib/internal/Magento/Framework/Test/Unit/RegistryTest.php b/lib/internal/Magento/Framework/Test/Unit/RegistryTest.php index 914c984341377..73ee9808340bf 100644 --- a/lib/internal/Magento/Framework/Test/Unit/RegistryTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/RegistryTest.php @@ -27,7 +27,7 @@ protected function setUp() $this->registry = new Registry(); $this->data = [ 'key' => 'customer', - 'value' => '\Magento\Customer\Model\Customer', + 'value' => \Magento\Customer\Model\Customer::class, ]; $this->registry->register($this->data['key'], $this->data['value']); } @@ -65,7 +65,7 @@ public function testRegisterKeyExists() public function testUnregister() { $key = 'csv_adapter'; - $valueObj = $this->getMock('\Magento\ImportExport\Model\Export\Adapter\Csv', [], [], '', false, false); + $valueObj = $this->getMock(\Magento\ImportExport\Model\Export\Adapter\Csv::class, [], [], '', false, false); $this->registry->register($key, $valueObj); $this->assertEquals($valueObj, $this->registry->registry($key)); $this->registry->unregister($key); diff --git a/lib/internal/Magento/Framework/Test/Unit/ShellTest.php b/lib/internal/Magento/Framework/Test/Unit/ShellTest.php index 83505d48162a7..d61d2f28829c7 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ShellTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ShellTest.php @@ -22,7 +22,7 @@ class ShellTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->logger = $this->getMockBuilder('Zend_Log') + $this->logger = $this->getMockBuilder(\Zend_Log::class) ->setMethods(['log']) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php b/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php index 1e33d4fe2b041..7131bdb4d334a 100644 --- a/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php @@ -59,17 +59,17 @@ class TranslateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->viewDesign = $this->getMock('\Magento\Framework\View\DesignInterface', [], [], '', false); - $this->cache = $this->getMock('\Magento\Framework\Cache\FrontendInterface', [], [], '', false); - $this->viewFileSystem = $this->getMock('\Magento\Framework\View\FileSystem', [], [], '', false); - $this->moduleList = $this->getMock('\Magento\Framework\Module\ModuleList', [], [], '', false); - $this->modulesReader = $this->getMock('\Magento\Framework\Module\Dir\Reader', [], [], '', false); - $this->scopeResolver = $this->getMock('\Magento\Framework\App\ScopeResolverInterface', [], [], '', false); - $this->resource = $this->getMock('\Magento\Framework\Translate\ResourceInterface', [], [], '', false); - $this->locale = $this->getMock('\Magento\Framework\Locale\ResolverInterface', [], [], '', false); - $this->appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false); + $this->viewDesign = $this->getMock(\Magento\Framework\View\DesignInterface::class, [], [], '', false); + $this->cache = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class, [], [], '', false); + $this->viewFileSystem = $this->getMock(\Magento\Framework\View\FileSystem::class, [], [], '', false); + $this->moduleList = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $this->modulesReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); + $this->scopeResolver = $this->getMock(\Magento\Framework\App\ScopeResolverInterface::class, [], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\Translate\ResourceInterface::class, [], [], '', false); + $this->locale = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class, [], [], '', false); + $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->request = $this->getMockForAbstractClass( - '\Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -77,10 +77,16 @@ protected function setUp() true, ['getParam', 'getControllerModule'] ); - $this->csvParser = $this->getMock('\Magento\Framework\File\Csv', [], [], '', false); - $this->packDictionary = $this->getMock('\Magento\Framework\App\Language\Dictionary', [], [], '', false); - $this->directory = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface', [], [], '', false); - $filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); + $this->csvParser = $this->getMock(\Magento\Framework\File\Csv::class, [], [], '', false); + $this->packDictionary = $this->getMock(\Magento\Framework\App\Language\Dictionary::class, [], [], '', false); + $this->directory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadInterface::class, + [], + [], + '', + false + ); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystem->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($this->directory)); $this->translate = new Translate( diff --git a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php index a1ecfb2ed4f88..abaf2fdaaf734 100644 --- a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php @@ -61,16 +61,16 @@ class UrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->routeParamsResolverMock = $this->getMock( - 'Magento\Framework\Url\RouteParamsResolver', + $this->routeParamsResolverMock = $this->getMock( + \Magento\Framework\Url\RouteParamsResolver::class, ['getType', 'hasData', 'getData', 'getRouteParams'], [], '', false ); - $this->routeParamsPreprocessorMock = $this->getMockForAbstractClass( - 'Magento\Framework\Url\RouteParamsPreprocessorInterface', + $this->routeParamsPreprocessorMock = $this->getMockForAbstractClass( + \Magento\Framework\Url\RouteParamsPreprocessorInterface::class, [], '', false, @@ -79,20 +79,20 @@ protected function setUp() [] ); - $this->scopeResolverMock = $this->getMock('Magento\Framework\Url\ScopeResolverInterface'); - $this->scopeMock = $this->getMock('Magento\Framework\Url\ScopeInterface'); - $this->queryParamsResolverMock = $this->getMock( - 'Magento\Framework\Url\QueryParamsResolverInterface', + $this->scopeResolverMock = $this->getMock(\Magento\Framework\Url\ScopeResolverInterface::class); + $this->scopeMock = $this->getMock(\Magento\Framework\Url\ScopeInterface::class); + $this->queryParamsResolverMock = $this->getMock( + \Magento\Framework\Url\QueryParamsResolverInterface::class, [], [], '', false ); - $this->sidResolverMock = $this->getMock('Magento\Framework\Session\SidResolverInterface'); - $this->sessionMock = $this->getMock('Magento\Framework\Session\Generic', [], [], '', false); - $this->scopeConfig = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->sidResolverMock = $this->getMock(\Magento\Framework\Session\SidResolverInterface::class); + $this->sessionMock = $this->getMock(\Magento\Framework\Session\Generic::class, [], [], '', false); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->urlModifier = $this->getMock('Magento\Framework\Url\ModifierInterface'); + $this->urlModifier = $this->getMock(\Magento\Framework\Url\ModifierInterface::class); $this->urlModifier->expects($this->any()) ->method('execute') ->willReturnArgument(0); @@ -104,8 +104,8 @@ protected function setUp() */ protected function getRouteParamsResolverFactory($resolve = true) { - $routeParamsResolverFactoryMock = $this->getMock( - 'Magento\Framework\Url\RouteParamsResolverFactory', + $routeParamsResolverFactoryMock = $this->getMock( + \Magento\Framework\Url\RouteParamsResolverFactory::class, [], [], '', @@ -124,7 +124,7 @@ protected function getRouteParamsResolverFactory($resolve = true) */ protected function getRequestMock() { - return $this->getMockBuilder('Magento\Framework\App\Request\Http') + return $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); } @@ -136,7 +136,7 @@ protected function getUrlModel($arguments = []) { $arguments = array_merge($arguments, ['scopeType' => \Magento\Store\Model\ScopeInterface::SCOPE_STORE]); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $model = $objectManager->getObject('Magento\Framework\Url', $arguments); + $model = $objectManager->getObject(\Magento\Framework\Url::class, $arguments); $modelProperty = (new \ReflectionClass(get_class($model))) ->getProperty('urlModifier'); @@ -218,7 +218,7 @@ public function testGetUrlValidateFilter() public function testGetUrl($query, $queryResult, $returnUri) { $requestMock = $this->getRequestMock(); - $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); + $routeConfigMock = $this->getMock(\Magento\Framework\App\Route\ConfigInterface::class); $model = $this->getUrlModel( [ 'scopeResolver' => $this->scopeResolverMock, @@ -251,7 +251,7 @@ public function testGetUrl($query, $queryResult, $returnUri) ->will($this->returnValue($queryResult)); $url = $model->getUrl('catalog/product/view', [ - '_scope' => $this->getMockForAbstractClass('Magento\Store\Api\Data\StoreInterface'), + '_scope' => $this->getMockForAbstractClass(\Magento\Store\Api\Data\StoreInterface::class), '_fragment' => 'anchor', '_escape' => 1, '_query' => $query, @@ -350,7 +350,7 @@ public function getUrlDataProvider() public function testGetUrlWithAsterisksPath() { $requestMock = $this->getRequestMock(); - $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); + $routeConfigMock = $this->getMock(\Magento\Framework\App\Route\ConfigInterface::class); $model = $this->getUrlModel( [ 'scopeResolver' => $this->scopeResolverMock, @@ -386,7 +386,7 @@ public function testGetUrlWithAsterisksPath() public function testGetDirectUrl() { $requestMock = $this->getRequestMock(); - $routeConfigMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); + $routeConfigMock = $this->getMock(\Magento\Framework\App\Route\ConfigInterface::class); $model = $this->getUrlModel( [ 'scopeResolver' => $this->scopeResolverMock, @@ -556,7 +556,7 @@ public function isOwnOriginUrlDataProvider() */ public function testGetConfigData($urlType, $configPath, $isSecure, $isSecureCallCount, $key) { - $urlSecurityInfoMock = $this->getMock('Magento\Framework\Url\SecurityInfoInterface'); + $urlSecurityInfoMock = $this->getMock(\Magento\Framework\Url\SecurityInfoInterface::class); $model = $this->getUrlModel([ 'urlSecurityInfo' => $urlSecurityInfoMock, 'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(), diff --git a/lib/internal/Magento/Framework/Test/Unit/ValidatorFactoryTest.php b/lib/internal/Magento/Framework/Test/Unit/ValidatorFactoryTest.php index 82048073f75a9..2c8dca01988e7 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ValidatorFactoryTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ValidatorFactoryTest.php @@ -23,15 +23,16 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->model = $objectManager->getObject('Magento\Framework\ValidatorFactory', + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->model = $objectManager->getObject( + \Magento\Framework\ValidatorFactory::class, ['objectManager' => $this->objectManagerMock] ); } public function testCreateWithInstanceName() { - $setName = 'Magento\Framework\DataObject'; + $setName = \Magento\Framework\DataObject::class; $returnMock = $this->getMock($setName); $this->objectManagerMock->expects($this->once())->method('create') ->willReturn($returnMock); @@ -41,7 +42,7 @@ public function testCreateWithInstanceName() public function testCreateDefault() { - $default = 'Magento\Framework\Validator'; + $default = \Magento\Framework\Validator::class; $returnMock = $this->getMock($default); $this->objectManagerMock->expects($this->once())->method('create') ->willReturn($returnMock); diff --git a/lib/internal/Magento/Framework/Test/Unit/ValidatorTest.php b/lib/internal/Magento/Framework/Test/Unit/ValidatorTest.php index 9dc72d930f921..af48d24de887d 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ValidatorTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ValidatorTest.php @@ -69,7 +69,7 @@ public function isValidDataProvider() $value = 'test'; // Case 1. Validators fails without breaking chain - $validatorA = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $validatorA = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $validatorA->expects($this->once())->method('isValid')->with($value)->will($this->returnValue(false)); $validatorA->expects( $this->once() @@ -79,7 +79,7 @@ public function isValidDataProvider() $this->returnValue(['foo' => ['Foo message 1'], 'bar' => ['Foo message 2']]) ); - $validatorB = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $validatorB = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $validatorB->expects($this->once())->method('isValid')->with($value)->will($this->returnValue(false)); $validatorB->expects( $this->once() @@ -97,7 +97,7 @@ public function isValidDataProvider() ]; // Case 2. Validators fails with breaking chain - $validatorA = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $validatorA = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $validatorA->expects($this->once())->method('isValid')->with($value)->will($this->returnValue(false)); $validatorA->expects( $this->once() @@ -107,17 +107,17 @@ public function isValidDataProvider() $this->returnValue(['field' => 'Error message']) ); - $validatorB = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $validatorB = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $validatorB->expects($this->never())->method('isValid'); $result[] = [$value, [$validatorA, $validatorB], false, ['field' => 'Error message'], true]; // Case 3. Validators succeed - $validatorA = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $validatorA = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $validatorA->expects($this->once())->method('isValid')->with($value)->will($this->returnValue(true)); $validatorA->expects($this->never())->method('getMessages'); - $validatorB = $this->getMock('Magento\Framework\Validator\ValidatorInterface'); + $validatorB = $this->getMock(\Magento\Framework\Validator\ValidatorInterface::class); $validatorB->expects($this->once())->method('isValid')->with($value)->will($this->returnValue(true)); $validatorB->expects($this->never())->method('getMessages'); @@ -136,7 +136,9 @@ public function testAddValidator() $propertyValidator = new \Magento\Framework\Validator\Constraint\Property($classConstraint, 'name', 'id'); /** @var \Magento\Framework\Translate\AbstractAdapter $translator */ - $translator = $this->getMockBuilder('Magento\Framework\Translate\AbstractAdapter')->getMockForAbstractClass(); + $translator = $this->getMockBuilder( + \Magento\Framework\Translate\AbstractAdapter::class + )->getMockForAbstractClass(); \Magento\Framework\Validator\AbstractValidator::setDefaultTranslator($translator); $this->_validator->addValidator($classConstraint); @@ -157,7 +159,9 @@ public function testSetTranslator() $fooValidator = new \Magento\Framework\Validator\Test\Unit\Test\IsTrue(); $this->_validator->addValidator($fooValidator); /** @var \Magento\Framework\Translate\AbstractAdapter $translator */ - $translator = $this->getMockBuilder('Magento\Framework\Translate\AbstractAdapter')->getMockForAbstractClass(); + $translator = $this->getMockBuilder( + \Magento\Framework\Translate\AbstractAdapter::class + )->getMockForAbstractClass(); $this->_validator->setTranslator($translator); $this->assertEquals($translator, $fooValidator->getTranslator()); $this->assertEquals($translator, $this->_validator->getTranslator()); diff --git a/lib/internal/Magento/Framework/Test/Unit/View/Design/Theme/Label/OptionsTest.php b/lib/internal/Magento/Framework/Test/Unit/View/Design/Theme/Label/OptionsTest.php index c1679b5678563..c550977508a93 100644 --- a/lib/internal/Magento/Framework/Test/Unit/View/Design/Theme/Label/OptionsTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/View/Design/Theme/Label/OptionsTest.php @@ -18,7 +18,7 @@ class OptionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->listMock = $this->getMockBuilder('Magento\Framework\View\Design\Theme\Label\ListInterface') + $this->listMock = $this->getMockBuilder(\Magento\Framework\View\Design\Theme\Label\ListInterface::class) ->getMockForAbstractClass(); $this->model = new Options($this->listMock); From 6741032d07938e42c653357a454816923ef5c242 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:18:07 +0300 Subject: [PATCH 05/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Authentication/OauthHelper.php | 8 +-- .../Authentication/Rest/OauthClient.php | 2 +- .../Magento/TestFramework/Helper/Customer.php | 22 ++++--- .../TestCase/Webapi/Adapter/Rest.php | 8 +-- .../TestCase/Webapi/Adapter/Soap.php | 6 +- .../TestFramework/TestCase/WebapiAbstract.php | 26 ++++---- .../api-functional/framework/bootstrap.php | 4 +- .../Bundle/Api/CartItemRepositoryTest.php | 11 ++-- .../Bundle/Api/OrderItemRepositoryTest.php | 8 +-- .../Bundle/Api/ProductLinkManagementTest.php | 4 +- .../Magento/Bundle/Api/ProductServiceTest.php | 2 +- .../Api/AttributeSetManagementTest.php | 4 +- .../Api/AttributeSetRepositoryTest.php | 2 +- .../Catalog/Api/CartItemRepositoryTest.php | 8 +-- .../Api/CategoryLinkRepositoryTest.php | 5 +- .../Catalog/Api/CategoryManagementTest.php | 2 +- .../Catalog/Api/CategoryRepositoryTest.php | 4 +- .../Catalog/Api/OrderItemRepositoryTest.php | 8 +-- .../ProductAttributeGroupRepositoryTest.php | 2 +- .../Api/ProductAttributeManagementTest.php | 2 +- ...uteMediaGalleryManagementInterfaceTest.php | 4 +- .../Api/ProductCustomOptionRepositoryTest.php | 10 +-- .../ProductLinkManagementInterfaceTest.php | 2 +- .../ProductLinkRepositoryInterfaceTest.php | 6 +- .../Api/ProductRepositoryInterfaceTest.php | 2 +- .../Api/ProductRepositoryMultiStoreTest.php | 9 +-- .../Api/ProductTierPriceManagementTest.php | 6 +- .../CatalogInventory/Api/StockItemTest.php | 11 ++-- .../CatalogInventory/Api/StockStatusTest.php | 2 +- .../Api/CheckoutAgreementsRepositoryTest.php | 2 +- .../Magento/Cms/Api/BlockRepositoryTest.php | 17 ++--- .../Magento/Cms/Api/PageRepositoryTest.php | 16 ++--- .../Api/CartItemRepositoryTest.php | 18 ++--- .../Api/ConfigurableProductManagementTest.php | 2 +- .../Api/OrderItemRepositoryTest.php | 8 +-- .../Api/ProductRepositoryTest.php | 4 +- .../AccountManagementCustomAttributesTest.php | 16 ++--- .../Customer/Api/AccountManagementMeTest.php | 14 ++-- .../Customer/Api/AccountManagementTest.php | 20 +++--- .../Customer/Api/AddressMetadataTest.php | 4 +- .../Customer/Api/AddressRepositoryTest.php | 11 ++-- .../Customer/Api/CustomerRepositoryTest.php | 50 +++++++------- .../Customer/Api/GroupManagementTest.php | 4 +- .../Customer/Api/GroupRepositoryTest.php | 14 ++-- .../Api/CountryInformationAcquirerTest.php | 9 +-- .../Api/CurrencyInformationAcquirerTest.php | 8 ++- .../Api/CartItemRepositoryTest.php | 24 +++---- .../Downloadable/Api/LinkRepositoryTest.php | 7 +- .../Api/OrderItemRepositoryTest.php | 8 +-- .../Downloadable/Api/SampleRepositoryTest.php | 6 +- .../Eav/Api/AttributeSetManagementTest.php | 4 +- .../Eav/Api/AttributeSetRepositoryTest.php | 4 +- .../Framework/Stdlib/CookieManagerTest.php | 4 +- .../GiftMessage/Api/CartRepositoryTest.php | 14 ++-- .../Api/GuestCartRepositoryTest.php | 11 ++-- .../Api/GuestItemRepositoryTest.php | 14 ++-- .../GiftMessage/Api/ItemRepositoryTest.php | 26 ++++---- .../Api/ProductLinkRepositoryTest.php | 2 +- .../Model/AdminTokenServiceTest.php | 7 +- .../Model/CustomerTokenServiceTest.php | 12 ++-- .../Integration/Model/IntegrationTest.php | 3 +- .../Api/BillingAddressManagementTest.php | 16 ++--- .../Quote/Api/CartItemRepositoryTest.php | 18 ++--- .../Magento/Quote/Api/CartManagementTest.php | 41 ++++++------ .../Magento/Quote/Api/CartRepositoryTest.php | 11 ++-- .../Quote/Api/CartTotalRepositoryTest.php | 10 +-- .../Quote/Api/CouponManagementTest.php | 36 +++++----- .../Api/GuestBillingAddressManagementTest.php | 8 +-- .../Quote/Api/GuestCartItemRepositoryTest.php | 26 ++++---- .../Quote/Api/GuestCartManagementTest.php | 47 ++++++------- .../Quote/Api/GuestCartRepositoryTest.php | 6 +- .../Api/GuestCartTotalRepositoryTest.php | 8 +-- .../Quote/Api/GuestCouponManagementTest.php | 20 +++--- .../Api/GuestPaymentMethodManagementTest.php | 18 ++--- .../Api/GuestShippingMethodManagementTest.php | 14 ++-- .../Quote/Api/PaymentMethodManagementTest.php | 21 +++--- .../Api/ShippingMethodManagementTest.php | 14 ++-- .../Service/V1/CreditmemoAddCommentTest.php | 2 +- .../Sales/Service/V1/CreditmemoCancelTest.php | 4 +- .../Service/V1/CreditmemoCommentsListTest.php | 9 ++- .../Sales/Service/V1/CreditmemoCreateTest.php | 2 +- .../Sales/Service/V1/CreditmemoEmailTest.php | 4 +- .../Sales/Service/V1/CreditmemoGetTest.php | 2 +- .../Sales/Service/V1/CreditmemoListTest.php | 4 +- .../Service/V1/InvoiceAddCommentTest.php | 2 +- .../Sales/Service/V1/InvoiceCaptureTest.php | 2 +- .../Service/V1/InvoiceCommentsListTest.php | 6 +- .../Sales/Service/V1/InvoiceCreateTest.php | 2 +- .../Sales/Service/V1/InvoiceEmailTest.php | 2 +- .../Sales/Service/V1/InvoiceGetTest.php | 2 +- .../Sales/Service/V1/InvoiceListTest.php | 4 +- .../Sales/Service/V1/InvoiceVoidTest.php | 2 +- .../Service/V1/OrderAddressUpdateTest.php | 4 +- .../Sales/Service/V1/OrderCancelTest.php | 2 +- .../Service/V1/OrderCommentsListTest.php | 4 +- .../Sales/Service/V1/OrderCreateTest.php | 21 +++--- .../Sales/Service/V1/OrderEmailTest.php | 2 +- .../Sales/Service/V1/OrderGetStatusTest.php | 2 +- .../Magento/Sales/Service/V1/OrderGetTest.php | 2 +- .../Sales/Service/V1/OrderHoldTest.php | 2 +- .../Sales/Service/V1/OrderItemGetListTest.php | 6 +- .../Sales/Service/V1/OrderItemGetTest.php | 2 +- .../Sales/Service/V1/OrderListTest.php | 4 +- .../Service/V1/OrderStatusHistoryAddTest.php | 2 +- .../Sales/Service/V1/OrderUnHoldTest.php | 2 +- .../Service/V1/ShipmentAddCommentTest.php | 4 +- .../Sales/Service/V1/ShipmentAddTrackTest.php | 4 +- .../Service/V1/ShipmentCommentsListTest.php | 6 +- .../Sales/Service/V1/ShipmentCreateTest.php | 2 +- .../Sales/Service/V1/ShipmentEmailTest.php | 2 +- .../Sales/Service/V1/ShipmentGetTest.php | 8 ++- .../Sales/Service/V1/ShipmentLabelGetTest.php | 4 +- .../Sales/Service/V1/ShipmentListTest.php | 4 +- .../Service/V1/ShipmentRemoveTrackTest.php | 6 +- .../Sales/Service/V1/TransactionTest.php | 12 ++-- .../SalesRule/Api/CouponManagementTest.php | 2 +- .../SalesRule/Api/CouponRepositoryTest.php | 2 +- .../SalesRule/Api/RuleRepositoryTest.php | 8 +-- .../Tax/Api/TaxClassRepositoryTest.php | 10 +-- .../Magento/Tax/Api/TaxRateRepositoryTest.php | 32 ++++----- .../Api/TaxRuleRepositoryInterfaceTest.php | 27 ++++---- .../CustomAttributeTypeWsdlGenerationTest.php | 2 +- .../Magento/Webapi/JoinDirectivesTest.php | 8 +-- .../JsonGenerationFromDataObjectTest.php | 4 +- .../Magento/Webapi/PartialResponseTest.php | 2 +- .../Webapi/Routing/CoreRoutingTest.php | 2 +- .../Webapi/Routing/RequestIdOverrideTest.php | 2 +- .../Webapi/Routing/RestErrorHandlingTest.php | 2 +- .../Webapi/Routing/ServiceVersionV1Test.php | 6 +- .../WsdlGenerationFromDataObjectTest.php | 2 +- .../Magento/Mtf/App/State/AbstractState.php | 6 +- .../lib/Magento/Mtf/App/State/State1.php | 2 +- .../lib/Magento/Mtf/Util/Generate/Factory.php | 12 ++-- .../Mtf/Util/Generate/Factory/Fixture.php | 3 +- .../Mtf/Util/Generate/Factory/Handler.php | 2 +- .../Mtf/Util/Generate/Factory/Page.php | 2 +- .../Mtf/Util/Generate/Factory/Repository.php | 3 +- .../Util/Generate/Fixture/FieldsProvider.php | 4 +- .../Mtf/Util/Generate/Fixture/SchemaXml.php | 2 +- .../Generate/Repository/TableCollection.php | 4 +- .../Util/ModuleResolver/SequenceSorter.php | 2 +- .../CurlTransport/WebapiDecorator.php | 8 ++- .../app/Magento/Backend/Test/Block/Cache.php | 2 +- .../Test/Block/Dashboard/Tab/Products.php | 2 +- .../Backend/Test/Block/Widget/Grid.php | 5 +- .../Backend/Test/Handler/Extractor.php | 2 +- .../Catalog/Product/Edit/Section/Bundle.php | 2 +- .../Product/Edit/Section/Bundle/Option.php | 4 +- .../Test/Block/Catalog/Product/View.php | 2 +- .../Test/Block/AbstractConfigureBlock.php | 2 +- .../Adminhtml/Category/Edit/CategoryForm.php | 5 +- .../Category/Edit/Section/Products.php | 2 +- .../Test/Block/Adminhtml/Category/Tree.php | 2 +- .../Product/Attribute/Edit/Options.php | 2 +- .../Product/Attribute/Edit/Tab/Options.php | 2 +- .../Adminhtml/Product/Attribute/Set/Main.php | 2 +- .../Adminhtml/Product/Composite/Configure.php | 2 +- .../Product/Edit/Section/AdvancedPricing.php | 2 +- .../Product/Edit/Section/Options.php | 4 +- .../Product/Edit/Section/ProductDetails.php | 2 +- .../Product/Edit/Section/Related.php | 2 +- .../Block/Adminhtml/Product/ProductForm.php | 6 +- .../Block/Product/Compare/ListCompare.php | 2 +- .../Test/Block/Product/ListProduct.php | 2 +- .../Block/Product/ProductList/ProductItem.php | 2 +- .../Product/ProductList/PromotedSection.php | 4 +- .../Block/Product/ProductList/Related.php | 4 +- .../Catalog/Test/Block/Product/View.php | 8 +-- ...sertAddedProductAttributeOnProductForm.php | 2 +- ...ductTierPriceOnProductPageWithCustomer.php | 4 +- .../Catalog/Test/Fixture/Product/TaxClass.php | 4 +- .../Product/AbstractCompareProductsTest.php | 2 +- .../Product/CreateSimpleProductEntityTest.php | 4 +- .../Product/MassProductUpdateTest.php | 6 +- .../Product/UpdateSimpleProductEntityTest.php | 4 +- .../UpdateProductAttributeEntityTest.php | 2 +- .../SaveAttributeOnProductPageStep.php | 2 +- .../Test/TestStep/SaveAttributeStep.php | 2 +- ...sertCatalogPriceRuleAppliedCatalogPage.php | 4 +- ...CatalogPriceRuleAppliedOnepageCheckout.php | 12 ++-- ...sertCatalogPriceRuleAppliedProductPage.php | 4 +- ...ertCatalogPriceRuleAppliedShoppingCart.php | 6 +- ...CatalogPriceRuleNotAppliedShoppingCart.php | 2 +- .../Test/Handler/CatalogRule/Curl.php | 4 +- .../AbstractCatalogRuleEntityTest.php | 2 +- ...ApplySeveralCatalogPriceRuleEntityTest.php | 2 +- .../app/Magento/Checkout/Test/Block/Cart.php | 2 +- .../Checkout/Test/Block/Cart/Sidebar.php | 2 +- .../Checkout/Test/Block/Cart/Sidebar/Item.php | 2 +- .../Checkout/Test/Block/Onepage/Payment.php | 2 +- .../Test/Block/Onepage/Payment/Method.php | 2 +- .../AddProductsToShoppingCartEntityTest.php | 4 +- .../DeleteProductFromMiniShoppingCartTest.php | 4 +- .../DeleteProductsFromShoppingCartTest.php | 4 +- ...eProductFromMiniShoppingCartEntityTest.php | 4 +- .../Constraint/AssertTermAbsentOnCheckout.php | 23 +++++-- .../Test/Constraint/AssertTermOnCheckout.php | 23 +++++-- ...mRequireMessageOnMultishippingCheckout.php | 29 ++++---- .../Block/Adminhtml/Block/Edit/BlockForm.php | 2 +- .../Block/Adminhtml/Page/Edit/Tab/Content.php | 4 +- .../Edit/Section/Variations/Config.php | 6 +- .../Section/Variations/Config/Attribute.php | 10 +-- .../Edit/Section/Variations/Config/Matrix.php | 4 +- .../Adminhtml/Product/FormPageActions.php | 2 +- .../Test/Block/Product/View.php | 2 +- .../Product/View/ConfigurableOptions.php | 2 +- ...rtChildProductIsNotDisplayedSeparately.php | 2 +- .../AssertConfigurableProductForm.php | 2 +- .../AbstractCurrencySymbolEntityTest.php | 4 +- .../Block/Account/AddressesAdditional.php | 2 +- .../AssertAddressDeletedBackend.php | 2 +- .../AssertCustomerPasswordChanged.php | 2 +- .../Test/TestCase/AbstractApplyVatIdTest.php | 2 +- .../Customer/Test/TestCase/ApplyVatIdTest.php | 4 +- .../TestCase/ChangeCustomerPasswordTest.php | 2 +- .../CreateExistingCustomerFrontendEntity.php | 2 +- .../TestCase/DeleteCustomerAddressTest.php | 2 +- .../UpdateCustomerFrontendEntityTest.php | 2 +- .../Test/TestCase/CreateCurrencyRateTest.php | 2 +- .../Edit/Section/Downloadable/Links.php | 2 +- .../Edit/Section/Downloadable/Samples.php | 2 +- .../Test/Block/Catalog/Product/View.php | 4 +- .../Test/Block/Adminhtml/Order/Create.php | 2 +- .../Block/Adminhtml/Order/Create/Items.php | 2 +- .../Order/Create/Items/ItemProduct.php | 2 +- .../Test/Block/Adminhtml/Order/View/Items.php | 2 +- .../Order/View/Items/ItemProduct.php | 2 +- .../Test/Block/Cart/GiftOptions.php | 2 +- .../Test/Block/Cart/Item/GiftOptions.php | 2 +- .../AssertGiftMessageInFrontendOrder.php | 2 +- .../AssertGiftMessageInFrontendOrderItems.php | 2 +- .../Product/Grouped/AssociatedProducts.php | 4 +- .../Test/Block/Cart/Sidebar.php | 2 +- .../Test/Block/Catalog/Product/View.php | 2 +- .../Test/Block/Checkout/Cart.php | 2 +- .../Install/Test/TestCase/InstallTest.php | 4 +- .../Adminhtml/Integration/IntegrationGrid.php | 6 +- .../Test/TestCase/FilterProductListTest.php | 4 +- .../Msrp/Test/Block/Product/ListProduct.php | 2 +- .../Block/Product/ProductList/ProductItem.php | 2 +- .../Magento/Msrp/Test/Block/Product/View.php | 2 +- .../Msrp/Test/TestCase/ApplyMapTest.php | 6 +- .../TestStep/FillCustomerAddressesStep.php | 4 +- .../Paypal/Test/Block/Express/Review.php | 2 +- .../Product/Edit/Tab/ImagesAndVideos.php | 2 +- .../Test/Block/Adminhtml/AbstractFilter.php | 2 +- .../Block/Adminhtml/Customer/AccountsGrid.php | 2 +- .../Block/Adminhtml/Product/Sold/Grid.php | 2 +- .../AbandonedCartsReportEntityTest.php | 8 +-- .../CustomerReviewReportEntityTest.php | 2 +- .../DownloadProductsReportEntityTest.php | 7 +- .../ProductsInCartReportEntityTest.php | 6 +- .../TestCase/SalesInvoiceReportEntityTest.php | 5 +- .../TestCase/SalesOrderReportEntityTest.php | 5 +- .../TestCase/SalesRefundsReportEntityTest.php | 7 +- .../TestCase/SalesTaxReportEntityTest.php | 4 +- .../Adminhtml/Customer/Edit/Tab/Reviews.php | 2 +- .../Product/Edit/Section/Reviews.php | 2 +- ...anageProductReviewFromCustomerPageTest.php | 2 +- ...teProductReviewEntityOnProductPageTest.php | 3 +- .../Test/Block/Adminhtml/Order/Actions.php | 2 +- .../Test/Block/Adminhtml/Order/Create.php | 20 +++--- .../Block/Adminhtml/Order/Create/Coupons.php | 2 +- .../Order/Create/CustomerActivities.php | 15 +++-- .../Block/Adminhtml/Order/Create/Items.php | 4 +- .../Order/Create/Shipping/Address.php | 2 +- .../Block/Adminhtml/Order/Creditmemo/Form.php | 2 +- .../Adminhtml/Order/Creditmemo/Form/Items.php | 2 +- .../Block/Adminhtml/Order/Invoice/Form.php | 2 +- .../Adminhtml/Order/Invoice/Form/Items.php | 2 +- .../Block/Adminhtml/Order/View/OrderForm.php | 2 +- .../Adminhtml/Order/View/Tab/CreditMemos.php | 2 +- .../Adminhtml/Order/View/Tab/Invoices.php | 2 +- .../Adminhtml/Order/View/Tab/Shipments.php | 2 +- .../Adminhtml/Order/View/Tab/Transactions.php | 2 +- .../Magento/Sales/Test/Block/Order/View.php | 2 +- .../AbstractAssertOrderOnFrontend.php | 2 +- .../AssertOrderInOrdersGridOnFrontend.php | 2 +- .../AssertOrderNotVisibleOnMyAccount.php | 2 +- .../AssertSalesPrintOrderBillingAddress.php | 2 +- .../TestCase/AssignCustomOrderStatusTest.php | 2 +- .../Test/TestCase/CancelCreatedOrderTest.php | 2 +- .../TestCase/CreateCreditMemoEntityTest.php | 6 +- .../Test/TestCase/CreateInvoiceEntityTest.php | 6 +- .../Test/TestCase/HoldCreatedOrderTest.php | 2 +- .../Test/TestCase/MassOrdersUpdateTest.php | 2 +- .../MoveProductsInComparedOnOrderPageTest.php | 4 +- ...ecentlyComparedProductsOnOrderPageTest.php | 4 +- ...eRecentlyViewedProductsOnOrderPageTest.php | 16 ++--- ...oveShoppingCartProductsOnOrderPageTest.php | 4 +- .../TestCase/UpdateCustomOrderStatusTest.php | 2 +- .../SalesRule/Test/Block/Order/View.php | 2 +- .../AssertCartPriceRuleApplying.php | 2 +- .../SalesRule/Test/Handler/SalesRule/Curl.php | 24 +++---- .../ApplySeveralSalesRuleEntityTest.php | 2 +- .../Test/Page/UserAccountForgotPassword.php | 4 +- ...dminUserWhenCreatingNewIntegrationTest.php | 4 +- .../LockAdminUserWhenCreatingNewRoleTest.php | 4 +- .../TestCase/LockCustomerOnEditPageTest.php | 6 +- .../TestCase/LockCustomerOnLoginPageTest.php | 4 +- .../Shipping/Test/Block/Adminhtml/Form.php | 4 +- .../Test/Block/Adminhtml/Form/Items.php | 2 +- .../Test/Block/Adminhtml/Order/Tracking.php | 2 +- .../Shipping/Test/Block/Order/Shipment.php | 2 +- .../TestCase/CreateShipmentEntityTest.php | 4 +- .../Test/Block/Adminhtml/Rule/Edit/Form.php | 2 +- ...stractAssertTaxWithCrossBorderApplying.php | 2 +- .../Test/Constraint/AssertTaxRuleApplying.php | 2 +- .../TestCase/ApplyTaxBasedOnVatIdTest.php | 8 +-- .../Test/TestCase/CreateTaxRuleEntityTest.php | 2 +- .../Test/TestCase/TaxWithCrossBorderTest.php | 10 +-- .../Test/TestCase/UpdateTaxRuleEntityTest.php | 2 +- .../Ui/Test/Block/Adminhtml/DataGrid.php | 5 +- .../Test/TestCase/UpgradeSystemTest.php | 4 +- .../Test/Block/Adminhtml/Role/Tab/Role.php | 3 +- .../Test/Block/Adminhtml/User/Edit/Form.php | 2 +- .../Block/Adminhtml/User/Edit/PageActions.php | 2 +- .../Test/Block/Adminhtml/User/Tab/Role.php | 3 +- .../AssertUserRoleRestrictedAccess.php | 5 +- .../Constraint/AssertUserSuccessLogin.php | 5 +- .../Test/Fixture/User/CurrentPassword.php | 2 +- .../UserLoginAfterChangingPermissionsTest.php | 3 +- .../System/Variable/FormPageActions.php | 2 +- .../UpdateCustomVariableEntityTest.php | 6 +- .../DeleteCreditCardFromMyAccountStep.php | 5 +- .../app/Magento/Weee/Test/Block/Cart.php | 2 +- .../Magento/Weee/Test/Block/Cart/CartItem.php | 4 +- .../Magento/Weee/Test/Block/Cart/Totals.php | 2 +- .../Weee/Test/Block/Product/ListProduct.php | 2 +- .../Block/Product/ProductList/ProductItem.php | 2 +- .../Magento/Weee/Test/Block/Product/View.php | 2 +- .../Test/TestCase/CreateTaxWithFptTest.php | 8 +-- .../Block/Adminhtml/Widget/ChosenOption.php | 12 ++-- .../ParametersType/CatalogCategoryLink.php | 2 +- .../Tab/ParametersType/CatalogProductLink.php | 2 +- .../Edit/Tab/ParametersType/CmsPageLink.php | 2 +- .../Tab/ParametersType/CmsStaticBlock.php | 2 +- .../Tab/ParametersType/ParametersForm.php | 2 +- .../Instance/Edit/Tab/WidgetInstance.php | 2 +- .../Edit/Tab/WidgetInstanceType/Products.php | 2 +- .../WidgetInstanceType/WidgetInstanceForm.php | 2 +- .../AssertWidgetRecentlyViewedProducts.php | 2 +- .../AbstractCreateWidgetEntityTest.php | 2 +- .../Adminhtml/Customer/Edit/Tab/Wishlist.php | 2 +- .../Customer/Edit/Tab/Wishlist/Grid.php | 2 +- .../Wishlist/Test/Block/Customer/Wishlist.php | 2 +- .../Test/Block/Customer/Wishlist/Items.php | 2 +- .../AssertProductsIsAbsentInWishlist.php | 2 +- .../Test/TestCase/AbstractWishlistTest.php | 6 +- ...eProductFromShoppingCartToWishlistTest.php | 2 +- .../Test/TestCase/ShareWishlistEntityTest.php | 4 +- .../Magento/Mtf/TestSuite/InjectableTests.php | 6 +- dev/tests/functional/utils/generate.php | 10 +-- .../functional/utils/generate/factory.php | 2 +- .../functional/utils/generate/fixture.php | 2 +- .../functional/utils/generate/handler.php | 2 +- dev/tests/functional/utils/generate/page.php | 2 +- .../functional/utils/generate/repository.php | 4 +- .../functional/utils/generateFixtureXml.php | 2 +- .../LiteralNamespacesSniff.php | 66 +++++++++++++++++++ .../CodingStandard/Tool/CodeMessDetector.php | 2 +- .../static/framework/Magento/ruleset.xml | 3 + .../Test/Integrity/Library/InjectableTest.php | 18 ++--- .../Library/PhpParser/ParserFactoryTest.php | 11 ++-- .../Library/PhpParser/StaticCallsTest.php | 4 +- .../Library/PhpParser/ThrowsTest.php | 4 +- .../Library/PhpParser/TokensTest.php | 10 +-- .../Tool/CodeMessDetectorTest.php | 2 +- .../CodingStandard/Tool/CodeSnifferTest.php | 2 +- .../Inspection/JsHint/CommandTest.php | 2 +- .../App/Language/CircularDependencyTest.php | 12 +++- .../Magento/Test/Integrity/ClassesTest.php | 3 +- .../Magento/Test/Integrity/ComposerTest.php | 2 +- .../Test/Integrity/Di/CompilerTest.php | 14 ++-- .../Test/Integrity/ExceptionHierarchyTest.php | 2 +- .../Api/ExtensibleInterfacesTest.php | 2 +- .../Integrity/ObserverImplementationTest.php | 2 +- .../Test/Integrity/Phrase/ArgumentsTest.php | 2 +- .../Test/Integrity/TestPlacementTest.php | 2 +- .../Integrity/_files/blacklist/reference.txt | 34 ++++++++++ 380 files changed, 1208 insertions(+), 981 deletions(-) create mode 100644 dev/tests/static/framework/Magento/Sniffs/LiteralNamespaces/LiteralNamespacesSniff.php diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php index f4cf3f1a0921c..8db89d44152bd 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php @@ -37,7 +37,7 @@ public static function getConsumerCredentials($date = null) $integration = self::_createIntegration('all'); $objectManager = Bootstrap::getObjectManager(); /** @var $oauthService \Magento\Integration\Api\OauthServiceInterface */ - $oauthService = $objectManager->get('Magento\Integration\Api\OauthServiceInterface'); + $oauthService = $objectManager->get(\Magento\Integration\Api\OauthServiceInterface::class); $consumer = $oauthService->loadConsumer($integration->getConsumerId()); $url = TESTS_BASE_URL; $consumer->setCallbackUrl($url); @@ -46,7 +46,7 @@ public static function getConsumerCredentials($date = null) $consumer->setCreatedAt($date); } $consumer->save(); - $token = $objectManager->create('Magento\Integration\Model\Oauth\Token'); + $token = $objectManager->create(\Magento\Integration\Model\Oauth\Token::class); $verifier = $token->createVerifierToken($consumer->getId())->getVerifier(); return [ @@ -112,7 +112,7 @@ public static function getApiAccessCredentials($resources = null, Integration $i $integration = $integrationModel === null ? self::_createIntegration($resources) : $integrationModel; $objectManager = Bootstrap::getObjectManager(); /** @var \Magento\Integration\Api\OauthServiceInterface $oauthService */ - $oauthService = $objectManager->get('Magento\Integration\Api\OauthServiceInterface'); + $oauthService = $objectManager->get(\Magento\Integration\Api\OauthServiceInterface::class); $oauthService->createAccessToken($integration->getConsumerId()); $accessToken = $oauthService->getAccessToken($integration->getConsumerId()); if (!$accessToken) { @@ -176,7 +176,7 @@ protected static function _createIntegration($resources) { $objectManager = Bootstrap::getObjectManager(); /** @var $integrationService \Magento\Integration\Api\IntegrationServiceInterface */ - $integrationService = $objectManager->get('Magento\Integration\Api\IntegrationServiceInterface'); + $integrationService = $objectManager->get(\Magento\Integration\Api\IntegrationServiceInterface::class); $params = ['name' => 'Integration' . microtime()]; diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php index c96717155594a..6b78b9f07664c 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php @@ -89,7 +89,7 @@ public function getAccessTokenEndpoint() */ public function getTestApiEndpoint() { - $defaultStoreCode = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + $defaultStoreCode = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore()->getCode(); return new Uri(TESTS_BASE_URL . '/rest/' . $defaultStoreCode . '/V1/testmodule1'); } diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php index cbf2b44bc7c78..6cc38952aef7c 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php @@ -45,10 +45,12 @@ class Customer extends WebapiAbstract * @var \Magento\Customer\Api\Data\AddressInterfaceFactory */ private $customerAddressFactory; + /** * @var \Magento\Customer\Api\Data\CustomerInterfaceFactory */ private $customerDataFactory; + /** * @var \Magento\Framework\Api\DataObjectHelper */ @@ -62,19 +64,19 @@ public function __construct($name = null, array $data = [], $dataName = '') parent::__construct($name, $data, $dataName); $this->customerAddressFactory = Bootstrap::getObjectManager()->create( - 'Magento\Customer\Api\Data\AddressInterfaceFactory' + \Magento\Customer\Api\Data\AddressInterfaceFactory::class ); $this->customerDataFactory = Bootstrap::getObjectManager()->create( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory' + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class ); $this->dataObjectHelper = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\DataObjectHelper' + \Magento\Framework\Api\DataObjectHelper::class ); $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Reflection\DataObjectProcessor' + \Magento\Framework\Reflection\DataObjectProcessor::class ); } @@ -93,7 +95,7 @@ public function createSampleCustomer() ]; $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( $this->createSampleCustomerDataObject(), - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $requestData = ['customer' => $customerDataArray, 'password' => self::PASSWORD]; $customerData = $this->_webApiCall($serviceInfo, $requestData); @@ -113,7 +115,7 @@ public function createSampleCustomerDataObject() $customerAddress1->setIsDefaultShipping(true); $customerAddress1->setPostcode('75477'); $customerAddress1->setRegion( - Bootstrap::getObjectManager()->create('Magento\Customer\Api\Data\RegionInterfaceFactory') + Bootstrap::getObjectManager()->create(\Magento\Customer\Api\Data\RegionInterfaceFactory::class) ->create() ->setRegionCode(self::ADDRESS_REGION_CODE1) ->setRegion('Alabama') @@ -126,7 +128,7 @@ public function createSampleCustomerDataObject() $customerAddress1->setLastname('Smith'); $address1 = $this->dataObjectProcessor->buildOutputDataArray( $customerAddress1, - 'Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); $customerAddress2 = $this->customerAddressFactory->create(); @@ -135,7 +137,7 @@ public function createSampleCustomerDataObject() $customerAddress2->setIsDefaultShipping(false); $customerAddress2->setPostcode('47676'); $customerAddress2->setRegion( - Bootstrap::getObjectManager()->create('Magento\Customer\Api\Data\RegionInterfaceFactory') + Bootstrap::getObjectManager()->create(\Magento\Customer\Api\Data\RegionInterfaceFactory::class) ->create() ->setRegionCode(self::ADDRESS_REGION_CODE2) ->setRegion('Alabama') @@ -148,7 +150,7 @@ public function createSampleCustomerDataObject() $customerAddress2->setLastname('Smith'); $address2 = $this->dataObjectProcessor->buildOutputDataArray( $customerAddress2, - 'Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); $customerData = [ @@ -179,7 +181,7 @@ public function createSampleCustomerDataObject() $this->dataObjectHelper->populateWithArray( $customer, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); return $customer; } diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Rest.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Rest.php index 96f9773042682..d20bff89be33f 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Rest.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Rest.php @@ -48,13 +48,13 @@ public function __construct() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = Bootstrap::getObjectManager(); - $this->_config = $objectManager->get('Magento\Webapi\Model\Config'); - $this->curlClient = $objectManager->get('Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient'); + $this->_config = $objectManager->get(\Magento\Webapi\Model\Config::class); + $this->curlClient = $objectManager->get(\Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient::class); $this->documentationGenerator = $objectManager->get( - 'Magento\TestFramework\TestCase\Webapi\Adapter\Rest\DocumentationGenerator' + \Magento\TestFramework\TestCase\Webapi\Adapter\Rest\DocumentationGenerator::class ); $this->defaultStoreCode = Bootstrap::getObjectManager() - ->get('Magento\Store\Model\StoreManagerInterface') + ->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore() ->getCode(); } diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Soap.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Soap.php index ba3f9e4a06f99..bbaffc7de6bf0 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Soap.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Soap.php @@ -40,8 +40,8 @@ public function __construct() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = Bootstrap::getObjectManager(); - $this->_soapConfig = $objectManager->get('Magento\Webapi\Model\Soap\Config'); - $this->_converter = $objectManager->get('Magento\Framework\Api\SimpleDataObjectConverter'); + $this->_soapConfig = $objectManager->get(\Magento\Webapi\Model\Soap\Config::class); + $this->_converter = $objectManager->get(\Magento\Framework\Api\SimpleDataObjectConverter::class); ini_set('default_socket_timeout', 120); } @@ -124,7 +124,7 @@ public function generateWsdlUrl($services, $storeCode = null) ksort($services); if ($storeCode == null) { $storeCode = Bootstrap::getObjectManager() - ->get('Magento\Store\Model\StoreManagerInterface') + ->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore() ->getCode(); } diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php index 60678a2d91a11..918e197b4160a 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php @@ -13,6 +13,7 @@ /** * @SuppressWarnings(PHPMD.NumberOfChildren) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ abstract class WebapiAbstract extends \PHPUnit_Framework_TestCase { @@ -94,8 +95,8 @@ abstract class WebapiAbstract extends \PHPUnit_Framework_TestCase * @var array */ protected $_webApiAdaptersMap = [ - self::ADAPTER_SOAP => 'Magento\TestFramework\TestCase\Webapi\Adapter\Soap', - self::ADAPTER_REST => 'Magento\TestFramework\TestCase\Webapi\Adapter\Rest', + self::ADAPTER_SOAP => \Magento\TestFramework\TestCase\Webapi\Adapter\Soap::class, + self::ADAPTER_REST => \Magento\TestFramework\TestCase\Webapi\Adapter\Rest::class, ]; /** @@ -341,9 +342,9 @@ protected static function _enableSecureArea($flag = true) /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->unregister('isSecureArea'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('isSecureArea'); if ($flag) { - $objectManager->get('Magento\Framework\Registry')->register('isSecureArea', $flag); + $objectManager->get(\Magento\Framework\Registry::class)->register('isSecureArea', $flag); } } @@ -421,16 +422,16 @@ protected function _getAppCache() //set application path $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Framework\App\Config\ScopeConfigInterface $config */ - $config = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'); + $config = $objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class); $options = $config->getOptions(); $currentCacheDir = $options->getCacheDir(); $currentEtcDir = $options->getEtcDir(); /** @var Filesystem $filesystem */ - $filesystem = $objectManager->get('Magento\Framework\Filesystem'); + $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class); $options->setCacheDir($filesystem->getDirectoryRead(DirectoryList::CACHE)->getAbsolutePath()); $options->setEtcDir($filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath()); - $this->_appCache = $objectManager->get('Magento\Framework\App\Cache'); + $this->_appCache = $objectManager->get(\Magento\Framework\App\Cache::class); //revert paths options $options->setCacheDir($currentCacheDir); @@ -477,13 +478,13 @@ protected function _updateAppConfig( $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var $config \Magento\Config\Model\Config */ - $config = $objectManager->create('Magento\Config\Model\Config'); + $config = $objectManager->create(\Magento\Config\Model\Config::class); $data[$group]['fields'][$node]['value'] = $value; $config->setSection($section)->setGroups($data)->save(); if ($restore && !isset($this->_origConfigValues[$path])) { $this->_origConfigValues[$path] = (string)$objectManager->get( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class )->getNode( $path, 'default' @@ -493,8 +494,8 @@ protected function _updateAppConfig( //refresh local cache if ($cleanAppCache) { if ($updateLocalConfig) { - $objectManager->get('Magento\Framework\App\Config\ReinitableConfigInterface')->reinit(); - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->reinitStores(); + $objectManager->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class)->reinit(); + $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores(); } if (!$this->_cleanAppConfigCache()) { @@ -572,7 +573,8 @@ protected function checkSoapFault( if ($traceString) { /** Check error trace */ $traceNode = Fault::NODE_DETAIL_TRACE; - $mode = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\State') + $mode = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\App\State::class) ->getMode(); if ($mode == \Magento\Framework\App\State::MODE_DEVELOPER) { /** Developer mode changes tested behavior and it cannot properly be tested for now */ diff --git a/dev/tests/api-functional/framework/bootstrap.php b/dev/tests/api-functional/framework/bootstrap.php index bbf4353442d9e..ff4e69fe743da 100644 --- a/dev/tests/api-functional/framework/bootstrap.php +++ b/dev/tests/api-functional/framework/bootstrap.php @@ -91,9 +91,9 @@ \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap)); $dirSearch = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Framework\Component\DirSearch'); + ->create(\Magento\Framework\Component\DirSearch::class); $themePackageList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Framework\View\Design\Theme\ThemePackageList'); + ->create(\Magento\Framework\View\Design\Theme\ThemePackageList::class); \Magento\Framework\App\Utility\Files::setInstance( new \Magento\Framework\App\Utility\Files( new \Magento\Framework\Component\ComponentRegistrar(), diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/CartItemRepositoryTest.php index aff558da4fca9..054cda57fe899 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/CartItemRepositoryTest.php @@ -29,7 +29,7 @@ protected function setUp() public function testGetAll() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load( + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load( 'test_order_bundle', 'reserved_order_id' ); @@ -69,8 +69,8 @@ public function testGetAll() public function testAddItem() { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(3); - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load( + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(3); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load( 'test_order_item_with_items', 'reserved_order_id' ); @@ -133,7 +133,7 @@ public function testAddItem() public function testUpdate() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load( + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load( 'test_order_bundle', 'reserved_order_id' ); @@ -185,8 +185,7 @@ public function testUpdate() ]; $this->_webApiCall($serviceInfo, $requestData); - - $quoteUpdated = $this->objectManager->create('Magento\Quote\Model\Quote')->load( + $quoteUpdated = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load( 'test_order_bundle', 'reserved_order_id' ); diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php index 9609fbac20e1a..a1bc7e4ff11b3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php @@ -32,7 +32,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $orderItem = current($order->getItems()); @@ -60,13 +60,13 @@ public function testGet() public function testGetList() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + $searchCriteriaBuilder = $this->objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ - $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = $this->objectManager->create(\Magento\Framework\Api\FilterBuilder::class); $searchCriteriaBuilder->addFilters( [ diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php index 9fa2c6a60c22b..070de886077ff 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php @@ -167,10 +167,10 @@ private function addChild($productSku, $optionId, $linkedProduct) protected function getProductOptions($productId) { /** @var \Magento\Catalog\Model\Product $product */ - $product = Bootstrap::getObjectManager()->get('Magento\Catalog\Model\Product'); + $product = Bootstrap::getObjectManager()->get(\Magento\Catalog\Model\Product::class); $product->load($productId); /** @var \Magento\Bundle\Model\Product\Type $type */ - $type = Bootstrap::getObjectManager()->get('Magento\Bundle\Model\Product\Type'); + $type = Bootstrap::getObjectManager()->get(\Magento\Bundle\Model\Product\Type::class); return $type->getOptionsIds($product); } diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php index fa7b172b69c7c..47e6db6a27e0b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php @@ -33,7 +33,7 @@ class ProductServiceTest extends WebapiAbstract public function setUp() { $objectManager = Bootstrap::getObjectManager(); - $this->productCollection = $objectManager->get('Magento\Catalog\Model\ResourceModel\Product\Collection'); + $this->productCollection = $objectManager->get(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetManagementTest.php index cdbba950ba816..af56d58816ce9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetManagementTest.php @@ -196,7 +196,7 @@ protected function getAttributeSetByName($attributeSetName) { $objectManager = Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */ - $attributeSet = $objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') + $attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) ->load($attributeSetName, 'attribute_set_name'); if ($attributeSet->getId() === null) { return null; @@ -214,7 +214,7 @@ protected function getEntityTypeByCode($entityTypeCode) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Type $entityType */ - $entityType = $objectManager->create('Magento\Eav\Model\Config') + $entityType = $objectManager->create(\Magento\Eav\Model\Config::class) ->getEntityType($entityTypeCode); return $entityType; } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetRepositoryTest.php index 2591adad1d4ad..dd29fd0fd666e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetRepositoryTest.php @@ -218,7 +218,7 @@ protected function getAttributeSetByName($attributeSetName) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */ - $attributeSet = $objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') + $attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) ->load($attributeSetName, 'attribute_set_name'); if ($attributeSet->getId() === null) { return null; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php index cdc2a820a9ad4..fd40f76aebf4e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php @@ -31,12 +31,12 @@ protected function setUp() */ public function testAddProductToCartWithCustomOptions() { - $productRepository = $this->objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); + $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var \Magento\Catalog\Api\Data\ProductInterface $product */ $product = $productRepository->get(self::SIMPLE_PRODUCT_SKU); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -81,7 +81,7 @@ public function testAddProductToCartWithCustomOptions() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -119,7 +119,7 @@ public function testGetList() protected function getOptions() { /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ - $productRepository = $this->objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); + $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); $product = $productRepository->get(self::SIMPLE_PRODUCT_SKU); $options = []; /** @var ProductCustomOptionInterface $option */ diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php index a87476dbe13e5..9828d85fb5de0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php @@ -142,7 +142,8 @@ public function testDelete() private function isProductInCategory($categoryId, $productId, $productPosition) { /** @var \Magento\Catalog\Api\CategoryRepositoryInterface $categoryLoader */ - $categoryLoader = Bootstrap::getObjectManager()->create('Magento\Catalog\Api\CategoryRepositoryInterface'); + $categoryLoader = Bootstrap::getObjectManager() + ->create(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $category = $categoryLoader->get($categoryId); $productsPosition = $category->getProductsPosition(); @@ -162,7 +163,7 @@ private function checkIfTestable() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Framework\App\Config\ScopeConfigInterface $config */ - $config = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'); + $config = $objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class); if ($config->getValue('catalog/custom_categories_sort') == 1) { $this->markTestSkipped('Will be fixed after MAGETWO-41737'); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php index f0ad456f1841c..1fded94a26739 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php @@ -81,7 +81,7 @@ public function testUpdateMove($categoryId, $parentId, $afterId, $expectedPositi ]; $this->assertTrue($this->_webApiCall($serviceInfo, $categoryData)); /** @var \Magento\Catalog\Model\Category $model */ - $readService = Bootstrap::getObjectManager()->create('Magento\Catalog\Api\CategoryRepositoryInterface'); + $readService = Bootstrap::getObjectManager()->create(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $model = $readService->get($categoryId); $this->assertEquals($expectedPath, $model->getPath()); $this->assertEquals($expectedPosition, $model->getPosition()); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php index e59b37c918fa4..50a7ef46690b9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php @@ -103,7 +103,7 @@ public function testCreate() public function testDelete() { /** @var \Magento\UrlRewrite\Model\Storage\DbStorage $storage */ - $storage = Bootstrap::getObjectManager()->get('Magento\UrlRewrite\Model\Storage\DbStorage'); + $storage = Bootstrap::getObjectManager()->get(\Magento\UrlRewrite\Model\Storage\DbStorage::class); $categoryId = $this->modelId; $data = [ UrlRewrite::ENTITY_ID => $categoryId, @@ -169,7 +169,7 @@ public function testUpdate() $result = $this->updateCategory($categoryId, $categoryData); $this->assertEquals($categoryId, $result['id']); /** @var \Magento\Catalog\Model\Category $model */ - $model = Bootstrap::getObjectManager()->get('Magento\Catalog\Model\Category'); + $model = Bootstrap::getObjectManager()->get(\Magento\Catalog\Model\Category::class); $category = $model->load($categoryId); $this->assertFalse((bool)$category->getIsActive(), 'Category "is_active" must equal to false'); $this->assertEquals("Update Category Test", $category->getName()); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php index ff51cc0a69afe..1cc85d2175ef9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php @@ -32,7 +32,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $orderItem = current($order->getItems()); @@ -60,13 +60,13 @@ public function testGet() public function testGetList() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + $searchCriteriaBuilder = $this->objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ - $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = $this->objectManager->create(\Magento\Framework\Api\FilterBuilder::class); $searchCriteriaBuilder->addFilters( [ diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php index 0aeabf7613462..39ca92e1eda21 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php @@ -180,7 +180,7 @@ protected function getGroupByName($groupName) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Attribute\Group */ - $attributeGroup = $objectManager->create('Magento\Eav\Model\Entity\Attribute\Group') + $attributeGroup = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Group::class) ->load($groupName, 'attribute_group_name'); if ($attributeGroup->getId() === null) { return null; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php index e0969fc1cc13b..082ae7f108b8e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php @@ -130,7 +130,7 @@ public function testUnassignAttribute() //Assign attribute to attribute set /** @var \Magento\Eav\Model\AttributeManagement $attributeManagement */ - $attributeManagement = Bootstrap::getObjectManager()->get('Magento\Eav\Model\AttributeManagement'); + $attributeManagement = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\AttributeManagement::class); $attributeManagement->assign( \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE, $payload['attributeSetId'], diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php index 1087c3f48be03..19e3112acfba2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php @@ -86,7 +86,7 @@ protected function setUp() protected function getTargetSimpleProduct() { $objectManager = Bootstrap::getObjectManager(); - return $objectManager->get('Magento\Catalog\Model\ProductFactory')->create()->load(1); + return $objectManager->get(\Magento\Catalog\Model\ProductFactory::class)->create()->load(1); } /** @@ -521,7 +521,7 @@ public function testGet() $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\ProductRepository $repository */ - $repository = $objectManager->create('Magento\Catalog\Model\ProductRepository'); + $repository = $objectManager->create(\Magento\Catalog\Model\ProductRepository::class); $product = $repository->get($productSku); $image = current($product->getMediaGallery('images')); $imageId = $image['value_id']; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php index 621a77663b931..0b761d8c191ab 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php @@ -30,7 +30,7 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->productFactory = $this->objectManager->get('Magento\Catalog\Model\ProductFactory'); + $this->productFactory = $this->objectManager->get(\Magento\Catalog\Model\ProductFactory::class); } /** @@ -42,7 +42,7 @@ public function testRemove() $sku = 'simple'; /** @var ProductRepository $productRepository */ $productRepository = $this->objectManager->create( - 'Magento\Catalog\Model\ProductRepository' + \Magento\Catalog\Model\ProductRepository::class ); /** @var \Magento\Catalog\Model\Product $product */ $product = $productRepository->get($sku, false, null, true); @@ -75,7 +75,7 @@ public function testGet() $productSku = 'simple'; /** @var \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $service */ $service = Bootstrap::getObjectManager() - ->get('Magento\Catalog\Api\ProductCustomOptionRepositoryInterface'); + ->get(\Magento\Catalog\Api\ProductCustomOptionRepositoryInterface::class); $options = $service->getList('simple'); $option = current($options); $optionId = $option->getOptionId(); @@ -243,7 +243,7 @@ public function testUpdate() $productSku = 'simple'; /** @var ProductRepository $productRepository */ $productRepository = $this->objectManager->create( - 'Magento\Catalog\Model\ProductRepository' + \Magento\Catalog\Model\ProductRepository::class ); $options = $productRepository->get($productSku, true)->getOptions(); @@ -309,7 +309,7 @@ public function testUpdateOptionAddingNewValue($optionType) /** @var ProductRepository $productRepository */ $productRepository = $this->objectManager->create( - 'Magento\Catalog\Model\ProductRepository' + \Magento\Catalog\Model\ProductRepository::class ); /** @var \Magento\Catalog\Model\Product $product */ $product = $productRepository->get('simple', false, null, true); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php index d379d1661264e..e2451e2cf1594 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php @@ -138,7 +138,7 @@ public function testAssign() protected function getLinkedProducts($sku, $linkType) { /** @var \Magento\Catalog\Model\ProductLink\Management $linkManagement */ - $linkManagement = $this->objectManager->get('Magento\Catalog\Api\ProductLinkManagementInterface'); + $linkManagement = $this->objectManager->get(\Magento\Catalog\Api\ProductLinkManagementInterface::class); $linkedProducts = $linkManagement->getLinkedItemsByType($sku, $linkType); return $linkedProducts; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php index 15820c77b91be..c9ae0e23e5cb3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php @@ -16,7 +16,7 @@ class ProductLinkRepositoryInterfaceTest extends WebapiAbstract const RESOURCE_PATH = '/V1/products/'; /** - * @var \Magento\Framework\ObjectManager + * @var \Magento\Framework\ObjectManagerInterface */ protected $objectManager; @@ -53,7 +53,7 @@ public function testDelete() ] ); /** @var \Magento\Catalog\Model\ProductLink\Management $linkManagement */ - $linkManagement = $this->objectManager->create('Magento\Catalog\Api\ProductLinkManagementInterface'); + $linkManagement = $this->objectManager->create(\Magento\Catalog\Api\ProductLinkManagementInterface::class); $linkedProducts = $linkManagement->getLinkedItemsByType($productSku, $linkType); $this->assertCount(1, $linkedProducts); /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $product */ @@ -95,7 +95,7 @@ public function testSave() ); /** @var \Magento\Catalog\Model\ProductLink\Management $linkManagement */ - $linkManagement = $this->objectManager->get('Magento\Catalog\Api\ProductLinkManagementInterface'); + $linkManagement = $this->objectManager->get(\Magento\Catalog\Api\ProductLinkManagementInterface::class); $actual = $linkManagement->getLinkedItemsByType($productSku, $linkType); $this->assertCount(1, $actual, 'Invalid actual linked products count'); $this->assertEquals(1000, $actual[0]->getPosition(), 'Product position is not updated'); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php index 7b19a0d19c250..7399b405b7e5d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php @@ -149,7 +149,7 @@ public function testCreateAllStoreCode($fixtureProduct) /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ $storeManager = \Magento\TestFramework\ObjectManager::getInstance()->get( - 'Magento\Store\Model\StoreManagerInterface' + \Magento\Store\Model\StoreManagerInterface::class ); foreach ($storeManager->getStores(true) as $store) { diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php index d27349bb2b181..fab38602f6049 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php @@ -43,7 +43,7 @@ public function testGetMultiStore() $productData = $this->productData[0]; $nameInFixtureStore = 'Name in fixture store'; /** @var $store \Magento\Store\Model\Group */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); $this->assertEquals( self::STORE_NAME_FROM_FIXTURE, @@ -52,7 +52,7 @@ public function testGetMultiStore() ); $sku = $productData[Product::SKU]; /** @var \Magento\Catalog\Model\Product $product */ - $product = Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); + $product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku($sku)); $product->setName($nameInFixtureStore)->setStoreId($store->getId())->save(); $serviceInfo = [ @@ -90,13 +90,14 @@ public static function tearDownAfterClass() { parent::tearDownAfterClass(); /** @var \Magento\Framework\Registry $registry */ - $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); /** @var $store \Magento\Store\Model\Store */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); $store->load('fixturestore'); if ($store->getId()) { $store->delete(); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php index b1fd692527cad..b1a1e7a36858d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php @@ -122,7 +122,7 @@ public function testAdd() $this->_webApiCall($serviceInfo, $requestData); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductTierPriceManagementInterface $service */ - $service = $objectManager->get('Magento\Catalog\Api\ProductTierPriceManagementInterface'); + $service = $objectManager->get(\Magento\Catalog\Api\ProductTierPriceManagementInterface::class); $prices = $service->getList($productSku, 1); $this->assertCount(1, $prices); $this->assertEquals(10, $prices[0]->getValue()); @@ -160,7 +160,7 @@ public function testAddWithAllCustomerGrouped() $this->_webApiCall($serviceInfo, $requestData); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductTierPriceManagementInterface $service */ - $service = $objectManager->get('Magento\Catalog\Api\ProductTierPriceManagementInterface'); + $service = $objectManager->get(\Magento\Catalog\Api\ProductTierPriceManagementInterface::class); $prices = $service->getList($productSku, 'all'); $this->assertCount(3, $prices); $this->assertEquals(20, (int)$prices[2]->getValue()); @@ -198,7 +198,7 @@ public function testUpdateWithAllGroups() $this->_webApiCall($serviceInfo, $requestData); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductTierPriceManagementInterface $service */ - $service = $objectManager->get('Magento\Catalog\Api\ProductTierPriceManagementInterface'); + $service = $objectManager->get(\Magento\Catalog\Api\ProductTierPriceManagementInterface::class); $prices = $service->getList($productSku, 'all'); $this->assertCount(2, $prices); $this->assertEquals(20, (int)$prices[0]->getValue()); diff --git a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php index 60fd6215e3787..dad4ffce472b7 100644 --- a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php @@ -101,14 +101,14 @@ public function testStockItemPUTWithWrongInput($newData, $expectedResult, $fixtu /** @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemDetailsDo */ $stockItemDetailsDo = $this->objectManager - ->get('Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory') + ->get(\Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class) ->create(); /** @var \Magento\Framework\Api\DataObjectHelper $dataObjectHelper */ - $dataObjectHelper = $this->objectManager->get('Magento\Framework\Api\DataObjectHelper'); + $dataObjectHelper = $this->objectManager->get(\Magento\Framework\Api\DataObjectHelper::class); $dataObjectHelper->populateWithArray( $stockItemDetailsDo, $newData, - '\Magento\CatalogInventory\Api\Data\StockItemInterface' + \Magento\CatalogInventory\Api\Data\StockItemInterface::class ); $data = $stockItemDetailsDo->getData(); $data['show_default_notification_message'] = false; @@ -116,10 +116,11 @@ public function testStockItemPUTWithWrongInput($newData, $expectedResult, $fixtu $this->assertEquals($stockItemOld['item_id'], $this->_webApiCall($serviceInfo, $arguments)); /** @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory */ - $stockItemFactory = $this->objectManager->get('Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory'); + $stockItemFactory = $this->objectManager + ->get(\Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class); $stockItem = $stockItemFactory->create(); /** @var \Magento\CatalogInventory\Model\ResourceModel\Stock\Item $stockItemResource */ - $stockItemResource = $this->objectManager->get('Magento\CatalogInventory\Model\ResourceModel\Stock\Item'); + $stockItemResource = $this->objectManager->get(\Magento\CatalogInventory\Model\ResourceModel\Stock\Item::class); $stockItemResource->loadByProductId($stockItem, $stockItemOld['product_id'], $stockItemOld['stock_id']); $expectedResult['item_id'] = $stockItem->getItemId(); $this->assertEquals($expectedResult, array_intersect_key($stockItem->getData(), $expectedResult)); diff --git a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php index bd1cb45b1ab18..1d06c58e89910 100644 --- a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php @@ -25,7 +25,7 @@ public function testGetProductStockStatus() $objectManager = Bootstrap::getObjectManager(); /** @var \Magento\Catalog\Model\Product $product */ - $product = $objectManager->get('Magento\Catalog\Model\Product')->load(1); + $product = $objectManager->get(\Magento\Catalog\Model\Product::class)->load(1); $expectedData = $product->getQuantityAndStockStatus(); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php index 413899a684e6c..cb700eee89537 100644 --- a/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryTest.php @@ -40,7 +40,7 @@ protected function getAgreementByName($name) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var $agreement \Magento\CheckoutAgreements\Model\Agreement */ - $agreement = $objectManager->create('Magento\CheckoutAgreements\Model\Agreement'); + $agreement = $objectManager->create(\Magento\CheckoutAgreements\Model\Agreement::class); $agreement->load($name, 'name'); if (!$agreement->getId()) { throw new \InvalidArgumentException('There is no checkout agreement with provided ID.'); diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php index 554cbe195800d..df814b01e1ac4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php @@ -48,11 +48,12 @@ class BlockRepositoryTest extends WebapiAbstract */ public function setUp() { - $this->blockFactory = Bootstrap::getObjectManager()->create('Magento\Cms\Api\Data\BlockInterfaceFactory'); - $this->blockRepository = Bootstrap::getObjectManager()->create('Magento\Cms\Api\BlockRepositoryInterface'); - $this->dataObjectHelper = Bootstrap::getObjectManager()->create('Magento\Framework\Api\DataObjectHelper'); + $this->blockFactory = Bootstrap::getObjectManager()->create(\Magento\Cms\Api\Data\BlockInterfaceFactory::class); + $this->blockRepository = Bootstrap::getObjectManager() + ->create(\Magento\Cms\Api\BlockRepositoryInterface::class); + $this->dataObjectHelper = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\DataObjectHelper::class); $this->dataObjectProcessor = Bootstrap::getObjectManager() - ->create('Magento\Framework\Reflection\DataObjectProcessor'); + ->create(\Magento\Framework\Reflection\DataObjectProcessor::class); } /** @@ -152,11 +153,11 @@ public function testUpdate() $this->dataObjectHelper->populateWithArray( $this->currentBlock, [BlockInterface::TITLE => $newBlockTitle], - 'Magento\Cms\Api\Data\BlockInterface' + \Magento\Cms\Api\Data\BlockInterface::class ); $blockData = $this->dataObjectProcessor->buildOutputDataArray( $this->currentBlock, - 'Magento\Cms\Api\Data\BlockInterface' + \Magento\Cms\Api\Data\BlockInterface::class ); $serviceInfo = [ @@ -221,10 +222,10 @@ public function testSearch() ->setIdentifier($blockIdentifier); $this->currentBlock = $this->blockRepository->save($blockDataObject); - $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() - ->create('Magento\Framework\Api\SearchCriteriaBuilder'); + ->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); $filter = $filterBuilder ->setField(BlockInterface::IDENTIFIER) ->setValue($blockIdentifier) diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php index 88a32e8789dd3..328578e1e4c08 100644 --- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php @@ -48,11 +48,11 @@ class PageRepositoryTest extends WebapiAbstract */ public function setUp() { - $this->pageFactory = Bootstrap::getObjectManager()->create('Magento\Cms\Api\Data\PageInterfaceFactory'); - $this->pageRepository = Bootstrap::getObjectManager()->create('Magento\Cms\Api\PageRepositoryInterface'); - $this->dataObjectHelper = Bootstrap::getObjectManager()->create('Magento\Framework\Api\DataObjectHelper'); + $this->pageFactory = Bootstrap::getObjectManager()->create(\Magento\Cms\Api\Data\PageInterfaceFactory::class); + $this->pageRepository = Bootstrap::getObjectManager()->create(\Magento\Cms\Api\PageRepositoryInterface::class); + $this->dataObjectHelper = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\DataObjectHelper::class); $this->dataObjectProcessor = Bootstrap::getObjectManager() - ->create('Magento\Framework\Reflection\DataObjectProcessor'); + ->create(\Magento\Framework\Reflection\DataObjectProcessor::class); } /** @@ -152,11 +152,11 @@ public function testUpdate() $this->dataObjectHelper->populateWithArray( $this->currentPage, [PageInterface::TITLE => $newPageTitle], - 'Magento\Cms\Api\Data\PageInterface' + \Magento\Cms\Api\Data\PageInterface::class ); $pageData = $this->dataObjectProcessor->buildOutputDataArray( $this->currentPage, - 'Magento\Cms\Api\Data\PageInterface' + \Magento\Cms\Api\Data\PageInterface::class ); $serviceInfo = [ @@ -221,10 +221,10 @@ public function testSearch() ->setIdentifier($pageIdentifier); $this->currentPage = $this->pageRepository->save($pageDataObject); - $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() - ->create('Magento\Framework\Api\SearchCriteriaBuilder'); + ->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); $filter = $filterBuilder ->setField(PageInterface::IDENTIFIER) ->setValue($pageIdentifier) diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/CartItemRepositoryTest.php index ab2ec81cfdd14..34e44bbc1e4b1 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/CartItemRepositoryTest.php @@ -31,7 +31,7 @@ protected function setUp() public function testAddProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -76,7 +76,7 @@ public function testAddProduct() public function testAddProductWithIncorrectOptions() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -111,7 +111,7 @@ public function testUpdateIncorrectItem() { $qty = 1; /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_cart_with_configurable', 'reserved_order_id'); $cartId = $quote->getId(); @@ -143,7 +143,7 @@ public function testUpdate() $this->updateStockForItem(20, 100); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_cart_with_configurable', 'reserved_order_id'); $cartId = $quote->getId(); @@ -198,7 +198,7 @@ public function testUpdate() protected function updateStockForItem($itemId, $qty) { /** @var \Magento\CatalogInventory\Model\Stock\Status $stockStatus */ - $stockStatus = $this->objectManager->create('Magento\CatalogInventory\Model\Stock\Status'); + $stockStatus = $this->objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class); $stockStatus->load($itemId, 'product_id'); if (!$stockStatus->getProductId()) { $stockStatus->setProductId($itemId); @@ -208,7 +208,7 @@ protected function updateStockForItem($itemId, $qty) $stockStatus->save(); /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ - $stockItem = $this->objectManager->create('Magento\CatalogInventory\Model\Stock\Item'); + $stockItem = $this->objectManager->create(\Magento\CatalogInventory\Model\Stock\Item::class); $stockItem->load($itemId, 'product_id'); if (!$stockItem->getProductId()) { @@ -228,7 +228,7 @@ public function testUpdateQty() { $qty = 1; /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_cart_with_configurable', 'reserved_order_id'); $cartId = $quote->getId(); @@ -281,7 +281,7 @@ public function testUpdateQty() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_cart_with_configurable', 'reserved_order_id'); $cartId = $quote->getId(); @@ -325,7 +325,7 @@ public function testGetList() protected function getRequestData($cartId, $selectedOption = null) { /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ - $productRepository = $this->objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); + $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); $product = $productRepository->get(self::CONFIGURABLE_PRODUCT_SKU); $configurableProductOptions = $product->getExtensionAttributes()->getConfigurableProductOptions(); diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ConfigurableProductManagementTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ConfigurableProductManagementTest.php index 548c423bc3af4..bcfc3b858d363 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ConfigurableProductManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ConfigurableProductManagementTest.php @@ -32,7 +32,7 @@ public function testGetVariation() ]; /** @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository */ $attributeRepository = Bootstrap::getObjectManager()->get( - 'Magento\Catalog\Api\ProductAttributeRepositoryInterface' + \Magento\Catalog\Api\ProductAttributeRepositoryInterface::class ); $attribute = $attributeRepository->get('test_configurable'); $attributeOptionValue = $attribute->getOptions()[1]->getValue(); diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php index 854c26d147a5e..d913a0c4b6109 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php @@ -32,7 +32,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $orderItem = current($order->getItems()); @@ -60,13 +60,13 @@ public function testGet() public function testGetList() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + $searchCriteriaBuilder = $this->objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ - $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = $this->objectManager->create(\Magento\Framework\Api\FilterBuilder::class); $searchCriteriaBuilder->addFilters( [ diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ProductRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ProductRepositoryTest.php index 6862d178acc22..14656f779040a 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ProductRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ProductRepositoryTest.php @@ -42,7 +42,7 @@ class ProductRepositoryTest extends WebapiAbstract public function setUp() { $this->objectManager = Bootstrap::getObjectManager(); - $this->eavConfig = $this->objectManager->get('Magento\Eav\Model\Config'); + $this->eavConfig = $this->objectManager->get(\Magento\Eav\Model\Config::class); } /** @@ -58,7 +58,7 @@ protected function getConfigurableAttributeOptions() { /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection $optionCollection */ $optionCollection = $this->objectManager->create( - 'Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection' + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class ); $options = $optionCollection->setAttributeFilter($this->configurableAttribute->getId())->getData(); return $options; diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php index e9da19b5f7d2c..3f897786232d9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php @@ -68,18 +68,18 @@ class AccountManagementCustomAttributesTest extends WebapiAbstract public function setUp() { $this->accountManagement = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Api\AccountManagementInterface' + \Magento\Customer\Api\AccountManagementInterface::class ); $this->customerHelper = new CustomerHelper(); $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Reflection\DataObjectProcessor' + \Magento\Framework\Reflection\DataObjectProcessor::class ); - $this->imageFactory = Bootstrap::getObjectManager()->get('Magento\Framework\Api\ImageContentFactory'); + $this->imageFactory = Bootstrap::getObjectManager()->get(\Magento\Framework\Api\ImageContentFactory::class); - $this->fileSystem = Bootstrap::getObjectManager()->get('Magento\Framework\Filesystem'); + $this->fileSystem = Bootstrap::getObjectManager()->get(\Magento\Framework\Filesystem::class); } public function tearDown() @@ -122,7 +122,7 @@ protected function createCustomerWithDefaultImageAttribute() $imageData = $this->dataObjectProcessor->buildOutputDataArray( $image, - '\Magento\Framework\Api\Data\ImageContentInterface' + \Magento\Framework\Api\Data\ImageContentInterface::class ); return $this->createCustomerWithImageAttribute($imageData); } @@ -151,7 +151,7 @@ protected function createCustomerWithImageAttribute($imageData) $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $customerDataArray['custom_attributes'][] = [ 'attribute_code' => 'customer_image', @@ -205,7 +205,7 @@ public function testCreateCustomerWithInvalidImageAttribute() $imageData = $this->dataObjectProcessor->buildOutputDataArray( $image, - '\Magento\Framework\Api\Data\ImageContentInterface' + \Magento\Framework\Api\Data\ImageContentInterface::class ); $expectedMessage = 'The image content must be valid base64 encoded data.'; try { @@ -239,7 +239,7 @@ public function testUpdateCustomerWithImageAttribute() ->setBase64EncodedData($imageData); $imageData = $this->dataObjectProcessor->buildOutputDataArray( $image, - '\Magento\Framework\Api\Data\ImageContentInterface' + \Magento\Framework\Api\Data\ImageContentInterface::class ); //Replace image attribute diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php index 4f79db11674c7..0b6dd9d6b9ba3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php @@ -67,16 +67,16 @@ public function setUp() $this->_markTestAsRestOnly(); $this->customerRegistry = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Model\CustomerRegistry' + \Magento\Customer\Model\CustomerRegistry::class ); $this->customerRepository = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, ['customerRegistry' => $this->customerRegistry] ); $this->customerAccountManagement = Bootstrap::getObjectManager() - ->get('Magento\Customer\Api\AccountManagementInterface'); + ->get(\Magento\Customer\Api\AccountManagementInterface::class); $this->customerHelper = new CustomerHelper(); $this->customerData = $this->customerHelper->createSampleCustomer(); @@ -85,7 +85,7 @@ public function setUp() $this->resetTokenForCustomerSampleData(); $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Reflection\DataObjectProcessor' + \Magento\Framework\Reflection\DataObjectProcessor::class ); } @@ -97,7 +97,7 @@ public function tearDown() unset($this->customerRepository); /** @var \Magento\Framework\Registry $registry */ - $registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); @@ -130,7 +130,7 @@ public function testUpdateCustomer() $updatedCustomerData = $this->dataObjectProcessor->buildOutputDataArray( $customerData, - 'Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $updatedCustomerData[CustomerInterface::LASTNAME] = $lastName . 'Updated'; $updatedCustomerData[CustomerInterface::ID] = 25; @@ -157,7 +157,7 @@ public function testGetCustomerData() $customerData = $this->_getCustomerData($this->customerData[CustomerInterface::ID]); $expectedCustomerDetails = $this->dataObjectProcessor->buildOutputDataArray( $customerData, - 'Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $expectedCustomerDetails['addresses'][0]['id'] = (int)$expectedCustomerDetails['addresses'][0]['id']; diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index 376b240770aad..d18415f54b822 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -83,24 +83,24 @@ class AccountManagementTest extends WebapiAbstract public function setUp() { $this->accountManagement = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Api\AccountManagementInterface' + \Magento\Customer\Api\AccountManagementInterface::class ); $this->searchCriteriaBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->sortOrderBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SortOrderBuilder' + \Magento\Framework\Api\SortOrderBuilder::class ); $this->filterGroupBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\Search\FilterGroupBuilder' + \Magento\Framework\Api\Search\FilterGroupBuilder::class ); $this->customerHelper = new CustomerHelper(); $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Reflection\DataObjectProcessor' + \Magento\Framework\Reflection\DataObjectProcessor::class ); $this->config = Bootstrap::getObjectManager()->create( - 'Magento\Config\Model\Config' + \Magento\Config\Model\Config::class ); if ($this->config->getConfigDataValue( @@ -170,7 +170,7 @@ public function testCreateCustomerWithErrors() $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( $this->customerHelper->createSampleCustomerDataObject(), - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $invalidEmail = 'invalid'; $customerDataArray['email'] = $invalidEmail; @@ -276,7 +276,7 @@ public function testValidateResetPasswordLinkToken() { $customerData = $this->_createCustomer(); /** @var \Magento\Customer\Model\Customer $customerModel */ - $customerModel = Bootstrap::getObjectManager()->create('Magento\Customer\Model\CustomerFactory') + $customerModel = Bootstrap::getObjectManager()->create(\Magento\Customer\Model\CustomerFactory::class) ->create(); $customerModel->load($customerData[Customer::ID]); $rpToken = 'lsdj579slkj5987slkj595lkj'; @@ -566,7 +566,7 @@ public function testValidateCustomerData() ]; $customerData = $this->dataObjectProcessor->buildOutputDataArray( $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $requestData = ['customer' => $customerData]; $validationResponse = $this->_webApiCall($serviceInfo, $requestData); @@ -674,7 +674,7 @@ public function testCustomAttributes() $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $requestData = ['customer' => $customerDataArray, 'password' => CustomerHelper::PASSWORD]; $customerData = $this->_webApiCall($serviceInfo, $requestData); diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php index 3201dec47760c..4b5065d0b8aac 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php @@ -68,7 +68,7 @@ public function getAttributeMetadataDataProvider() AttributeMetadata::VALIDATION_RULES => [], AttributeMetadata::VISIBLE => true, AttributeMetadata::REQUIRED => false, - AttributeMetadata::DATA_MODEL => 'Magento\Customer\Model\Attribute\Data\Postcode', + AttributeMetadata::DATA_MODEL => \Magento\Customer\Model\Attribute\Data\Postcode::class, AttributeMetadata::OPTIONS => [], AttributeMetadata::FRONTEND_CLASS => '', AttributeMetadata::USER_DEFINED => false, @@ -270,7 +270,7 @@ public static function tearDownAfterClass() parent::tearDownAfterClass(); /** @var \Magento\Customer\Model\Attribute $attribute */ $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Model\Attribute' + \Magento\Customer\Model\Attribute::class ); foreach (['custom_attribute1', 'custom_attribute2'] as $attributeCode) { $attribute->loadByCode('customer_address', $attributeCode); diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php index 18b32837190ae..607e6d6731598 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php @@ -25,10 +25,10 @@ protected function setUp() { $objectManager = Bootstrap::getObjectManager(); $this->customerRepository = $objectManager->get( - 'Magento\Customer\Api\CustomerRepositoryInterface' + \Magento\Customer\Api\CustomerRepositoryInterface::class ); $this->addressRepository = $objectManager->get( - 'Magento\Customer\Api\AddressRepositoryInterface' + \Magento\Customer\Api\AddressRepositoryInterface::class ); parent::setUp(); } @@ -39,7 +39,7 @@ protected function setUp() protected function tearDown() { /** @var \Magento\Framework\Registry $registry */ - $registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); @@ -116,7 +116,10 @@ public function testDeleteAddress() $response = $this->_webApiCall($serviceInfo, $requestData); $this->assertTrue($response, 'Expected response should be true.'); - $this->setExpectedException('Magento\Framework\Exception\NoSuchEntityException', 'No such entity with addressId = 1'); + $this->setExpectedException( + \Magento\Framework\Exception\NoSuchEntityException::class, + 'No such entity with addressId = 1' + ); $this->addressRepository->getById($fixtureAddressId); } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index cf2e2fa3b7d71..62e4cbaa5cbbc 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -88,32 +88,32 @@ class CustomerRepositoryTest extends WebapiAbstract public function setUp() { $this->customerRegistry = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Model\CustomerRegistry' + \Magento\Customer\Model\CustomerRegistry::class ); $this->customerRepository = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, ['customerRegistry' => $this->customerRegistry] ); $this->dataObjectHelper = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\DataObjectHelper' + \Magento\Framework\Api\DataObjectHelper::class ); $this->customerDataFactory = Bootstrap::getObjectManager()->create( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory' + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class ); $this->searchCriteriaBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->sortOrderBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SortOrderBuilder' + \Magento\Framework\Api\SortOrderBuilder::class ); $this->filterGroupBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\Search\FilterGroupBuilder' + \Magento\Framework\Api\Search\FilterGroupBuilder::class ); $this->customerHelper = new CustomerHelper(); $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Reflection\DataObjectProcessor' + \Magento\Framework\Reflection\DataObjectProcessor::class ); } @@ -167,7 +167,7 @@ public function testDeleteCustomer() //Verify if the customer is deleted $this->setExpectedException( - 'Magento\Framework\Exception\NoSuchEntityException', + \Magento\Framework\Exception\NoSuchEntityException::class, sprintf("No such entity with customerId = %s", $customerData[Customer::ID]) ); $this->_getCustomerData($customerData[Customer::ID]); @@ -218,7 +218,7 @@ public function testUpdateCustomer() $this->dataObjectHelper->populateWithArray( $newCustomerDataObject, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $serviceInfo = [ @@ -234,7 +234,7 @@ public function testUpdateCustomer() ]; $newCustomerDataObject = $this->dataObjectProcessor->buildOutputDataArray( $newCustomerDataObject, - 'Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $requestData = ['customer' => $newCustomerDataObject]; $response = $this->_webApiCall($serviceInfo, $requestData); @@ -258,7 +258,7 @@ public function testUpdateCustomerNoWebsiteId() $this->dataObjectHelper->populateWithArray( $newCustomerDataObject, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $serviceInfo = [ @@ -274,7 +274,7 @@ public function testUpdateCustomerNoWebsiteId() ]; $newCustomerDataObject = $this->dataObjectProcessor->buildOutputDataArray( $newCustomerDataObject, - 'Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); unset($newCustomerDataObject['website_id']); $requestData = ['customer' => $newCustomerDataObject]; @@ -309,7 +309,7 @@ public function testUpdateCustomerException() $this->dataObjectHelper->populateWithArray( $newCustomerDataObject, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $serviceInfo = [ @@ -325,7 +325,7 @@ public function testUpdateCustomerException() ]; $newCustomerDataObject = $this->dataObjectProcessor->buildOutputDataArray( $newCustomerDataObject, - 'Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $requestData = ['customer' => $newCustomerDataObject]; @@ -355,7 +355,7 @@ public function testCreateCustomerWithoutAddressRequiresException() { $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( $this->customerHelper->createSampleCustomerDataObject(), - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); foreach ($customerDataArray[Customer::KEY_ADDRESSES] as & $address) { @@ -430,7 +430,7 @@ public function testCreateCustomerWithoutAddressRequiresException() */ public function testSearchCustomers() { - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $customerData = $this->_createCustomer(); $filter = $builder ->setField(Customer::EMAIL) @@ -439,7 +439,7 @@ public function testSearchCustomers() $this->searchCriteriaBuilder->addFilters([$filter]); $searchData = $this->dataObjectProcessor->buildOutputDataArray( $this->searchCriteriaBuilder->create(), - 'Magento\Framework\Api\SearchCriteriaInterface' + \Magento\Framework\Api\SearchCriteriaInterface::class ); $requestData = ['searchCriteria' => $searchData]; $serviceInfo = [ @@ -464,7 +464,7 @@ public function testSearchCustomers() public function testSearchCustomersUsingGET() { $this->_markTestAsRestOnly('SOAP test is covered in testSearchCustomers'); - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $customerData = $this->_createCustomer(); $filter = $builder ->setField(Customer::EMAIL) @@ -518,7 +518,7 @@ public function testSearchCustomersUsingGETEmptyFilter() */ public function testSearchCustomersMultipleFiltersWithSort() { - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $customerData1 = $this->_createCustomer(); $customerData2 = $this->_createCustomer(); $filter1 = $builder->setField(Customer::EMAIL) @@ -535,7 +535,7 @@ public function testSearchCustomersMultipleFiltersWithSort() /**@var \Magento\Framework\Api\SortOrderBuilder $sortOrderBuilder */ $sortOrderBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SortOrderBuilder' + \Magento\Framework\Api\SortOrderBuilder::class ); /** @var SortOrder $sortOrder */ $sortOrder = $sortOrderBuilder->setField(Customer::EMAIL)->setDirection(SortOrder::SORT_ASC)->create(); @@ -567,7 +567,7 @@ public function testSearchCustomersMultipleFiltersWithSort() public function testSearchCustomersMultipleFiltersWithSortUsingGET() { $this->_markTestAsRestOnly('SOAP test is covered in testSearchCustomers'); - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $customerData1 = $this->_createCustomer(); $customerData2 = $this->_createCustomer(); $filter1 = $builder->setField(Customer::EMAIL) @@ -603,7 +603,7 @@ public function testSearchCustomersMultipleFiltersWithSortUsingGET() */ public function testSearchCustomersNonExistentMultipleFilters() { - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $customerData1 = $this->_createCustomer(); $customerData2 = $this->_createCustomer(); $filter1 = $filter1 = $builder->setField(Customer::EMAIL) @@ -641,7 +641,7 @@ public function testSearchCustomersNonExistentMultipleFilters() public function testSearchCustomersNonExistentMultipleFiltersGET() { $this->_markTestAsRestOnly('SOAP test is covered in testSearchCustomers'); - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $customerData1 = $this->_createCustomer(); $customerData2 = $this->_createCustomer(); $filter1 = $filter1 = $builder->setField(Customer::EMAIL) @@ -677,7 +677,7 @@ public function testSearchCustomersMultipleFilterGroups() $customerData1 = $this->_createCustomer(); /** @var \Magento\Framework\Api\FilterBuilder $builder */ - $builder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $builder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); $filter1 = $builder->setField(Customer::EMAIL) ->setValue($customerData1[Customer::EMAIL]) ->create(); diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupManagementTest.php index d61efaa26b203..88eb687394920 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupManagementTest.php @@ -37,8 +37,8 @@ class GroupManagementTest extends WebapiAbstract public function setUp() { $objectManager = Bootstrap::getObjectManager(); - $this->groupRegistry = $objectManager->get('Magento\Customer\Model\GroupRegistry'); - $this->groupRepository = $objectManager->get('Magento\Customer\Model\ResourceModel\GroupRepository'); + $this->groupRegistry = $objectManager->get(\Magento\Customer\Model\GroupRegistry::class); + $this->groupRepository = $objectManager->get(\Magento\Customer\Model\ResourceModel\GroupRepository::class); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php index a16e7ee59f623..b9894dd1d37ed 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php @@ -43,9 +43,9 @@ class GroupRepositoryTest extends WebapiAbstract public function setUp() { $objectManager = Bootstrap::getObjectManager(); - $this->groupRegistry = $objectManager->get('Magento\Customer\Model\GroupRegistry'); - $this->groupRepository = $objectManager->get('Magento\Customer\Model\ResourceModel\GroupRepository'); - $this->customerGroupFactory = $objectManager->create('Magento\Customer\Api\Data\GroupInterfaceFactory'); + $this->groupRegistry = $objectManager->get(\Magento\Customer\Model\GroupRegistry::class); + $this->groupRepository = $objectManager->get(\Magento\Customer\Model\ResourceModel\GroupRepository::class); + $this->customerGroupFactory = $objectManager->create(\Magento\Customer\Api\Data\GroupInterfaceFactory::class); } /** @@ -922,10 +922,10 @@ public function testSearchGroupsDataProvider() */ public function testSearchGroups($filterField, $filterValue, $expectedResult) { - $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() - ->create('Magento\Framework\Api\SearchCriteriaBuilder'); + ->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); $filter = $filterBuilder ->setField($filterField) ->setValue($filterValue) @@ -970,10 +970,10 @@ public function testSearchGroups($filterField, $filterValue, $expectedResult) public function testSearchGroupsWithGET($filterField, $filterValue, $expectedResult) { $this->_markTestAsRestOnly('SOAP is covered in '); - $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\FilterBuilder::class); /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() - ->create('Magento\Framework\Api\SearchCriteriaBuilder'); + ->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); $filter = $filterBuilder ->setField($filterField) ->setValue($filterValue) diff --git a/dev/tests/api-functional/testsuite/Magento/Directory/Api/CountryInformationAcquirerTest.php b/dev/tests/api-functional/testsuite/Magento/Directory/Api/CountryInformationAcquirerTest.php index 7bf29eb67f4fa..92d5eca21d6b2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Directory/Api/CountryInformationAcquirerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Directory/Api/CountryInformationAcquirerTest.php @@ -22,7 +22,7 @@ class CountryInformationAcquirerTest extends WebapiAbstract public function testGetCountries() { /** @var $store \Magento\Store\Model\Group */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); $this->assertNotEmpty($store->getId(), 'Precondition failed: fixture store was not created.'); @@ -47,7 +47,7 @@ public function testGetCountries() public function testGetCountry() { /** @var $store \Magento\Store\Model\Group */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); $this->assertNotEmpty($store->getId(), 'Precondition failed: fixture store was not created.'); @@ -122,13 +122,14 @@ public static function tearDownAfterClass() { parent::tearDownAfterClass(); /** @var \Magento\Framework\Registry $registry */ - $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); /** @var $store \Magento\Store\Model\Store */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); if ($store->getId()) { $store->delete(); diff --git a/dev/tests/api-functional/testsuite/Magento/Directory/Api/CurrencyInformationAcquirerTest.php b/dev/tests/api-functional/testsuite/Magento/Directory/Api/CurrencyInformationAcquirerTest.php index d52ea26d44889..d5b4725c119a2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Directory/Api/CurrencyInformationAcquirerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Directory/Api/CurrencyInformationAcquirerTest.php @@ -21,7 +21,7 @@ class CurrencyInformationAcquirerTest extends WebapiAbstract public function testGet() { /** @var $store \Magento\Store\Model\Group */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); $this->assertNotEmpty($store->getId(), 'Precondition failed: fixture store was not created.'); @@ -103,13 +103,15 @@ public static function tearDownAfterClass() { parent::tearDownAfterClass(); /** @var \Magento\Framework\Registry $registry */ - $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); /** @var $store \Magento\Store\Model\Store */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Store\Model\Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); if ($store->getId()) { $store->delete(); diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php index 4dcb1fa60206e..469d568db0f4f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php @@ -29,10 +29,10 @@ protected function setUp() public function testAddItem() { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(1); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(1); $productSku = $product->getSku(); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('reserved_order_id', 'reserved_order_id'); $cartId = $quote->getId(); $serviceInfo = [ @@ -86,9 +86,9 @@ public function testAddItem() public function testAddItemWithInvalidLinkId() { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(1); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(1); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('reserved_order_id', 'reserved_order_id'); $cartId = $quote->getId(); $productSku = $product->getSku(); @@ -129,10 +129,10 @@ public function testAddItemWithInvalidLinkId() public function testUpdateItem() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('reserved_order_id_1', 'reserved_order_id'); $cartId = $quote->getId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('downloadable-product')); // use ID of the first quote item $itemId = $quote->getAllItems()[0]->getId(); @@ -187,10 +187,10 @@ public function testUpdateItem() public function testUpdateItemWithInvalidLinkId() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('reserved_order_id_1', 'reserved_order_id'); $cartId = $quote->getId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('downloadable-product')); // use ID of the first quote item $itemId = $quote->getAllItems()[0]->getId(); @@ -232,10 +232,10 @@ public function testUpdateItemWithInvalidLinkId() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('reserved_order_id_1', 'reserved_order_id'); $cartId = $quote->getId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('downloadable-product')); // use ID of the first downloadable link $linkId = array_values($product->getDownloadableLinks())[0]->getId(); @@ -281,9 +281,9 @@ public function testGetList() public function testUpdateItemQty() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('reserved_order_id_1', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('downloadable-product')); $cartId = $quote->getId(); // use ID of the first quote item diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php index 86c8439b6d507..524d91ab54877 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php @@ -82,9 +82,12 @@ protected function getTargetProduct($isScopeGlobal = false) { $objectManager = Bootstrap::getObjectManager(); if ($isScopeGlobal) { - $product = $objectManager->get('Magento\Catalog\Model\ProductFactory')->create()->setStoreId(0)->load(1); + $product = $objectManager->get(\Magento\Catalog\Model\ProductFactory::class) + ->create() + ->setStoreId(0) + ->load(1); } else { - $product = $objectManager->get('Magento\Catalog\Model\ProductFactory')->create()->load(1); + $product = $objectManager->get(\Magento\Catalog\Model\ProductFactory::class)->create()->load(1); } return $product; diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php index e586131adcfe5..56547eff8e600 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php @@ -32,7 +32,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $orderItem = current($order->getItems()); @@ -60,13 +60,13 @@ public function testGet() public function testGetList() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + $searchCriteriaBuilder = $this->objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ - $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = $this->objectManager->create(\Magento\Framework\Api\FilterBuilder::class); $searchCriteriaBuilder->addFilters( [ diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php index 8d00b0c94be8a..152ac1f628181 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php @@ -80,10 +80,12 @@ protected function setUp() protected function getTargetProduct($isScopeGlobal = false) { if ($isScopeGlobal) { - $product = Bootstrap::getObjectManager()->get('Magento\Catalog\Model\ProductFactory') + $product = Bootstrap::getObjectManager()->get(\Magento\Catalog\Model\ProductFactory::class) ->create()->setStoreId(0)->load(1); } else { - $product = Bootstrap::getObjectManager()->get('Magento\Catalog\Model\ProductFactory')->create()->load(1); + $product = Bootstrap::getObjectManager()->get(\Magento\Catalog\Model\ProductFactory::class) + ->create() + ->load(1); } return $product; diff --git a/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetManagementTest.php index 14e63bfdbdf76..b52a375cca373 100644 --- a/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetManagementTest.php @@ -210,7 +210,7 @@ protected function getAttributeSetByName($attributeSetName) { $objectManager = Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */ - $attributeSet = $objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') + $attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) ->load($attributeSetName, 'attribute_set_name'); if ($attributeSet->getId() === null) { return null; @@ -228,7 +228,7 @@ protected function getEntityTypeByCode($entityTypeCode) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Type $entityType */ - $entityType = $objectManager->create('Magento\Eav\Model\Config') + $entityType = $objectManager->create(\Magento\Eav\Model\Config::class) ->getEntityType($entityTypeCode); return $entityType; } diff --git a/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php index 2b6cef9caac4f..4de337a1f5747 100644 --- a/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php @@ -141,7 +141,7 @@ public function testDeleteByIdDefaultAttributeSet() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Config */ - $eavConfig = $objectManager->create('Magento\Eav\Model\Config'); + $eavConfig = $objectManager->create(\Magento\Eav\Model\Config::class); $defaultAttributeSetId = $eavConfig ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) @@ -250,7 +250,7 @@ protected function getAttributeSetByName($attributeSetName) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */ - $attributeSet = $objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') + $attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) ->load($attributeSetName, 'attribute_set_name'); if ($attributeSet->getId() === null) { return null; diff --git a/dev/tests/api-functional/testsuite/Magento/Framework/Stdlib/CookieManagerTest.php b/dev/tests/api-functional/testsuite/Magento/Framework/Stdlib/CookieManagerTest.php index a65323690962c..b148c02c2cae5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Framework/Stdlib/CookieManagerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Framework/Stdlib/CookieManagerTest.php @@ -24,8 +24,8 @@ class CookieManagerTest extends \Magento\TestFramework\TestCase\WebapiAbstract public function setUp() { $objectManager = Bootstrap::getObjectManager(); - $this->config = $objectManager->get('Magento\Webapi\Model\Config'); - $this->curlClient = $objectManager->get('Magento\TestFramework\TestCase\Webapi\Curl'); + $this->config = $objectManager->get(\Magento\Webapi\Model\Config::class); + $this->curlClient = $objectManager->get(\Magento\TestFramework\TestCase\Webapi\Curl::class); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php index ee8307d9043fb..8a1cacf27e1bf 100644 --- a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/CartRepositoryTest.php @@ -33,7 +33,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('message_order_21', 'reserved_order_id'); $cartId = $quote->getId(); @@ -73,7 +73,7 @@ public function testGetForMyCart() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -108,7 +108,7 @@ public function testSave() // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); $cartId = $quote->getId(); @@ -136,7 +136,7 @@ public function testSave() $quote->load('test_order_item_with_message', 'reserved_order_id'); $quote->getGiftMessageId(); /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($quote->getGiftMessageId()); + $message = $this->objectManager->create(\Magento\GiftMessage\Model\Message::class)->load($quote->getGiftMessageId()); $this->assertEquals('John Doe', $message->getRecipient()); $this->assertEquals('Jane Roe', $message->getSender()); $this->assertEquals('Gift Message Text New', $message->getMessage()); @@ -152,7 +152,7 @@ public function testSaveForMyCart() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -178,11 +178,11 @@ public function testSaveForMyCart() $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); $quote->getGiftMessageId(); /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($quote->getGiftMessageId()); + $message = $this->objectManager->create(\Magento\GiftMessage\Model\Message::class)->load($quote->getGiftMessageId()); $this->assertEquals('John Doe', $message->getRecipient()); $this->assertEquals('Jane Roe', $message->getSender()); $this->assertEquals('Gift Message Text New', $message->getMessage()); diff --git a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestCartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestCartRepositoryTest.php index e8af0c393e62b..59eee3389d431 100644 --- a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestCartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestCartRepositoryTest.php @@ -33,12 +33,12 @@ protected function setUp() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('message_order_21', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -79,12 +79,12 @@ public function testSave() // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -114,7 +114,8 @@ public function testSave() $quote->load('test_order_item_with_message', 'reserved_order_id'); $quote->getGiftMessageId(); /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($quote->getGiftMessageId()); + $message = $this->objectManager->create(\Magento\GiftMessage\Model\Message::class) + ->load($quote->getGiftMessageId()); $this->assertEquals('John Doe', $message->getRecipient()); $this->assertEquals('Jane Roe', $message->getSender()); $this->assertEquals('Gift Message Text New', $message->getMessage()); diff --git a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestItemRepositoryTest.php index 1d4ce015b23ef..a11e20a7f2db8 100644 --- a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/GuestItemRepositoryTest.php @@ -33,16 +33,16 @@ protected function setUp() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('simple_with_message')); $itemId = $quote->getItemByProduct($product)->getId(); /** @var \Magento\Catalog\Model\Product $product */ $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -83,15 +83,15 @@ public function testSave() // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('simple_with_message')); $itemId = $quote->getItemByProduct($product)->getId(); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -122,7 +122,7 @@ public function testSave() // $quote->load('test_order_item_with_message', 'reserved_order_id'); $messageId = $quote->getItemByProduct($product)->getGiftMessageId(); /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($messageId); + $message = $this->objectManager->create(\Magento\GiftMessage\Model\Message::class)->load($messageId); $this->assertEquals('John Doe', $message->getRecipient()); $this->assertEquals('Jane Roe', $message->getSender()); $this->assertEquals('Gift Message Text New', $message->getMessage()); diff --git a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php index 85c804bb05a01..4f047dddc99b3 100644 --- a/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GiftMessage/Api/ItemRepositoryTest.php @@ -33,9 +33,9 @@ protected function setUp() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('simple_with_message')); $itemId = $quote->getItemByProduct($product)->getId(); /** @var \Magento\Catalog\Model\Product $product */ @@ -75,15 +75,14 @@ public function testGetForMyCart() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ - $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + $customerTokenService = $this->objectManager->create(\Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('simple_with_message')); $itemId = $quote->getItemByProduct($product)->getId(); /** @var \Magento\Catalog\Model\Product $product */ @@ -118,10 +117,10 @@ public function testSave() // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); $cartId = $quote->getId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('simple_with_message')); $itemId = $quote->getItemByProduct($product)->getId(); $serviceInfo = [ @@ -149,7 +148,7 @@ public function testSave() // $quote->load('test_order_item_with_message', 'reserved_order_id'); $messageId = $quote->getItemByProduct($product)->getGiftMessageId(); /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($messageId); + $message = $this->objectManager->create(\Magento\GiftMessage\Model\Message::class)->load($messageId); $this->assertEquals('John Doe', $message->getRecipient()); $this->assertEquals('Jane Roe', $message->getSender()); $this->assertEquals('Gift Message Text New', $message->getMessage()); @@ -164,8 +163,7 @@ public function testSaveForMyCart() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ - $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + $customerTokenService = $this->objectManager->create(\Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -173,9 +171,9 @@ public function testSaveForMyCart() // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed $this->markTestIncomplete('This test relies on system configuration state.'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_message', 'reserved_order_id'); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($product->getIdBySku('simple_with_message')); $itemId = $quote->getItemByProduct($product)->getId(); $serviceInfo = [ @@ -198,7 +196,7 @@ public function testSaveForMyCart() // $quote->load('test_order_item_with_message', 'reserved_order_id'); $messageId = $quote->getItemByProduct($product)->getGiftMessageId(); /** @var \Magento\GiftMessage\Model\Message $message */ - $message = $this->objectManager->create('Magento\GiftMessage\Model\Message')->load($messageId); + $message = $this->objectManager->create(\Magento\GiftMessage\Model\Message::class)->load($messageId); $this->assertEquals('John Doe', $message->getRecipient()); $this->assertEquals('Jane Roe', $message->getSender()); $this->assertEquals('Gift Message Text New', $message->getMessage()); diff --git a/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php index 4c2a8b2a7217f..9c2b2e15a6692 100644 --- a/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php @@ -57,7 +57,7 @@ public function testSave() $this->_webApiCall($serviceInfo, ['entity' => $productData]); /** @var \Magento\Catalog\Api\ProductLinkManagementInterface $linkManagement */ - $linkManagement = $this->objectManager->get('Magento\Catalog\Api\ProductLinkManagementInterface'); + $linkManagement = $this->objectManager->get(\Magento\Catalog\Api\ProductLinkManagementInterface::class); $actual = $linkManagement->getLinkedItemsByType($productSku, $linkType); array_walk($actual, function (&$item) { $item = $item->__toArray(); diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php index 3f0471ba7cee1..e01d02959f5d4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php @@ -16,6 +16,7 @@ /** * api-functional test for \Magento\Integration\Model\AdminTokenService. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AdminTokenServiceTest extends WebapiAbstract { @@ -49,9 +50,9 @@ class AdminTokenServiceTest extends WebapiAbstract public function setUp() { $this->_markTestAsRestOnly(); - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Model\AdminTokenService'); - $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); - $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); + $this->tokenService = Bootstrap::getObjectManager()->get(\Magento\Integration\Model\AdminTokenService::class); + $this->tokenModel = Bootstrap::getObjectManager()->get(\Magento\Integration\Model\Oauth\Token::class); + $this->userModel = Bootstrap::getObjectManager()->get(\Magento\User\Model\User::class); /** @var TokenThrottlerConfig $tokenThrottlerConfig */ $tokenThrottlerConfig = Bootstrap::getObjectManager()->get(TokenThrottlerConfig::class); $this->attemptsCountToLockAccount = $tokenThrottlerConfig->getMaxFailuresCount(); diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php index f04f1472e0f58..7836723647699 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php @@ -19,6 +19,8 @@ /** * api-functional test for \Magento\Integration\Model\CustomerTokenService. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CustomerTokenServiceTest extends WebapiAbstract { @@ -57,15 +59,17 @@ class CustomerTokenServiceTest extends WebapiAbstract public function setUp() { $this->_markTestAsRestOnly(); - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Model\CustomerTokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get( + \Magento\Integration\Model\CustomerTokenService::class + ); $this->customerAccountManagement = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Api\AccountManagementInterface' + \Magento\Customer\Api\AccountManagementInterface::class ); $tokenCollectionFactory = Bootstrap::getObjectManager()->get( - 'Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory' + \Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory::class ); $this->tokenCollection = $tokenCollectionFactory->create(); - $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); + $this->userModel = Bootstrap::getObjectManager()->get(\Magento\User\Model\User::class); /** @var TokenThrottlerConfig $tokenThrottlerConfig */ $tokenThrottlerConfig = Bootstrap::getObjectManager()->get(TokenThrottlerConfig::class); $this->attemptsCountToLockAccount = $tokenThrottlerConfig->getMaxFailuresCount(); diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php index c8258deb9ad79..7585c704e37c0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php @@ -13,12 +13,11 @@ class IntegrationTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** @var \Magento\Integration\Model\Integration */ protected $integration; - protected function setUp() { $objectManager = Bootstrap::getObjectManager(); /** @var $integrationService \Magento\Integration\Api\IntegrationServiceInterface */ - $integrationService = $objectManager->get('Magento\Integration\Api\IntegrationServiceInterface'); + $integrationService = $objectManager->get(\Magento\Integration\Api\IntegrationServiceInterface::class); $params = [ 'all_resources' => true, diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php index 351a006b1cd29..4213b0c5c1ff3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php @@ -30,7 +30,7 @@ protected function setUp() */ public function testGetAddress() { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); /** @var \Magento\Quote\Model\Quote\Address $address */ @@ -85,7 +85,7 @@ public function testGetAddress() public function testSetAddress() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = [ @@ -123,7 +123,7 @@ public function testSetAddress() $addressId = $this->_webApiCall($serviceInfo, $requestData); //reset $quote to reload data - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $address = $quote->getBillingAddress(); $address->getRegionCode(); @@ -152,11 +152,11 @@ public function testGetMyAddress() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); /** @var \Magento\Quote\Model\Quote\Address $address */ @@ -208,12 +208,12 @@ public function testSetMyAddress() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = [ @@ -245,7 +245,7 @@ public function testSetMyAddress() $addressId = $this->_webApiCall($serviceInfo, $requestData); //reset $quote to reload data - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $address = $quote->getBillingAddress(); $address->getRegionCode(); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php index 2df5e512403bf..eda5e523ce90d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php @@ -30,7 +30,7 @@ protected function setUp() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); $output = []; @@ -71,10 +71,10 @@ public function testGetList() public function testAddItem() { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(2); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(2); $productSku = $product->getSku(); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); $serviceInfo = [ @@ -107,10 +107,10 @@ public function testAddItem() public function testRemoveItem() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $productId = $product->getIdBySku('simple_one'); $product->load($productId); $itemId = $quote->getItemByProduct($product)->getId(); @@ -131,7 +131,7 @@ public function testRemoveItem() "itemId" => $itemId, ]; $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertFalse($quote->hasProductId($productId)); } @@ -142,10 +142,10 @@ public function testRemoveItem() public function testUpdateItem() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $productId = $product->getIdBySku('simple_one'); $product->load($productId); $itemId = $quote->getItemByProduct($product)->getId(); @@ -178,7 +178,7 @@ public function testUpdateItem() ]; } $this->_webApiCall($serviceInfo, $requestData); - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertTrue($quote->hasProductId(1)); $item = $quote->getItemByProduct($product); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php index 8bcca6865bc63..43134e838c9c7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php @@ -30,7 +30,7 @@ protected function setUp() public function tearDown() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); foreach ($this->createdQuotes as $quoteId) { $quote->load($quoteId); $quote->delete(); @@ -63,7 +63,7 @@ public function testCreateEmptyCartForGuest() public function testCreateEmptyCartForCustomer() { /** @var $repository \Magento\Customer\Api\CustomerRepositoryInterface */ - $repository = $this->objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface'); + $repository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */ $customer = $repository->getById(1); $customerId = $customer->getId(); @@ -95,7 +95,7 @@ public function testCreateEmptyCartAndGetCartForCustomer() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -131,10 +131,10 @@ public function testCreateEmptyCartAndGetCartForCustomer() public function testAssignCustomer() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var $repository \Magento\Customer\Api\CustomerRepositoryInterface */ - $repository = $this->objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface'); + $repository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */ $customer = $repository->getById(1); $customerId = $customer->getId(); @@ -161,7 +161,7 @@ public function testAssignCustomer() $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); // Reload target quote - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $this->assertEquals(0, $quote->getCustomerIsGuest()); $this->assertEquals($customer->getId(), $quote->getCustomerId()); $this->assertEquals($customer->getFirstname(), $quote->getCustomerFirstname()); @@ -175,7 +175,7 @@ public function testAssignCustomer() public function testAssignCustomerThrowsExceptionIfThereIsNoCustomerWithGivenId() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); $customerId = 9999; $serviceInfo = [ @@ -234,10 +234,10 @@ public function testAssignCustomerThrowsExceptionIfThereIsNoCartWithGivenId() public function testAssignCustomerThrowsExceptionIfTargetCartIsNotAnonymous() { /** @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->objectManager->create('Magento\Customer\Model\Customer')->load(1); + $customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class)->load(1); $customerId = $customer->getId(); /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); $serviceInfo = [ @@ -268,11 +268,11 @@ public function testAssignCustomerThrowsExceptionIfTargetCartIsNotAnonymous() */ public function testAssignCustomerThrowsExceptionIfCartIsAssignedToDifferentStore() { - $repository = $this->objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface'); + $repository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */ $customer = $repository->getById(1); /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $customerId = $customer->getId(); $cartId = $quote->getId(); @@ -306,14 +306,14 @@ public function testAssignCustomerThrowsExceptionIfCartIsAssignedToDifferentStor public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart() { /** @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->objectManager->create('Magento\Customer\Model\Customer')->load(1); + $customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class)->load(1); // Customer has a quote with reserved order ID test_order_1 (see fixture) /** @var $customerQuote \Magento\Quote\Model\Quote */ - $customerQuote = $this->objectManager->create('Magento\Quote\Model\Quote') + $customerQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class) ->load('test_order_1', 'reserved_order_id'); $customerQuote->setIsActive(1)->save(); /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); $customerId = $customer->getId(); @@ -344,7 +344,8 @@ public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart( public function testPlaceOrder() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test_order_1', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class) + ->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); $serviceInfo = [ @@ -362,7 +363,7 @@ public function testPlaceOrder() $orderId = $this->_webApiCall($serviceInfo, ['cartId' => $cartId]); /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); $items = $order->getAllItems(); $this->assertCount(1, $items); $this->assertEquals('Simple Product', $items[0]->getName()); @@ -378,7 +379,7 @@ public function testPlaceOrderForMyCart() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -393,7 +394,7 @@ public function testPlaceOrderForMyCart() $orderId = $this->_webApiCall($serviceInfo, []); /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); $items = $order->getAllItems(); $this->assertCount(1, $items); $this->assertEquals('Simple Product', $items[0]->getName()); @@ -409,7 +410,7 @@ public function testGetCartForCustomer() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -465,7 +466,7 @@ public function testGetCartForCustomer() protected function getCart($reservedOrderId) { /** @var $cart \Magento\Quote\Model\Quote */ - $cart = $this->objectManager->get('Magento\Quote\Model\Quote'); + $cart = $this->objectManager->get(\Magento\Quote\Model\Quote::class); $cart->load($reservedOrderId, 'reserved_order_id'); if (!$cart->getId()) { throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php index f957221877ac6..feb1d10634cde 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php @@ -12,6 +12,9 @@ use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CartRepositoryTest extends WebapiAbstract { /** @@ -38,13 +41,13 @@ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $this->sortOrderBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SortOrderBuilder' + \Magento\Framework\Api\SortOrderBuilder::class ); $this->searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); } @@ -69,7 +72,7 @@ protected function tearDown() protected function getCart($reservedOrderId) { /** @var $cart \Magento\Quote\Model\Quote */ - $cart = $this->objectManager->get('Magento\Quote\Model\Quote'); + $cart = $this->objectManager->get(\Magento\Quote\Model\Quote::class); $cart->load($reservedOrderId, 'reserved_order_id'); if (!$cart->getId()) { throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php index 9008cf4d96998..8c3e5672578cd 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php @@ -34,10 +34,10 @@ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); } @@ -47,7 +47,7 @@ protected function setUp() public function testGetTotals() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -194,12 +194,12 @@ public function testGetMyTotals() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php index 4b8c90d7c9f58..34a24e542ea47 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php @@ -31,7 +31,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); $couponCode = $quote->getCouponCode(); @@ -57,7 +57,7 @@ public function testGet() public function testDelete() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); $serviceInfo = [ @@ -85,7 +85,7 @@ public function testDelete() public function testSetCouponThrowsExceptionIfCouponDoesNotExist() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -118,12 +118,12 @@ public function testSetCouponThrowsExceptionIfCouponDoesNotExist() public function testSetCouponSuccess() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\SalesRule\Model\Rule $salesRule */ - $salesRule = $this->objectManager->create('Magento\SalesRule\Model\Rule'); - $salesRuleId = $this->objectManager->get('Magento\Framework\Registry') + $salesRule = $this->objectManager->create(\Magento\SalesRule\Model\Rule::class); + $salesRuleId = $this->objectManager->get(\Magento\Framework\Registry::class) ->registry('Magento/Checkout/_file/discount_10percent'); $salesRule->load($salesRuleId); $couponCode = $salesRule->getPrimaryCoupon()->getCode(); @@ -146,7 +146,7 @@ public function testSetCouponSuccess() $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quoteWithCoupon = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quoteWithCoupon = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quoteWithCoupon->load('test01', 'reserved_order_id'); $this->assertEquals($quoteWithCoupon->getCouponCode(), $couponCode); @@ -162,12 +162,12 @@ public function testGetMyCoupon() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $couponCode = $quote->getCouponCode(); $serviceInfo = [ @@ -192,12 +192,12 @@ public function testDeleteMyCoupon() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = [ 'rest' => [ @@ -224,7 +224,7 @@ public function testSetMyCouponThrowsExceptionIfCouponDoesNotExist() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -257,24 +257,24 @@ public function testSetMyCouponSuccess() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\SalesRule\Model\Rule $salesRule */ - $salesRule = $this->objectManager->create('Magento\SalesRule\Model\Rule'); - $salesRuleId = $this->objectManager->get('Magento\Framework\Registry') + $salesRule = $this->objectManager->create(\Magento\SalesRule\Model\Rule::class); + $salesRuleId = $this->objectManager->get(\Magento\Framework\Registry::class) ->registry('Magento/Checkout/_file/discount_10percent_generalusers'); $salesRule->load($salesRuleId); $couponCode = $salesRule->getPrimaryCoupon()->getCode(); /* Since this isn't a full quote fixture, need to assign it to the right customer */ $cartManagementService = $this->objectManager->create( - 'Magento\Quote\Api\CartManagementInterface' + \Magento\Quote\Api\CartManagementInterface::class ); $cartManagementService->assignCustomer($cartId, 1, 1); @@ -292,7 +292,7 @@ public function testSetMyCouponSuccess() $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quoteWithCoupon = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quoteWithCoupon = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quoteWithCoupon->load('test01', 'reserved_order_id'); $this->assertEquals($quoteWithCoupon->getCouponCode(), $couponCode); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php index 12b10608a3208..fe811eb2dcd25 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php @@ -28,7 +28,7 @@ protected function setUp() protected function getQuoteMaskedId($quoteId) { /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMaskFactory')->create(); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)->create(); $quoteIdMask->load($quoteId, 'quote_id'); return $quoteIdMask->getMaskedId(); } @@ -38,7 +38,7 @@ protected function getQuoteMaskedId($quoteId) */ public function testGetAddress() { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); /** @var \Magento\Quote\Model\Quote\Address $address */ @@ -92,7 +92,7 @@ public function testGetAddress() public function testSetAddress() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getQuoteMaskedId($quote->getId()); @@ -132,7 +132,7 @@ public function testSetAddress() $addressId = $this->_webApiCall($serviceInfo, $requestData); //reset $quote to reload data - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $address = $quote->getBillingAddress(); $address->getRegionCode(); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php index dba8d6e666c16..ac42c45bcc9f3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php @@ -30,13 +30,13 @@ protected function setUp() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -82,16 +82,16 @@ public function testGetList() public function testAddItem() { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->objectManager->create('Magento\Catalog\Model\Product')->load(2); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(2); $productSku = $product->getSku(); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -127,19 +127,19 @@ public function testAddItem() public function testRemoveItem() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id $cartId = $quoteIdMask->getMaskedId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $productId = $product->getIdBySku('simple_one'); $product->load($productId); $itemId = $quote->getItemByProduct($product)->getId(); @@ -160,7 +160,7 @@ public function testRemoveItem() "itemId" => $itemId, ]; $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertFalse($quote->hasProductId($productId)); } @@ -171,19 +171,19 @@ public function testRemoveItem() public function testUpdateItem() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id $cartId = $quoteIdMask->getMaskedId(); - $product = $this->objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $productId = $product->getIdBySku('simple_one'); $product->load($productId); $itemId = $quote->getItemByProduct($product)->getId(); @@ -216,7 +216,7 @@ public function testUpdateItem() ]; } $this->_webApiCall($serviceInfo, $requestData); - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertTrue($quote->hasProductId(1)); $item = $quote->getItemByProduct($product); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php index 9edc016983f6b..b25dff65cb7e6 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php @@ -49,12 +49,12 @@ public function testCreate() public function tearDown() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); foreach ($this->createdQuotes as $quoteId) { $quote->load($quoteId); $quote->delete(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMask'); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMask::class); $quoteIdMask->load($quoteId, 'quote_id'); $quoteIdMask->delete(); } @@ -67,11 +67,11 @@ public function tearDown() public function testAssignCustomer() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMaskFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory'); + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class); $quoteIdMask = $quoteIdMaskFactory->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -80,11 +80,11 @@ public function testAssignCustomer() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var $repository \Magento\Customer\Api\CustomerRepositoryInterface */ - $repository = $this->objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface'); + $repository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */ $customer = $repository->getById(1); $customerId = $customer->getId(); @@ -113,7 +113,7 @@ public function testAssignCustomer() $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); // Reload target quote - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $this->assertEquals(0, $quote->getCustomerIsGuest()); $this->assertEquals($customer->getId(), $quote->getCustomerId()); $this->assertEquals($customer->getFirstname(), $quote->getCustomerFirstname()); @@ -128,7 +128,7 @@ public function testAssignCustomer() public function testAssignCustomerThrowsExceptionIfThereIsNoCustomerWithGivenId() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); $customerId = 9999; $serviceInfo = [ @@ -187,15 +187,15 @@ public function testAssignCustomerThrowsExceptionIfThereIsNoCartWithGivenId() public function testAssignCustomerThrowsExceptionIfTargetCartIsNotAnonymous() { /** @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->objectManager->create('Magento\Customer\Model\Customer')->load(1); + $customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class)->load(1); $customerId = $customer->getId(); /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -204,7 +204,7 @@ public function testAssignCustomerThrowsExceptionIfTargetCartIsNotAnonymous() // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -239,20 +239,20 @@ public function testAssignCustomerThrowsExceptionIfTargetCartIsNotAnonymous() public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart() { /** @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->objectManager->create('Magento\Customer\Model\Customer')->load(1); + $customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class)->load(1); // Customer has a quote with reserved order ID test_order_1 (see fixture) /** @var $customerQuote \Magento\Quote\Model\Quote */ - $customerQuote = $this->objectManager->create('Magento\Quote\Model\Quote') + $customerQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class) ->load('test_order_1', 'reserved_order_id'); $customerQuote->setIsActive(1)->save(); /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -263,7 +263,7 @@ public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart( // get customer ID token /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); $serviceInfo = [ @@ -294,11 +294,12 @@ public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart( public function testPlaceOrder() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test_order_1', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class) + ->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -319,7 +320,7 @@ public function testPlaceOrder() $orderId = $this->_webApiCall($serviceInfo, ['cartId' => $cartId]); /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); $items = $order->getAllItems(); $this->assertCount(1, $items); $this->assertEquals('Simple Product', $items[0]->getName()); @@ -334,16 +335,16 @@ public function testPlaceOrder() public function testAssignCustomerByGuestUser() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote')->load('test01', 'reserved_order_id'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id'); $cartId = $quote->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMaskFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory'); + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class); $quoteIdMask = $quoteIdMaskFactory->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id $cartId = $quoteIdMask->getMaskedId(); - $repository = $this->objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface'); + $repository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */ $customer = $repository->getById(1); $customerId = $customer->getId(); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartRepositoryTest.php index 125009ca86efc..aa251f1e7745f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartRepositoryTest.php @@ -27,7 +27,7 @@ protected function tearDown() $cartId = $cart->getId(); $cart->delete(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMask'); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMask::class); $quoteIdMask->load($cartId, 'quote_id'); $quoteIdMask->delete(); } catch (\InvalidArgumentException $e) { @@ -46,7 +46,7 @@ protected function tearDown() protected function getCart($reservedOrderId) { /** @var $cart \Magento\Quote\Model\Quote */ - $cart = $this->objectManager->get('Magento\Quote\Model\Quote'); + $cart = $this->objectManager->get(\Magento\Quote\Model\Quote::class); $cart->load($reservedOrderId, 'reserved_order_id'); if (!$cart->getId()) { throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); @@ -64,7 +64,7 @@ public function testGetCart() /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php index c348e8104b221..c7227d4ecca16 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php @@ -34,17 +34,17 @@ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); } protected function getQuoteMaskedId($quoteId) { /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMaskFactory')->create(); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)->create(); $quoteIdMask->load($quoteId, 'quote_id'); return $quoteIdMask->getMaskedId(); } @@ -56,7 +56,7 @@ public function testGetTotals() { $this->markTestSkipped('Will be fixed after MAGETWO-35573'); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getQuoteMaskedId($quote->getId()); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCouponManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCouponManagementTest.php index eba7cdb2cd4ee..5427ac6542df9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCouponManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCouponManagementTest.php @@ -29,12 +29,12 @@ public function tearDown() { $createdQuotes = ['test_order_1', 'test01']; /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); foreach ($createdQuotes as $quoteId) { $quote->load($quoteId, 'reserved_order_id'); $quote->delete(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMask'); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMask::class); $quoteIdMask->load($quoteId, 'quote_id'); $quoteIdMask->delete(); } @@ -43,7 +43,7 @@ public function tearDown() protected function getQuoteMaskedId($quoteId) { /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMaskFactory')->create(); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)->create(); $quoteIdMask->load($quoteId, 'quote_id'); return $quoteIdMask->getMaskedId(); } @@ -54,7 +54,7 @@ protected function getQuoteMaskedId($quoteId) public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getQuoteMaskedId($quote->getId()); @@ -82,7 +82,7 @@ public function testGet() public function testDelete() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getQuoteMaskedId($quote->getId()); $serviceInfo = [ @@ -110,7 +110,7 @@ public function testDelete() public function testSetCouponThrowsExceptionIfCouponDoesNotExist() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getQuoteMaskedId($quote->getId()); @@ -143,11 +143,11 @@ public function testSetCouponThrowsExceptionIfCouponDoesNotExist() public function testSetCouponSuccess() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test01', 'reserved_order_id'); $cartId = $this->getQuoteMaskedId($quote->getId()); - $salesRule = $this->objectManager->create('Magento\SalesRule\Model\Rule'); - $salesRuleId = $this->objectManager->get('Magento\Framework\Registry') + $salesRule = $this->objectManager->create(\Magento\SalesRule\Model\Rule::class); + $salesRuleId = $this->objectManager->get(\Magento\Framework\Registry::class) ->registry('Magento/Checkout/_file/discount_10percent'); $salesRule->load($salesRuleId); $couponCode = $salesRule->getPrimaryCoupon()->getCode(); @@ -170,7 +170,7 @@ public function testSetCouponSuccess() $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quoteWithCoupon = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quoteWithCoupon = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quoteWithCoupon->load('test01', 'reserved_order_id'); $this->assertEquals($quoteWithCoupon->getCouponCode(), $couponCode); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestPaymentMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestPaymentMethodManagementTest.php index b4d97f342b18e..72ba254066414 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestPaymentMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestPaymentMethodManagementTest.php @@ -40,14 +40,14 @@ protected function deleteCart($reservedOrderId) { try { /** @var $cart \Magento\Quote\Model\Quote */ - $cart = $this->objectManager->get('Magento\Quote\Model\Quote'); + $cart = $this->objectManager->get(\Magento\Quote\Model\Quote::class); $cart->load($reservedOrderId, 'reserved_order_id'); if (!$cart->getId()) { throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); } $cart->delete(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMask'); + $quoteIdMask = $this->objectManager->create(\Magento\Quote\Model\QuoteIdMask::class); $quoteIdMask->load($cart->getId(), 'quote_id'); $quoteIdMask->delete(); } catch (\InvalidArgumentException $e) { @@ -61,7 +61,7 @@ protected function deleteCart($reservedOrderId) public function testReSetPayment() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1_with_payment', 'reserved_order_id'); $cartId = $this->getMaskedCartId($quote->getId()); @@ -94,7 +94,7 @@ public function testReSetPayment() public function testSetPaymentWithVirtualProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_with_virtual_product', 'reserved_order_id'); $cartId = $this->getMaskedCartId($quote->getId()); @@ -126,7 +126,7 @@ public function testSetPaymentWithVirtualProduct() public function testSetPaymentWithSimpleProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getMaskedCartId($quote->getId()); @@ -161,7 +161,7 @@ public function testSetPaymentWithSimpleProduct() public function testSetPaymentWithSimpleProductWithoutAddress() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); $cartId = $this->getMaskedCartId($quote->getId()); @@ -193,7 +193,7 @@ public function testSetPaymentWithSimpleProductWithoutAddress() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $this->getMaskedCartId($quote->getId()); @@ -227,7 +227,7 @@ public function testGetList() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1_with_payment', 'reserved_order_id'); $cartId = $this->getMaskedCartId($quote->getId()); @@ -272,7 +272,7 @@ protected function getMaskedCartId($cartId) { /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); return $quoteIdMask->getMaskedId(); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php index a59381f9ca19b..9a1673f82f738 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php @@ -33,8 +33,8 @@ class GuestShippingMethodManagementTest extends WebapiAbstract protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $this->totalsCollector = $this->objectManager->create('Magento\Quote\Model\Quote\TotalsCollector'); + $this->quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + $this->totalsCollector = $this->objectManager->create(\Magento\Quote\Model\Quote\TotalsCollector::class); } /** @@ -43,12 +43,12 @@ protected function setUp() */ public function testGetListForVirtualCart() { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -63,7 +63,7 @@ public function testGetListForVirtualCart() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); if (!$cartId) { @@ -72,7 +72,7 @@ public function testGetList() /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->create(); $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id @@ -121,7 +121,7 @@ protected function convertRates($groupedRates, $currencyCode) { $result = []; /** @var \Magento\Quote\Model\Cart\ShippingMethodConverter $converter */ - $converter = $this->objectManager->create('\Magento\Quote\Model\Cart\ShippingMethodConverter'); + $converter = $this->objectManager->create(\Magento\Quote\Model\Cart\ShippingMethodConverter::class); foreach ($groupedRates as $carrierRates) { foreach ($carrierRates as $rate) { $result[] = $converter->modelToDataObject($rate, $currencyCode)->__toArray(); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php index cb373135dca5e..012e1d5ec9c5a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php @@ -27,7 +27,7 @@ protected function setUp() public function testReSetPayment() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1_with_payment', 'reserved_order_id'); $cartId = $quote->getId(); @@ -60,7 +60,7 @@ public function testReSetPayment() public function testSetPaymentWithVirtualProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_with_virtual_product', 'reserved_order_id'); $cartId = $quote->getId(); @@ -92,7 +92,7 @@ public function testSetPaymentWithVirtualProduct() public function testSetPaymentWithSimpleProduct() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -127,7 +127,7 @@ public function testSetPaymentWithSimpleProduct() public function testSetPaymentWithSimpleProductWithoutAddress() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); $cartId = $quote->getId(); @@ -159,7 +159,7 @@ public function testSetPaymentWithSimpleProductWithoutAddress() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); @@ -193,7 +193,7 @@ public function testGetList() public function testGet() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1_with_payment', 'reserved_order_id'); $cartId = $quote->getId(); @@ -228,7 +228,7 @@ public function testGetListMine() $this->_markTestAsRestOnly(); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = [ @@ -250,7 +250,6 @@ public function testGetListMine() $this->assertContains($expectedResponse, $requestResponse); } - /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_payment_saved.php */ @@ -259,7 +258,7 @@ public function testGetMine() $this->_markTestAsRestOnly(); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1_with_payment', 'reserved_order_id'); $serviceInfo = [ @@ -287,7 +286,7 @@ public function testSetPaymentWithSimpleProductMine() $this->_markTestAsRestOnly(); /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('\Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = [ @@ -325,7 +324,7 @@ protected function getCustomerToken() { /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); return $token; diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php index 7251d5981a1aa..8ab7c765409b5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php @@ -33,8 +33,8 @@ class ShippingMethodManagementTest extends WebapiAbstract protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $this->totalsCollector = $this->objectManager->create('Magento\Quote\Model\Quote\TotalsCollector'); + $this->quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + $this->totalsCollector = $this->objectManager->create(\Magento\Quote\Model\Quote\TotalsCollector::class); } /** @@ -43,7 +43,7 @@ protected function setUp() */ public function testGetListForVirtualCart() { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); $this->assertEquals([], $this->_webApiCall($this->getListServiceInfo($cartId), ["cartId" => $cartId])); @@ -55,7 +55,7 @@ public function testGetListForVirtualCart() public function testGetList() { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); if (!$cartId) { @@ -85,13 +85,13 @@ public function testGetListForMyCart() /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */ $shippingMethodManagementService = $this->objectManager->create( - 'Magento\Quote\Api\ShippingMethodManagementInterface' + \Magento\Quote\Api\ShippingMethodManagementInterface::class ); $shippingMethodManagementService->set($this->quote->getId(), 'flatrate', 'flatrate'); @@ -156,7 +156,7 @@ protected function convertRates($groupedRates, $currencyCode) { $result = []; /** @var \Magento\Quote\Model\Cart\ShippingMethodConverter $converter */ - $converter = $this->objectManager->create('\Magento\Quote\Model\Cart\ShippingMethodConverter'); + $converter = $this->objectManager->create(\Magento\Quote\Model\Cart\ShippingMethodConverter::class); foreach ($groupedRates as $carrierRates) { foreach ($carrierRates as $rate) { $result[] = $converter->modelToDataObject($rate, $currencyCode)->__toArray(); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php index 5f813f8d84cc3..cecf12ecbebd3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php @@ -52,7 +52,7 @@ public function testCreditmemoAddComment() { /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditmemoCollection */ $creditmemoCollection = - $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection'); + $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class); $creditmemo = $creditmemoCollection->getFirstItem(); $commentData = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCancelTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCancelTest.php index b7896d47e2e18..d9f7bf1425c96 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCancelTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCancelTest.php @@ -27,7 +27,9 @@ public function testCreditmemoCancel() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditmemoCollection */ - $creditmemoCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection'); + $creditmemoCollection = $objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class + ); $creditmemo = $creditmemoCollection->getFirstItem(); $serviceInfo = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCommentsListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCommentsListTest.php index ce372dd8e9922..83e3e81316ad4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCommentsListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCommentsListTest.php @@ -25,9 +25,11 @@ public function testCreditmemoCommentsList() $comment = 'Test comment'; $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditmemoCollection */ - $creditmemoCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection'); + $creditmemoCollection = $objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class + ); $creditmemo = $creditmemoCollection->getFirstItem(); - $creditmemoComment = $objectManager->get('Magento\Sales\Model\Order\Creditmemo\Comment'); + $creditmemoComment = $objectManager->get(\Magento\Sales\Model\Order\Creditmemo\Comment::class); $commentData = [ CreditmemoCommentInterface::COMMENT => 'Hello world!', @@ -55,7 +57,8 @@ public function testCreditmemoCommentsList() // TODO Test fails, due to the inability of the framework API to handle data collection $this->assertNotEmpty($result); foreach ($result['items'] as $item) { - $comment = $objectManager->get('Magento\Sales\Model\Order\Creditmemo\Comment')->load($item['entity_id']); + $comment = $objectManager->get(\Magento\Sales\Model\Order\Creditmemo\Comment::class) + ->load($item['entity_id']); $this->assertEquals($comment->getComment(), $item['comment']); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php index b6c178ed8e1ed..51bb66dfcf4af 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php @@ -37,7 +37,7 @@ protected function setUp() public function testInvoke() { /** @var \Magento\Sales\Model\Order $order */ - $orderCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Collection'); + $orderCollection = $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Collection::class); $order = $orderCollection->getFirstItem(); // $order = $this->objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoEmailTest.php index 8639200be5650..01429033d6771 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoEmailTest.php @@ -26,7 +26,9 @@ public function testCreditmemoEmail() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditmemoCollection */ - $creditmemoCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection'); + $creditmemoCollection = $objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class + ); $creditmemo = $creditmemoCollection->getFirstItem(); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoGetTest.php index e5a452df8c0ac..8f561adad1f10 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoGetTest.php @@ -83,7 +83,7 @@ public function testCreditmemoGet() { /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditmemoCollection */ $creditmemoCollection = - $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection'); + $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class); $creditmemo = $creditmemoCollection->getFirstItem(); $serviceInfo = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php index 34cd077c4620c..f0f4bf410fa23 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php @@ -50,12 +50,12 @@ public function testCreditmemoList() { /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ $searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ $filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $searchCriteriaBuilder->addFilters( diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php index 8a572a424759b..8aab982f1ef1f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php @@ -32,7 +32,7 @@ public function testInvoiceAddComment() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoiceCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Invoice\Collection'); + $invoiceCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class); $invoice = $invoiceCollection->getFirstItem(); $commentData = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCaptureTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCaptureTest.php index 1ed15b7728937..60af3097002ef 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCaptureTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCaptureTest.php @@ -25,7 +25,7 @@ public function testInvoiceCapture() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoice = $objectManager->get('Magento\Sales\Model\Order\Invoice')->loadByIncrementId('100000001'); + $invoice = $objectManager->get(\Magento\Sales\Model\Order\Invoice::class)->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/invoices/' . $invoice->getId() . '/capture', diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php index aab702b7b4ff7..781798c9e93eb 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php @@ -25,9 +25,9 @@ public function testInvoiceCommentsList() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\ResourceModel\Order\Invoice\Collection $invoiceCollection */ - $invoiceCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Invoice\Collection'); + $invoiceCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class); $invoice = $invoiceCollection->getFirstItem(); - $invoiceComment = $objectManager->get('Magento\Sales\Model\Order\Invoice\Comment'); + $invoiceComment = $objectManager->get(\Magento\Sales\Model\Order\Invoice\Comment::class); $invoiceComment->setComment($comment); $invoiceComment->setParentId($invoice->getId()); $invoiceComment->save(); @@ -48,7 +48,7 @@ public function testInvoiceCommentsList() $result = $this->_webApiCall($serviceInfo, $requestData); foreach ($result['items'] as $item) { /** @var \Magento\Sales\Model\Order\Invoice\Comment $invoiceHistoryStatus */ - $invoiceHistoryStatus = $objectManager->get('Magento\Sales\Model\Order\Invoice\Comment') + $invoiceHistoryStatus = $objectManager->get(\Magento\Sales\Model\Order\Invoice\Comment::class) ->load($item['entity_id']); $this->assertEquals($invoiceHistoryStatus->getComment(), $item['comment']); } diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php index e4ce93b3b45c0..e9d27534a4547 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php @@ -34,7 +34,7 @@ protected function setUp() public function testInvoke() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH, diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php index 45d2c28a5e713..c7910e6ba4e58 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php @@ -22,7 +22,7 @@ class InvoiceEmailTest extends WebapiAbstract public function testInvoiceEmail() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $invoiceCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Invoice\Collection'); + $invoiceCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class); $invoice = $invoiceCollection->getFirstItem(); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php index 912f222a8e8f2..124112b4ff654 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php @@ -25,7 +25,7 @@ public function testInvoiceGet() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoiceCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Invoice\Collection'); + $invoiceCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class); $invoice = $invoiceCollection->getFirstItem(); $expectedInvoiceData = [ 'grand_total' => '100.0000', diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php index 06b5856230b52..b03e73ab2adab 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php @@ -35,12 +35,12 @@ public function testInvoiceList() { /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ $searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ $filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $searchCriteriaBuilder->addFilters( diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceVoidTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceVoidTest.php index 7d5e7d5518517..d009a45ea8c0f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceVoidTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceVoidTest.php @@ -25,7 +25,7 @@ public function testInvoiceVoid() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoice = $objectManager->get('Magento\Sales\Model\Order\Invoice')->loadByIncrementId('100000001'); + $invoice = $objectManager->get(\Magento\Sales\Model\Order\Invoice::class)->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/invoices/' . $invoice->getId() . '/void', diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php index 1611bc23ef110..de70099ff6f32 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php @@ -25,7 +25,7 @@ public function testOrderAddressUpdate() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order $order */ - $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); $address = [ OrderAddress::REGION => 'CA', @@ -71,7 +71,7 @@ public function testOrderAddressUpdate() $this->assertGreaterThan(1, count($result)); /** @var \Magento\Sales\Model\Order $actualOrder */ - $actualOrder = $objectManager->get('Magento\Sales\Model\Order')->load($order->getId()); + $actualOrder = $objectManager->get(\Magento\Sales\Model\Order::class)->load($order->getId()); $billingAddress = $actualOrder->getBillingAddress(); $validate = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php index 0355826789dfb..4733e39825b67 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php @@ -20,7 +20,7 @@ class OrderCancelTest extends WebapiAbstract public function testOrderCancel() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/orders/' . $order->getId() . '/cancel', diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php index 63ca7992c5c2c..56285325f67a7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php @@ -22,7 +22,7 @@ public function testOrderCommentsList() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order $order */ - $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); $history = $order->addStatusHistoryComment($comment, $order->getStatus()); $history->save(); @@ -40,7 +40,7 @@ public function testOrderCommentsList() $requestData = ['id' => $order->getId()]; $result = $this->_webApiCall($serviceInfo, $requestData); foreach ($result['items'] as $history) { - $orderHistoryStatus = $objectManager->get('Magento\Sales\Model\Order\Status\History') + $orderHistoryStatus = $objectManager->get(\Magento\Sales\Model\Order\Status\History::class) ->load($history['entity_id']); $this->assertEquals($orderHistoryStatus->getComment(), $history['comment']); $this->assertEquals($orderHistoryStatus->getStatus(), $history['status']); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php index 390a4e12537a8..1ebf56c1e3349 100755 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php @@ -8,6 +8,9 @@ use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Catalog\Api\Data\ProductCustomOptionInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class OrderCreateTest extends WebapiAbstract { const RESOURCE_PATH = '/V1/orders'; @@ -31,22 +34,22 @@ protected function setUp() protected function prepareOrder() { /** @var \Magento\Sales\Model\Order $orderBuilder */ - $orderFactory = $this->objectManager->get('Magento\Sales\Model\OrderFactory'); + $orderFactory = $this->objectManager->get(\Magento\Sales\Model\OrderFactory::class); /** @var \Magento\Sales\Api\Data\OrderItemFactory $orderItemFactory */ - $orderItemFactory = $this->objectManager->get('Magento\Sales\Model\Order\ItemFactory'); + $orderItemFactory = $this->objectManager->get(\Magento\Sales\Model\Order\ItemFactory::class); /** @var \Magento\Sales\Api\Data\OrderPaymentFactory $orderPaymentFactory */ - $orderPaymentFactory = $this->objectManager->get('Magento\Sales\Model\Order\PaymentFactory'); + $orderPaymentFactory = $this->objectManager->get(\Magento\Sales\Model\Order\PaymentFactory::class); /** @var \Magento\Sales\Model\Order\AddressRepository $orderAddressRepository */ - $orderAddressRepository = $this->objectManager->get('Magento\Sales\Model\Order\AddressRepository'); + $orderAddressRepository = $this->objectManager->get(\Magento\Sales\Model\Order\AddressRepository::class); $order = $orderFactory->create( - ['data' => $this->getDataStructure('Magento\Sales\Api\Data\OrderInterface')] + ['data' => $this->getDataStructure(\Magento\Sales\Api\Data\OrderInterface::class)] ); $orderItem = $orderItemFactory->create( - ['data' => $this->getDataStructure('Magento\Sales\Api\Data\OrderItemInterface')] + ['data' => $this->getDataStructure(\Magento\Sales\Api\Data\OrderItemInterface::class)] ); $orderPayment = $orderPaymentFactory->create( - ['data' => $this->getDataStructure('Magento\Sales\Api\Data\OrderPaymentInterface')] + ['data' => $this->getDataStructure(\Magento\Sales\Api\Data\OrderPaymentInterface::class)] ); $email = uniqid() . 'email@example.com'; @@ -104,7 +107,7 @@ protected function getDataStructure($className) protected function addProductOption($orderItem) { /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ - $productRepository = $this->objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); + $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); $product = $productRepository->get('simple'); $options = []; foreach ($product->getOptions() as $option) { @@ -165,7 +168,7 @@ public function testOrderCreate() $this->assertNotEmpty($this->_webApiCall($serviceInfo, ['entity' => $order])); /** @var \Magento\Sales\Model\Order $model */ - $model = $this->objectManager->get('Magento\Sales\Model\Order'); + $model = $this->objectManager->get(\Magento\Sales\Model\Order::class); $model->load($order['customer_email'], 'customer_email'); $this->assertTrue((bool)$model->getId()); $this->assertEquals($order['base_grand_total'], $model->getBaseGrandTotal()); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php index 3e5170419ae3e..689acb4c44891 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php @@ -20,7 +20,7 @@ class OrderEmailTest extends WebapiAbstract public function testOrderEmail() { $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Sales\Model\Order'); + ->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php index 6e991db8fb5e6..76cb5006290e0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php @@ -37,7 +37,7 @@ protected function setUp() public function testOrderGetStatus() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $serviceInfo = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php index f71b6cbec323d..da8ddd7e1c85a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php @@ -51,7 +51,7 @@ public function testOrderGet() ]; /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $serviceInfo = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php index d5f752c08198c..c90e50c3aa718 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php @@ -20,7 +20,7 @@ class OrderHoldTest extends WebapiAbstract public function testOrderHold() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/orders/' . $order->getId() . '/hold', diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php index 4f0b13ee9bf30..25af17f6bb1ab 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php @@ -32,13 +32,13 @@ protected function setUp() public function testGetList() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ - $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + $searchCriteriaBuilder = $this->objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ - $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + $filterBuilder = $this->objectManager->create(\Magento\Framework\Api\FilterBuilder::class); $searchCriteriaBuilder->addFilters( [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php index 88a94ca32fc50..4b506da4181a7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php @@ -32,7 +32,7 @@ protected function setUp() public function testGet() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); /** @var \Magento\Sales\Model\Order\Item $orderItem */ $orderItem = current($order->getItems()); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php index 7ced0101e026e..13a7de4201914 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php @@ -36,12 +36,12 @@ public function testOrderList() { /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ $searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ $filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $searchCriteriaBuilder->addFilters( diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php index 414697139c873..7e1690f12c6a5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php @@ -40,7 +40,7 @@ protected function setUp() public function testOrderCommentAdd() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); $order->loadByIncrementId(self::ORDER_INCREMENT_ID); $commentData = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php index aa61fd136868e..a6d21fe0bd9e8 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php @@ -21,7 +21,7 @@ public function testOrderUnHold() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\Order $order */ - $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); if ($order->canHold()) { $order->hold()->save(); } diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php index 0ee368a72388f..86bad779b9a6e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php @@ -46,7 +46,9 @@ protected function setUp() public function testShipmentAddComment() { /** @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection $shipmentCollection */ - $shipmentCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $this->objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class + ); $shipment = $shipmentCollection->getFirstItem(); $commentData = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php index 8eba6f4c15dae..290d174a40d5e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php @@ -46,7 +46,9 @@ protected function setUp() public function testShipmentAddTrack() { /** @var \Magento\Sales\Model\Order\Shipment $shipment */ - $shipmentCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $this->objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class + ); $shipment = $shipmentCollection->getFirstItem(); $trackData = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCommentsListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCommentsListTest.php index 5d9194859e383..517e5f632ab20 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCommentsListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCommentsListTest.php @@ -25,9 +25,9 @@ public function testShipmentCommentsList() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection $shipmentCollection */ - $shipmentCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class); $shipment = $shipmentCollection->getFirstItem(); - $shipmentComment = $objectManager->get('Magento\Sales\Model\Order\Shipment\Comment'); + $shipmentComment = $objectManager->get(\Magento\Sales\Model\Order\Shipment\Comment::class); $shipmentComment->setComment($comment); $shipmentComment->setParentId($shipment->getId()); $shipmentComment->save(); @@ -48,7 +48,7 @@ public function testShipmentCommentsList() // TODO Test fails, due to the inability of the framework API to handle data collection foreach ($result['items'] as $item) { /** @var \Magento\Sales\Model\Order\Shipment\Comment $shipmentHistoryStatus */ - $shipmentHistoryStatus = $objectManager->get('Magento\Sales\Model\Order\Shipment\Comment') + $shipmentHistoryStatus = $objectManager->get(\Magento\Sales\Model\Order\Shipment\Comment::class) ->load($item['entity_id']); $this->assertEquals($shipmentHistoryStatus->getComment(), $item['comment']); } diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCreateTest.php index 9929fbeff374b..ea8116f6a82e2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCreateTest.php @@ -36,7 +36,7 @@ protected function setUp() public function testInvoke() { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001'); $orderItem = current($order->getAllItems()); $items = [ [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php index 185c96497655f..3147f14ec8208 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php @@ -23,7 +23,7 @@ class ShipmentEmailTest extends WebapiAbstract public function testShipmentEmail() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $shipmentCollection = $objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class); $shipment = $shipmentCollection->getFirstItem(); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentGetTest.php index 6867ebb944452..6b7c3cf582eb0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentGetTest.php @@ -32,7 +32,9 @@ protected function setUp() public function testShipmentGet() { /** @var \Magento\Sales\Model\Order\Shipment $shipment */ - $shipmentCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $this->objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class + ); $shipment = $shipmentCollection->getFirstItem(); $shipment->load($shipment->getId()); $serviceInfo = [ @@ -58,14 +60,14 @@ public function testShipmentGet() $this->assertEquals($shipment->getData($key), $value, $key); } } - $shipmentItem = $this->objectManager->get('Magento\Sales\Model\Order\Shipment\Item'); + $shipmentItem = $this->objectManager->get(\Magento\Sales\Model\Order\Shipment\Item::class); foreach ($result['items'] as $item) { $shipmentItem->load($item['entity_id']); foreach ($item as $key => $value) { $this->assertEquals($shipmentItem->getData($key), $value, $key); } } - $shipmentTrack = $this->objectManager->get('Magento\Sales\Model\Order\Shipment\Track'); + $shipmentTrack = $this->objectManager->get(\Magento\Sales\Model\Order\Shipment\Track::class); foreach ($result['tracks'] as $item) { $shipmentTrack->load($item['entity_id']); foreach ($item as $key => $value) { diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentLabelGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentLabelGetTest.php index e171247115d44..30fff2be557d0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentLabelGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentLabelGetTest.php @@ -32,7 +32,9 @@ protected function setUp() public function testShipmentGet() { /** @var \Magento\Sales\Model\Order\Shipment $shipment */ - $shipmentCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $this->objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class + ); $shipment = $shipmentCollection->getFirstItem(); $shipment->setShippingLabel('test_shipping_label'); $shipment->save(); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php index f4cd591bba56b..7624aaf8b3463 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php @@ -35,12 +35,12 @@ public function testShipmentList() { /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ $searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ $filterBuilder = $this->objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $searchCriteriaBuilder->addFilters([$filterBuilder->setField('shipment_status')->setValue(1)->create()]); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentRemoveTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentRemoveTrackTest.php index 7db4ad66293a8..2f86204afdfe5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentRemoveTrackTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentRemoveTrackTest.php @@ -46,11 +46,13 @@ protected function setUp() public function testShipmentRemoveTrack() { /** @var \Magento\Sales\Model\Order\Shipment $shipment */ - $shipmentCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Shipment\Collection'); + $shipmentCollection = $this->objectManager->get( + \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class + ); $shipment = $shipmentCollection->getFirstItem(); /** @var \Magento\Sales\Model\Order\Shipment\Track $track */ - $track = $this->objectManager->create('Magento\Sales\Model\Order\Shipment\TrackFactory')->create(); + $track = $this->objectManager->create(\Magento\Sales\Model\Order\Shipment\TrackFactory::class)->create(); $track->addData( [ ShipmentTrackInterface::ENTITY_ID => null, diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php index b85ef9e08ce46..48b7dd587e8cb 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php @@ -49,11 +49,11 @@ protected function setUp() public function testTransactionGet() { /** @var Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); /** * @var $transactionRepository \Magento\Sales\Model\Order\Payment\Transaction\Repository */ - $transactionRepository = 'Magento\Sales\Model\Order\Payment\Transaction\Repository'; + $transactionRepository = \Magento\Sales\Model\Order\Payment\Transaction\Repository::class; $transactionRepository = $this->objectManager->create($transactionRepository); $order->loadByIncrementId('100000006'); @@ -93,11 +93,11 @@ public function testTransactionGet() public function testTransactionList($filters) { /** @var Order $order */ - $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); /** * @var $transactionRepository \Magento\Sales\Model\Order\Payment\Transaction\Repository */ - $transactionRepository = 'Magento\Sales\Model\Order\Payment\Transaction\Repository'; + $transactionRepository = \Magento\Sales\Model\Order\Payment\Transaction\Repository::class; $transactionRepository = $this->objectManager->create($transactionRepository); $order->loadByIncrementId('100000006'); @@ -112,7 +112,7 @@ public function testTransactionList($filters) /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ $searchCriteriaBuilder = $this->objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $searchCriteriaBuilder->addFilters($filters); @@ -185,7 +185,7 @@ public function filtersDataProvider() { /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ $filterBuilder = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); return [ diff --git a/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponManagementTest.php b/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponManagementTest.php index e98bd3a341b39..81a6c545e0cb8 100644 --- a/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponManagementTest.php @@ -30,7 +30,7 @@ class CouponManagementTest extends WebapiAbstract public function testManagement($count, $length, $format, $regex) { /** @var $registry \Magento\Framework\Registry */ - $registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); /** @var $salesRule \Magento\SalesRule\Model\Rule */ $salesRule = $registry->registry('_fixture/Magento_SalesRule_Api_RuleRepository'); diff --git a/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponRepositoryTest.php index 81214977cdd73..8e4fc715a2de1 100644 --- a/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/CouponRepositoryTest.php @@ -37,7 +37,7 @@ public function testCrud() $inputData = $this->getCouponData(); /** @var $registry \Magento\Framework\Registry */ - $registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); /** @var $salesRule \Magento\SalesRule\Model\Rule */ $salesRule = $registry->registry('_fixture/Magento_SalesRule_Api_RuleRepository'); $ruleId = $salesRule->getRuleId(); diff --git a/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/RuleRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/RuleRepositoryTest.php index 80432685d504e..6dd9d7319a79c 100644 --- a/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/RuleRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/SalesRule/Api/RuleRepositoryTest.php @@ -35,10 +35,10 @@ protected function getSalesRuleData() 'uses_per_customer' => 2, 'is_active' => 1, 'condition' => [ - 'condition_type' => 'Magento\SalesRule\Model\Rule\Condition\Combine', + 'condition_type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'conditions' => [ [ - 'condition_type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'condition_type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'operator' => '>', 'attribute_name' => 'base_subtotal', 'value' => 800 @@ -49,10 +49,10 @@ protected function getSalesRuleData() 'value' => null, ], 'action_condition' => [ - 'condition_type' => 'Magento\SalesRule\Model\Rule\Condition\Product\Combine', + 'condition_type' => \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class, "conditions" => [ [ - 'condition_type' => 'Magento\SalesRule\Model\Rule\Condition\Product', + 'condition_type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'operator' => '==', 'attribute_name' => 'attribute_set_id', 'value' => '4', diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php index 9e0016d3c5631..8035900a22d58 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php @@ -49,19 +49,19 @@ class TaxClassRepositoryTest extends WebapiAbstract public function setUp() { $this->searchCriteriaBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->filterBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $this->taxClassFactory = Bootstrap::getObjectManager()->create( - 'Magento\Tax\Api\Data\TaxClassInterfaceFactory' + \Magento\Tax\Api\Data\TaxClassInterfaceFactory::class ); $this->taxClassRegistry = Bootstrap::getObjectManager()->create( - 'Magento\Tax\Model\ClassModelRegistry' + \Magento\Tax\Model\ClassModelRegistry::class ); $this->taxClassRepository = Bootstrap::getObjectManager()->create( - 'Magento\Tax\Model\TaxClass\Repository', + \Magento\Tax\Model\TaxClass\Repository::class, ['classModelRegistry' => $this->taxClassRegistry] ); } diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php index ec0c6da582e69..4115db42dd880 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php @@ -59,15 +59,15 @@ class TaxRateRepositoryTest extends WebapiAbstract public function setUp() { $objectManager = Bootstrap::getObjectManager(); - $this->taxRateService = $objectManager->get('Magento\Tax\Api\TaxRateRepositoryInterface'); + $this->taxRateService = $objectManager->get(\Magento\Tax\Api\TaxRateRepositoryInterface::class); $this->searchCriteriaBuilder = $objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->filterBuilder = $objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $this->sortOrderBuilder = $objectManager->create( - 'Magento\Framework\Api\SortOrderBuilder' + \Magento\Framework\Api\SortOrderBuilder::class ); /** Initialize tax classes, tax rates and tax rules defined in fixture Magento/Tax/_files/tax_classes.php */ $this->getFixtureTaxRates(); @@ -166,7 +166,7 @@ public function testCreateTaxRate() $taxRateId = $result['id']; /** Ensure that tax rate was actually created in DB */ /** @var \Magento\Tax\Model\Calculation\Rate $taxRate */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $this->assertEquals($taxRateId, $taxRate->load($taxRateId)->getId(), 'Tax rate was not created in DB.'); $taxRate->delete(); } @@ -201,7 +201,7 @@ public function testCreateTaxRateWithZipRange() $taxRateId = $result['id']; /** Ensure that tax rate was actually created in DB */ /** @var \Magento\Tax\Model\Calculation\Rate $taxRate */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $this->assertEquals($taxRateId, $taxRate->load($taxRateId)->getId(), 'Tax rate was not created in DB.'); $this->assertEquals('17-25', $taxRate->getTaxPostcode(), 'Zip range is not saved in DB.'); $taxRate->delete(); @@ -240,7 +240,7 @@ public function testUpdateTaxRate() $expectedRateData = $data['tax_rate']; /** Ensure that tax rate was actually updated in DB */ /** @var \Magento\Tax\Model\Calculation\Rate $taxRate */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $taxRateModel = $taxRate->load($fixtureRate->getId()); $this->assertEquals($expectedRateData['id'], $taxRateModel->getId(), 'Tax rate was not updated in DB.'); $this->assertEquals( @@ -390,7 +390,7 @@ public function testDeleteTaxRate() $this->assertTrue($result); /** Ensure that tax rate was actually removed from DB */ /** @var \Magento\Tax\Model\Calculation\Rate $taxRate */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $this->assertNull($taxRate->load($taxRateId)->getId(), 'Tax rate was not deleted from DB.'); } @@ -545,7 +545,7 @@ private function getFixtureTaxRates() $taxRateIds = (array)$this->getFixtureTaxRules()[0]->getRates(); foreach ($taxRateIds as $taxRateId) { /** @var \Magento\Tax\Model\Calculation\Rate $taxRate */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $this->fixtureTaxRates[] = $taxRate->load($taxRateId); } } @@ -569,7 +569,7 @@ private function getFixtureTaxClasses() ); foreach ($taxClassIds as $taxClassId) { /** @var \Magento\Tax\Model\ClassModel $taxClass */ - $taxClass = Bootstrap::getObjectManager()->create('Magento\Tax\Model\ClassModel'); + $taxClass = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\ClassModel::class); $this->fixtureTaxClasses[] = $taxClass->load($taxClassId); } } @@ -589,7 +589,7 @@ private function getFixtureTaxRules() $taxRuleCodes = ['Test Rule Duplicate', 'Test Rule']; foreach ($taxRuleCodes as $taxRuleCode) { /** @var \Magento\Tax\Model\Calculation\Rule $taxRule */ - $taxRule = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rule'); + $taxRule = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rule::class); $taxRule->load($taxRuleCode, 'code'); if ($taxRule->getId()) { $this->fixtureTaxRules[] = $taxRule; @@ -616,7 +616,7 @@ private function setupTaxRatesForSearch() 'rate' => 22, 'region_name' => 'CA', ]; - $rates['codeUs12'] = $objectManager->create('Magento\Tax\Model\Calculation\Rate') + $rates['codeUs12'] = $objectManager->create(\Magento\Tax\Model\Calculation\Rate::class) ->setData($taxRateUs12) ->save(); @@ -627,7 +627,7 @@ private function setupTaxRatesForSearch() 'code' => 'codeUs14', 'rate' => 22, ]; - $rates['codeUs14'] = $objectManager->create('Magento\Tax\Model\Calculation\Rate') + $rates['codeUs14'] = $objectManager->create(\Magento\Tax\Model\Calculation\Rate::class) ->setData($taxRateUs14) ->save(); $taxRateBr13 = [ @@ -637,7 +637,7 @@ private function setupTaxRatesForSearch() 'code' => 'codeBr13', 'rate' => 7.5, ]; - $rates['codeBr13'] = $objectManager->create('Magento\Tax\Model\Calculation\Rate') + $rates['codeBr13'] = $objectManager->create(\Magento\Tax\Model\Calculation\Rate::class) ->setData($taxRateBr13) ->save(); @@ -647,7 +647,7 @@ private function setupTaxRatesForSearch() 'code' => 'codeCz1', 'rate' => 1.1, ]; - $rates['codeCz1'] = $objectManager->create('Magento\Tax\Model\Calculation\Rate') + $rates['codeCz1'] = $objectManager->create(\Magento\Tax\Model\Calculation\Rate::class) ->setData($taxRateCz1) ->save(); $taxRateCz2 = [ @@ -656,7 +656,7 @@ private function setupTaxRatesForSearch() 'code' => 'codeCz2', 'rate' => 2.2, ]; - $rates['codeCz2'] = $objectManager->create('Magento\Tax\Model\Calculation\Rate') + $rates['codeCz2'] = $objectManager->create(\Magento\Tax\Model\Calculation\Rate::class) ->setData($taxRateCz2) ->save(); diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php index 15880a8b9801b..dad1f3c493ef0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php @@ -39,18 +39,18 @@ class TaxRuleRepositoryInterfaceTest extends WebapiAbstract public function setUp() { $this->searchCriteriaBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->filterBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); $objectManager = Bootstrap::getObjectManager(); $this->searchCriteriaBuilder = $objectManager->create( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ); $this->filterBuilder = $objectManager->create( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ); /** Initialize tax classes, tax rates and tax rules defined in fixture Magento/Tax/_files/tax_classes.php */ @@ -100,7 +100,7 @@ public function testDeleteTaxRule() $this->assertTrue($result); /** Ensure that tax rule was actually removed from DB */ /** @var \Magento\Tax\Model\Calculation\Rule $taxRule */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $this->assertNull($taxRate->load($taxRuleId)->getId(), 'Tax rule was not deleted from DB.'); } @@ -136,7 +136,7 @@ public function testCreateTaxRule() $this->assertEquals($requestData['rule'], $taxRuleData, "Tax rule is created with invalid data."); /** Ensure that tax rule was actually created in DB */ /** @var \Magento\Tax\Model\Calculation\Rule $taxRule */ - $taxRule = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rule'); + $taxRule = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rule::class); $this->assertEquals($taxRuleId, $taxRule->load($taxRuleId)->getId(), 'Tax rule was not created in DB.'); $taxRule->delete(); } @@ -220,7 +220,7 @@ public function testCreateTaxRuleExistingCode() // Clean up the new tax rule so it won't affect other tests /** @var \Magento\Tax\Model\Calculation\Rule $taxRule */ - $taxRule = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rule'); + $taxRule = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rule::class); $taxRule->load($newTaxRuleData['id']); $taxRule->delete(); } @@ -259,6 +259,7 @@ public function testGetTaxRule() $result = $this->_webApiCall($serviceInfo, $requestData); $this->assertEquals($expectedRuleData, $result); } + /** * @magentoApiDataFixture Magento/Tax/_files/tax_classes.php */ @@ -400,6 +401,7 @@ public function testGetTaxRuleNotExist() ); } } + /** * @magentoApiDataFixture Magento/Tax/_files/tax_classes.php */ @@ -433,10 +435,10 @@ public function testUpdateTaxRule() $expectedRuleData = $requestData['rule']; /** Ensure that tax rule was actually updated in DB */ /** @var \Magento\Tax\Model\Calculation $taxCalculation */ - $taxCalculation = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation'); + $taxCalculation = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation::class); /** @var \Magento\Tax\Model\Calculation\Rule $taxRule */ $taxRule = Bootstrap::getObjectManager()->create( - 'Magento\Tax\Model\Calculation\Rule', + \Magento\Tax\Model\Calculation\Rule::class, ['calculation' => $taxCalculation] ); $taxRuleModel = $taxRule->load($fixtureRule->getId()); @@ -518,7 +520,6 @@ public function testSearchTaxRule() { $fixtureRule = $this->getFixtureTaxRules()[0]; - $filter = $this->filterBuilder->setField('code') ->setValue($fixtureRule->getCode()) ->create(); @@ -555,7 +556,7 @@ private function getFixtureTaxRates() $taxRateIds = (array)$this->getFixtureTaxRules()[0]->getRates(); foreach ($taxRateIds as $taxRateId) { /** @var \Magento\Tax\Model\Calculation\Rate $taxRate */ - $taxRate = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rate'); + $taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class); $this->fixtureTaxRates[] = $taxRate->load($taxRateId); } } @@ -579,7 +580,7 @@ private function getFixtureTaxClasses() ); foreach ($taxClassIds as $taxClassId) { /** @var \Magento\Tax\Model\ClassModel $taxClass */ - $taxClass = Bootstrap::getObjectManager()->create('Magento\Tax\Model\ClassModel'); + $taxClass = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\ClassModel::class); $this->fixtureTaxClasses[] = $taxClass->load($taxClassId); } } @@ -599,7 +600,7 @@ private function getFixtureTaxRules() $taxRuleCodes = ['Test Rule Duplicate', 'Test Rule']; foreach ($taxRuleCodes as $taxRuleCode) { /** @var \Magento\Tax\Model\Calculation\Rule $taxRule */ - $taxRule = Bootstrap::getObjectManager()->create('Magento\Tax\Model\Calculation\Rule'); + $taxRule = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rule::class); $taxRule->load($taxRuleCode, 'code'); if ($taxRule->getId()) { $this->fixtureTaxRules[] = $taxRule; diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/CustomAttributeTypeWsdlGenerationTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/CustomAttributeTypeWsdlGenerationTest.php index 6bc221b7f71cd..6e01999ce40f5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/CustomAttributeTypeWsdlGenerationTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/CustomAttributeTypeWsdlGenerationTest.php @@ -25,7 +25,7 @@ class CustomAttributeTypeWsdlGenerationTest extends \Magento\TestFramework\TestC protected function setUp() { $this->_markTestAsSoapOnly("WSDL generation tests are intended to be executed for SOAP adapter only."); - $this->_storeCode = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + $this->_storeCode = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore()->getCode(); $this->_soapUrl = "{$this->_baseUrl}/soap/{$this->_storeCode}?wsdl=1&services=testModuleMSCAllSoapAndRestV1"; parent::setUp(); diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php index ee60b191eee89..26bfc7af77266 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php @@ -37,10 +37,10 @@ class JoinDirectivesTest extends \Magento\TestFramework\TestCase\WebapiAbstract protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->searchBuilder = $objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); - $this->sortOrderBuilder = $objectManager->create('Magento\Framework\Api\SortOrderBuilder'); - $this->filterBuilder = $objectManager->create('Magento\Framework\Api\FilterBuilder'); - $this->user = $objectManager->create('Magento\User\Model\User'); + $this->searchBuilder = $objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class); + $this->sortOrderBuilder = $objectManager->create(\Magento\Framework\Api\SortOrderBuilder::class); + $this->filterBuilder = $objectManager->create(\Magento\Framework\Api\FilterBuilder::class); + $this->user = $objectManager->create(\Magento\User\Model\User::class); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/JsonGenerationFromDataObjectTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/JsonGenerationFromDataObjectTest.php index 1f078d5c034a8..68e337f59ae6f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/JsonGenerationFromDataObjectTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/JsonGenerationFromDataObjectTest.php @@ -34,10 +34,10 @@ protected function setUp() { $this->_markTestAsRestOnly("JSON generation tests are intended to be executed for REST adapter only."); - $this->storeCode = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + $this->storeCode = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore()->getCode(); - $this->productMetadata = Bootstrap::getObjectManager()->get('Magento\Framework\App\ProductMetadataInterface'); + $this->productMetadata = Bootstrap::getObjectManager()->get(\Magento\Framework\App\ProductMetadataInterface::class); parent::setUp(); } diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/PartialResponseTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/PartialResponseTest.php index ce8302e581035..9b83ace969253 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/PartialResponseTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/PartialResponseTest.php @@ -23,7 +23,7 @@ protected function setUp() $this->_markTestAsRestOnly('Partial response functionality available in REST mode only.'); $this->customerHelper = Bootstrap::getObjectManager() - ->get('Magento\TestFramework\Helper\Customer'); + ->get(\Magento\TestFramework\Helper\Customer::class); $this->customerData = $this->customerHelper->createSampleCustomer(); } diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php index 6884d7d9c3fcb..4d5c73f87467f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php @@ -82,7 +82,7 @@ public function testRestNoAcceptHeader() $this->_markTestAsRestOnly(); /** @var $curlClient CurlClient */ $curlClient = Bootstrap::getObjectManager()->get( - 'Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient' + \Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient::class ); $response = $curlClient->get('/V1/testmodule1/resource1/1', [], ['Accept:']); $this->assertEquals('testProduct1', $response['name'], "Empty Accept header failed to return response."); diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php index 3891cb04124ea..36d85652da6ec 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php @@ -41,7 +41,7 @@ protected function setUp() $this->_version = 'V1'; $this->_restResourcePath = "/{$this->_version}/TestModule5/"; $this->itemFactory = Bootstrap::getObjectManager() - ->create('Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory'); + ->create(\Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory::class); } public function testOverride() diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php index f3347ce4741e7..e0ecb6e75647c 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php @@ -20,7 +20,7 @@ class RestErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra protected function setUp() { $this->_markTestAsRestOnly(); - $this->mode = Bootstrap::getObjectManager()->get('Magento\Framework\App\State')->getMode(); + $this->mode = Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class)->getMode(); parent::setUp(); } diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php index 9f960dd53fc84..a55d3052ce3b3 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php @@ -21,10 +21,12 @@ class ServiceVersionV1Test extends \Magento\Webapi\Routing\BaseService * @var string */ protected $_version; + /** * @var string */ protected $_restResourcePath; + /** * @var string */ @@ -43,11 +45,11 @@ protected function setUp() $this->_restResourcePath = "/{$this->_version}/testmodule1/"; $this->valueFactory = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\AttributeValueFactory' + \Magento\Framework\Api\AttributeValueFactory::class ); $this->itemFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\ItemFactory' + \Magento\TestModule1\Service\V1\Entity\ItemFactory::class ); } diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php index 9afdb1f26067a..f884f9f19d248 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php @@ -30,7 +30,7 @@ class WsdlGenerationFromDataObjectTest extends \Magento\TestFramework\TestCase\W protected function setUp() { $this->_markTestAsSoapOnly("WSDL generation tests are intended to be executed for SOAP adapter only."); - $this->_storeCode = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + $this->_storeCode = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore()->getCode(); parent::setUp(); } diff --git a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php index 58d86c228a9da..429664cd131be 100644 --- a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php +++ b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php @@ -42,13 +42,13 @@ public function apply() public function clearInstance() { $dirList = \Magento\Mtf\ObjectManagerFactory::getObjectManager() - ->get('Magento\Framework\Filesystem\DirectoryList'); + ->get(\Magento\Framework\Filesystem\DirectoryList::class); $configFilePool = \Magento\Mtf\ObjectManagerFactory::getObjectManager() - ->get('\Magento\Framework\Config\File\ConfigFilePool'); + ->get(\Magento\Framework\Config\File\ConfigFilePool::class); $driverPool = \Magento\Mtf\ObjectManagerFactory::getObjectManager() - ->get('\Magento\Framework\Filesystem\DriverPool'); + ->get(\Magento\Framework\Filesystem\DriverPool::class); $reader = new Reader($dirList, $driverPool, $configFilePool); $deploymentConfig = new DeploymentConfig($reader); diff --git a/dev/tests/functional/lib/Magento/Mtf/App/State/State1.php b/dev/tests/functional/lib/Magento/Mtf/App/State/State1.php index 1d10c3a02c811..8005f4bff16f7 100644 --- a/dev/tests/functional/lib/Magento/Mtf/App/State/State1.php +++ b/dev/tests/functional/lib/Magento/Mtf/App/State/State1.php @@ -46,7 +46,7 @@ public function apply() parent::apply(); if (file_exists(dirname(dirname(dirname(MTF_BP))) . '/app/etc/config.php')) { $this->objectManager->create( - '\Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->config] )->run(); } diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory.php index 08af9ba817e91..1d4aff02fa4f3 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory.php @@ -37,13 +37,13 @@ public function __construct(ObjectManagerInterface $objectManager) */ public function launch() { - $this->objectManager->create('Magento\Mtf\Util\Generate\Factory\Block')->launch(); - $this->objectManager->create('Magento\Mtf\Util\Generate\Factory\Fixture')->launch(); - $this->objectManager->create('Magento\Mtf\Util\Generate\Factory\Handler')->launch(); - $this->objectManager->create('Magento\Mtf\Util\Generate\Factory\Page')->launch(); - $this->objectManager->create('Magento\Mtf\Util\Generate\Factory\Repository')->launch(); + $this->objectManager->create(\Magento\Mtf\Util\Generate\Factory\Block::class)->launch(); + $this->objectManager->create(\Magento\Mtf\Util\Generate\Factory\Fixture::class)->launch(); + $this->objectManager->create(\Magento\Mtf\Util\Generate\Factory\Handler::class)->launch(); + $this->objectManager->create(\Magento\Mtf\Util\Generate\Factory\Page::class)->launch(); + $this->objectManager->create(\Magento\Mtf\Util\Generate\Factory\Repository::class)->launch(); - return $this->objectManager->get('Magento\Framework\App\ResponseInterface'); + return $this->objectManager->get(\Magento\Framework\App\ResponseInterface::class); } /** diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Fixture.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Fixture.php index 3390c70fce1c9..d13b3054e572d 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Fixture.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Fixture.php @@ -54,7 +54,8 @@ protected function addFixtureToFactory($item) $this->factoryContent .= "\n"; } - $this->factoryContent .= " return \$this->objectManager->create('{$realClass}', " + $this->factoryContent .= " return \$this->objectManager->create( + {$realClass}::class, " . "array('placeholders' => \$placeholders));\n"; $this->factoryContent .= " }\n"; diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Handler.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Handler.php index 01a39607c218f..30fb7a62ca66a 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Handler.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Handler.php @@ -81,7 +81,7 @@ protected function _addHandlerToFactory($methodNameSuffix, $item) $this->factoryContent .= "\n"; } - $this->factoryContent .= " \$handler = \$this->objectManager->get('{$realClass}');\n"; + $this->factoryContent .= " \$handler = \$this->objectManager->get({$realClass}::class);\n"; $this->factoryContent .= " return \$handler->persist(\$fixture);"; $this->factoryContent .= "\n }\n"; diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Page.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Page.php index ced95c5353d9e..a539c1cb89901 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Page.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Page.php @@ -66,7 +66,7 @@ protected function _addPageToFactory($item) $this->factoryContent .= "\n"; } - $this->factoryContent .= " return \$this->objectManager->create('{$realClass}');"; + $this->factoryContent .= " return \$this->objectManager->create({$realClass}::class);"; $this->factoryContent .= "\n }\n"; $this->cnt++; diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Repository.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Repository.php index e3d79f573df5f..4f23b639e239f 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Repository.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/Repository.php @@ -56,7 +56,8 @@ protected function _addToFactory($item) $this->factoryContent .= "\n"; } - $this->factoryContent .= " return \$this->objectManager->create('{$realClass}', " + $this->factoryContent .= " return \$this->objectManager->create( + {$realClass}::class, " . "array('defaultConfig' => \$defaultConfig, 'defaultData' => \$defaultData));\n"; $this->factoryContent .= " }\n"; diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/FieldsProvider.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/FieldsProvider.php index b02157971072f..39d8cb39c803b 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/FieldsProvider.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/FieldsProvider.php @@ -43,8 +43,8 @@ class FieldsProvider */ public function __construct(ObjectManagerInterface $objectManager) { - $this->eavConfig = $objectManager->create('Magento\Eav\Model\Config'); - $this->resource = $objectManager->create('Magento\Framework\App\ResourceConnection'); + $this->eavConfig = $objectManager->create(\Magento\Eav\Model\Config::class); + $this->resource = $objectManager->create(\Magento\Framework\App\ResourceConnection::class); } /** diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/SchemaXml.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/SchemaXml.php index c8aa71e0d65c0..3b23f0922930d 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/SchemaXml.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Fixture/SchemaXml.php @@ -52,7 +52,7 @@ class SchemaXml public function __construct(ObjectManagerInterface $objectManager) { $this->objectManager = $objectManager; - $this->fieldsProvider = $this->objectManager->create('Magento\Mtf\Util\Generate\Fixture\FieldsProvider'); + $this->fieldsProvider = $this->objectManager->create(\Magento\Mtf\Util\Generate\Fixture\FieldsProvider::class); $this->dom = new \DOMDocument('1.0'); $this->dom->load(dirname(__FILE__) . '/template.xml'); $this->dom->preserveWhiteSpace = false; diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php index 61e4c83165129..8292e96eed444 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php @@ -38,8 +38,8 @@ public function __construct( \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null, array $fixture = [] ) { - $this->setModel('Magento\Framework\DataObject'); - $this->setResourceModel('Magento\Mtf\Util\Generate\Repository\RepositoryResource'); + $this->setModel(\Magento\Framework\DataObject::class); + $this->setResourceModel(\Magento\Mtf\Util\Generate\Repository\RepositoryResource::class); $resource = $this->getResource(); $resource->setFixture($fixture); diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/ModuleResolver/SequenceSorter.php b/dev/tests/functional/lib/Magento/Mtf/Util/ModuleResolver/SequenceSorter.php index b1ac39685d4db..d25db14e1aa9b 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/ModuleResolver/SequenceSorter.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/ModuleResolver/SequenceSorter.php @@ -48,7 +48,7 @@ protected function initObjectManager() */ protected function getModuleSequence() { - return $this->magentoObjectManager->create('\Magento\Framework\Module\ModuleList\Loader')->load(); + return $this->magentoObjectManager->create(\Magento\Framework\Module\ModuleList\Loader::class)->load(); } /** diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Protocol/CurlTransport/WebapiDecorator.php b/dev/tests/functional/lib/Magento/Mtf/Util/Protocol/CurlTransport/WebapiDecorator.php index 40aa1c53bd030..d96122af23a63 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Protocol/CurlTransport/WebapiDecorator.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Protocol/CurlTransport/WebapiDecorator.php @@ -15,6 +15,8 @@ /** * Curl transport on webapi. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class WebapiDecorator implements CurlInterface { @@ -102,7 +104,7 @@ protected function init() $this->disableSecretKey(); /** @var \Magento\Integration\Test\Fixture\Integration $integration */ $integration = $this->fixtureFactory->create( - 'Magento\Integration\Test\Fixture\Integration', + \Magento\Integration\Test\Fixture\Integration::class, ['dataset' => 'default_active'] ); $integration->persist(); @@ -119,7 +121,7 @@ protected function init() protected function disableSecretKey() { $config = $this->fixtureFactory->create( - 'Magento\Config\Test\Fixture\ConfigData', + \Magento\Config\Test\Fixture\ConfigData::class, ['dataset' => 'secret_key_disable'] ); $config->persist(); @@ -149,7 +151,7 @@ protected function setConfiguration(Integration $integration) } $dom->save($fileConfig); - $this->configuration = $this->objectManager->create('Magento\Mtf\Config\DataInterface'); + $this->configuration = $this->objectManager->create(\Magento\Mtf\Config\DataInterface::class); } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php index 90e7d3f929b3a..5f43674b87c20 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php @@ -89,7 +89,7 @@ public function isMagentoCacheFlushed() protected function getMessagesBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Messages', + \Magento\Backend\Test\Block\Messages::class, ['element' => $this->_rootElement->find($this->messagesSelector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Dashboard/Tab/Products.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Dashboard/Tab/Products.php index 10a1b906c8606..ed20ea4232368 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Dashboard/Tab/Products.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Dashboard/Tab/Products.php @@ -26,7 +26,7 @@ class Products extends Tab public function getBestsellersGrid() { return $this->blockFactory->create( - '\Magento\Backend\Test\Block\Dashboard\Tab\Products\Ordered', + \Magento\Backend\Test\Block\Dashboard\Tab\Products\Ordered::class, ['element' => $this->browser->find($this->orderedProductsGrid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php index 9007ae355984c..6badacf44b674 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php @@ -357,7 +357,10 @@ protected function massActionSubmit($acceptAlert) if ($acceptAlert) { $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create( + \Magento\Ui\Test\Block\Adminhtml\Modal::class, + ['element' => $element] + ); $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Extractor.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Extractor.php index 0d64b13d9b450..41410708f6c8e 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Extractor.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Extractor.php @@ -62,7 +62,7 @@ public function __construct($url, $regExpPattern, $isAll = false) public function getData() { /** @var \Magento\Mtf\Config\DataInterface $config */ - $config = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->get('Magento\Mtf\Config\DataInterface'); + $config = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->get(\Magento\Mtf\Config\DataInterface::class); $url = $_ENV['app_backend_url'] . $this->url; $curl = new BackendDecorator(new CurlTransport(), $config); $curl->addOption(CURLOPT_HEADER, 1); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle.php index a61d9f5d5ff02..e94ec38d010f3 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle.php @@ -63,7 +63,7 @@ class Bundle extends Section private function getBundleOptionBlock($rowNumber, ElementInterface $element) { return $this->blockFactory->create( - 'Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option', + \Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option::class, [ 'element' => $element->find(sprintf($this->bundleOptionRow, $rowNumber), Locator::SELECTOR_XPATH) ] diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php index 905690502c2da..a520c1a473c69 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php @@ -51,7 +51,7 @@ class Option extends Form protected function getSearchGridBlock() { return $this->blockFactory->create( - 'Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option\Search\Grid', + \Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option\Search\Grid::class, ['element' => $this->browser->find($this->searchGridBlock)] ); } @@ -65,7 +65,7 @@ protected function getSearchGridBlock() protected function getSelectionBlock($rowIndex) { return $this->blockFactory->create( - 'Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option\Selection', + \Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option\Selection::class, ['element' => $this->_rootElement->find(sprintf($this->selectionBlock, ++$rowIndex))] ); } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php index cb6a3b439686f..db349d16a86c6 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php @@ -54,7 +54,7 @@ class View extends \Magento\Catalog\Test\Block\Product\View public function getBundleBlock() { return $this->blockFactory->create( - 'Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle', + \Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle::class, ['element' => $this->_rootElement->find($this->bundleBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/AbstractConfigureBlock.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/AbstractConfigureBlock.php index fb02c2f9c3d4c..43d79aed44515 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/AbstractConfigureBlock.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/AbstractConfigureBlock.php @@ -33,7 +33,7 @@ abstract class AbstractConfigureBlock extends Form public function getCustomOptionsBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\View\CustomOptions', + \Magento\Catalog\Test\Block\Product\View\CustomOptions::class, ['element' => $this->_rootElement->find($this->customOptionsSelector)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php index 91693e77c03fb..66e25da5b4d54 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php @@ -53,7 +53,10 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null) $storeSwitcherBlock->find($this->dropdownBlock, Locator::SELECTOR_CSS, 'liselectstore')->setValue($store); $modalElement = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $modalElement]); + $modal = $this->blockFactory->create( + \Magento\Ui\Test\Block\Adminhtml\Modal::class, + ['element' => $modalElement] + ); $modal->acceptAlert(); } return parent::fill($fixture, $element); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/Section/Products.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/Section/Products.php index 27ce328b32e4b..3a531b6db697b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/Section/Products.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/Section/Products.php @@ -79,7 +79,7 @@ public function getFieldsData($fields = null, SimpleElement $element = null) public function getProductGrid() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Category\Edit\Section\ProductGrid', + \Magento\Catalog\Test\Block\Adminhtml\Category\Edit\Section\ProductGrid::class, ['element' => $this->_rootElement->find($this->productGrid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php index cfe959d2b88bb..15a624c4b734f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php @@ -68,7 +68,7 @@ class Tree extends Block protected function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Options.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Options.php index 8c1f41f907e48..295a5be684b16 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Options.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Options.php @@ -68,7 +68,7 @@ public function getValue() protected function getFormInstance(SimpleElement $element = null) { return ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\Tab\Options\Option', + \Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\Tab\Options\Option::class, ['element' => $element === null ? $this->find($this->option . ':last-child') : $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Tab/Options.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Tab/Options.php index 369c70f7cf02b..06a1b6db415c0 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Tab/Options.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/Tab/Options.php @@ -35,7 +35,7 @@ public function setFieldsData(array $fields, SimpleElement $element = null) foreach ($fields['options']['value'] as $field) { $this->_rootElement->find($this->addOption)->click(); $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\Tab\Options\Option', + \Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\Tab\Options\Option::class, ['element' => $this->_rootElement->find('.ui-sortable tr:last-child')] )->fillOptions($field); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php index 5f68546497587..777ec75e832ff 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php @@ -132,7 +132,7 @@ public function addAttributeSetGroup($groupName) $this->_rootElement->find($this->addGroupButton)->click(); $element = $this->browser->find($this->promptModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->setAlertText($groupName); $modal->acceptAlert(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php index 0b47f4036560e..23ed222dd0a9b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php @@ -131,7 +131,7 @@ function () { public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php index 30be13bc8ba48..e29c7d00108bb 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php @@ -100,7 +100,7 @@ public function getTierPriceForm(SimpleElement $element = null) { $element = $element ?: $this->browser->find($this->advancedPricingRootElement); return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\AdvancedPricing\OptionTier', + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\AdvancedPricing\OptionTier::class, ['element' => $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php index 02fd77bfae522..7cf367c57d214 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php @@ -151,7 +151,7 @@ protected function importOptions(array $products) protected function getSearchGridBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Search\Grid', + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Search\Grid::class, ['element' => $this->browser->find($this->importGrid)] ); } @@ -167,7 +167,7 @@ private function getRowBlock($index, SimpleElement $element = null) { $element = $element ?: $this->_rootElement; return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Row', + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Row::class, ['element' => $element->find(sprintf($this->dynamicDataRow, ++$index))] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails.php index e0c1df9939105..36765ef2cf4fd 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails.php @@ -66,7 +66,7 @@ public function setFieldsData(array $fields, SimpleElement $element = null) && !$fields['category_ids']['source']->getCategories()[0]->hasData('id') ) { $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds', + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds::class, ['element' => $this->browser->find($this->newCategoryRootElement)] )->addNewCategory($fields['category_ids']['source']->getCategories()[0]); } else { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Related.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Related.php index dcab5b020d5a8..1616b7ca7172e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Related.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Related.php @@ -88,7 +88,7 @@ protected function getRelatedGrid(SimpleElement $element = null) { $element = $element ?: $this->_rootElement; return $this->blockFactory->create( - '\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Related\Grid', + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Related\Grid::class, ['element' => $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php index 24a2a2f7b8c8c..b6e95f5393e14 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php @@ -149,7 +149,7 @@ public function checkAttributeLabel($productAttribute) public function getAttributesSearchGrid() { return $this->blockFactory->create( - '\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Attributes\Grid', + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Attributes\Grid::class, ['element' => $this->browser->find($this->attributeSearch)] ); } @@ -188,7 +188,7 @@ public function openCustomSection($sectionName) public function getAttributeForm() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\AttributeForm', + \Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\AttributeForm::class, ['element' => $this->browser->find($this->newAttributeModal)] ); } @@ -204,7 +204,7 @@ public function getAttributeElement(CatalogProductAttribute $attribute) return $this->_rootElement->find( sprintf($this->attributeBlock, $attribute->getAttributeCode()), Locator::SELECTOR_CSS, - 'Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\CustomAttribute' + \Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\CustomAttribute::class ); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php index 768777906f1fd..546b055b0045b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php @@ -201,7 +201,7 @@ public function removeAllProducts() $this->waitForElementVisible(sprintf($this->removeButton, 1), Locator::SELECTOR_XPATH); /** @var \Magento\Backend\Test\Block\Messages $messageBlock */ $messageBlock = $this->blockFactory->create( - 'Magento\Backend\Test\Block\Messages', + \Magento\Backend\Test\Block\Messages::class, ['element' => $this->browser->find($this->messageBlock)] ); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php index d6b779245ff1d..2584f437bff75 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php @@ -48,7 +48,7 @@ public function getProductItem(FixtureInterface $product) $locator = sprintf($this->productItem, $product->getName()); return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\ProductList\ProductItem', + \Magento\Catalog\Test\Block\Product\ProductList\ProductItem::class, ['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/ProductItem.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/ProductItem.php index c5c31ac903b9e..7bb7898ed54f1 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/ProductItem.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/ProductItem.php @@ -101,7 +101,7 @@ public function clickAddToCart() public function getPriceBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', + \Magento\Catalog\Test\Block\Product\Price::class, ['element' => $this->_rootElement->find($this->priceBox)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/PromotedSection.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/PromotedSection.php index 0f7c04da94bdf..1ca480fb464af 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/PromotedSection.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/PromotedSection.php @@ -50,7 +50,7 @@ public function getProductItem(FixtureInterface $product) $locator = sprintf($this->productItemByName, $product->getName()); return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\ProductList\ProductItem', + \Magento\Catalog\Test\Block\Product\ProductList\ProductItem::class, ['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)] ); } @@ -71,7 +71,7 @@ public function getProducts() foreach ($elements as $element) { $result[] = $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\ProductList\ProductItem', + \Magento\Catalog\Test\Block\Product\ProductList\ProductItem::class, ['element' => $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Related.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Related.php index c81cab9de5297..a7d83584f1bb3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Related.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Related.php @@ -26,7 +26,7 @@ public function getProductItem(FixtureInterface $product) $locator = sprintf($this->productItemByName, $product->getName()); return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem', + \Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem::class, ['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)] ); } @@ -47,7 +47,7 @@ public function getProducts() foreach ($elements as $element) { $result[] = $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem', + \Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem::class, ['element' => $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php index e71fb091a2c66..d3a4563672132 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php @@ -197,7 +197,7 @@ class View extends AbstractConfigureBlock public function getPriceBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', + \Magento\Catalog\Test\Block\Product\Price::class, ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] ); } @@ -212,7 +212,7 @@ public function addToCart(FixtureInterface $product) { /** @var \Magento\Checkout\Test\Block\Cart\Sidebar $miniCart */ $miniCart = $this->blockFactory->create( - '\Magento\Checkout\Test\Block\Cart\Sidebar', + \Magento\Checkout\Test\Block\Cart\Sidebar::class, ['element' => $this->browser->find($this->miniCartBlock)] ); /** @var CatalogProductSimple $product */ @@ -302,7 +302,7 @@ public function braintreePaypalCheckout() { /** @var \Magento\Checkout\Test\Block\Cart\Sidebar $miniCart */ $miniCart = $this->blockFactory->create( - '\Magento\Checkout\Test\Block\Cart\Sidebar', + \Magento\Checkout\Test\Block\Cart\Sidebar::class, ['element' => $this->browser->find($this->miniCartBlock)] ); @@ -428,7 +428,7 @@ public function clickAddToCompare() { /** @var \Magento\Backend\Test\Block\Messages $messageBlock */ $messageBlock = $this->blockFactory->create( - 'Magento\Backend\Test\Block\Messages', + \Magento\Backend\Test\Block\Messages::class, ['element' => $this->browser->find($this->messageBlock)] ); $this->_rootElement->find($this->clickAddToCompare, Locator::SELECTOR_CSS)->click(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php index 6116c66f06478..78e28abebe44b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php @@ -77,7 +77,7 @@ public function processAssert( $productAttributeOriginal = $attribute; } $product = $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\CreateProductWithAttributeSetStep', + \Magento\Catalog\Test\TestStep\CreateProductWithAttributeSetStep::class, [ 'attribute' => $productAttributeOriginal, 'attributeSet' => $attributeSet diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTierPriceOnProductPageWithCustomer.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTierPriceOnProductPageWithCustomer.php index 1c73868b69b47..cb6897271e08b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTierPriceOnProductPageWithCustomer.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTierPriceOnProductPageWithCustomer.php @@ -36,7 +36,7 @@ public function processAssert( $this->loginCustomer($customer); $productTierPriceAssert = $this->objectManager->get( - 'Magento\Catalog\Test\Constraint\AssertProductTierPriceOnProductPage' + \Magento\Catalog\Test\Constraint\AssertProductTierPriceOnProductPage::class ); $productTierPriceAssert->processAssert($browser, $catalogProductView, $product); } @@ -51,7 +51,7 @@ public function processAssert( protected function loginCustomer($customer) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php index 118702c11cb1b..4a21f52574ee3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php @@ -87,7 +87,9 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, $data protected function setTaxClassId($taxClassName) { $url = $_ENV['app_backend_url'] . 'tax/rule/new/'; - $config = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->create('Magento\Mtf\Config\DataInterface'); + $config = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->create( + \Magento\Mtf\Config\DataInterface::class + ); $curl = new BackendDecorator(new CurlTransport(), $config); $curl->addOption(CURLOPT_HEADER, 1); $curl->write($url, [], CurlInterface::GET); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/AbstractCompareProductsTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/AbstractCompareProductsTest.php index 23cd711e7ba66..1c266fd9040dd 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/AbstractCompareProductsTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/AbstractCompareProductsTest.php @@ -112,7 +112,7 @@ public function __inject( protected function loginCustomer() { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php index 0c4ec6e66775d..5f2e4482244c6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php @@ -75,7 +75,7 @@ public function testCreate( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); @@ -96,7 +96,7 @@ public function testCreate( public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php index 9ca512c748d09..36c04d0bbbdf6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php @@ -90,7 +90,7 @@ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $initialProduct->persist(); $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $configData] )->run(); @@ -101,7 +101,7 @@ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $this->attributeMassActionPage->getFormPageActions()->save(); $data = array_merge($initialProduct->getData(), $product->getData()); $product = $this->objectManager->create( - 'Magento\Catalog\Test\Fixture\CatalogProductSimple', + \Magento\Catalog\Test\Fixture\CatalogProductSimple::class, ['data' => $data] ); @@ -119,7 +119,7 @@ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php index d608ed2276759..d2730644dc6bf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php @@ -93,7 +93,7 @@ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple : $initialCategory; $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $configData] )->run(); @@ -117,7 +117,7 @@ public function tearDown() { if ($this->configData) { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php index d2a2c957f615a..e30bb6622af66 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php @@ -92,7 +92,7 @@ public function testUpdateProductAttribute( $product->persist(); $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\AddAttributeToAttributeSetStep', + \Magento\Catalog\Test\TestStep\AddAttributeToAttributeSetStep::class, [ 'attribute' => $productAttributeOriginal, 'attributeSet' => $attributeSet diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeOnProductPageStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeOnProductPageStep.php index c01b09a684ce6..d4310746311a4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeOnProductPageStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeOnProductPageStep.php @@ -71,7 +71,7 @@ public function run() public function cleanup() { $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\DeleteAttributeStep', + \Magento\Catalog\Test\TestStep\DeleteAttributeStep::class, ['attribute' => $this->attribute] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php index 52a71f09e0149..1d4d2b48a8d2b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php @@ -71,7 +71,7 @@ public function run() public function cleanup() { $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\DeleteAttributeStep', + \Magento\Catalog\Test\TestStep\DeleteAttributeStep::class, ['attribute' => $this->attribute] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php index ac7823b41eede..5b3b8a652df50 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php @@ -37,11 +37,11 @@ public function processAssert( ) { if ($customer !== null) { $this->objectManager->create( - '\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } else { - $this->objectManager->create('\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); } $cmsIndexPage->open(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php index 7b4028e8029b2..a5fdc57ef9231 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php @@ -39,24 +39,24 @@ public function processAssert( array $payment ) { $this->objectManager->create( - '\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $this->objectManager->create( - '\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] )->run(); - $this->objectManager->create('\Magento\Checkout\Test\TestStep\ProceedToCheckoutStep')->run(); + $this->objectManager->create(\Magento\Checkout\Test\TestStep\ProceedToCheckoutStep::class)->run(); $this->objectManager->create( - '\Magento\Checkout\Test\TestStep\FillBillingInformationStep', + \Magento\Checkout\Test\TestStep\FillBillingInformationStep::class, ['customer' => $customer, 'checkoutMethod' => 'register'] )->run(); $this->objectManager->create( - '\Magento\Checkout\Test\TestStep\FillShippingMethodStep', + \Magento\Checkout\Test\TestStep\FillShippingMethodStep::class, ['shipping' => $shipping] )->run(); $this->objectManager->create( - '\Magento\Checkout\Test\TestStep\SelectPaymentMethodStep', + \Magento\Checkout\Test\TestStep\SelectPaymentMethodStep::class, ['payment' => $payment] )->run(); $actualPrices['grand_total'] = $checkoutOnepage->getReviewBlock()->getGrandTotal(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedProductPage.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedProductPage.php index 3505043ba7402..653792417be5a 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedProductPage.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedProductPage.php @@ -38,11 +38,11 @@ public function processAssert( ) { if ($customer !== null) { $this->objectManager->create( - '\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } else { - $this->objectManager->create('\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); } $cmsIndexPage->open(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php index 4570814dc9d27..b2d24b98c0ce8 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php @@ -36,15 +36,15 @@ public function processAssert( ) { if ($customer !== null) { $this->objectManager->create( - '\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } else { - $this->objectManager->create('\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); } $this->objectManager->create( - '\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] )->run(); $checkoutCartPage->open(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleNotAppliedShoppingCart.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleNotAppliedShoppingCart.php index 35a9d24c5a8f1..ce31ae79f2b22 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleNotAppliedShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleNotAppliedShoppingCart.php @@ -28,7 +28,7 @@ public function processAssert( array $productPrice ) { $this->objectManager->create( - '\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] )->run(); $checkoutCartPage->open(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php index ac9c059b265f7..4726a8a260f0e 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php @@ -26,12 +26,12 @@ class Curl extends Conditions implements CatalogRuleInterface */ protected $mapTypeParams = [ 'Conditions combination' => [ - 'type' => 'Magento\CatalogRule\Model\Rule\Condition\Combine', + 'type' => \Magento\CatalogRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => 1, ], 'Category' => [ - 'type' => 'Magento\CatalogRule\Model\Rule\Condition\Product', + 'type' => \Magento\CatalogRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php index 797fdbc4ee010..c8be2045f96a1 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php @@ -73,6 +73,6 @@ public function __inject( */ public function tearDown() { - $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); + $this->objectManager->create(\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php index 2d3b097416fd9..4a439de2b52dd 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php @@ -58,7 +58,7 @@ public function testApplySeveralCatalogPriceRules(array $catalogRulesOriginal) } // Create product $products = $this->objectManager->create( - '\Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => 'catalogProductSimple::simple_for_salesrule_1'] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php index ae74c3e0e7c3d..7452ee92f4ca5 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php @@ -129,7 +129,7 @@ public function getCartItem(FixtureInterface $product) Locator::SELECTOR_XPATH ); $cartItem = $this->blockFactory->create( - 'Magento\Checkout\Test\Block\Cart\CartItem', + \Magento\Checkout\Test\Block\Cart\CartItem::class, ['element' => $cartItemBlock] ); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar.php index fedd7dd7677fe..556dbd7c84daf 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar.php @@ -187,7 +187,7 @@ public function getCartItem(FixtureInterface $product) Locator::SELECTOR_XPATH ); $cartItem = $this->blockFactory->create( - 'Magento\Checkout\Test\Block\Cart\Sidebar\Item', + \Magento\Checkout\Test\Block\Cart\Sidebar\Item::class, ['element' => $cartItemBlock] ); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php index 7fd3910a83162..bb0fb6ef7a4cc 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php @@ -59,7 +59,7 @@ public function removeItemFromMiniCart() $this->_rootElement->find($this->removeItem)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); $modal->waitModalWindowToDisappear(); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php index 0d6851aa8c8b4..f1776d2bf933e 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php @@ -120,7 +120,7 @@ public function getSelectedPaymentMethodBlock() $element = $this->_rootElement->find($this->activePaymentMethodSelector); return $this->blockFactory->create( - '\Magento\Checkout\Test\Block\Onepage\Payment\Method', + \Magento\Checkout\Test\Block\Onepage\Payment\Method::class, ['element' => $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php index 6961ee8d24dd2..3d5cd6c519781 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php @@ -91,7 +91,7 @@ public function getBillingBlock() $element = $this->_rootElement->find($this->billingAddressSelector); return $this->blockFactory->create( - '\Magento\Checkout\Test\Block\Onepage\Payment\Method\Billing', + \Magento\Checkout\Test\Block\Onepage\Payment\Method\Billing::class, ['element' => $element] ); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php index e220ec77ecb10..5bacdb833ecc6 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php @@ -110,7 +110,7 @@ public function test($productsData, array $cart) protected function prepareProducts($productList) { $addToCartStep = ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $productList] ); @@ -127,7 +127,7 @@ protected function prepareProducts($productList) protected function addToCart(array $products) { $addToCartStep = ObjectManager::getInstance()->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] ); $addToCartStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php index d16351d1a324d..36383b66e0025 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php @@ -95,7 +95,7 @@ public function test($products, $deletedProductIndex) protected function prepareProducts($productList) { $productsStep = ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $productList] ); @@ -112,7 +112,7 @@ protected function prepareProducts($productList) protected function addToCart(array $products) { $addToCartStep = ObjectManager::getInstance()->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] ); $addToCartStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php index be1e97267ea57..b5fee15d6b808 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php @@ -107,7 +107,7 @@ public function test($productsData) protected function prepareProducts($productList) { $createProductsStep = ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $productList] ); @@ -124,7 +124,7 @@ protected function prepareProducts($productList) protected function addToCart(array $products) { $addToCartStep = ObjectManager::getInstance()->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] ); $addToCartStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php index 3cbf401b04da0..bae074a0b9cc1 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php @@ -117,7 +117,7 @@ public function test($originalProduct, $checkoutData) protected function createProduct($product, array $data = []) { $createProductsStep = $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $product, 'data' => $data] ); return $createProductsStep->run()['products'][0]; @@ -132,7 +132,7 @@ protected function createProduct($product, array $data = []) protected function addToCart(FixtureInterface $product) { $addToCartStep = $this->objectManager->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => [$product]] ); $addToCartStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php index acdab5ccc70aa..436f16afffee1 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php @@ -41,12 +41,23 @@ public function processAssert( $shippingMethodData = ['shipping' => $shipping]; $paymentData = ['payment' => $payment]; - $products = $objectManager->create('Magento\Catalog\Test\TestStep\CreateProductsStep', $productsData)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', $products)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\ProceedToCheckoutStep')->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\FillShippingAddressStep', $shippingAddressData)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\FillShippingMethodStep', $shippingMethodData)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\SelectPaymentMethodStep', $paymentData)->run(); + $products = $objectManager->create( + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, + $productsData + )->run(); + $objectManager->create(\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, $products)->run(); + $objectManager->create( + \Magento\Checkout\Test\TestStep\ProceedToCheckoutStep::class + )->run(); + $objectManager->create( + \Magento\Checkout\Test\TestStep\FillShippingAddressStep::class, + $shippingAddressData + )->run(); + $objectManager->create( + \Magento\Checkout\Test\TestStep\FillShippingMethodStep::class, + $shippingMethodData + )->run(); + $objectManager->create(\Magento\Checkout\Test\TestStep\SelectPaymentMethodStep::class, $paymentData)->run(); \PHPUnit_Framework_Assert::assertFalse( $checkoutOnepage->getAgreementReview()->checkAgreement($agreement), diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php index 152e87e4b4642..a29c6ea615f69 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php @@ -56,12 +56,23 @@ public function processAssert( $shippingMethodData = ['shipping' => $shipping]; $paymentData = ['payment' => $payment]; - $products = $objectManager->create('Magento\Catalog\Test\TestStep\CreateProductsStep', $productsData)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', $products)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\ProceedToCheckoutStep')->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\FillShippingAddressStep', $shippingAddressData)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\FillShippingMethodStep', $shippingMethodData)->run(); - $objectManager->create('Magento\Checkout\Test\TestStep\SelectPaymentMethodStep', $paymentData)->run(); + $products = $objectManager->create( + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, + $productsData + )->run(); + $objectManager->create(\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, $products)->run(); + $objectManager->create( + \Magento\Checkout\Test\TestStep\ProceedToCheckoutStep::class + )->run(); + $objectManager->create( + \Magento\Checkout\Test\TestStep\FillShippingAddressStep::class, + $shippingAddressData + )->run(); + $objectManager->create( + \Magento\Checkout\Test\TestStep\FillShippingMethodStep::class, + $shippingMethodData + )->run(); + $objectManager->create(\Magento\Checkout\Test\TestStep\SelectPaymentMethodStep::class, $paymentData)->run(); $paymentBlock->getSelectedPaymentMethodBlock()->clickPlaceOrder(); \PHPUnit_Framework_Assert::assertEquals( diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermRequireMessageOnMultishippingCheckout.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermRequireMessageOnMultishippingCheckout.php index 4399a5b80ac6c..a29e0b1eaf953 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermRequireMessageOnMultishippingCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermRequireMessageOnMultishippingCheckout.php @@ -12,6 +12,7 @@ /** * Check that Terms and Conditions is present on the last checkout step - Order Review. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AssertTermRequireMessageOnMultishippingCheckout extends AbstractConstraint { @@ -43,39 +44,41 @@ public function processAssert( $shipping ) { $customer = ['customer' => ['dataset' => 'johndoe_with_multiple_addresses']]; - $customer = $stepFactory->create('\Magento\Customer\Test\TestStep\CreateCustomerStep', $customer)->run(); - $products = $stepFactory->create('\Magento\Catalog\Test\TestStep\CreateProductsStep', ['products' => $products]) - ->run(); - $stepFactory->create('\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', $customer)->run(); - $stepFactory->create('\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', $products)->run(); - $stepFactory->create('\Magento\Multishipping\Test\TestStep\ProceedToMultipleAddressCheckoutStep')->run(); + $customer = $stepFactory->create(\Magento\Customer\Test\TestStep\CreateCustomerStep::class, $customer)->run(); + $products = $stepFactory->create( + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, + ['products' => $products] + )->run(); + $stepFactory->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, $customer)->run(); + $stepFactory->create(\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, $products)->run(); + $stepFactory->create(\Magento\Multishipping\Test\TestStep\ProceedToMultipleAddressCheckoutStep::class)->run(); $stepFactory->create( - '\Magento\Multishipping\Test\TestStep\FillCustomerAddressesStep', + \Magento\Multishipping\Test\TestStep\FillCustomerAddressesStep::class, array_merge($products, $customer) )->run(); $stepFactory->create( - '\Magento\Multishipping\Test\TestStep\FillShippingInformationStep', + \Magento\Multishipping\Test\TestStep\FillShippingInformationStep::class, array_merge(['shippingMethod' => $shipping], $customer) )->run(); $stepFactory->create( - '\Magento\Multishipping\Test\TestStep\SelectPaymentMethodStep', + \Magento\Multishipping\Test\TestStep\SelectPaymentMethodStep::class, ['payment' => $payment] )->run(); $stepFactory->create( - '\Magento\CheckoutAgreements\Test\TestStep\CheckTermOnMultishippingStep', + \Magento\CheckoutAgreements\Test\TestStep\CheckTermOnMultishippingStep::class, ['agreementValue' => 'No'] )->run(); - $stepFactory->create('\Magento\Multishipping\Test\TestStep\PlaceOrderStep')->run(); + $stepFactory->create(\Magento\Multishipping\Test\TestStep\PlaceOrderStep::class)->run(); \PHPUnit_Framework_Assert::assertEquals( self::NOTIFICATION_MESSAGE, $page->getAgreementReview()->getNotificationMassage(), 'Notification required message of Terms and Conditions is absent.' ); $stepFactory->create( - '\Magento\CheckoutAgreements\Test\TestStep\CheckTermOnMultishippingStep', + \Magento\CheckoutAgreements\Test\TestStep\CheckTermOnMultishippingStep::class, ['agreementValue' => 'Yes'] )->run(); - $stepFactory->create('\Magento\Multishipping\Test\TestStep\PlaceOrderStep')->run(); + $stepFactory->create(\Magento\Multishipping\Test\TestStep\PlaceOrderStep::class)->run(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/Edit/BlockForm.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/Edit/BlockForm.php index 290398f023a8a..3538c6ee3b3a7 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/Edit/BlockForm.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/Edit/BlockForm.php @@ -64,7 +64,7 @@ public function clickInsertVariable() public function getWysiwygConfig() { return $this->blockFactory->create( - 'Magento\Cms\Test\Block\Adminhtml\Wysiwyg\Config', + \Magento\Cms\Test\Block\Adminhtml\Wysiwyg\Config::class, ['element' => $this->_rootElement->find($this->customVariableBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php index 9407e47684d44..a4f1bd4d1f85e 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php @@ -109,7 +109,7 @@ public function clickInsertWidget(SimpleElement $element = null) public function getWysiwygConfig() { return $this->blockFactory->create( - 'Magento\Cms\Test\Block\Adminhtml\Wysiwyg\Config', + \Magento\Cms\Test\Block\Adminhtml\Wysiwyg\Config::class, ['element' => $this->_rootElement->find($this->systemVariableBlock, Locator::SELECTOR_XPATH)] ); } @@ -122,7 +122,7 @@ public function getWysiwygConfig() public function getWidgetBlock() { return $this->blockFactory->create( - 'Magento\Widget\Test\Block\Adminhtml\WidgetForm', + \Magento\Widget\Test\Block\Adminhtml\WidgetForm::class, ['element' => $this->_rootElement->find($this->widgetBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config.php index 6fa06e0736c34..c26421c5a65d0 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config.php @@ -130,7 +130,7 @@ public function generateVariations() public function getAttributeBlock() { return $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Section\Variations\Config\Attribute', + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Section\Variations\Config\Attribute::class, ['element' => $this->_rootElement] ); } @@ -143,7 +143,7 @@ public function getAttributeBlock() public function getVariationsBlock() { return $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Section\Variations\Config\Matrix', + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Section\Variations\Config\Matrix::class, ['element' => $this->_rootElement->find($this->variationsMatrix)] ); } @@ -156,7 +156,7 @@ public function getVariationsBlock() public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->template, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Attribute.php index 9b91ecbbc15e9..805f20d89640a 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Attribute.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Attribute.php @@ -206,7 +206,7 @@ public function fillAttributes(array $attributes) public function getAttributesGrid() { return $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AttributesGrid', + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AttributesGrid::class, ['element' => $this->browser->find('#variation-steps-wizard_step1 .admin__data-grid-outer-wrap')] ); } @@ -220,7 +220,7 @@ public function getAttributesGrid() protected function createNewVariationSet(array $attribute) { $attributeFixture = ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\Fixture\CatalogProductAttribute', + \Magento\Catalog\Test\Fixture\CatalogProductAttribute::class, ['data' => $attribute] ); @@ -341,7 +341,7 @@ protected function isVisibleOption(SimpleElement $attributeBlock, $number) protected function getNewAttributeForm() { return $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\NewConfigurableAttributeForm', + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\NewConfigurableAttributeForm::class, ['element' => $this->browser->find($this->newAttribute)] ); } @@ -356,7 +356,7 @@ public function getAttributeSelector() return $this->_rootElement->find( $this->variationSearchBlock, Locator::SELECTOR_CSS, - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Section\Variations\Config\Attribute' + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Section\Variations\Config\Attribute::class . '\AttributeSelector' ); } @@ -464,7 +464,7 @@ protected function getOptionalFields(SimpleElement $context, array $fields = []) protected function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Matrix.php index ed8cbc800b2e6..4e656c21f34b7 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Matrix.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Section/Variations/Config/Matrix.php @@ -186,7 +186,7 @@ protected function getDataFields(SimpleElement $context, array $fields) public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->template, Locator::SELECTOR_XPATH)] ); } @@ -207,7 +207,7 @@ public function deleteVariations() public function getAssociatedProductGrid() { return $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AssociatedProductGrid', + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AssociatedProductGrid::class, ['element' => $this->browser->find($this->associatedProductGrid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php index 11c66f128b5b2..9484e7439c057 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php @@ -47,7 +47,7 @@ public function save(FixtureInterface $product = null) protected function getAffectedAttributeSetForm() { return $this->blockFactory->create( - '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet', + \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet::class, ['element' => $this->browser->find($this->affectedAttributeSetForm)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php index 39db67cde6744..69c22b37edc0a 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php @@ -25,7 +25,7 @@ class View extends \Magento\Catalog\Test\Block\Product\View public function getConfigurableOptionsBlock() { return $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Product\View\ConfigurableOptions', + \Magento\ConfigurableProduct\Test\Block\Product\View\ConfigurableOptions::class, ['element' => $this->_rootElement] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php index 85b0f03a2bdc2..d5279557ec5af 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php @@ -133,7 +133,7 @@ protected function getOptionPrice($variationOptions, $attributesData) protected function getPriceBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', + \Magento\Catalog\Test\Block\Product\Price::class, ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php index 416a5ce08e30c..9af9a9d604ded 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php @@ -40,7 +40,7 @@ public function processAssert( $cmsIndex->open(); foreach ($configurableAttributesData['matrix'] as $variation) { $product = $this->objectManager->create( - 'Magento\Catalog\Test\Fixture\CatalogProductSimple', + \Magento\Catalog\Test\Fixture\CatalogProductSimple::class, [ 'data' => [ 'name' => $variation['name'] diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php index e358b52a3e252..d7235effea12b 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -150,7 +150,7 @@ protected function processFixture(FixtureInterface $product) { $data = array_diff_key($product->getData(), ['price' => 0, 'special_price' => 0]); return $this->objectManager->create( - 'Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct', + \Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct::class, ['data' => $data] ); } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php index ab40860e1f4bb..4919d364dc6fa 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php @@ -84,7 +84,7 @@ public function __inject( protected function importCurrencyRate($configData) { $this->objectManager->getInstance()->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $configData] )->run(); @@ -110,7 +110,7 @@ protected function importCurrencyRate($configData) public function tearDown() { $this->objectManager->getInstance()->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'config_currency_symbols_usd'] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php index 7fb5110ea6f05..22342a1107c07 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php @@ -55,7 +55,7 @@ public function deleteAdditionalAddress(Address $address) ->find($this->deleteAddressLink)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php index b0edc79b70710..c89c22f19bbad 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertAddressDeletedBackend.php @@ -39,7 +39,7 @@ public function processAssert( $orderCreateIndex->getStoreBlock()->selectStoreView(); $actualAddresses = $orderCreateIndex->getCreateBlock()->getBillingAddressBlock()->getExistingAddresses(); $addressRenderer = $this->objectManager->create( - 'Magento\Customer\Test\Block\Address\Renderer', + \Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $deletedAddress] ); $addressToSearch = $addressRenderer->render(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerPasswordChanged.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerPasswordChanged.php index c9445d22944ba..a5be1b485d6a5 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerPasswordChanged.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerPasswordChanged.php @@ -48,7 +48,7 @@ public function processAssert( ); $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php index 1f7d447f71a58..40e7b10d8168e 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php @@ -120,7 +120,7 @@ protected function prepareVatConfig(ConfigData $vatConfig, $customerGroup) public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php index c0485ce8ca8f9..bc0fea4b563d3 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php @@ -84,7 +84,7 @@ public function test( $this->configData = $configData; $this->customer = $customer; $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); $this->customer->persist(); @@ -92,7 +92,7 @@ public function test( // Steps $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer] )->run(); $this->customerAccountIndex->getDashboardAddress()->editBillingAddress(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ChangeCustomerPasswordTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ChangeCustomerPasswordTest.php index 01737a3426585..ecc981db97251 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ChangeCustomerPasswordTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ChangeCustomerPasswordTest.php @@ -99,7 +99,7 @@ public function test(Customer $initialCustomer, Customer $customer) // Steps $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $initialCustomer] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php index 5f01f0fe58c35..25108d19534f1 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php @@ -97,6 +97,6 @@ public function testCreateExistingCustomer(Customer $customer) */ public function tearDown() { - $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php index 494271c740b3a..7943a1d993265 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.php @@ -66,7 +66,7 @@ public function test(Customer $customer) // Steps: $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book'); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php index 01d1e64e4a953..9efc7e49c4ff4 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php @@ -121,7 +121,7 @@ public function test( // Steps $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $initialCustomer] )->run(); $this->customerAccountIndex->getInfoBlock()->openEditContactInfo(); diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php index 33d65437fbcca..15567c4ef8d16 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php @@ -80,7 +80,7 @@ public function test(CurrencyRate $currencyRate, CatalogProductSimple $product, public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'config_currency_symbols_usd'] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php index ef654e9d4311b..be2196cd6496c 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php @@ -53,7 +53,7 @@ public function getRowBlock($index, SimpleElement $element = null) { $element = $element ?: $this->_rootElement; return $this->blockFactory->create( - 'Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable\LinkRow', + \Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable\LinkRow::class, ['element' => $element->find(sprintf($this->rowBlock, ++$index))] ); } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Samples.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Samples.php index 2f1b9c9c41d0e..21fea0a53afe4 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Samples.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Samples.php @@ -45,7 +45,7 @@ public function getRowBlock($index, SimpleElement $element = null) { $element = $element ?: $this->_rootElement; return $this->blockFactory->create( - 'Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable\SampleRow', + \Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable\SampleRow::class, ['element' => $element->find(sprintf($this->rowBlock, ++$index))] ); } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php index 61cbd8745b037..8d9227da86ccc 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Catalog/Product/View.php @@ -38,7 +38,7 @@ class View extends \Magento\Catalog\Test\Block\Product\View public function getDownloadableLinksBlock() { return $this->blockFactory->create( - 'Magento\Downloadable\Test\Block\Catalog\Product\View\Links', + \Magento\Downloadable\Test\Block\Catalog\Product\View\Links::class, [ 'element' => $this->_rootElement->find($this->blockDownloadableLinks, Locator::SELECTOR_XPATH) ] @@ -53,7 +53,7 @@ public function getDownloadableLinksBlock() public function getDownloadableSamplesBlock() { return $this->blockFactory->create( - 'Magento\Downloadable\Test\Block\Catalog\Product\View\Samples', + \Magento\Downloadable\Test\Block\Catalog\Product\View\Samples::class, [ 'element' => $this->_rootElement->find($this->blockDownloadableSamples) ] diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create.php index 38853468ab54e..cbbe561713720 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create.php @@ -33,7 +33,7 @@ public function fillGiftMessageForItems(array $products, GiftMessage $giftMessag $this->_rootElement->click(); /** @var \Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Items $items */ $items = $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Items', + \Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Items::class, ['element' => $this->_rootElement->find($this->itemsBlock)] ); foreach ($giftMessage->getItems() as $key => $giftMessageItem) { diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items.php index 6c580c0bd69e1..6e7060a1ce1f5 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items.php @@ -32,7 +32,7 @@ class Items extends \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items public function getItemProduct(InjectableFixture $product) { return $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Items\ItemProduct', + \Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Items\ItemProduct::class, [ 'element' => $this->browser->find( sprintf($this->itemProduct, $product->getName()), diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php index 7b4e4497e6bab..aa4b5fc1079df 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php @@ -54,7 +54,7 @@ function () use ($giftMessageFormSelector, $browser) { ); /** @var \Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Form $giftMessageForm */ $giftMessageForm = $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Form', + \Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Form::class, ['element' => $this->browser->find($this->giftMessageForm, Locator::SELECTOR_XPATH)] ); $giftMessageForm->fill($giftMessage); diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items.php index 3a7d57b3cf0fe..914faabb18809 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items.php @@ -32,7 +32,7 @@ class Items extends \Magento\Sales\Test\Block\Adminhtml\Order\View\Items public function getItemProduct(InjectableFixture $product) { return $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Adminhtml\Order\View\Items\ItemProduct', + \Magento\GiftMessage\Test\Block\Adminhtml\Order\View\Items\ItemProduct::class, [ 'element' => $this->_rootElement->find( sprintf($this->itemProduct, $product->getName()), diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items/ItemProduct.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items/ItemProduct.php index 8d8a732927bad..31d44f047bf5f 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items/ItemProduct.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/View/Items/ItemProduct.php @@ -50,7 +50,7 @@ function () use ($giftMessageFormSelector, $browser) { ); /** @var \Magento\GiftMessage\Test\Block\Adminhtml\Order\View\Form $giftMessageForm */ $giftMessageForm = $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Adminhtml\Order\View\Form', + \Magento\GiftMessage\Test\Block\Adminhtml\Order\View\Form::class, ['element' => $this->browser->find($this->giftMessageForm, Locator::SELECTOR_XPATH)] ); $data = $giftMessageForm->getData($giftMessage); diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions.php index 52e078b629192..f77fa0f506df0 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions.php @@ -90,7 +90,7 @@ public function fillGiftMessageOrder(GiftMessage $giftMessage) if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') { $this->_rootElement->find($this->allowGiftOptions)->click(); $giftMessageForm = $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm', + \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm::class, ['element' => $this->_rootElement->find($this->giftMessageOrderForm)] ); $formData = [ diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php index 1f400763c4bb1..a730a2c958242 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php @@ -96,7 +96,7 @@ public function fillGiftMessageItem(GiftMessage $giftMessage, $products = []) Locator::SELECTOR_XPATH )->click(); $giftMessageForm = $this->blockFactory->create( - 'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm', + \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm::class, ['element' => $this->_rootElement->find($this->giftMessageItemForm)] ); $giftMessage = $giftMessage->getItems()[0]; diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrder.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrder.php index f675a1645737f..7cbe843449945 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrder.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrder.php @@ -38,7 +38,7 @@ public function processAssert( $orderId ) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php index 67d938520452e..3dabe9ec7d8ca 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php @@ -41,7 +41,7 @@ public function processAssert( $products = [] ) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php index 2befaae5b08c1..903e9103956c2 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php @@ -60,7 +60,7 @@ class AssociatedProducts extends Tab protected function getSearchGridBlock() { return $this->blockFactory->create( - 'Magento\GroupedProduct\Test\Block\Adminhtml\Product\Grouped\AssociatedProducts\Search\Grid', + \Magento\GroupedProduct\Test\Block\Adminhtml\Product\Grouped\AssociatedProducts\Search\Grid::class, ['element' => $this->browser->find($this->productSearchGrid)] ); } @@ -73,7 +73,7 @@ protected function getSearchGridBlock() protected function getListAssociatedProductsBlock() { return $this->blockFactory->create( - 'Magento\GroupedProduct\Test\Block\Adminhtml\Product\Grouped\AssociatedProducts\ListAssociatedProducts', + ListAssociatedProducts::class, ['element' => $this->_rootElement->find($this->associatedProductsBlock)] ); } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Cart/Sidebar.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Cart/Sidebar.php index 8344741e5beef..bc36ba9a6423d 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Cart/Sidebar.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Cart/Sidebar.php @@ -24,7 +24,7 @@ class Sidebar extends MiniShoppingCart public function getCartItem(FixtureInterface $product) { return $this->blockFactory->create( - 'Magento\GroupedProduct\Test\Block\Cart\Sidebar\Item', + \Magento\GroupedProduct\Test\Block\Cart\Sidebar\Item::class, [ 'element' => $this->_rootElement, 'config' => [ diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php index 0be625cc7f0e0..bd774f806053e 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php @@ -44,7 +44,7 @@ class View extends ParentView public function getGroupedProductBlock() { return $this->blockFactory->create( - 'Magento\GroupedProduct\Test\Block\Catalog\Product\View\Type\Grouped', + \Magento\GroupedProduct\Test\Block\Catalog\Product\View\Type\Grouped::class, [ 'element' => $this->_rootElement->find($this->groupedProductBlock) ] diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php index 23b025015357d..b7260b1b88e30 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Checkout/Cart.php @@ -24,7 +24,7 @@ class Cart extends \Magento\Checkout\Test\Block\Cart public function getCartItem(FixtureInterface $product) { return $this->blockFactory->create( - 'Magento\GroupedProduct\Test\Block\Checkout\Cart\CartItem', + \Magento\GroupedProduct\Test\Block\Checkout\Cart\CartItem::class, [ 'element' => $this->_rootElement, 'config' => [ diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php index c617257fd6493..427bec3528169 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php +++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php @@ -56,7 +56,7 @@ class InstallTest extends Injectable */ public function __prepare() { - $config = $this->objectManager->get('Magento\Mtf\Config\DataInterface'); + $config = $this->objectManager->get(\Magento\Mtf\Config\DataInterface::class); // Prepare config data $configData['dbHost'] = $config->get('install/0/host/0'); $configData['dbUser'] = $config->get('install/0/user/0'); @@ -108,7 +108,7 @@ public function test( $dataConfig['https'] = str_replace('http', 'https', $dataConfig['baseUrl']); } /** @var InstallConfig $installConfig */ - $installConfig = $fixtureFactory->create('Magento\Install\Test\Fixture\Install', ['data' => $dataConfig]); + $installConfig = $fixtureFactory->create(\Magento\Install\Test\Fixture\Install::class, ['data' => $dataConfig]); // Steps $this->installPage->open(); // Verify license agreement. diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php b/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php index 8a31a9a9f5dc0..aea9de43a427d 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php @@ -93,7 +93,7 @@ public function searchAndDelete(array $item) $this->_rootElement->find($this->deleteLink)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); } @@ -130,7 +130,7 @@ public function getResourcesPopup() { /** @var ResourcesPopup $resourcesPopup */ $resourcesPopup = $this->blockFactory->create( - 'Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\ResourcesPopup', + \Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\ResourcesPopup::class, ['element' => $this->_rootElement->find($this->resourcesPopupSelector, Locator::SELECTOR_XPATH)] ); @@ -145,7 +145,7 @@ public function getResourcesPopup() public function getTokensPopup() { $tokensPopup = $this->blockFactory->create( - 'Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\TokensPopup', + \Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\TokensPopup::class, ['element' => $this->_rootElement->find($this->tokensPopupSelector, Locator::SELECTOR_XPATH)] ); $this->waitForElementVisible($this->tokensPopupSelector, Locator::SELECTOR_XPATH); diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php index 2bfa5ba8af57e..976d52fb0f156 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php @@ -50,7 +50,7 @@ public function test($configData, Category $category) // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); @@ -66,7 +66,7 @@ public function test($configData, Category $category) public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ListProduct.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ListProduct.php index 7c3ed1432b6f4..2f69d496b3632 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ListProduct.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ListProduct.php @@ -26,7 +26,7 @@ public function getProductItem(FixtureInterface $product) $locator = sprintf($this->productItem, $product->getName()); return $this->blockFactory->create( - 'Magento\Msrp\Test\Block\Product\ProductList\ProductItem', + \Magento\Msrp\Test\Block\Product\ProductList\ProductItem::class, ['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ProductList/ProductItem.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ProductList/ProductItem.php index 81dbe21ad9865..923b139bac6e1 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ProductList/ProductItem.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ProductList/ProductItem.php @@ -47,7 +47,7 @@ public function openMapBlock() public function getMapBlock() { return $this->blockFactory->create( - 'Magento\Msrp\Test\Block\Product\Map', + \Magento\Msrp\Test\Block\Product\Map::class, ['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/View.php index f82d8935236b9..d1d1caafc456c 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/View.php @@ -46,7 +46,7 @@ public function openMapBlock() public function getMapBlock() { return $this->blockFactory->create( - 'Magento\Msrp\Test\Block\Product\Map', + \Magento\Msrp\Test\Block\Product\Map::class, ['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.php index ccb39d8221452..19332e899e1ab 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.php @@ -34,11 +34,11 @@ public function test($product) { // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'msrp'] )->run(); $product = $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\CreateProductStep', + \Magento\Catalog\Test\TestStep\CreateProductStep::class, ['product' => $product] )->run(); @@ -53,7 +53,7 @@ public function test($product) public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'msrp', 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php index da092f7c43193..5996974ee057b 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php @@ -60,7 +60,7 @@ public function __construct( $this->products = $products; $this->objectManeger = $objectManager; $this->objectManeger->configure( - ['\Magento\Customer\Test\Block\Address\Renderer' => ['shared' => false]] + [\Magento\Customer\Test\Block\Address\Renderer::class => ['shared' => false]] ); } @@ -77,7 +77,7 @@ public function run() foreach ($this->products as $key => $product) { $productName = $product->getName(); $addressRender = $this->objectManeger->create( - '\Magento\Customer\Test\Block\Address\Renderer', + \Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addresses[$key], 'type' => 'oneline'] ); $bindings[$productName] = $addressRender->render(); diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Express/Review.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Express/Review.php index cf3ef9a53d751..72f632ff4729c 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Express/Review.php +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Express/Review.php @@ -32,7 +32,7 @@ public function selectShippingMethod(array $shippingMethod) $shippingElement = $this->_rootElement->find( $this->shippingMethod, Locator::SELECTOR_CSS, - 'Magento\Paypal\Test\Block\Express\Review\ShippingoptgroupElement' + \Magento\Paypal\Test\Block\Express\Review\ShippingoptgroupElement::class ); $shippingElement->setValue($shippingMethod['shipping_service'] . '/' . $shippingMethod['shipping_method']); $this->waitForElementVisible('#review-please-wait'); diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php index d97b2c75473d7..10cb562137910 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php @@ -44,7 +44,7 @@ public function getVideoDialog() { $this->waitForElementVisible($this->newVideoDialog); return $this->blockFactory->create( - 'Magento\ProductVideo\Test\Block\Adminhtml\Product\Edit\Tab\Images\VideoDialog', + \Magento\ProductVideo\Test\Block\Adminhtml\Product\Edit\Tab\Images\VideoDialog::class, ['element' => $this->browser->find($this->newVideoDialog)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/AbstractFilter.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/AbstractFilter.php index ba277954e80f2..00730bcb3802a 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/AbstractFilter.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/AbstractFilter.php @@ -40,7 +40,7 @@ protected function prepareData(array $viewsReport) foreach ($viewsReport as $key => $reportFilter) { if (in_array($key, $this->dateFields)) { $date = ObjectManager::getInstance()->create( - '\Magento\Backend\Test\Fixture\Source\Date', + \Magento\Backend\Test\Fixture\Source\Date::class, ['params' => [], 'data' => ['pattern' => $reportFilter]] ); $viewsReport[$key] = $date->getData(); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php index f16759246292d..044ec83c5f7d4 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php @@ -87,7 +87,7 @@ protected function prepareData(array $customersReport) continue; } $date = ObjectManager::getInstance()->create( - '\Magento\Backend\Test\Fixture\Source\Date', + \Magento\Backend\Test\Fixture\Source\Date::class, ['params' => [], 'data' => ['pattern' => $reportFilter]] ); $customersReport[$name] = $date->getData(); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php index 057d529c7736c..e9a5a00635196 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Product/Sold/Grid.php @@ -78,7 +78,7 @@ protected function prepareData(array $customersReport) continue; } $date = ObjectManager::getInstance()->create( - '\Magento\Backend\Test\Fixture\Source\Date', + \Magento\Backend\Test\Fixture\Source\Date::class, ['params' => [], 'data' => ['pattern' => $reportFilter]] ); $customersReport[$name] = $date->getData(); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php index ea135c9d766dd..20feecc8a5431 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php @@ -89,12 +89,12 @@ public function test($products, Customer $customer) $products = $this->createProducts($products); $customer->persist(); $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $this->addProductsToCart($products); $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); @@ -110,7 +110,7 @@ public function test($products, Customer $customer) protected function createProducts($products) { $createProductsStep = $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $products] ); @@ -126,7 +126,7 @@ protected function createProducts($products) protected function addProductsToCart(array $products) { $addProductsToCart = $this->objectManager->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => $products] ); $addProductsToCart->run(); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.php index 2b334fb52d481..208fba464a3bc 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.php @@ -142,7 +142,7 @@ public function test( $this->cmsIndex->open(); if ($customerLogin == 'Yes') { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/DownloadProductsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/DownloadProductsReportEntityTest.php index f17acbdb33ee6..97ea72404ecdd 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/DownloadProductsReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/DownloadProductsReportEntityTest.php @@ -85,7 +85,10 @@ public function test(OrderInjectable $order, $downloads) { // Preconditions $order->persist(); - $invoice = $this->objectManager->create('Magento\Sales\Test\TestStep\CreateInvoiceStep', ['order' => $order]); + $invoice = $this->objectManager->create( + \Magento\Sales\Test\TestStep\CreateInvoiceStep::class, + ['order' => $order] + ); $invoice->run(); $this->openDownloadableLink($order, (int)$downloads); } @@ -100,7 +103,7 @@ public function test(OrderInjectable $order, $downloads) protected function openDownloadableLink(OrderInjectable $order, $downloads) { $customerLogin = $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer()] ); $customerLogin->run(); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntityTest.php index aaa9188cbb48f..fb8007bc24434 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntityTest.php @@ -97,14 +97,14 @@ public function test( //Steps $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $productUrl = $_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'; $browser->open($productUrl); $this->catalogProductView->getViewBlock()->addToCart($product); if ($isGuest) { - $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); $browser->open($productUrl); $this->catalogProductView->getViewBlock()->addToCart($product); } @@ -117,6 +117,6 @@ public function test( */ public function tearDown() { - $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesInvoiceReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesInvoiceReportEntityTest.php index eed8cf7386dd6..6e480ca94bc84 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesInvoiceReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesInvoiceReportEntityTest.php @@ -58,7 +58,10 @@ public function test(SalesInvoiceReport $salesInvoiceReport, OrderInjectable $or $initialInvoiceResult = $salesInvoiceReport->getGridBlock()->getLastResult(); $initialInvoiceTotalResult = $salesInvoiceReport->getGridBlock()->getTotalResult(); $order->persist(); - $invoice = $this->objectManager->create('Magento\Sales\Test\TestStep\CreateInvoiceStep', ['order' => $order]); + $invoice = $this->objectManager->create( + \Magento\Sales\Test\TestStep\CreateInvoiceStep::class, + ['order' => $order] + ); $invoice->run(); return [ diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesOrderReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesOrderReportEntityTest.php index e569c39ca6a39..014148b561ead 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesOrderReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesOrderReportEntityTest.php @@ -76,7 +76,10 @@ public function test(OrderInjectable $order, array $salesReport) $initialSalesTotalResult = $this->salesReport->getGridBlock()->getTotalResult(); $order->persist(); - $invoice = $this->objectManager->create('Magento\Sales\Test\TestStep\CreateInvoiceStep', ['order' => $order]); + $invoice = $this->objectManager->create( + \Magento\Sales\Test\TestStep\CreateInvoiceStep::class, + ['order' => $order] + ); $invoice->run(); return ['initialSalesResult' => $initialSalesResult, 'initialSalesTotalResult' => $initialSalesTotalResult]; diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesRefundsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesRefundsReportEntityTest.php index f9d780a82faba..2b411a19c22ed 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesRefundsReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesRefundsReportEntityTest.php @@ -74,10 +74,13 @@ public function test(OrderInjectable $order, array $refundsReport) $initialRefundsResult = $this->refundsReport->getGridBlock()->getLastResult(); $order->persist(); - $invoice = $this->objectManager->create('Magento\Sales\Test\TestStep\CreateInvoiceStep', ['order' => $order]); + $invoice = $this->objectManager->create( + \Magento\Sales\Test\TestStep\CreateInvoiceStep::class, + ['order' => $order] + ); $invoice->run(); $creditMemo = $this->objectManager->create( - 'Magento\Sales\Test\TestStep\CreateCreditMemoStep', + \Magento\Sales\Test\TestStep\CreateCreditMemoStep::class, ['order' => $order] ); $creditMemo->run(); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesTaxReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesTaxReportEntityTest.php index a78388c9692bc..844a30bed98a3 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesTaxReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SalesTaxReportEntityTest.php @@ -107,7 +107,7 @@ class SalesTaxReportEntityTest extends Injectable */ public function __prepare() { - $deleteTaxRule = $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep'); + $deleteTaxRule = $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class); $deleteTaxRule->run(); } @@ -204,7 +204,7 @@ protected function processOrder($orderSteps, OrderInjectable $order) */ public function tearDown() { - $deleteTaxRule = $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep'); + $deleteTaxRule = $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class); $deleteTaxRule->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php index 42e2dee9c7ee8..9f931570d441f 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php @@ -28,7 +28,7 @@ class Reviews extends Tab public function getReviewsGrid() { return $this->blockFactory->create( - 'Magento\Review\Test\Block\Adminhtml\Grid', + \Magento\Review\Test\Block\Adminhtml\Grid::class, ['element' => $this->_rootElement->find($this->reviews)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php index 0f5a646fcefae..37ea3df90a89f 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php @@ -28,7 +28,7 @@ class Reviews extends Section public function getReviewsGrid() { return $this->blockFactory->create( - 'Magento\Review\Test\Block\Adminhtml\Product\Grid', + \Magento\Review\Test\Block\Adminhtml\Product\Grid::class, ['element' => $this->_rootElement->find($this->reviews)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php index 9472f58036710..09ed2350b0c1f 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php @@ -191,7 +191,7 @@ public function test( protected function login(Customer $customer) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php index f67c3b27d7765..555217246c65b 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php @@ -30,6 +30,7 @@ * * @group Reviews_and_Ratings_(MX) * @ZephyrId MAGETWO-27743 + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpdateProductReviewEntityOnProductPageTest extends Injectable { @@ -130,7 +131,7 @@ public function test(Review $review, $rating) $review = $this->createReview($review, $rating); $product = $this->reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\OpenProductOnBackendStep', + \Magento\Catalog\Test\TestStep\OpenProductOnBackendStep::class, ['product' => $product] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php index e8a912080d5a5..ee5d4c978fa0c 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php @@ -179,7 +179,7 @@ public function cancel() $this->_rootElement->find($this->cancel)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php index adec617c57084..b83991db3c308 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php @@ -129,7 +129,7 @@ class Create extends Block public function getItemsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Items', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items::class, ['element' => $this->_rootElement->find($this->itemsBlock, Locator::SELECTOR_CSS)] ); } @@ -142,7 +142,7 @@ public function getItemsBlock() public function getBillingAddressBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Address', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Address::class, ['element' => $this->_rootElement->find($this->billingAddressBlock, Locator::SELECTOR_CSS)] ); } @@ -155,7 +155,7 @@ public function getBillingAddressBlock() protected function getShippingAddressBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Address', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Address::class, ['element' => $this->_rootElement->find($this->shippingAddressBlock, Locator::SELECTOR_CSS)] ); } @@ -168,7 +168,7 @@ protected function getShippingAddressBlock() protected function getBillingMethodBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Method', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Method::class, ['element' => $this->_rootElement->find($this->billingMethodBlock, Locator::SELECTOR_CSS)] ); } @@ -181,7 +181,7 @@ protected function getBillingMethodBlock() protected function getShippingMethodBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Method', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Method::class, ['element' => $this->_rootElement->find($this->shippingMethodBlock, Locator::SELECTOR_CSS)] ); } @@ -194,7 +194,7 @@ protected function getShippingMethodBlock() protected function getTotalsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals::class, ['element' => $this->_rootElement->find($this->totalsBlock, Locator::SELECTOR_CSS)] ); } @@ -207,7 +207,7 @@ protected function getTotalsBlock() public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } @@ -220,7 +220,7 @@ public function getTemplateBlock() public function getGridBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Search\Grid', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Search\Grid::class, ['element' => $this->_rootElement->find($this->gridBlock, Locator::SELECTOR_CSS)] ); } @@ -233,7 +233,7 @@ public function getGridBlock() public function getAccountBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Form\Account', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Form\Account::class, ['element' => $this->_rootElement->find($this->accountInformationBlock, Locator::SELECTOR_CSS)] ); } @@ -258,7 +258,7 @@ public function updateProductsData(array $products) { /** @var \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items $items */ $items = $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Items', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items::class, ['element' => $this->_rootElement->find($this->itemsBlock)] ); foreach ($products as $product) { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php index 31cf3a9b6f48c..a68b9f52dc8d0 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php @@ -61,7 +61,7 @@ public function applyCouponCode(SalesRule $code) public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->template, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities.php index 729cd03d63bf6..8ca4e7fb5b2cd 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities.php @@ -18,6 +18,7 @@ /** * Class CustomerActivities * Customer's Activities block + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CustomerActivities extends Block { @@ -88,7 +89,7 @@ class CustomerActivities extends Block public function getLastOrderedItemsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\LastOrderedItems', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\LastOrderedItems::class, ['element' => $this->_rootElement->find($this->reorderSidebar)] ); } @@ -101,7 +102,7 @@ public function getLastOrderedItemsBlock() public function getRecentlyViewedItemsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\RecentlyViewedItems', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\RecentlyViewedItems::class, ['element' => $this->_rootElement->find($this->recentlyViewedSidebar)] ); } @@ -114,7 +115,7 @@ public function getRecentlyViewedItemsBlock() public function getProductsInComparisonBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\ProductsInComparison', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\ProductsInComparison::class, ['element' => $this->_rootElement->find($this->comparedSidebar)] ); } @@ -127,7 +128,7 @@ public function getProductsInComparisonBlock() public function getRecentlyComparedProductsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\RecentlyComparedProducts', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\RecentlyComparedProducts::class, ['element' => $this->_rootElement->find($this->recentlyComparedSidebar)] ); } @@ -140,7 +141,7 @@ public function getRecentlyComparedProductsBlock() public function getRecentlyViewedProductsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\RecentlyViewedProducts', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\RecentlyViewedProducts::class, ['element' => $this->_rootElement->find($this->recentlyViewedSidebar)] ); } @@ -153,7 +154,7 @@ public function getRecentlyViewedProductsBlock() public function getShoppingCartItemsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\ShoppingCartItems', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities\Sidebar\ShoppingCartItems::class, ['element' => $this->_rootElement->find($this->shoppingCartSidebar)] ); } @@ -166,7 +167,7 @@ public function getShoppingCartItemsBlock() public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php index f39a10ec29d9a..69ef66d947597 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php @@ -71,7 +71,7 @@ function () use ($element, $selector) { public function getItemProductByName($name) { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Create\Items\ItemProduct', + \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items\ItemProduct::class, ['element' => $this->_rootElement->find(sprintf($this->itemProduct, $name), Locator::SELECTOR_XPATH)] ); } @@ -103,7 +103,7 @@ public function getProductsDataByFields($fields) public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->template, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Shipping/Address.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Shipping/Address.php index 5e3ca0b474ade..a18f4856ef1a9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Shipping/Address.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Shipping/Address.php @@ -82,7 +82,7 @@ function () { protected function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php index 8826279eced4b..ffac9ddff9932 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php @@ -29,7 +29,7 @@ class Form extends AbstractForm public function getItemsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items', + \Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items::class, ['element' => $this->_rootElement->find($this->items)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php index 28dde52c48b50..52ff585cc43d6 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php @@ -40,7 +40,7 @@ public function getItemProductBlock(FixtureInterface $product) { $selector = sprintf($this->productItems, $product->getSku()); return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product', + \Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php index 3adbef032c5df..320d48eb195a9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php @@ -30,7 +30,7 @@ class Form extends AbstractForm public function getItemsBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items', + \Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items::class, ['element' => $this->_rootElement->find($this->items)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php index 37941061eb27d..baee80abd72df 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php @@ -27,7 +27,7 @@ public function getItemProductBlock(FixtureInterface $product) { $selector = sprintf($this->productItem, $product->getSku()); return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product', + \Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php index 958c7d6ad6d8a..757a025605b9b 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php @@ -29,7 +29,7 @@ class OrderForm extends FormTabs public function getOrderInfoBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info', + \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info::class, ['element' => $this->_rootElement->find($this->orderInfoBlock)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos.php index 7363aa2221529..148292da25704 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos.php @@ -29,7 +29,7 @@ class CreditMemos extends Tab public function getGridBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\CreditMemos\Grid', + \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\CreditMemos\Grid::class, ['element' => $this->_rootElement->find($this->grid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices.php index c4bb6d2c03bf8..69ea64754ac80 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices.php @@ -30,7 +30,7 @@ class Invoices extends Tab public function getGridBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid', + \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid::class, ['element' => $this->_rootElement->find($this->grid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments.php index 2984640bf92ff..0710933ebe08e 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments.php @@ -29,7 +29,7 @@ class Shipments extends Tab public function getGridBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Shipments\Grid', + \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Shipments\Grid::class, ['element' => $this->_rootElement->find($this->grid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Transactions.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Transactions.php index ebd12641ab1b1..80309405fcd05 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Transactions.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Transactions.php @@ -30,7 +30,7 @@ class Transactions extends Tab public function getGridBlock() { return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Transactions\Grid', + \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Transactions\Grid::class, ['element' => $this->_rootElement->find($this->grid, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php index e250a33966a10..51d56076362ec 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php @@ -141,7 +141,7 @@ public function getItemBlock($id = null) { $selector = ($id === null) ? $this->content : sprintf($this->itemBlock, $id) . $this->content; return $this->blockFactory->create( - 'Magento\Sales\Test\Block\Order\Items', + \Magento\Sales\Test\Block\Order\Items::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php index ce0b7f8eb135a..01157079e07d2 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php @@ -60,7 +60,7 @@ protected function loginCustomerAndOpenOrderPage(Customer $customer) { $this->cmsIndex->open(); $loginCustomerOnFrontendStep = $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] ); $loginCustomerOnFrontendStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php index 44879cad87fd9..8dc910caf8251 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php @@ -51,7 +51,7 @@ public function processAssert( ]; $objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders'); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php index 1899720790ef6..0bf23a8f814c5 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php @@ -39,7 +39,7 @@ public function processAssert( 'status' => $status, ]; $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders'); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderBillingAddress.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderBillingAddress.php index 1b85580897d0a..6c9bbd8eaf733 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderBillingAddress.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderBillingAddress.php @@ -25,7 +25,7 @@ class AssertSalesPrintOrderBillingAddress extends AbstractConstraint public function processAssert(SalesGuestPrint $salesGuestPrint, Address $billingAddress) { $addressRenderer = $this->objectManager->create( - 'Magento\Customer\Test\Block\Address\Renderer', + \Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $billingAddress, 'type' => 'html'] ); $expectedBillingAddress = $addressRenderer->render(); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php index 84fe74fb7fd1d..62bc18ee07f1e 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php @@ -173,7 +173,7 @@ public function tearDown() $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter); $this->orderStatusIndex->getMessagesBlock()->waitSuccessMessage(); $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'checkmo_custom_new_order_status_rollback'] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php index 536329cb02906..91f697e332baa 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php @@ -56,7 +56,7 @@ class CancelCreatedOrderTest extends Injectable public function __prepare() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'checkmo, flatrate', 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php index 36c9972bc9842..57f18d9e8644d 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php @@ -66,7 +66,7 @@ public function __prepare(FixtureFactory $fixtureFactory) $this->fixtureFactory = $fixtureFactory; $setupConfigurationStep = $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'checkmo, flatrate'] ); $setupConfigurationStep->run(); @@ -83,11 +83,11 @@ public function test(OrderInjectable $order, array $data) { // Preconditions $order->persist(); - $this->objectManager->create('Magento\Sales\Test\TestStep\CreateInvoiceStep', ['order' => $order])->run(); + $this->objectManager->create(\Magento\Sales\Test\TestStep\CreateInvoiceStep::class, ['order' => $order])->run(); // Steps $createCreditMemoStep = $this->objectManager->create( - 'Magento\Sales\Test\TestStep\CreateCreditMemoStep', + \Magento\Sales\Test\TestStep\CreateCreditMemoStep::class, ['order' => $order, 'data' => $data] ); $result = $createCreditMemoStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php index aff2cf493db50..1bde546b2d644 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php @@ -41,7 +41,7 @@ class CreateInvoiceEntityTest extends Injectable public function __prepare() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'checkmo, flatrate'] )->run(); } @@ -60,7 +60,7 @@ public function test(OrderInjectable $order, array $data) // Steps $result = $this->objectManager->create( - 'Magento\Sales\Test\TestStep\CreateInvoiceStep', + \Magento\Sales\Test\TestStep\CreateInvoiceStep::class, ['order' => $order, 'data' => $data] )->run(); @@ -74,6 +74,6 @@ public function test(OrderInjectable $order, array $data) */ public function tearDown() { - $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php index 533187dbc0f8c..9e6b2c9556a5d 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php @@ -56,7 +56,7 @@ class HoldCreatedOrderTest extends Injectable public function __prepare() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'checkmo, flatrate', 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php index 5735c26625106..2b1b3142901b7 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php @@ -116,7 +116,7 @@ protected function processSteps(OrderInjectable $order, $steps) foreach ($steps as $step) { $action = str_replace(' ', '', ucwords($step)); $methodAction = (($action != 'OnHold') ? 'Create' : '') . $action . 'Step'; - $path = 'Magento\Sales\Test\TestStep'; + $path = \Magento\Sales\Test\TestStep::class; $processStep = $this->objectManager->create($path . '\\' . $methodAction, ['order' => $order]); $processStep->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php index e1f9e98e78974..6cfeabdd056ae 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php @@ -103,7 +103,7 @@ public function __prepare(Customer $customer, BrowserInterface $browser) $customer->persist(); // Login under customer $this->objectManager - ->create('Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', ['customer' => $customer]) + ->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer]) ->run(); $this->browser = $browser; @@ -149,7 +149,7 @@ public function test(Customer $customer, $products) // Preconditions // Create products $products = $this->objectManager->create( - '\Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $products] )->run()['products']; // Add products to compare diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php index 79821933b69e4..cd95ec1479ec8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php @@ -104,7 +104,7 @@ public function __prepare(Customer $customer, BrowserInterface $browser) $customer->persist(); // Login under customer $this->objectManager - ->create('Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', ['customer' => $customer]) + ->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer]) ->run(); $this->browser = $browser; @@ -150,7 +150,7 @@ public function test(Customer $customer, $products) // Preconditions // Create product $products = $this->objectManager->create( - '\Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $products] )->run()['products']; foreach ($products as $itemProduct) { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php index 450f3a67c6095..da79ca807c7ad 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php @@ -48,7 +48,7 @@ public function __prepare(Customer $customer) { $customer->persist(); $this->objectManager - ->create('Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', ['customer' => $customer]) + ->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer]) ->run(); return ['customer' => $customer]; @@ -65,23 +65,23 @@ public function test(Customer $customer, $products) { // Preconditions $products = $this->objectManager - ->create('Magento\Catalog\Test\TestStep\CreateProductsStep', ['products' => $products]) + ->create(\Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $products]) ->run()['products']; $this->objectManager - ->create('Magento\Catalog\Test\TestStep\OpenProductsOnFrontendStep', ['products' => $products]) + ->create(\Magento\Catalog\Test\TestStep\OpenProductsOnFrontendStep::class, ['products' => $products]) ->run(); // Steps $this->objectManager - ->create('Magento\Customer\Test\TestStep\OpenCustomerOnBackendStep', ['customer' => $customer]) + ->create(\Magento\Customer\Test\TestStep\OpenCustomerOnBackendStep::class, ['customer' => $customer]) ->run(); - $this->objectManager->create('Magento\Customer\Test\TestStep\CreateOrderFromCustomerAccountStep')->run(); - $this->objectManager->create('Magento\Sales\Test\TestStep\SelectStoreStep')->run(); + $this->objectManager->create(\Magento\Customer\Test\TestStep\CreateOrderFromCustomerAccountStep::class)->run(); + $this->objectManager->create(\Magento\Sales\Test\TestStep\SelectStoreStep::class)->run(); $this->objectManager - ->create('Magento\Sales\Test\TestStep\AddRecentlyViewedProductsToCartStep', ['products' => $products]) + ->create(\Magento\Sales\Test\TestStep\AddRecentlyViewedProductsToCartStep::class, ['products' => $products]) ->run(); $this->objectManager - ->create('Magento\Sales\Test\TestStep\ConfigureProductsStep', ['products' => $products]) + ->create(\Magento\Sales\Test\TestStep\ConfigureProductsStep::class, ['products' => $products]) ->run(); return ['products' => $products]; diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php index dcbf06351ed6f..628cfa0871619 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php @@ -135,12 +135,12 @@ public function test(Customer $customer, $product) //Preconditions // Create product $product = $this->objectManager->create( - '\Magento\Catalog\Test\TestStep\CreateProductStep', + \Magento\Catalog\Test\TestStep\CreateProductStep::class, ['product' => $product] )->run()['product']; // Login under customer $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php index eaf759b92f680..98726fbd9d31a 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php @@ -160,7 +160,7 @@ public function tearDown() $filter = ['label' => $this->orderStatus->getLabel(), 'status' => $this->orderStatusInitial->getStatus()]; $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter); $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'checkmo_custom_new_order_status_rollback'] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php index 4cd4cedaed1e3..832fd4b6205e5 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php @@ -23,7 +23,7 @@ public function getItemBlock($id = null) { $selector = ($id === null) ? $this->content : sprintf($this->itemBlock, $id) . $this->content; return $this->blockFactory->create( - 'Magento\SalesRule\Test\Block\Order\Items', + \Magento\SalesRule\Test\Block\Order\Items::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php index eb8cf00133514..89ba90032b35b 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php @@ -195,7 +195,7 @@ public function processAssert( protected function login() { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php index ed8c34e1d09c7..5ab10a0e26f79 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php @@ -38,52 +38,52 @@ class Curl extends Conditions implements SalesRuleInterface */ protected $mapTypeParams = [ 'Subtotal' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', ], 'Total Items Quantity' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'total_qty', ], 'Conditions combination' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', ], 'Products subselection' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product\Subselect', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Subselect::class, 'attribute' => 'qty', 'operator' => '==', 'value' => '1', 'aggregator' => 'all', ], 'Product attribute combination' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product\Found', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Found::class, 'value' => '1', 'aggregator' => 'all', ], 'Shipping Country' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'country_id', ], 'Shipping Postcode' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'postcode', ], 'Category' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', ], 'Price in cart' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'quote_item_price', ], 'Quantity in cart' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'quote_item_qty', ], 'Row total in cart' => [ - 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'quote_item_row_total', ] ]; @@ -207,7 +207,7 @@ public function prepareData(FixtureInterface $fixture) if (isset($this->data['actions_serialized'])) { $this->mapTypeParams['Conditions combination']['type'] = - 'Magento\SalesRule\Model\Rule\Condition\Product\Combine'; + \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class; $this->data['rule']['actions'] = $this->prepareCondition($this->data['actions_serialized']); unset($this->data['actions_serialized']); } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/ApplySeveralSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/ApplySeveralSalesRuleEntityTest.php index e4a0ee1478afe..30f2a1546cb2e 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/ApplySeveralSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/ApplySeveralSalesRuleEntityTest.php @@ -82,6 +82,6 @@ public function testApplySeveralSalesRules( */ public function tearDown() { - $this->objectManager->create('\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->objectManager->create(\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/Page/UserAccountForgotPassword.php b/dev/tests/functional/tests/app/Magento/Security/Test/Page/UserAccountForgotPassword.php index 7525ee7a0a883..80c91f29be4a3 100644 --- a/dev/tests/functional/tests/app/Magento/Security/Test/Page/UserAccountForgotPassword.php +++ b/dev/tests/functional/tests/app/Magento/Security/Test/Page/UserAccountForgotPassword.php @@ -22,12 +22,12 @@ class UserAccountForgotPassword extends Page */ protected $blocks = [ 'messagesBlock' => [ - 'class' => 'Magento\Backend\Test\Block\Messages', + 'class' => \Magento\Backend\Test\Block\Messages::class, 'locator' => '.messages', 'strategy' => 'css selector', ], 'forgotPasswordForm' => [ - 'class' => 'Magento\Security\Test\Block\Form\ForgotPassword', + 'class' => \Magento\Security\Test\Block\Form\ForgotPassword::class, 'locator' => '#login-form', 'strategy' => 'css selector', ], diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewIntegrationTest.php b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewIntegrationTest.php index 77f62a3d06e0b..9a36e05e60aba 100644 --- a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewIntegrationTest.php +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewIntegrationTest.php @@ -99,7 +99,7 @@ public function test( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); $customAdmin->persist(); @@ -130,7 +130,7 @@ public function test( public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewRoleTest.php b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewRoleTest.php index 18db2a4321f42..03b38c58a9a1a 100644 --- a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewRoleTest.php +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenCreatingNewRoleTest.php @@ -98,7 +98,7 @@ public function testLockAdminUser( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); $customAdmin->persist(); @@ -129,7 +129,7 @@ public function testLockAdminUser( public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnEditPageTest.php b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnEditPageTest.php index a3e6e3810f061..03c7a33533e91 100644 --- a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnEditPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnEditPageTest.php @@ -112,14 +112,14 @@ public function test( $this->configData = $configData; // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); $initialCustomer->persist(); // Steps $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $initialCustomer] )->run(); @@ -142,7 +142,7 @@ public function test( public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnLoginPageTest.php b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnLoginPageTest.php index 9f7147b9aaf77..75b06ed87b4fc 100644 --- a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnLoginPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockCustomerOnLoginPageTest.php @@ -79,7 +79,7 @@ public function test( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); $initialCustomer->persist(); @@ -104,7 +104,7 @@ public function test( public function tearDown() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php index 10880577f4072..f46b812ef0def 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php @@ -37,7 +37,7 @@ class Form extends AbstractForm protected function getItemsBlock() { return $this->blockFactory->create( - 'Magento\Shipping\Test\Block\Adminhtml\Form\Items', + \Magento\Shipping\Test\Block\Adminhtml\Form\Items::class, ['element' => $this->_rootElement->find($this->items)] ); } @@ -50,7 +50,7 @@ protected function getItemsBlock() protected function getTrackingBlock() { return $this->blockFactory->create( - 'Magento\Shipping\Test\Block\Adminhtml\Order\Tracking', + \Magento\Shipping\Test\Block\Adminhtml\Order\Tracking::class, ['element' => $this->_rootElement->find($this->tracking)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php index d704f413c99a5..132c56c7d9c3e 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php @@ -26,7 +26,7 @@ public function getItemProductBlock(FixtureInterface $product) { $selector = sprintf($this->productItem, $product->getSku()); return $this->blockFactory->create( - 'Magento\Shipping\Test\Block\Adminhtml\Form\Items\Product', + \Magento\Shipping\Test\Block\Adminhtml\Form\Items\Product::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Order/Tracking.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Order/Tracking.php index d96499da39175..a7929cd128ab7 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Order/Tracking.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Order/Tracking.php @@ -39,7 +39,7 @@ class Tracking extends Block protected function getItemTrackingBlock($index) { return $this->blockFactory->create( - 'Magento\Shipping\Test\Block\Adminhtml\Order\Tracking\Item', + \Magento\Shipping\Test\Block\Adminhtml\Order\Tracking\Item::class, ['element' => $this->_rootElement->find(sprintf($this->itemTracking, $index), Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Order/Shipment.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Order/Shipment.php index 216eaab4a5833..c28327666a333 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Order/Shipment.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Order/Shipment.php @@ -40,7 +40,7 @@ public function getItemShipmentBlock($id) { $selector = sprintf($this->shipmentItemBlock, $id) . $this->shipmentContent; return $this->blockFactory->create( - 'Magento\Shipping\Test\Block\Order\Shipment\Items', + \Magento\Shipping\Test\Block\Order\Shipment\Items::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php index 96a4c3c68575e..3ac010409f326 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php @@ -42,7 +42,7 @@ class CreateShipmentEntityTest extends Injectable public function __prepare() { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => "checkmo,flatrate"] )->run(); } @@ -61,7 +61,7 @@ public function test(OrderInjectable $order, array $data) // Steps $createShipping = $this->objectManager->create( - 'Magento\Sales\Test\TestStep\CreateShipmentStep', + \Magento\Sales\Test\TestStep\CreateShipmentStep::class, ['order' => $order, 'data' => $data] ); diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php index 5756871008d0e..b7d98d8496e54 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php @@ -181,7 +181,7 @@ function () use ($rootForm, $taxRateMultiSelectList) { $taxRateBlock = $this->_rootElement->find($this->taxRateBlock, Locator::SELECTOR_CSS, 'multiselectlist'); /** @var \Magento\Tax\Test\Block\Adminhtml\Rule\Edit\TaxRate $taxRateForm */ $taxRateForm = $this->blockFactory->create( - 'Magento\Tax\Test\Block\Adminhtml\Rule\Edit\TaxRate', + \Magento\Tax\Test\Block\Adminhtml\Rule\Edit\TaxRate::class, ['element' => $this->browser->find($this->taxRateForm)] ); diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php index 277535b337a48..935d3beb38922 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php @@ -183,7 +183,7 @@ protected function getCartPrice(CatalogProductSimple $product, $actualPrices) protected function loginCustomer($customer) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php index 09f1481c17043..6c7408660a8dc 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php @@ -126,7 +126,7 @@ public function processAssert( $this->productSimple->persist(); // Customer login $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); // Clearing shopping cart and adding product to shopping cart diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php index f026bb512a86b..5837793ab263e 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php @@ -82,7 +82,7 @@ public function test( // Preconditions $this->configData = $configData; $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); $taxRule->persist(); @@ -99,11 +99,11 @@ public function test( // Steps $order->persist(); $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer] )->run(); $this->objectManager->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, $order->getEntityId() )->run(); $this->checkoutCart->open(); @@ -128,6 +128,6 @@ public function test( public function tearDown() { parent::tearDown(); - $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRuleEntityTest.php index e63e30ab04278..7722a7e977329 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRuleEntityTest.php @@ -82,6 +82,6 @@ public function testCreateTaxRule(TaxRule $taxRule) */ public function tearDown() { - $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep', [])->run(); + $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class, [])->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php index d06b207298183..7e972c17c4922 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php @@ -128,7 +128,7 @@ public function test( $this->catalogRule = $catalogRule; } $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $configData] )->run(); $product->persist(); @@ -142,18 +142,18 @@ public function test( public function tearDown() { if (isset($this->salesRule)) { - $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->objectManager->create(\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep::class)->run(); $this->salesRule = null; } if (isset($this->catalogRule)) { - $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); + $this->objectManager->create(\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep::class)->run(); $this->catalogRule = null; } // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331 - $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class)->run(); $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'default_tax_configuration'] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php index ea9887181521b..b9cf14a74e7fe 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php @@ -104,6 +104,6 @@ public function testUpdateTaxRule( */ public function tearDown() { - $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep', [])->run(); + $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class, [])->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index 50c79987b8c09..9a3e2dffec59c 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -279,7 +279,10 @@ public function massaction(array $items, $action, $acceptAlert = false, $massAct if ($acceptAlert) { $element = $this->browser->find($this->alertModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create( + \Magento\Ui\Test\Block\Adminhtml\Modal::class, + ['element' => $element] + ); $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php b/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php index 50afbd48e4151..2180434bd00a2 100644 --- a/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php +++ b/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php @@ -62,13 +62,13 @@ public function test( $upgrade = [] ) { // Create fixture - $upgradeFixture = $fixtureFactory->create('Magento\Upgrade\Test\Fixture\Upgrade', ['data' => $upgrade]); + $upgradeFixture = $fixtureFactory->create(\Magento\Upgrade\Test\Fixture\Upgrade::class, ['data' => $upgrade]); $createBackupConfig = array_intersect_key( $upgrade, ['optionsCode' => '', 'optionsMedia' => '', 'optionsDb' => ''] ); $createBackupFixture = $fixtureFactory->create( - 'Magento\Upgrade\Test\Fixture\Upgrade', + \Magento\Upgrade\Test\Fixture\Upgrade::class, ['data' => $createBackupConfig] ); $version = $upgrade['upgradeVersion']; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/Role/Tab/Role.php b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/Role/Tab/Role.php index f69ef323df543..4d2463b1faa4c 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/Role/Tab/Role.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/Role/Tab/Role.php @@ -21,6 +21,7 @@ class Role extends Tab * @param array $fields * @param SimpleElement $element * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setFieldsData(array $fields, SimpleElement $element = null) { @@ -40,7 +41,7 @@ public function setFieldsData(array $fields, SimpleElement $element = null) public function getUserGrid() { return $this->blockFactory->create( - 'Magento\User\Test\Block\Adminhtml\Role\Tab\User\Grid', + \Magento\User\Test\Block\Adminhtml\Role\Tab\User\Grid::class, ['element' => $this->_rootElement->find('#roleUserGrid')] ); } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/Form.php b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/Form.php index 291bcdd95541f..2537403d2084d 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/Form.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/Form.php @@ -42,7 +42,7 @@ public function openRoleTab() public function getRolesGrid() { return $this->blockFactory->create( - 'Magento\User\Test\Block\Adminhtml\User\Edit\Tab\Roles', + \Magento\User\Test\Block\Adminhtml\User\Edit\Tab\Roles::class, ['element' => $this->_rootElement->find('#permissionsUserRolesGrid')] ); } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php index dcdd3a91d0ed3..99177d143b4fe 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php @@ -38,7 +38,7 @@ public function forceSignIn() $this->_rootElement->find($this->forceSignIn)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Tab/Role.php b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Tab/Role.php index 20aa416103942..5b23907f17b00 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Tab/Role.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Tab/Role.php @@ -21,6 +21,7 @@ class Role extends Tab * @param array $fields * @param SimpleElement|null $element * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setFieldsData(array $fields, SimpleElement $element = null) { @@ -35,7 +36,7 @@ public function setFieldsData(array $fields, SimpleElement $element = null) public function getRoleGrid() { return $this->blockFactory->create( - 'Magento\User\Test\Block\Adminhtml\User\Tab\Role\Grid', + \Magento\User\Test\Block\Adminhtml\User\Tab\Role\Grid::class, ['element' => $this->_rootElement->find('#permissionsUserRolesGrid')] ); } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleRestrictedAccess.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleRestrictedAccess.php index 5912c05e9aabc..4fd8e44a90bea 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleRestrictedAccess.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleRestrictedAccess.php @@ -35,7 +35,10 @@ public function processAssert( array $restrictedAccess, $denyUrl ) { - $this->objectManager->create('Magento\User\Test\TestStep\LoginUserOnBackendStep', ['user' => $user])->run(); + $this->objectManager->create( + \Magento\User\Test\TestStep\LoginUserOnBackendStep::class, + ['user' => $user] + )->run(); $menuItems = $dashboard->getMenuBlock()->getTopMenuItems(); \PHPUnit_Framework_Assert::assertEquals($menuItems, $restrictedAccess, 'Wrong display menu.'); diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php index 3d943cb790b30..7976ecd3ad735 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php @@ -24,7 +24,10 @@ class AssertUserSuccessLogin extends AbstractConstraint */ public function processAssert(User $user, Dashboard $dashboard) { - $this->objectManager->create('Magento\User\Test\TestStep\LoginUserOnBackendStep', ['user' => $user])->run(); + $this->objectManager->create( + \Magento\User\Test\TestStep\LoginUserOnBackendStep::class, + ['user' => $user] + )->run(); \PHPUnit_Framework_Assert::assertTrue( $dashboard->getAdminPanelHeader()->isLoggedIn(), 'Admin user was not logged in.' diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Fixture/User/CurrentPassword.php b/dev/tests/functional/tests/app/Magento/User/Test/Fixture/User/CurrentPassword.php index fdd52d07a8245..09a4ba7a91d0b 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Fixture/User/CurrentPassword.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Fixture/User/CurrentPassword.php @@ -38,7 +38,7 @@ public function __construct(array $params, $data = '') $this->params = $params; /** @var \Magento\Mtf\Config\DataInterface $systemConfig */ if ($data == '%current_password%') { - $systemConfig = ObjectManager::getInstance()->create('Magento\Mtf\Config\DataInterface'); + $systemConfig = ObjectManager::getInstance()->create(\Magento\Mtf\Config\DataInterface::class); $data = $systemConfig->get('application/0/backendPassword/0/value'); } $this->data = $data; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UserLoginAfterChangingPermissionsTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UserLoginAfterChangingPermissionsTest.php index 462b416b8f53a..235d078b2831c 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UserLoginAfterChangingPermissionsTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UserLoginAfterChangingPermissionsTest.php @@ -37,6 +37,7 @@ * * @group ACL_(PS) * @ZephyrId MAGETWO-28828 + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UserLoginAfterChangingPermissionsTest extends Injectable { @@ -136,7 +137,7 @@ public function testLoginAfterChangingPermissions( $role->persist(); /** @var User $user */ $user = $this->fixtureFactory->create( - 'Magento\User\Test\Fixture\User', + \Magento\User\Test\Fixture\User::class, ['data' => array_merge($user->getData(), ['role_id' => ['role' => $role]])] ); $user->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php index 2bf065b527923..6af36abf59e35 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php @@ -65,7 +65,7 @@ public function selectStoreView($storeName) } $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); return null; diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/UpdateCustomVariableEntityTest.php b/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/UpdateCustomVariableEntityTest.php index 6c6b6a5f2894f..1236e56f4be10 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/UpdateCustomVariableEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/UpdateCustomVariableEntityTest.php @@ -125,12 +125,12 @@ public function tearDown() { // TODO: Move store clean up to "tearDownAfterClass" method after fix bug MAGETWO-29331 if ($this->store !== null) { - $storeIndex = $this->objectManager->create('Magento\Backend\Test\Page\Adminhtml\StoreIndex'); + $storeIndex = $this->objectManager->create(\Magento\Backend\Test\Page\Adminhtml\StoreIndex::class); $storeIndex->open(); $storeIndex->getStoreGrid()->searchAndOpen(['store_title' => $this->store->getName()]); - $storeNew = $this->objectManager->create('Magento\Backend\Test\Page\Adminhtml\StoreNew'); + $storeNew = $this->objectManager->create(\Magento\Backend\Test\Page\Adminhtml\StoreNew::class); $storeNew->getFormPageActions()->delete(); - $storeDelete = $this->objectManager->create('Magento\Backend\Test\Page\Adminhtml\StoreDelete'); + $storeDelete = $this->objectManager->create(\Magento\Backend\Test\Page\Adminhtml\StoreDelete::class); $storeDelete->getStoreForm()->fillForm(['create_backup' => 'No']); $storeDelete->getFormPageActions()->delete(); } diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php index 85150d6c4798e..13c9eb9ee7259 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php @@ -14,6 +14,9 @@ use Magento\Vault\Test\Constraint\AssertCreditCardDeletedMessage; use Magento\Vault\Test\Page\MyCreditCards; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DeleteCreditCardFromMyAccountStep implements TestStepInterface { /** @@ -90,7 +93,7 @@ public function __construct( public function run() { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer] )->run(); $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Credit Cards'); diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart.php index d707e6835474f..e46318d777ec6 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart.php @@ -35,7 +35,7 @@ public function getCartItem(FixtureInterface $product) Locator::SELECTOR_XPATH ); $cartItem = $this->blockFactory->create( - 'Magento\Weee\Test\Block\Cart\CartItem', + \Magento\Weee\Test\Block\Cart\CartItem::class, ['element' => $cartItemBlock] ); } diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/CartItem.php b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/CartItem.php index 7c762fb43a1f1..9e01856f9ba1e 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/CartItem.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/CartItem.php @@ -36,7 +36,7 @@ class CartItem extends \Magento\Checkout\Test\Block\Cart\CartItem public function getPriceFptBlock() { return $this->blockFactory->create( - 'Magento\Weee\Test\Block\Cart\CartItem\Fpt', + \Magento\Weee\Test\Block\Cart\CartItem\Fpt::class, ['element' => $this->_rootElement->find($this->priceFptBlock, Locator::SELECTOR_XPATH)] ); } @@ -49,7 +49,7 @@ public function getPriceFptBlock() public function getSubtotalFptBlock() { return $this->blockFactory->create( - 'Magento\Weee\Test\Block\Cart\CartItem\Fpt', + \Magento\Weee\Test\Block\Cart\CartItem\Fpt::class, ['element' => $this->_rootElement->find($this->subtotalFptBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/Totals.php b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/Totals.php index 94821a9529e6e..c1813428d9978 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Cart/Totals.php @@ -28,7 +28,7 @@ class Totals extends \Magento\Checkout\Test\Block\Cart\Totals public function getFptBlock() { return $this->blockFactory->create( - 'Magento\Weee\Test\Block\Cart\Totals\Fpt', + \Magento\Weee\Test\Block\Cart\Totals\Fpt::class, ['element' => $this->_rootElement->find($this->fptBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ListProduct.php b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ListProduct.php index 0cca5cfe14867..2ef6913407573 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ListProduct.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ListProduct.php @@ -25,7 +25,7 @@ public function getProductItem(FixtureInterface $product) { $locator = sprintf($this->productItem, $product->getName()); return $this->blockFactory->create( - 'Magento\Weee\Test\Block\Product\ProductList\ProductItem', + \Magento\Weee\Test\Block\Product\ProductList\ProductItem::class, ['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ProductList/ProductItem.php b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ProductList/ProductItem.php index 47326a30602b0..279909c30493d 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ProductList/ProductItem.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/ProductList/ProductItem.php @@ -21,7 +21,7 @@ class ProductItem extends \Magento\Catalog\Test\Block\Product\ProductList\Produc public function getPriceBlock() { return $this->blockFactory->create( - 'Magento\Weee\Test\Block\Product\Price', + \Magento\Weee\Test\Block\Product\Price::class, ['element' => $this->_rootElement->find($this->priceBox)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/View.php index 17b77496d779e..fb09c67e15157 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/Block/Product/View.php @@ -26,7 +26,7 @@ class View extends \Magento\Catalog\Test\Block\Category\View public function getPriceBlock() { return $this->blockFactory->create( - 'Magento\Weee\Test\Block\Product\Price', + \Magento\Weee\Test\Block\Product\Price::class, ['element' => $this->_rootElement->find($this->priceBox)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Weee/Test/TestCase/CreateTaxWithFptTest.php b/dev/tests/functional/tests/app/Magento/Weee/Test/TestCase/CreateTaxWithFptTest.php index 375e76a9957e8..5f3d91b58d147 100644 --- a/dev/tests/functional/tests/app/Magento/Weee/Test/TestCase/CreateTaxWithFptTest.php +++ b/dev/tests/functional/tests/app/Magento/Weee/Test/TestCase/CreateTaxWithFptTest.php @@ -87,7 +87,7 @@ public function __prepare(FixtureFactory $fixtureFactory) protected function loginCustomer(Customer $customer) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); } @@ -114,7 +114,7 @@ public function test( ); $product->persist(); $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $configData] )->run(); $this->loginCustomer($customer); @@ -129,9 +129,9 @@ public function test( */ public function tearDown() { - $this->objectManager->create('\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class)->run(); $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => 'default_tax_configuration,shipping_tax_class_taxable_goods_rollback'] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php index 7a400056b93fa..08acc10b83946 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php @@ -42,21 +42,21 @@ class ChosenOption extends SimpleElement * * @var string */ - protected $pageWidgetChooserBlockClass = 'Magento\Cms\Test\Block\Adminhtml\Page\Widget\Chooser'; + protected $pageWidgetChooserBlockClass = \Magento\Cms\Test\Block\Adminhtml\Page\Widget\Chooser::class; /** * Category widget chooser block class. * * @var string */ - protected $categoryWidgetChooserBlockClass = '\Magento\Catalog\Test\Block\Adminhtml\Category\Widget\Chooser'; + protected $categoryWidgetChooserBlockClass = \Magento\Catalog\Test\Block\Adminhtml\Category\Widget\Chooser::class; /** * Product widget chooser block class. * * @var string */ - protected $productWidgetChooserBlockClass = '\Magento\Catalog\Test\Block\Adminhtml\Product\Widget\Chooser'; + protected $productWidgetChooserBlockClass = \Magento\Catalog\Test\Block\Adminhtml\Product\Widget\Chooser::class; /** * Entity chooser block class mapping. @@ -64,9 +64,9 @@ class ChosenOption extends SimpleElement * @var array */ protected $chooserClasses = [ - 'page' => 'Magento\Cms\Test\Block\Adminhtml\Page\Widget\Chooser', - 'category' => 'Magento\Catalog\Test\Block\Adminhtml\Category\Widget\Chooser', - 'product' => 'Magento\Catalog\Test\Block\Adminhtml\Product\Widget\Chooser', + 'page' => \Magento\Cms\Test\Block\Adminhtml\Page\Widget\Chooser::class, + 'category' => \Magento\Catalog\Test\Block\Adminhtml\Category\Widget\Chooser::class, + 'product' => \Magento\Catalog\Test\Block\Adminhtml\Product\Widget\Chooser::class, ]; /** diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogCategoryLink.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogCategoryLink.php index 97ea2142a5aad..962698478d492 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogCategoryLink.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogCategoryLink.php @@ -35,7 +35,7 @@ protected function selectEntity(array $entities) $this->getTemplateBlock()->waitLoader(); /** @var Form $catalogCategoryLinkForm */ $catalogCategoryLinkForm = $this->blockFactory->create( - 'Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CatalogCategoryLink\Form', + Form::class, ['element' => $this->_rootElement->find($this->cmsCategoryLink, Locator::SELECTOR_XPATH)] ); $elementNew = $this->_rootElement->find($this->cmsCategoryLink, Locator::SELECTOR_XPATH); diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogProductLink.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogProductLink.php index 922003025f74c..11a25fffcfba3 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogProductLink.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CatalogProductLink.php @@ -26,7 +26,7 @@ class CatalogProductLink extends ParametersForm * @var string */ // @codingStandardsIgnoreStart - protected $pathToGrid = 'Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CatalogProductLink\Grid'; + protected $pathToGrid = \Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CatalogProductLink\Grid::class; // @codingStandardsIgnoreEnd /** diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsPageLink.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsPageLink.php index b7126d4f3809f..42e04e00876d7 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsPageLink.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsPageLink.php @@ -24,6 +24,6 @@ class CmsPageLink extends ParametersForm * @var string */ // @codingStandardsIgnoreStart - protected $pathToGrid = 'Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CmsPageLink\Grid'; + protected $pathToGrid = \Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CmsPageLink\Grid::class; // @codingStandardsIgnoreEnd } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsStaticBlock.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsStaticBlock.php index 76f3785250a6e..1314f2064e9b6 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsStaticBlock.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/CmsStaticBlock.php @@ -24,6 +24,6 @@ class CmsStaticBlock extends ParametersForm * @var string */ // @codingStandardsIgnoreStart - protected $pathToGrid = 'Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CmsStaticBlock\Grid'; + protected $pathToGrid = \Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\ParametersType\CmsStaticBlock\Grid::class; // @codingStandardsIgnoreEnd } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/ParametersForm.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/ParametersForm.php index 413036e48a38a..39459548d1ba7 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/ParametersForm.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/ParametersType/ParametersForm.php @@ -116,7 +116,7 @@ protected function prepareFilter(InjectableFixture $entity) public function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->template, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstance.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstance.php index c27abdb9ecaba..a3f9c59447ac1 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstance.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstance.php @@ -81,7 +81,7 @@ protected function addLayoutUpdates() protected function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/Products.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/Products.php index dbd0f4a6e2404..05bff542aab3a 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/Products.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/Products.php @@ -56,7 +56,7 @@ protected function selectEntityInGrid(FixtureInterface $product) /** @var Grid $productGrid */ $productGrid = $this->blockFactory->create( - 'Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\WidgetInstanceType\Product\Grid', + \Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\Tab\WidgetInstanceType\Product\Grid::class, [ 'element' => $this->_rootElement ->find($this->productGrid, Locator::SELECTOR_XPATH) diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/WidgetInstanceForm.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/WidgetInstanceForm.php index b6f1a6c171994..87fddd2bca997 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/WidgetInstanceForm.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/Instance/Edit/Tab/WidgetInstanceType/WidgetInstanceForm.php @@ -89,7 +89,7 @@ public function getDataOptions(array $fields = null, SimpleElement $element = nu protected function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyViewedProducts.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyViewedProducts.php index 733b3ccde1796..cbe07cbe5ae86 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyViewedProducts.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyViewedProducts.php @@ -74,7 +74,7 @@ public function processAssert( // Log in customer $customer->persist(); $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/AbstractCreateWidgetEntityTest.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/AbstractCreateWidgetEntityTest.php index 89564d970c96b..123e5381e6919 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/AbstractCreateWidgetEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/AbstractCreateWidgetEntityTest.php @@ -63,6 +63,6 @@ public function __inject( */ public function tearDown() { - $this->objectManager->create('Magento\Widget\Test\TestStep\DeleteAllWidgetsStep')->run(); + $this->objectManager->create(\Magento\Widget\Test\TestStep\DeleteAllWidgetsStep::class)->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php index e79ae698ed220..60f8bfa3c3eef 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php @@ -31,7 +31,7 @@ class Wishlist extends Tab public function getSearchGridBlock() { return $this->blockFactory->create( - 'Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid', + \Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid::class, ['element' => $this->_rootElement->find($this->wishlistGrid)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php index 72d4a5e44839f..2e0057add1118 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php @@ -74,7 +74,7 @@ protected function delete() $this->_rootElement->find($this->rowItem . ' ' . $this->deleteLink)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ - $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]); $modal->acceptAlert(); } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php index fec1a6847d982..47f787da38b04 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php @@ -75,7 +75,7 @@ public function getProductItemsBlock() { $this->waitFormToLoad(); return $this->blockFactory->create( - 'Magento\Wishlist\Test\Block\Customer\Wishlist\Items', + \Magento\Wishlist\Test\Block\Customer\Wishlist\Items::class, ['element' => $this->_rootElement->find($this->productItems)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php index 13d0e874c3a3a..37b687a212765 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php @@ -40,7 +40,7 @@ public function getItemProduct(FixtureInterface $product) { $productBlock = sprintf($this->itemBlock, $product->getName()); return $this->blockFactory->create( - 'Magento\Wishlist\Test\Block\Customer\Wishlist\Items\Product', + \Magento\Wishlist\Test\Block\Customer\Wishlist\Items\Product::class, ['element' => $this->_rootElement->find($productBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductsIsAbsentInWishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductsIsAbsentInWishlist.php index 6da347984e34f..32baaa6bd0561 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductsIsAbsentInWishlist.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductsIsAbsentInWishlist.php @@ -33,7 +33,7 @@ public function processAssert( Customer $customer ) { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $customerAccountIndex->open()->getAccountMenuBlock()->openMenuItem("My Wish List"); diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php index 110a76984084e..6c76e927fa56e 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php @@ -88,7 +88,7 @@ public function __inject( protected function loginCustomer(Customer $customer) { $loginCustomerOnFrontendStep = $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] ); $loginCustomerOnFrontendStep->run(); @@ -103,7 +103,7 @@ protected function loginCustomer(Customer $customer) protected function createProducts($products) { $createProductsStep = $this->objectManager->create( - 'Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $products] ); @@ -120,7 +120,7 @@ protected function createProducts($products) protected function addToWishlist(array $products, $configure = false) { $this->objectManager->create( - 'Magento\Wishlist\Test\TestStep\AddProductsToWishlistStep', + \Magento\Wishlist\Test\TestStep\AddProductsToWishlistStep::class, ['products' => $products, 'configure' => $configure] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.php index e4c6266cb7e88..33c47f4406970 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.php @@ -82,7 +82,7 @@ public function test( protected function addToCart(FixtureInterface $product) { $addProductsToTheCartStep = $this->objectManager->create( - 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, ['products' => [$product]] ); $addProductsToTheCartStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php index f85447b6570d7..fd8abbe0644fd 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php @@ -110,11 +110,11 @@ public function test( ) { //Steps $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer] )->run(); $this->objectManager->create( - 'Magento\Wishlist\Test\TestStep\AddProductsToWishlistStep', + \Magento\Wishlist\Test\TestStep\AddProductsToWishlistStep::class, ['products' => [$product]] )->run(); $this->wishlistIndex->getMessagesBlock()->waitSuccessMessage(); diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php index 0bba7783f665b..6c7e8b334baa5 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php @@ -74,7 +74,7 @@ public static function suite() public function prepareSuite() { $this->init(); - return $this->objectManager->create('Magento\Mtf\TestSuite\AppState'); + return $this->objectManager->create(\Magento\Mtf\TestSuite\AppState::class); } /** @@ -97,11 +97,11 @@ private function initObjectManager() $configFilePath = realpath(MTF_BP . '/testsuites/' . $_ENV['testsuite_rule_path']); /** @var \Magento\Mtf\Config\DataInterface $configData */ - $configData = $objectManagerFactory->getObjectManager()->create('Magento\Mtf\Config\TestRunner'); + $configData = $objectManagerFactory->getObjectManager()->create(\Magento\Mtf\Config\TestRunner::class); $configData->setFileName($configFileName . '.xml')->load($configFilePath); $this->objectManager = $objectManagerFactory->create( - ['Magento\Mtf\Config\TestRunner' => $configData] + [\Magento\Mtf\Config\TestRunner::class => $configData] ); } } diff --git a/dev/tests/functional/utils/generate.php b/dev/tests/functional/utils/generate.php index 254d1701ec719..55d89892d57f8 100644 --- a/dev/tests/functional/utils/generate.php +++ b/dev/tests/functional/utils/generate.php @@ -6,18 +6,18 @@ require_once dirname(__FILE__) . '/' . 'bootstrap.php'; // Generate page -$objectManager->create('Magento\Mtf\Util\Generate\Page')->launch(); +$objectManager->create(\Magento\Mtf\Util\Generate\Page::class)->launch(); // Generate fixtures $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); $magentoObjectManager = $magentoObjectManagerFactory->create($_SERVER); -$objectManager->create('Magento\Mtf\Util\Generate\Fixture')->launch(); +$objectManager->create(\Magento\Mtf\Util\Generate\Fixture::class)->launch(); // Generate repositories -$magentoObjectManager->get('Magento\Framework\App\State')->setAreaCode('frontend'); -$objectManager->create('Magento\Mtf\Util\Generate\Repository')->launch(); +$magentoObjectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend'); +$objectManager->create(\Magento\Mtf\Util\Generate\Repository::class)->launch(); // Generate factories for old end-to-end tests -$magentoObjectManager->create('Magento\Mtf\Util\Generate\Factory')->launch(); +$magentoObjectManager->create(\Magento\Mtf\Util\Generate\Factory::class)->launch(); \Magento\Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/functional/utils/generate/factory.php b/dev/tests/functional/utils/generate/factory.php index cc7eed68f8501..d3af305ce1692 100644 --- a/dev/tests/functional/utils/generate/factory.php +++ b/dev/tests/functional/utils/generate/factory.php @@ -5,5 +5,5 @@ */ require_once dirname(__DIR__) . '/' . 'bootstrap.php'; -$magentoObjectManager->create('Magento\Mtf\Util\Generate\Factory')->launch(); +$magentoObjectManager->create(\Magento\Mtf\Util\Generate\Factory::class)->launch(); \Magento\Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/functional/utils/generate/fixture.php b/dev/tests/functional/utils/generate/fixture.php index b474f43281a63..e1b17d21209b6 100644 --- a/dev/tests/functional/utils/generate/fixture.php +++ b/dev/tests/functional/utils/generate/fixture.php @@ -7,4 +7,4 @@ $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); $magentoObjectManager = $magentoObjectManagerFactory->create($_SERVER); -$objectManager->create('Magento\Mtf\Util\Generate\Fixture')->launch(); +$objectManager->create(\Magento\Mtf\Util\Generate\Fixture::class)->launch(); diff --git a/dev/tests/functional/utils/generate/handler.php b/dev/tests/functional/utils/generate/handler.php index 96138824d7631..81a2d1003f907 100644 --- a/dev/tests/functional/utils/generate/handler.php +++ b/dev/tests/functional/utils/generate/handler.php @@ -5,5 +5,5 @@ */ require_once dirname(__DIR__) . '/' . 'bootstrap.php'; -$objectManager->create('Magento\Mtf\Util\Generate\Handler')->launch(); +$objectManager->create(\Magento\Mtf\Util\Generate\Handler::class)->launch(); \Magento\Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/functional/utils/generate/page.php b/dev/tests/functional/utils/generate/page.php index ac647d3473f27..32bc9f043f17b 100644 --- a/dev/tests/functional/utils/generate/page.php +++ b/dev/tests/functional/utils/generate/page.php @@ -5,5 +5,5 @@ */ require_once dirname(__DIR__) . '/' . 'bootstrap.php'; -$objectManager->create('Magento\Mtf\Util\Generate\Page')->launch(); +$objectManager->create(\Magento\Mtf\Util\Generate\Page::class)->launch(); \Magento\Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/functional/utils/generate/repository.php b/dev/tests/functional/utils/generate/repository.php index 67920111ac888..917b94b60a060 100644 --- a/dev/tests/functional/utils/generate/repository.php +++ b/dev/tests/functional/utils/generate/repository.php @@ -5,5 +5,5 @@ */ require_once dirname(__DIR__) . '/' . 'bootstrap.php'; -$magentoObjectManager->get('Magento\Framework\App\State')->setAreaCode('frontend'); -$objectManager->create('Magento\Mtf\Util\Generate\Repository')->launch(); +$magentoObjectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend'); +$objectManager->create(\Magento\Mtf\Util\Generate\Repository::class)->launch(); diff --git a/dev/tests/functional/utils/generateFixtureXml.php b/dev/tests/functional/utils/generateFixtureXml.php index 63cdfd67c80ed..08a37d63a63c9 100644 --- a/dev/tests/functional/utils/generateFixtureXml.php +++ b/dev/tests/functional/utils/generateFixtureXml.php @@ -7,6 +7,6 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bootstrap.php'; $magentoObjectManager->create( - 'Magento\Mtf\Util\Generate\Fixture\SchemaXml', + \Magento\Mtf\Util\Generate\Fixture\SchemaXml::class, ['objectManager' => $magentoObjectManager] )->launch(); diff --git a/dev/tests/static/framework/Magento/Sniffs/LiteralNamespaces/LiteralNamespacesSniff.php b/dev/tests/static/framework/Magento/Sniffs/LiteralNamespaces/LiteralNamespacesSniff.php new file mode 100644 index 0000000000000..d064eec38d3b2 --- /dev/null +++ b/dev/tests/static/framework/Magento/Sniffs/LiteralNamespaces/LiteralNamespacesSniff.php @@ -0,0 +1,66 @@ +getTokens(); + if ($sourceFile->findPrevious(T_STRING_CONCAT, $stackPtr, $stackPtr - 3) || + $sourceFile->findNext(T_STRING_CONCAT, $stackPtr, $stackPtr + 3) + ) { + return; + } + + $content = trim($tokens[$stackPtr]['content'], "\"'"); + if (preg_match($this->literalNamespacePattern, $content) === 1 && $this->classExists($content)) { + $sourceFile->addError("Use ::class notation instead.", $stackPtr); + } + } + + /** + * @param string $className + * @return bool + */ + private function classExists($className) + { + if (!isset($this->classNames[$className])) { + $this->classNames[$className] = class_exists($className) || interface_exists($className); + } + return $this->classNames[$className]; + } +} diff --git a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php index 59167913e1d34..946b2c15ecc53 100644 --- a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php +++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php @@ -46,7 +46,7 @@ public function __construct($rulesetFile, $reportFile) */ public function canRun() { - return class_exists('PHPMD\TextUI\Command'); + return class_exists(\PHPMD\TextUI\Command::class); } /** diff --git a/dev/tests/static/framework/Magento/ruleset.xml b/dev/tests/static/framework/Magento/ruleset.xml index 02685a81dc132..c1b7fb98bd296 100644 --- a/dev/tests/static/framework/Magento/ruleset.xml +++ b/dev/tests/static/framework/Magento/ruleset.xml @@ -13,4 +13,7 @@ + + */_files/* + diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/InjectableTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/InjectableTest.php index 241603a1ab297..363d6bd5c6e17 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/InjectableTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/InjectableTest.php @@ -38,23 +38,23 @@ public function setUp() { $this->injectable = new Injectable(); $this->fileReflection = $this->getMockBuilder( - 'Zend\Code\Reflection\FileReflection' + \Zend\Code\Reflection\FileReflection::class )->disableOriginalConstructor()->getMock(); $classReflection = $this->getMockBuilder( - 'Zend\Code\Reflection\ClassReflection' + \Zend\Code\Reflection\ClassReflection::class )->disableOriginalConstructor()->getMock(); $methodReflection = $this->getMockBuilder( - 'Zend\Code\Reflection\MethodReflection' + \Zend\Code\Reflection\MethodReflection::class )->disableOriginalConstructor()->getMock(); $this->parameterReflection = $this->getMockBuilder( - 'Zend\Code\Reflection\ParameterReflection' + \Zend\Code\Reflection\ParameterReflection::class )->disableOriginalConstructor()->getMock(); $this->declaredClass = $this->getMockBuilder( - 'Zend\Code\Reflection\ClassReflection' + \Zend\Code\Reflection\ClassReflection::class )->disableOriginalConstructor()->getMock(); $methodReflection->expects( @@ -98,7 +98,7 @@ public function setUp() public function testGetDependencies() { $classReflection = $this->getMockBuilder( - 'Zend\Code\Reflection\ClassReflection' + \Zend\Code\Reflection\ClassReflection::class )->disableOriginalConstructor()->getMock(); $classReflection->expects( @@ -106,7 +106,7 @@ public function testGetDependencies() )->method( 'getName' )->will( - $this->returnValue('Magento\Core\Model\Object') + $this->returnValue(\Magento\Core\Model\Object::class) ); $this->parameterReflection->expects( @@ -118,7 +118,7 @@ public function testGetDependencies() ); $this->assertEquals( - ['Magento\Core\Model\Object'], + [\Magento\Core\Model\Object::class], $this->injectable->getDependencies($this->fileReflection) ); } @@ -139,7 +139,7 @@ function () { ); $this->assertEquals( - ['Magento\Core\Model\Object'], + [\Magento\Core\Model\Object::class], $this->injectable->getDependencies($this->fileReflection) ); } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ParserFactoryTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ParserFactoryTest.php index affa052076124..969284adde074 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ParserFactoryTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ParserFactoryTest.php @@ -22,7 +22,7 @@ class ParserFactoryTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->tokens = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Tokens' + \Magento\TestFramework\Integrity\Library\PhpParser\Tokens::class )->disableOriginalConstructor()->getMock(); } @@ -35,13 +35,16 @@ public function testCreateParsers() { $parseFactory = new ParserFactory(); $parseFactory->createParsers($this->tokens); - $this->assertInstanceOf('Magento\TestFramework\Integrity\Library\PhpParser\Uses', $parseFactory->getUses()); $this->assertInstanceOf( - 'Magento\TestFramework\Integrity\Library\PhpParser\StaticCalls', + \Magento\TestFramework\Integrity\Library\PhpParser\Uses::class, + $parseFactory->getUses() + ); + $this->assertInstanceOf( + \Magento\TestFramework\Integrity\Library\PhpParser\StaticCalls::class, $parseFactory->getStaticCalls() ); $this->assertInstanceOf( - 'Magento\TestFramework\Integrity\Library\PhpParser\Throws', + \Magento\TestFramework\Integrity\Library\PhpParser\Throws::class, $parseFactory->getThrows() ); } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/StaticCallsTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/StaticCallsTest.php index ab951cb53c7fe..811b702cd55b3 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/StaticCallsTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/StaticCallsTest.php @@ -27,7 +27,7 @@ class StaticCallsTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->tokens = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Tokens' + \Magento\TestFramework\Integrity\Library\PhpParser\Tokens::class )->disableOriginalConstructor()->getMock(); } @@ -75,7 +75,7 @@ function ($k) use ($tokens) { } $uses = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Uses' + \Magento\TestFramework\Integrity\Library\PhpParser\Uses::class )->disableOriginalConstructor()->getMock(); $uses->expects($this->once())->method('hasUses')->will($this->returnValue(true)); diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ThrowsTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ThrowsTest.php index 8050a6b371b1c..d910c849f6de4 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ThrowsTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/ThrowsTest.php @@ -27,7 +27,7 @@ class ThrowsTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->tokens = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Tokens' + \Magento\TestFramework\Integrity\Library\PhpParser\Tokens::class )->disableOriginalConstructor()->getMock(); } @@ -70,7 +70,7 @@ function ($k) use ($tokens) { } $uses = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Uses' + \Magento\TestFramework\Integrity\Library\PhpParser\Uses::class )->disableOriginalConstructor()->getMock(); $uses->expects($this->once())->method('hasUses')->will($this->returnValue(true)); diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/TokensTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/TokensTest.php index fda250bd8f12e..8e7127d263c84 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/TokensTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/PhpParser/TokensTest.php @@ -34,7 +34,7 @@ class TokensTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->parseFactory = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\ParserFactory' + \Magento\TestFramework\Integrity\Library\PhpParser\ParserFactory::class )->disableOriginalConstructor()->getMock(); } @@ -45,7 +45,7 @@ public function setUp() */ public function testParseContent() { - $parser = $this->getMock('Magento\TestFramework\Integrity\Library\PhpParser\ParserInterface'); + $parser = $this->getMock(\Magento\TestFramework\Integrity\Library\PhpParser\ParserInterface::class); $this->parseFactory->expects($this->any())->method('createParsers')->will($this->returnValue([$parser])); @@ -61,13 +61,13 @@ public function testParseContent() public function testGetDependencies() { $uses = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Uses' + \Magento\TestFramework\Integrity\Library\PhpParser\Uses::class )->disableOriginalConstructor()->getMock(); $this->parseFactory->expects($this->exactly(2))->method('getUses')->will($this->returnValue($uses)); $staticCalls = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\StaticCalls' + \Magento\TestFramework\Integrity\Library\PhpParser\StaticCalls::class )->disableOriginalConstructor()->getMock(); $staticCalls->expects( @@ -81,7 +81,7 @@ public function testGetDependencies() $this->parseFactory->expects($this->once())->method('getStaticCalls')->will($this->returnValue($staticCalls)); $throws = $this->getMockBuilder( - 'Magento\TestFramework\Integrity\Library\PhpParser\Throws' + \Magento\TestFramework\Integrity\Library\PhpParser\Throws::class )->disableOriginalConstructor()->getMock(); $throws->expects($this->once())->method('getDependencies')->will($this->returnValue(['ThrowDependency'])); diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php index 8447b3bbedb11..a44904233ae02 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php @@ -15,7 +15,7 @@ public function testCanRun() ); $this->assertEquals( - class_exists('PHPMD\TextUI\Command'), + class_exists(\PHPMD\TextUI\Command::class), $messDetector->canRun() ); } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeSnifferTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeSnifferTest.php index e03c5fb0fa745..8495b15a11044 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeSnifferTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeSnifferTest.php @@ -29,7 +29,7 @@ class CodeSnifferTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_wrapper = $this->getMock('Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper'); + $this->_wrapper = $this->getMock(\Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper::class); $this->_tool = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer( self::RULE_SET, self::REPORT_FILE, diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Inspection/JsHint/CommandTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Inspection/JsHint/CommandTest.php index 9c4e5b0c0bcef..0bafef54a634c 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Inspection/JsHint/CommandTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Inspection/JsHint/CommandTest.php @@ -15,7 +15,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_cmd = $this->getMock( - 'Magento\TestFramework\Inspection\JsHint\Command', + \Magento\TestFramework\Inspection\JsHint\Command::class, [ '_getHostScript', '_fileExists', diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php index 3157c3145f89f..bd34804c02637 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php @@ -24,10 +24,16 @@ public function testCircularDependencies() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $componentRegistrar = new ComponentRegistrar(); $declaredLanguages = $componentRegistrar->getPaths(ComponentRegistrar::LANGUAGE); - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); - $domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $domFactoryMock = $this->getMock(\Magento\Framework\Config\DomFactory::class, [], [], '', false); $domFactoryMock->expects($this->any()) ->method('createDom') ->willReturnCallback( @@ -45,7 +51,7 @@ function ($arguments) use ($validationStateMock) { $packs = []; foreach ($declaredLanguages as $language) { $languageConfig = $objectManager->getObject( - 'Magento\Framework\App\Language\Config', + \Magento\Framework\App\Language\Config::class, [ 'source' => file_get_contents($language . '/language.xml'), 'domFactory' => $domFactoryMock diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php index efffb09e3f23f..30fe41c36915b 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php @@ -169,6 +169,7 @@ protected function _assertClassesExist($classes, $path) $badClasses = []; $badUsages = []; foreach ($classes as $class) { + $class = trim($class, '\\'); try { if (strrchr($class, '\\') === false and !Classes::isVirtual($class)) { $badUsages[] = $class; @@ -188,7 +189,7 @@ protected function _assertClassesExist($classes, $path) } self::$_existingClasses[$class] = 1; } catch (\PHPUnit_Framework_AssertionFailedError $e) { - $badClasses[] = $class; + $badClasses[] = '\\' . $class; } } if ($badClasses) { diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php index 6b2f339f43d10..25fd59b796f84 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php @@ -97,7 +97,7 @@ public function validateComposerJsonDataProvider() private function validateComposerJsonFile($path) { /** @var \Magento\Framework\Composer\MagentoComposerApplicationFactory $appFactory */ - $appFactory = self::$objectManager->get('Magento\Framework\Composer\MagentoComposerApplicationFactory'); + $appFactory = self::$objectManager->get(\Magento\Framework\Composer\MagentoComposerApplicationFactory::class); $app = $appFactory->create(); $app->runComposerCommand(['command' => 'validate'], $path); } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php index 0afb7c54b2830..2393095691e50 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -299,15 +299,15 @@ public function testConstructorIntegrity() $generator = new \Magento\Framework\Code\Generator( $generatorIo, [ - Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', - Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', - Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', - Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', - SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults', + Factory::ENTITY_TYPE => \Magento\Framework\ObjectManager\Code\Generator\Factory::class, + Repository::ENTITY_TYPE => \Magento\Framework\ObjectManager\Code\Generator\Repository::class, + Converter::ENTITY_TYPE => \Magento\Framework\ObjectManager\Code\Generator\Converter::class, + Mapper::ENTITY_TYPE => \Magento\Framework\Api\Code\Generator\Mapper::class, + SearchResults::ENTITY_TYPE => \Magento\Framework\Api\Code\Generator\SearchResults::class, ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator::class, ExtensionAttributesGenerator::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator' + \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator::class ] ); $generationAutoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ExceptionHierarchyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ExceptionHierarchyTest.php index 6c7db8137170d..7f31ea875d9af 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ExceptionHierarchyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ExceptionHierarchyTest.php @@ -19,7 +19,7 @@ class ExceptionHierarchyTest extends \PHPUnit_Framework_TestCase public function testIsInheritedLocalizedException(\ReflectionClass $reflectionException) { $this->assertTrue( - $reflectionException->isSubclassOf('Magento\Framework\Exception\LocalizedException'), + $reflectionException->isSubclassOf(\Magento\Framework\Exception\LocalizedException::class), "{$reflectionException->name} is not inherited LocalizedException" ); } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php index 78c122807aba0..0519028c9ed78 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php @@ -15,7 +15,7 @@ */ class ExtensibleInterfacesTest extends \PHPUnit_Framework_TestCase { - const EXTENSIBLE_DATA_INTERFACE = 'Magento\\Framework\\Api\\ExtensibleDataInterface'; + const EXTENSIBLE_DATA_INTERFACE = \Magento\Framework\Api\ExtensibleDataInterface::class; /** * Check return types of getExtensionAttributes() methods. diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php index 8a2dcca5d118f..037069e8fd2ca 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php @@ -15,7 +15,7 @@ class ObserverImplementationTest extends \PHPUnit_Framework_TestCase /** * Observer interface */ - const OBSERVER_INTERFACE = 'Magento\Framework\Event\ObserverInterface'; + const OBSERVER_INTERFACE = \Magento\Framework\Event\ObserverInterface::class; /** * @var array diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php index 3746f45de03b9..2824035bfa57f 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php @@ -33,7 +33,7 @@ protected function setUp() $this->_phraseCollector = new \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector( new \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer(), true, - 'Magento\Framework\Phrase' + \Magento\Framework\Phrase::class ); $componentRegistrar = new ComponentRegistrar(); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/TestPlacementTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/TestPlacementTest.php index dbaf646ed5aef..7fce5b398c3a6 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/TestPlacementTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/TestPlacementTest.php @@ -31,7 +31,7 @@ public function testUnitTestFilesPlacement() { $objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager(); /** @var \Magento\Framework\Data\Collection\Filesystem $filesystem */ - $filesystem = $objectManager->get('Magento\Framework\Data\Collection\Filesystem'); + $filesystem = $objectManager->get(\Magento\Framework\Data\Collection\Filesystem::class); $filesystem->setCollectDirs(false) ->setCollectFiles(true) ->setCollectRecursively(true); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index cafac52cd5afe..3179ca0a7a217 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -75,4 +75,38 @@ Model3 \Magento\Mtf\TestSuite\AppState \Magento\Framework\A \Magento\Framework\B +\Magento\Test\Di\Child +\Magento\Test\Di\DiInterface +\Magento\Test\Di\DiParent +\Magento\Test\Di\Aggregate\AggregateParent +\Magento\Test\Di\Child\A +\Magento\Test\Di\Aggregate\WithOptional +\Magento\Test\Di\Aggregate\Child +\Magento\Framework\App\Cache\TagPlugin +\Magento\Store\Model\Action\Plugin DoubleColon +\Magento\Framework\App\Config\Data\TestBackendModel +\Magento\Framework\App\Config\Data\WrongBackendModel +\Magento\ModuleName\Model\ClassName +\Magento\Mtf\Config\DataInterface +\Magento\Sales\Test\TestStep +\Magento\Mtf\Config\TestRunner +\Magento\Composer\InfoCommand +\Magento\Composer\MagentoComposerApplication +\Magento\Composer\RequireUpdateDryRunCommand +\Magento\SomeModule\Model\One\Test +\Magento\SomeModule\Model\Two\Test +\Magento\SomeModule\Model\Three\Test +\Magento\SomeModule\Model\Four\Test +\Magento\SomeModule\Model\Five\Test +\Magento\SomeModule\Model\Six\Test +\Magento\Framework\DataObject_MyResult +\Magento\Framework\ObjectManager\Code\Generator\Sample\Repository +\Magento\Framework\ObjectManager\Code\Generator\SampleConverter +\Magento\Observer +\Magento\Framework\MessageQueue\Model\TestConsumer +\Magento\Catalog\Api\Data\Product +\Magento\Framework\ObjectManager\Code\Generator\Sample +\Magento\Framework\ObjectManager\Code\Generator\Sample +\Magento\Config\Block\Tooltip +\Magento\Framework\Model\Name From b959f667a8a9db2b9bbc8606a31be599bc3b852d Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:20:03 +0300 Subject: [PATCH 06/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../integration/etc/di/preferences/ce.php | 30 ++++---- .../Annotation/AdminConfigFixture.php | 4 +- .../TestFramework/Annotation/Cache.php | 4 +- .../Annotation/ComponentRegistrarFixture.php | 2 +- .../Annotation/ConfigFixture.php | 6 +- .../Magento/TestFramework/Application.php | 68 +++++++++-------- .../TestFramework/ErrorLog/Listener.php | 2 +- .../TestFramework/Event/Transaction.php | 2 +- .../Magento/TestFramework/Helper/Api.php | 16 ++-- .../TestFramework/Helper/Bootstrap.php | 4 +- .../Magento/TestFramework/Helper/Config.php | 2 +- .../Magento/TestFramework/Helper/Eav.php | 6 +- .../Isolation/DeploymentConfig.php | 2 +- .../Magento/TestFramework/ObjectManager.php | 25 ++++--- .../ObjectManager/Configurator.php | 4 +- .../TestFramework/ObjectManagerFactory.php | 24 +++--- .../TestCase/AbstractBackendController.php | 13 ++-- .../TestCase/AbstractConfigFiles.php | 16 ++-- .../TestCase/AbstractController.php | 10 +-- .../TestCase/AbstractIntegrity.php | 4 +- .../Workaround/Cleanup/StaticProperties.php | 15 ++-- dev/tests/integration/framework/bootstrap.php | 4 +- .../Annotation/AdminConfigFixtureTest.php | 2 +- .../Magento/Test/Annotation/AppAreaTest.php | 4 +- .../Test/Annotation/AppIsolationTest.php | 4 +- .../Test/Annotation/ConfigFixtureTest.php | 2 +- .../Test/Annotation/DataFixtureTest.php | 2 +- .../Magento/Test/ApplicationTest.php | 4 +- .../Magento/Test/Bootstrap/DocBlockTest.php | 6 +- .../Magento/Test/Bootstrap/MemoryTest.php | 4 +- .../Magento/Test/Bootstrap/ProfilerTest.php | 6 +- .../Magento/Test/Bootstrap/SettingsTest.php | 2 +- .../testsuite/Magento/Test/BootstrapTest.php | 22 +++--- .../Db/Adapter/TransactionInterfaceTest.php | 2 +- .../testsuite/Magento/Test/EntityTest.php | 9 ++- .../Magento/Test/Event/MagentoTest.php | 4 +- .../Magento/Test/Event/PhpUnitTest.php | 6 +- .../Magento/Test/Event/TransactionTest.php | 6 +- .../Magento/Test/EventManagerTest.php | 4 +- .../Magento/Test/Helper/BootstrapTest.php | 4 +- .../Magento/Test/Helper/FactoryTest.php | 12 +-- .../Magento/Test/Helper/MemoryTest.php | 2 +- .../Magento/Test/MemoryLimitTest.php | 2 +- .../Magento/Test/ObjectManagerTest.php | 73 ++++++++++-------- .../Test/Profiler/OutputBambooTest.php | 2 +- .../testsuite/Magento/Test/RequestTest.php | 10 +-- .../Test/TestCase/ControllerAbstractTest.php | 24 +++--- .../Cleanup/TestCasePropertiesTest.php | 2 +- .../Inbox/Collection/CriticalTest.php | 2 +- .../_files/notifications.php | 14 ++-- .../ResourceModel/Role/CollectionTest.php | 4 +- .../Role/Grid/CollectionTest.php | 2 +- .../Model/ResourceModel/RoleTest.php | 6 +- .../ResourceModel/Rules/CollectionTest.php | 4 +- .../Magento/Authorization/Model/RoleTest.php | 2 +- .../Magento/Authorization/Model/RulesTest.php | 2 +- .../Directpost/Payment/PlaceTest.php | 40 +++++----- .../Backend/App/AbstractActionTest.php | 12 +-- .../Magento/Backend/App/RouterTest.php | 25 ++++--- .../Backend/Block/Dashboard/GraphTest.php | 6 +- .../Magento/Backend/Block/MenuTest.php | 22 +++--- .../Magento/Backend/Block/Page/FooterTest.php | 6 +- .../Magento/Backend/Block/Page/HeaderTest.php | 6 +- .../Block/System/Account/Edit/FormTest.php | 12 +-- .../System/Design/Edit/Tab/GeneralTest.php | 12 +-- .../Backend/Block/System/Store/DeleteTest.php | 4 +- .../System/Store/Edit/Form/GroupTest.php | 14 ++-- .../System/Store/Edit/Form/StoreTest.php | 14 ++-- .../System/Store/Edit/Form/WebsiteTest.php | 14 ++-- .../Backend/Block/System/Store/EditTest.php | 40 +++++----- .../Magento/Backend/Block/TemplateTest.php | 4 +- .../Backend/Block/Widget/ContainerTest.php | 8 +- .../Block/Widget/Form/ContainerTest.php | 8 +- .../Magento/Backend/Block/Widget/FormTest.php | 14 ++-- .../Block/Widget/Grid/ColumnSetTest.php | 10 +-- .../Block/Widget/Grid/ContainerTest.php | 6 +- .../Block/Widget/Grid/ExtendedTest.php | 8 +- .../Backend/Block/Widget/Grid/ItemTest.php | 6 +- .../Widget/Grid/Massaction/AdditionalTest.php | 6 +- .../Block/Widget/Grid/MassactionTest.php | 12 +-- .../Magento/Backend/Block/Widget/GridTest.php | 39 +++++----- .../Magento/Backend/Block/Widget/TabsTest.php | 10 +-- .../Magento/Backend/Block/WidgetTest.php | 11 +-- .../Block/_files/form_key_disabled.php | 2 +- .../_files/form_key_disabled_rollback.php | 2 +- .../Backend/Controller/Adminhtml/AuthTest.php | 28 +++---- .../Adminhtml/Cache/CleanStaticFilesTest.php | 4 +- .../Adminhtml/Cache/MassActionTest.php | 8 +- .../Controller/Adminhtml/CacheTest.php | 12 ++- .../Controller/Adminhtml/DashboardTest.php | 2 +- .../Controller/Adminhtml/IndexTest.php | 2 +- .../Adminhtml/System/AccountTest.php | 6 +- .../Controller/Adminhtml/System/StoreTest.php | 4 +- .../Controller/Adminhtml/UrlRewriteTest.php | 2 +- .../Magento/Backend/Helper/DataTest.php | 22 +++--- .../Magento/Backend/Model/AuthTest.php | 20 +++-- .../Backend/Model/Locale/ResolverTest.php | 10 +-- .../Magento/Backend/Model/MenuTest.php | 11 +-- .../Backend/Model/Search/CustomerTest.php | 2 +- .../Backend/Model/Search/OrderTest.php | 4 +- .../Backend/Model/Session/AdminConfigTest.php | 4 +- .../Backend/Model/Session/QuoteTest.php | 4 +- .../Magento/Backend/Model/SessionTest.php | 4 +- .../Backend/Model/Translate/InlineTest.php | 4 +- .../Magento/Backend/Model/UrlTest.php | 14 ++-- .../_files/cache/all_types_invalidated.php | 2 +- .../_files/cache/application_cache.php | 2 +- .../_files/cache/empty_storage.php | 2 +- .../_files/cache/non_application_cache.php | 2 +- .../Tab/Bundle/Option/Search/GridTest.php | 4 +- .../Edit/Tab/Bundle/Option/SearchTest.php | 6 +- .../Magento/Bundle/Controller/ProductTest.php | 2 +- .../Bundle/Model/Product/OptionListTest.php | 4 +- .../Bundle/Model/Product/PriceTest.php | 4 +- .../Magento/Bundle/Model/Product/TypeTest.php | 6 +- .../Magento/Bundle/Model/ProductTest.php | 10 +-- .../order_item_with_bundle_and_options.php | 12 +-- .../Magento/Bundle/_files/product.php | 8 +- .../Bundle/_files/product_rollback.php | 4 +- .../_files/product_with_multiple_options.php | 10 +-- ...product_with_multiple_options_rollback.php | 4 +- .../_files/product_with_tier_pricing.php | 2 +- .../Model/Export/RowCustomizerTest.php | 4 +- .../Adminhtml/Captcha/DefaultCaptchaTest.php | 4 +- .../Captcha/Block/Captcha/DefaultTest.php | 4 +- ...tionWithInvalidCaptchaReturnsErrorTest.php | 6 +- ...IsRequiredAfterFailedLoginAttemptsTest.php | 6 +- ...successfulMessageWhenCaptchaFailedTest.php | 2 +- .../Magento/Captcha/_files/dummy_user.php | 2 +- .../Category/Checkboxes/TreeTest.php | 2 +- .../Block/Adminhtml/Category/TreeTest.php | 6 +- .../Product/Attribute/Edit/Tab/FrontTest.php | 8 +- .../Product/Attribute/Set/Toolbar/AddTest.php | 6 +- .../Block/Adminhtml/Product/Edit/JsTest.php | 4 +- .../Product/Edit/Tab/Options/OptionTest.php | 8 +- .../Edit/Tab/Options/Type/SelectTest.php | 4 +- .../Product/Helper/Form/CategoryTest.php | 8 +- .../Helper/Form/Gallery/ContentTest.php | 9 ++- .../Product/Helper/Form/WeightTest.php | 16 ++-- .../Adminhtml/Product/Options/AjaxTest.php | 8 +- .../Catalog/Block/Product/AbstractTest.php | 18 +++-- .../Catalog/Block/Product/ListTest.php | 22 +++--- .../Magento/Catalog/Block/Product/NewTest.php | 20 ++--- .../Product/ProductList/CrosssellTest.php | 12 +-- .../Block/Product/ProductList/RelatedTest.php | 12 +-- .../Block/Product/ProductList/ToolbarTest.php | 10 ++- .../Block/Product/View/AdditionalTest.php | 8 +- .../Block/Product/View/OptionsTest.php | 14 ++-- .../Catalog/Block/Product/ViewTest.php | 16 ++-- .../Command/ProductAttributesCleanUpTest.php | 14 ++-- .../Controller/Adminhtml/CategoryTest.php | 8 +- .../Product/Action/AttributeTest.php | 8 +- .../Adminhtml/Product/AttributeTest.php | 24 +++--- .../Adminhtml/Product/ReviewTest.php | 4 +- .../Adminhtml/Product/Set/DeleteTest.php | 2 +- .../Controller/Adminhtml/ProductTest.php | 6 +- .../Catalog/Controller/CategoryTest.php | 10 +-- .../Controller/Product/CompareTest.php | 61 ++++++++------- .../Catalog/Controller/ProductTest.php | 16 ++-- .../Magento/Catalog/Helper/CategoryTest.php | 12 +-- .../Magento/Catalog/Helper/DataTest.php | 46 ++++++------ .../Magento/Catalog/Helper/OutputTest.php | 4 +- .../Catalog/Helper/Product/CompareTest.php | 18 ++--- .../Catalog/Helper/Product/CompositeTest.php | 8 +- .../Catalog/Helper/Product/FlatTest.php | 8 +- .../Catalog/Helper/Product/ViewTest.php | 37 +++++---- .../Magento/Catalog/Helper/ProductTest.php | 44 +++++------ .../Magento/Catalog/Model/AbstractTest.php | 20 +++-- .../Model/Category/CategoryImageTest.php | 12 +-- .../StubZendLogWriterStream.php | 4 +- .../_files/category_without_image.php | 4 +- .../service_category_create_rollback.php | 4 +- .../Magento/Catalog/Model/CategoryTest.php | 20 ++--- .../Catalog/Model/CategoryTreeTest.php | 2 +- .../Magento/Catalog/Model/DesignTest.php | 6 +- .../Model/Indexer/Category/ProductTest.php | 10 +-- .../Catalog/Model/Indexer/FlatTest.php | 40 +++++----- .../Indexer/Product/Eav/Action/FullTest.php | 8 +- .../Indexer/Product/Eav/Action/RowTest.php | 8 +- .../Indexer/Product/Eav/Action/RowsTest.php | 8 +- .../Indexer/Product/Flat/Action/FullTest.php | 8 +- .../Indexer/Product/Flat/Action/RowTest.php | 10 +-- .../Indexer/Product/Flat/Action/RowsTest.php | 8 +- .../Indexer/Product/Flat/ProcessorTest.php | 12 +-- .../Indexer/Product/Price/Action/FullTest.php | 6 +- .../Indexer/Product/Price/Action/RowTest.php | 8 +- .../Indexer/Product/Price/Action/RowsTest.php | 14 ++-- .../Catalog/Model/Layer/CategoryTest.php | 43 ++++++----- .../Model/Layer/Filter/AttributeTest.php | 16 ++-- .../Model/Layer/Filter/CategoryTest.php | 56 +++++++------- .../Layer/Filter/DataProvider/PriceTest.php | 6 +- .../Model/Layer/Filter/DecimalTest.php | 14 ++-- .../Filter/Price/AlgorithmAdvancedTest.php | 20 ++--- .../Layer/Filter/Price/AlgorithmBaseTest.php | 23 +++--- .../Filter/Price/_files/products_advanced.php | 12 ++- .../_files/products_advanced_rollback.php | 8 +- .../Filter/Price/_files/products_base.php | 12 ++- .../Price/_files/products_base_rollback.php | 12 ++- .../Catalog/Model/Layer/Filter/PriceTest.php | 26 +++---- .../_files/attribute_weight_filterable.php | 4 +- .../Filter/_files/attribute_with_option.php | 14 ++-- .../_files/attribute_with_option_rollback.php | 14 ++-- .../Product/Attribute/Backend/PriceTest.php | 8 +- .../Product/Attribute/Backend/SkuTest.php | 6 +- .../Attribute/Backend/TierpriceTest.php | 22 +++--- .../create_attribute_service_rollback.php | 6 +- .../Attribute/_files/select_attribute.php | 8 +- .../_files/select_attribute_rollback.php | 2 +- .../Model/Product/Compare/ListCompareTest.php | 10 +-- .../Product/Gallery/CreateHandlerTest.php | 8 +- .../Model/Product/Gallery/ProcessorTest.php | 24 +++--- .../Model/Product/Gallery/ReadHandlerTest.php | 6 +- .../Catalog/Model/Product/ImageTest.php | 10 +-- .../Option/Type/File/ValidatorFileTest.php | 47 ++++++------ .../Option/Type/File/ValidatorInfoTest.php | 23 +++--- .../Model/Product/Type/AbstractTypeTest.php | 75 +++++++++++-------- .../Catalog/Model/Product/Type/PriceTest.php | 6 +- .../Model/Product/Type/VirtualTest.php | 4 +- .../Catalog/Model/Product/TypeTest.php | 22 +++--- .../Magento/Catalog/Model/Product/UrlTest.php | 16 ++-- .../service_product_create_rollback.php | 6 +- .../Catalog/Model/ProductExternalTest.php | 53 ++++++------- .../Catalog/Model/ProductGettersTest.php | 37 ++++----- .../Catalog/Model/ProductPriceTest.php | 4 +- .../Magento/Catalog/Model/ProductTest.php | 29 +++---- .../Model/ResourceModel/Eav/AttributeTest.php | 4 +- .../Product/Indexer/Eav/SourceTest.php | 10 +-- .../Product/Link/Product/CollectionTest.php | 10 +-- .../ResourceModel/_files/product_simple.php | 2 +- .../ResourceModel/_files/url_rewrites.php | 6 +- .../Option/Type/File/ProcessorTest.php | 10 +-- .../testsuite/Magento/Catalog/WidgetTest.php | 4 +- .../attribute_set_with_image_attribute.php | 8 +- ...bute_set_with_image_attribute_rollback.php | 8 +- .../Magento/Catalog/_files/categories.php | 36 ++++----- .../Catalog/_files/categories_no_products.php | 20 ++--- .../categories_no_products_rollback.php | 4 +- .../Catalog/_files/categories_rollback.php | 6 +- .../Magento/Catalog/_files/category.php | 2 +- .../Catalog/_files/category_attribute.php | 2 +- .../_files/category_attribute_rollback.php | 4 +- .../_files/category_backend_rollback.php | 4 +- .../Catalog/_files/category_duplicates.php | 6 +- .../Catalog/_files/category_product.php | 4 +- .../_files/category_product_rollback.php | 6 +- .../Catalog/_files/category_rollback.php | 4 +- .../Magento/Catalog/_files/category_tree.php | 4 +- .../Catalog/_files/category_tree_rollback.php | 4 +- .../Catalog/_files/category_with_position.php | 2 +- .../category_with_position_rollback.php | 4 +- .../Catalog/_files/empty_attribute_group.php | 4 +- .../_files/empty_attribute_group_rollback.php | 4 +- .../_files/enable_reindex_schedule.php | 5 +- .../enable_reindex_schedule_rollback.php | 5 +- .../Catalog/_files/filterable_attributes.php | 10 ++- .../_files/indexer_catalog_category.php | 16 ++-- .../indexer_catalog_category_rollback.php | 6 +- .../Catalog/_files/multiple_products.php | 6 +- .../_files/multiple_products_rollback.php | 4 +- .../Catalog/_files/multiselect_attribute.php | 8 +- ...r_item_with_product_and_custom_options.php | 14 ++-- .../Catalog/_files/price_row_fixture.php | 10 ++- .../_files/price_row_fixture_rollback.php | 6 +- .../Catalog/_files/product_associated.php | 2 +- .../_files/product_associated_rollback.php | 4 +- .../Catalog/_files/product_attribute.php | 2 +- .../_files/product_attribute_rollback.php | 4 +- ...roduct_attribute_with_invalid_apply_to.php | 8 +- .../_files/product_group_prices_rollback.php | 4 +- .../Magento/Catalog/_files/product_image.php | 4 +- .../Catalog/_files/product_image_rollback.php | 4 +- .../Magento/Catalog/_files/product_simple.php | 8 +- .../_files/product_simple_duplicated.php | 2 +- .../product_simple_duplicated_rollback.php | 4 +- .../_files/product_simple_multistore.php | 6 +- .../product_simple_multistore_rollback.php | 4 +- .../_files/product_simple_rollback.php | 4 +- .../product_simple_with_admin_store.php | 10 +-- .../_files/product_simple_with_url_key.php | 4 +- .../Catalog/_files/product_simple_xss.php | 8 +- .../Catalog/_files/product_special_price.php | 2 +- .../_files/product_special_price_rollback.php | 4 +- .../Catalog/_files/product_virtual.php | 2 +- .../_files/product_virtual_in_stock.php | 2 +- .../product_virtual_in_stock_rollback.php | 4 +- .../_files/product_virtual_rollback.php | 4 +- .../_files/product_with_dropdown_option.php | 16 ++-- .../product_with_dropdown_option_rollback.php | 4 +- .../Catalog/_files/product_with_image.php | 2 +- .../Catalog/_files/product_with_options.php | 4 +- .../_files/product_with_options_rollback.php | 4 +- .../_files/product_without_options.php | 2 +- .../product_without_options_rollback.php | 4 +- .../Magento/Catalog/_files/products.php | 4 +- .../Catalog/_files/products_crosssell.php | 6 +- .../_files/products_crosssell_rollback.php | 4 +- .../Catalog/_files/products_in_category.php | 6 +- .../_files/products_in_category_rollback.php | 8 +- .../Magento/Catalog/_files/products_new.php | 2 +- .../Catalog/_files/products_new_rollback.php | 4 +- .../Catalog/_files/products_related.php | 6 +- .../_files/products_related_multiple.php | 10 +-- .../products_related_multiple_rollback.php | 10 ++- .../_files/products_related_rollback.php | 4 +- .../Catalog/_files/products_rollback.php | 4 +- .../Catalog/_files/products_upsell.php | 6 +- .../_files/products_upsell_rollback.php | 8 +- .../products_with_multiselect_attribute.php | 10 ++- .../products_with_unique_input_attribute.php | 2 +- .../quote_with_product_and_custom_options.php | 14 ++-- .../Magento/Catalog/_files/row_fixture.php | 10 ++- .../Catalog/_files/row_fixture_rollback.php | 8 +- .../Catalog/_files/second_product_simple.php | 2 +- .../_files/second_product_simple_rollback.php | 4 +- .../Catalog/_files/unique_input_attribute.php | 8 +- .../Magento/Catalog/_files/url_rewrites.php | 10 ++- .../Catalog/_files/url_rewrites_invalid.php | 8 +- .../Catalog/_files/url_rewrites_rollback.php | 6 +- .../Magento/Catalog/_files/validate_image.php | 2 +- .../Catalog/_files/validate_image_info.php | 4 +- .../_files/validate_image_info_rollback.php | 4 +- .../_files/validate_image_rollback.php | 2 +- .../controllers/_files/attribute_system.php | 2 +- .../_files/attribute_system_popup.php | 2 +- .../attribute_system_with_applyto_data.php | 2 +- .../_files/attribute_user_defined.php | 2 +- .../Catalog/controllers/_files/products.php | 14 ++-- .../controllers/_files/products_rollback.php | 4 +- .../Model/Export/ProductTest.php | 2 +- .../Import/Product/Type/AbstractTest.php | 10 +-- .../Model/Import/ProductTest.php | 22 +++--- .../Import/_files/media_import_image.php | 2 +- .../_files/product_export_data.php | 4 +- ...product_export_with_product_links_data.php | 4 +- .../Form/Field/CustomergroupTest.php | 2 +- .../Model/Indexer/Stock/Action/FullTest.php | 6 +- .../Model/Indexer/Stock/Action/RowTest.php | 16 ++-- .../Model/Indexer/Stock/Action/RowsTest.php | 18 ++--- .../CatalogInventory/Model/Stock/ItemTest.php | 12 +-- .../Model/Indexer/BatchIndexTest.php | 8 +- .../Model/Indexer/IndexerBuilderTest.php | 8 +- .../Model/Indexer/ProductRuleTest.php | 6 +- .../Model/Indexer/RuleProductTest.php | 8 +- .../Magento/CatalogRule/Model/RuleTest.php | 6 +- .../Magento/CatalogRule/_files/attribute.php | 8 +- .../_files/catalog_rule_10_off_not_logged.php | 6 +- .../CatalogRule/_files/rule_by_attribute.php | 6 +- .../Magento/CatalogRule/_files/two_rules.php | 8 +- .../Block/Advanced/ResultTest.php | 28 +++++-- .../CatalogSearch/Block/ResultTest.php | 8 +- .../Magento/CatalogSearch/Block/TermTest.php | 4 +- .../CatalogSearch/Controller/ResultTest.php | 2 +- .../Magento/CatalogSearch/Helper/DataTest.php | 6 +- .../Model/Indexer/FulltextTest.php | 14 ++-- .../Model/Layer/Filter/AttributeTest.php | 12 +-- .../Model/Layer/Filter/CategoryTest.php | 33 ++++---- .../Model/Layer/Filter/DecimalTest.php | 14 ++-- .../Model/Layer/Filter/PriceTest.php | 12 +-- .../ResourceModel/Advanced/CollectionTest.php | 2 +- .../ResourceModel/Fulltext/CollectionTest.php | 2 +- .../Model/Search/RequestGeneratorTest.php | 2 +- .../CatalogSearch/_files/full_reindex.php | 2 +- .../CatalogSearch/_files/indexer_fulltext.php | 10 +-- .../_files/indexer_fulltext_rollback.php | 4 +- .../Magento/CatalogSearch/_files/query.php | 2 +- .../_files/search_attributes.php | 8 +- .../_files/search_attributes_rollback.php | 4 +- .../Model/CategoryUrlRewriteGeneratorTest.php | 8 +- .../CatalogUrlRewrite/_files/categories.php | 8 +- .../_files/categories_rollback.php | 4 +- .../_files/categories_with_product_ids.php | 14 ++-- .../_files/categories_with_products.php | 14 ++-- .../categories_with_products_rollback.php | 4 +- .../Block/Product/Widget/ConditionsTest.php | 10 +-- .../Model/Rule/Condition/ProductTest.php | 12 +-- .../agreement_active_with_html_content.php | 2 +- ...ment_active_with_html_content_rollback.php | 2 +- .../agreement_inactive_with_text_content.php | 2 +- ...nt_inactive_with_text_content_rollback.php | 2 +- 379 files changed, 1930 insertions(+), 1729 deletions(-) diff --git a/dev/tests/integration/etc/di/preferences/ce.php b/dev/tests/integration/etc/di/preferences/ce.php index 62b08ed23dba6..cec08b1d91da7 100644 --- a/dev/tests/integration/etc/di/preferences/ce.php +++ b/dev/tests/integration/etc/di/preferences/ce.php @@ -5,19 +5,19 @@ */ return [ - 'Magento\Framework\Stdlib\CookieManagerInterface' => 'Magento\TestFramework\CookieManager', - 'Magento\Framework\ObjectManager\DynamicConfigInterface' => - '\Magento\TestFramework\ObjectManager\Configurator', - 'Magento\Framework\App\RequestInterface' => 'Magento\TestFramework\Request', - 'Magento\Framework\App\Request\Http' => 'Magento\TestFramework\Request', - 'Magento\Framework\App\ResponseInterface' => 'Magento\TestFramework\Response', - 'Magento\Framework\App\Response\Http' => 'Magento\TestFramework\Response', - 'Magento\Framework\Interception\PluginListInterface' => - 'Magento\TestFramework\Interception\PluginList', - 'Magento\Framework\Interception\ObjectManager\Config\Developer' => - 'Magento\TestFramework\ObjectManager\Config', - 'Magento\Framework\View\LayoutInterface' => 'Magento\TestFramework\View\Layout', - 'Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface' => - 'Magento\TestFramework\Db\ConnectionAdapter', - 'Magento\Framework\Filesystem\DriverInterface' => 'Magento\Framework\Filesystem\Driver\File' + \Magento\Framework\Stdlib\CookieManagerInterface::class => \Magento\TestFramework\CookieManager::class, + \Magento\Framework\ObjectManager\DynamicConfigInterface::class => + \Magento\TestFramework\ObjectManager\Configurator::class, + \Magento\Framework\App\RequestInterface::class => \Magento\TestFramework\Request::class, + \Magento\Framework\App\Request\Http::class => \Magento\TestFramework\Request::class, + \Magento\Framework\App\ResponseInterface::class => \Magento\TestFramework\Response::class, + \Magento\Framework\App\Response\Http::class => \Magento\TestFramework\Response::class, + \Magento\Framework\Interception\PluginListInterface::class => + \Magento\TestFramework\Interception\PluginList::class, + \Magento\Framework\Interception\ObjectManager\Config\Developer::class => + \Magento\TestFramework\ObjectManager\Config::class, + \Magento\Framework\View\LayoutInterface::class => \Magento\TestFramework\View\Layout::class, + \Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface::class => + \Magento\TestFramework\Db\ConnectionAdapter::class, + \Magento\Framework\Filesystem\DriverInterface::class => \Magento\Framework\Filesystem\Driver\File::class ]; diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/AdminConfigFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/AdminConfigFixture.php index 852e4f798b9c6..780beaef7cc44 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/AdminConfigFixture.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/AdminConfigFixture.php @@ -34,7 +34,7 @@ class AdminConfigFixture protected function _getConfigValue($configPath) { return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\App\ConfigInterface' + \Magento\Backend\App\ConfigInterface::class )->getValue( $configPath ); @@ -49,7 +49,7 @@ protected function _getConfigValue($configPath) protected function _setConfigValue($configPath, $value) { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\App\ConfigInterface' + \Magento\Backend\App\ConfigInterface::class )->setValue( $configPath, $value diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/Cache.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/Cache.php index 3643e283370c4..760ebb1a8a97c 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/Cache.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/Cache.php @@ -98,7 +98,7 @@ private function setValues($values, \PHPUnit_Framework_TestCase $test) } } /** @var \Magento\Framework\App\Cache\StateInterface $states */ - $states = Bootstrap::getInstance()->getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); + $states = Bootstrap::getInstance()->getObjectManager()->get(\Magento\Framework\App\Cache\StateInterface::class); foreach ($values as $type => $isEnabled) { if (!isset($this->origValues[$type])) { self::fail("Unknown cache type specified: '{$type}' in @magentoCache", $test); @@ -114,7 +114,7 @@ private function setValues($values, \PHPUnit_Framework_TestCase $test) */ private static function getTypeList() { - return Bootstrap::getInstance()->getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); + return Bootstrap::getInstance()->getObjectManager()->get(\Magento\Framework\App\Cache\TypeListInterface::class); } /** diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ComponentRegistrarFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ComponentRegistrarFixture.php index 2e07d459af3a9..41d665eaed818 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ComponentRegistrarFixture.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ComponentRegistrarFixture.php @@ -23,7 +23,7 @@ class ComponentRegistrarFixture /**#@+ * Properties of components registrar */ - const REGISTRAR_CLASS = 'Magento\Framework\Component\ComponentRegistrar'; + const REGISTRAR_CLASS = \Magento\Framework\Component\ComponentRegistrar::class; const PATHS_FIELD = 'paths'; /**#@-*/ diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php index 3c87d2acbab97..25863089bd630 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php @@ -47,7 +47,7 @@ protected function _getConfigValue($configPath, $scopeCode = null) $result = null; if ($scopeCode !== false) { /** @var \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ - $scopeConfig = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'); + $scopeConfig = $objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class); $result = $scopeConfig->getValue( $configPath, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, @@ -71,7 +71,7 @@ protected function _setConfigValue($configPath, $value, $storeCode = false) if (strpos($configPath, 'default/') === 0) { $configPath = substr($configPath, 8); $objectManager->get( - 'Magento\Framework\App\Config\MutableScopeConfigInterface' + \Magento\Framework\App\Config\MutableScopeConfigInterface::class )->setValue( $configPath, $value, @@ -80,7 +80,7 @@ protected function _setConfigValue($configPath, $value, $storeCode = false) } } else { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\App\Config\MutableScopeConfigInterface' + \Magento\Framework\App\Config\MutableScopeConfigInterface::class )->setValue( $configPath, $value, diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index ef6b3e24da8e0..3ae2c994511c7 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -296,65 +296,65 @@ public function initialize($overriddenParams = []) ? $overriddenParams[\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : []; $directoryList = new DirectoryList(BP, $directories); - /** @var \Magento\TestFramework\ObjectManager $objectManager */ $objectManager = Helper\Bootstrap::getObjectManager(); if (!$objectManager) { $objectManager = $this->_factory->create($overriddenParams); - $objectManager->addSharedInstance($directoryList, 'Magento\Framework\App\Filesystem\DirectoryList'); - $objectManager->addSharedInstance($directoryList, 'Magento\Framework\Filesystem\DirectoryList'); + $objectManager->addSharedInstance($directoryList, \Magento\Framework\App\Filesystem\DirectoryList::class); + $objectManager->addSharedInstance($directoryList, \Magento\Framework\Filesystem\DirectoryList::class); } else { $objectManager = $this->_factory->restore($objectManager, $directoryList, $overriddenParams); } - /** @var \Magento\TestFramework\App\Filesystem $filesystem */ - $filesystem = $objectManager->get('Magento\TestFramework\App\Filesystem'); - $objectManager->removeSharedInstance('Magento\Framework\Filesystem'); - $objectManager->addSharedInstance($filesystem, 'Magento\Framework\Filesystem'); - + $filesystem = $objectManager->get(\Magento\TestFramework\App\Filesystem::class); + $objectManager->removeSharedInstance(\Magento\Framework\Filesystem::class); + $objectManager->addSharedInstance($filesystem, \Magento\Framework\Filesystem::class); /** @var \Psr\Log\LoggerInterface $logger */ $logger = $objectManager->create( - 'Magento\TestFramework\ErrorLog\Logger', + \Magento\TestFramework\ErrorLog\Logger::class, [ 'name' => 'integration-tests', 'handlers' => [ 'system' => $objectManager->create( - 'Magento\Framework\Logger\Handler\System', + \Magento\Framework\Logger\Handler\System::class, [ 'exceptionHandler' => $objectManager->create( - 'Magento\Framework\Logger\Handler\Exception', + \Magento\Framework\Logger\Handler\Exception::class, ['filePath' => $this->installDir] ), 'filePath' => $this->installDir ] ), 'debug' => $objectManager->create( - 'Magento\Framework\Logger\Handler\Debug', + \Magento\Framework\Logger\Handler\Debug::class, ['filePath' => $this->installDir] ), ] ] ); - $objectManager->removeSharedInstance('Magento\Framework\Logger\Monolog'); - $objectManager->addSharedInstance($logger, 'Magento\Framework\Logger\Monolog'); - $sequenceBuilder = $objectManager->get('\Magento\TestFramework\Db\Sequence\Builder'); - $objectManager->addSharedInstance($sequenceBuilder, 'Magento\SalesSequence\Model\Builder'); + $objectManager->removeSharedInstance(\Magento\Framework\Logger\Monolog::class); + $objectManager->addSharedInstance($logger, \Magento\Framework\Logger\Monolog::class); + $sequenceBuilder = $objectManager->get(\Magento\TestFramework\Db\Sequence\Builder::class); + $objectManager->addSharedInstance($sequenceBuilder, \Magento\SalesSequence\Model\Builder::class); Helper\Bootstrap::setObjectManager($objectManager); $objectManagerConfiguration = [ 'preferences' => [ - 'Magento\Framework\App\State' => 'Magento\TestFramework\App\State', - 'Magento\Framework\Mail\TransportInterface' => 'Magento\TestFramework\Mail\TransportInterfaceMock', - 'Magento\Framework\Mail\Template\TransportBuilder' - => 'Magento\TestFramework\Mail\Template\TransportBuilderMock', + \Magento\Framework\App\State::class => \Magento\TestFramework\App\State::class, + \Magento\Framework\Mail\TransportInterface::class => + \Magento\TestFramework\Mail\TransportInterfaceMock::class, + \Magento\Framework\Mail\Template\TransportBuilder::class + => \Magento\TestFramework\Mail\Template\TransportBuilderMock::class, ] ]; if ($this->loadTestExtensionAttributes) { $objectManagerConfiguration = array_merge( $objectManagerConfiguration, [ - 'Magento\Framework\Api\ExtensionAttribute\Config\Reader' => [ + \Magento\Framework\Api\ExtensionAttribute\Config\Reader::class => [ 'arguments' => [ - 'fileResolver' => ['instance' => 'Magento\TestFramework\Api\Config\Reader\FileResolver'], + 'fileResolver' => [ + 'instance' => \Magento\TestFramework\Api\Config\Reader\FileResolver::class + ], ], ], ] @@ -363,12 +363,12 @@ public function initialize($overriddenParams = []) $objectManager->configure($objectManagerConfiguration); /** Register event observer of Integration Framework */ /** @var \Magento\Framework\Event\Config\Data $eventConfigData */ - $eventConfigData = $objectManager->get('Magento\Framework\Event\Config\Data'); + $eventConfigData = $objectManager->get(\Magento\Framework\Event\Config\Data::class); $eventConfigData->merge( [ 'core_app_init_current_store_after' => [ 'integration_tests' => [ - 'instance' => 'Magento\TestFramework\Event\Magento', + 'instance' => \Magento\TestFramework\Event\Magento::class, 'name' => 'integration_tests' ] ] @@ -376,13 +376,15 @@ public function initialize($overriddenParams = []) ); $this->loadArea(\Magento\TestFramework\Application::DEFAULT_APP_AREA); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( - $objectManager->get('Magento\Framework\ObjectManager\DynamicConfigInterface')->getConfiguration() + $objectManager->get(\Magento\Framework\ObjectManager\DynamicConfigInterface::class)->getConfiguration() + ); + \Magento\Framework\Phrase::setRenderer( + $objectManager->get(\Magento\Framework\Phrase\Renderer\Placeholder::class) ); - \Magento\Framework\Phrase::setRenderer($objectManager->get('Magento\Framework\Phrase\Renderer\Placeholder')); /** @var \Magento\TestFramework\Db\Sequence $sequence */ - $sequence = $objectManager->get('Magento\TestFramework\Db\Sequence'); + $sequence = $objectManager->get(\Magento\TestFramework\Db\Sequence::class); $sequence->generateSequences(); - $objectManager->create('Magento\TestFramework\Config', ['configPath' => $this->globalConfigFile]) + $objectManager->create(\Magento\TestFramework\Config::class, ['configPath' => $this->globalConfigFile]) ->rewriteAdditionalConfig(); } @@ -407,7 +409,7 @@ public function run() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Framework\App\Http $app */ - $app = $objectManager->get('Magento\Framework\App\Http'); + $app = $objectManager->get(\Magento\Framework\App\Http::class); $response = $app->launch(); $response->sendResponse(); } @@ -603,16 +605,18 @@ public function getArea() public function loadArea($areaCode) { $this->_appArea = $areaCode; - $scope = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Config\Scope'); + $scope = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Framework\Config\Scope::class + ); $scope->setCurrentScope($areaCode); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\App\ObjectManager\ConfigLoader' + \Magento\Framework\App\ObjectManager\ConfigLoader::class )->load( $areaCode ) ); - $app = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\AreaList'); + $app = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\App\AreaList::class); if ($areaCode == \Magento\TestFramework\Application::DEFAULT_APP_AREA) { $app->getArea($areaCode)->load(\Magento\Framework\App\Area::PART_CONFIG); } else { diff --git a/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php b/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php index 0346e0409298d..426feedaa4981 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php @@ -73,7 +73,7 @@ public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) */ public function startTest(\PHPUnit_Framework_Test $test) { - $this->logger = Helper\Bootstrap::getObjectManager()->get('Magento\TestFramework\ErrorLog\Logger'); + $this->logger = Helper\Bootstrap::getObjectManager()->get(\Magento\TestFramework\ErrorLog\Logger::class); $this->logger->clearMessages(); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Event/Transaction.php b/dev/tests/integration/framework/Magento/TestFramework/Event/Transaction.php index e49ecf08e4cd1..531a4fc174083 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Event/Transaction.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Event/Transaction.php @@ -127,7 +127,7 @@ protected function _getConnection($connectionName = \Magento\Framework\App\Resou { /** @var $resource \Magento\Framework\App\ResourceConnection */ $resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\ResourceConnection'); + ->get(\Magento\Framework\App\ResourceConnection::class); return $resource->getConnection($connectionName); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Api.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Api.php index f9b930075ac21..8ce3a7446c3ce 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Api.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Api.php @@ -26,7 +26,7 @@ class Api */ public static function call(\PHPUnit_Framework_TestCase $testCase, $path, $params = []) { - $soapAdapterMock = $testCase->getMock('Magento\Api\Model\Server\Adapter\Soap', ['fault']); + $soapAdapterMock = $testCase->getMock(\stdClass::class, ['fault']); $soapAdapterMock->expects( $testCase->any() )->method( @@ -35,11 +35,11 @@ public static function call(\PHPUnit_Framework_TestCase $testCase, $path, $param $testCase->returnCallback([__CLASS__, 'soapAdapterFaultCallback']) ); - $serverMock = $testCase->getMock('Magento\Api\Model\Server', ['getAdapter']); + $serverMock = $testCase->getMock(\stdClass::class, ['getAdapter']); $serverMock->expects($testCase->any())->method('getAdapter')->will($testCase->returnValue($soapAdapterMock)); $apiSessionMock = $testCase->getMock( - 'Magento\Api\Model\Session', + \stdClass::class, ['isAllowed', 'isLoggedIn'], [], '', @@ -49,7 +49,7 @@ public static function call(\PHPUnit_Framework_TestCase $testCase, $path, $param $apiSessionMock->expects($testCase->any())->method('isLoggedIn')->will($testCase->returnValue(true)); $handlerMock = $testCase->getMock( - 'Magento\Api\Model\Server\Handler\Soap', + \stdClass::class, ['_getServer', '_getSession'], [], '', @@ -64,11 +64,11 @@ public static function call(\PHPUnit_Framework_TestCase $testCase, $path, $param /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->unregister('isSecureArea'); - $objectManager->get('Magento\Framework\Registry')->register('isSecureArea', true); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('isSecureArea'); + $objectManager->get(\Magento\Framework\Registry::class)->register('isSecureArea', true); $result = call_user_func_array([$handlerMock, $path], $params); - $objectManager->get('Magento\Framework\Registry')->unregister('isSecureArea'); - $objectManager->get('Magento\Framework\Registry')->register('isSecureArea', false); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('isSecureArea'); + $objectManager->get(\Magento\Framework\Registry::class)->register('isSecureArea', false); self::restoreErrorHandler(); return $result; diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php index a099b0f46d9a6..221cc58a2fecb 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php @@ -153,7 +153,7 @@ public function getBootstrap() */ public function loadArea($areaCode) { - self::$_objectManager->get('Magento\Framework\App\State')->setAreaCode($areaCode); - self::$_objectManager->get('Magento\Framework\App\AreaList')->getArea($areaCode)->load(); + self::$_objectManager->get(\Magento\Framework\App\State::class)->setAreaCode($areaCode); + self::$_objectManager->get(\Magento\Framework\App\AreaList::class)->getArea($areaCode)->load(); } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Config.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Config.php index a463c9467e26b..a73b61c7359b8 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Config.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Config.php @@ -20,7 +20,7 @@ public function getEnabledModules() { /** @var \Magento\Framework\Module\ModuleListInterface $moduleList */ $moduleList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\Module\ModuleListInterface' + \Magento\Framework\Module\ModuleListInterface::class ); return $moduleList->getNames(); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php index 44a8858f80f8c..fda76c84091f1 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php @@ -18,17 +18,17 @@ class Eav public static function setIncrementIdPrefix($entityType, $prefix) { $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + \Magento\Store\Model\StoreManagerInterface::class )->getWebsite(); $storeId = $website->getDefaultStore()->getId(); $entityTypeModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Eav\Model\Entity\Type' + \Magento\Eav\Model\Entity\Type::class )->loadByCode( $entityType ); /** @var \Magento\Eav\Model\Entity\Store $entityStore */ $entityStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Eav\Model\Entity\Store' + \Magento\Eav\Model\Entity\Store::class )->loadByEntityStore( $entityTypeModel->getId(), $storeId diff --git a/dev/tests/integration/framework/Magento/TestFramework/Isolation/DeploymentConfig.php b/dev/tests/integration/framework/Magento/TestFramework/Isolation/DeploymentConfig.php index 00adba85ac4cb..f6f73cc7d1bed 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Isolation/DeploymentConfig.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Isolation/DeploymentConfig.php @@ -39,7 +39,7 @@ class DeploymentConfig public function startTestSuite() { if (null === $this->reader) { - $this->reader = Bootstrap::getObjectManager()->get('Magento\Framework\App\DeploymentConfig\Reader'); + $this->reader = Bootstrap::getObjectManager()->get(\Magento\Framework\App\DeploymentConfig\Reader::class); $this->config = $this->reader->load(); } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php index 86a812cff10d1..c65ce09079128 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php @@ -14,20 +14,23 @@ class ObjectManager extends \Magento\Framework\App\ObjectManager * * @var array */ - protected $_classesToDestruct = ['Magento\Framework\View\Layout', 'Magento\Framework\Registry']; + protected $_classesToDestruct = [ + \Magento\Framework\View\Layout::class, + \Magento\Framework\Registry::class + ]; /** * @var array */ protected $persistedInstances = [ - 'Magento\Framework\App\ResourceConnection', - 'Magento\Framework\Config\Scope', - 'Magento\Framework\ObjectManager\RelationsInterface', - 'Magento\Framework\ObjectManager\ConfigInterface', - 'Magento\Framework\Interception\DefinitionInterface', - 'Magento\Framework\ObjectManager\DefinitionInterface', - 'Magento\Framework\Session\Config', - 'Magento\Framework\ObjectManager\Config\Mapper\Dom', + \Magento\Framework\App\ResourceConnection::class, + \Magento\Framework\Config\Scope::class, + \Magento\Framework\ObjectManager\RelationsInterface::class, + \Magento\Framework\ObjectManager\ConfigInterface::class, + \Magento\Framework\Interception\DefinitionInterface::class, + \Magento\Framework\ObjectManager\DefinitionInterface::class, + \Magento\Framework\Session\Config::class, + \Magento\Framework\ObjectManager\Config\Mapper\Dom::class, ]; /** @@ -45,8 +48,8 @@ public function clearCache() \Magento\Framework\App\Config\Base::destroy(); $sharedInstances = [ - 'Magento\Framework\ObjectManagerInterface' => $this, - 'Magento\Framework\App\ObjectManager' => $this, + \Magento\Framework\ObjectManagerInterface::class => $this, + \Magento\Framework\App\ObjectManager::class => $this, ]; foreach ($this->persistedInstances as $persistedClass) { if (isset($this->_sharedInstances[$persistedClass])) { diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php index 08adb5fce5b34..b4a9819228e5f 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php @@ -16,8 +16,8 @@ public function getConfiguration() { return [ 'preferences' => [ - 'Magento\Framework\Stdlib\CookieManagerInterface' => 'Magento\TestFramework\CookieManager', - 'Magento\Store\Model\StoreManagerInterface' => 'Magento\TestFramework\Store\StoreManager', + \Magento\Framework\Stdlib\CookieManagerInterface::class => \Magento\TestFramework\CookieManager::class, + \Magento\Store\Model\StoreManagerInterface::class => \Magento\TestFramework\Store\StoreManager::class, ] ]; } diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index 112e970882530..8e2976b941fb8 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -21,19 +21,19 @@ class ObjectManagerFactory extends \Magento\Framework\App\ObjectManagerFactory * * @var string */ - protected $_locatorClassName = 'Magento\TestFramework\ObjectManager'; + protected $_locatorClassName = \Magento\TestFramework\ObjectManager::class; /** * Config class name * * @var string */ - protected $_configClassName = 'Magento\TestFramework\ObjectManager\Config'; + protected $_configClassName = \Magento\TestFramework\ObjectManager\Config::class; /** * @var string */ - protected $envFactoryClassName = 'Magento\TestFramework\App\EnvironmentFactory'; + protected $envFactoryClassName = \Magento\TestFramework\App\EnvironmentFactory::class; /** * @var array @@ -53,20 +53,18 @@ public function restore(ObjectManager $objectManager, $directoryList, array $arg \Magento\TestFramework\ObjectManager::setInstance($objectManager); $this->directoryList = $directoryList; $objectManager->configure($this->_primaryConfigData); - $objectManager->addSharedInstance($this->directoryList, 'Magento\Framework\App\Filesystem\DirectoryList'); - $objectManager->addSharedInstance($this->directoryList, 'Magento\Framework\Filesystem\DirectoryList'); + $objectManager->addSharedInstance($this->directoryList, \Magento\Framework\App\Filesystem\DirectoryList::class); + $objectManager->addSharedInstance($this->directoryList, \Magento\Framework\Filesystem\DirectoryList::class); $deploymentConfig = $this->createDeploymentConfig($directoryList, $this->configFilePool, $arguments); $this->factory->setArguments($arguments); - $objectManager->addSharedInstance($deploymentConfig, 'Magento\Framework\App\DeploymentConfig'); + $objectManager->addSharedInstance($deploymentConfig, \Magento\Framework\App\DeploymentConfig::class); $objectManager->addSharedInstance( - $objectManager->get( - 'Magento\Framework\App\ObjectManager\ConfigLoader' - ), - 'Magento\Framework\ObjectManager\ConfigLoaderInterface' + $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class), + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class ); - $objectManager->get('Magento\Framework\Interception\PluginListInterface')->reset(); + $objectManager->get(\Magento\Framework\Interception\PluginListInterface::class)->reset(); $objectManager->configure( - $objectManager->get('Magento\Framework\App\ObjectManager\ConfigLoader')->load('global') + $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class)->load('global') ); return $objectManager; @@ -87,7 +85,7 @@ protected function _loadPrimaryConfig(DirectoryList $directoryList, $driverPool, $this->_primaryConfigData = array_replace( parent::_loadPrimaryConfig($directoryList, $driverPool, $argumentMapper, $appMode), [ - 'default_setup' => ['type' => 'Magento\TestFramework\Db\ConnectionAdapter'] + 'default_setup' => ['type' => \Magento\TestFramework\Db\ConnectionAdapter::class] ] ); $diPreferences = []; diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php index 4005b49428ae4..6fbd25fc23297 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php @@ -40,13 +40,13 @@ protected function setUp() { parent::setUp(); - $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); + $this->_objectManager->get(\Magento\Backend\Model\UrlInterface::class)->turnOffSecretKey(); - $this->_auth = $this->_objectManager->get('Magento\Backend\Model\Auth'); + $this->_auth = $this->_objectManager->get(\Magento\Backend\Model\Auth::class); $this->_session = $this->_auth->getAuthStorage(); $credentials = $this->_getAdminCredentials(); $this->_auth->login($credentials['user'], $credentials['password']); - $this->_objectManager->get('Magento\Security\Model\Plugin\Auth')->afterLogin($this->_auth); + $this->_objectManager->get(\Magento\Security\Model\Plugin\Auth::class)->afterLogin($this->_auth); } /** @@ -67,7 +67,7 @@ protected function tearDown() $this->_auth->getAuthStorage()->destroy(['send_expire_cookie' => false]); $this->_auth = null; $this->_session = null; - $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey(); + $this->_objectManager->get(\Magento\Backend\Model\UrlInterface::class)->turnOnSecretKey(); parent::tearDown(); } @@ -81,12 +81,11 @@ protected function tearDown() public function assertSessionMessages( \PHPUnit_Framework_Constraint $constraint, $messageType = null, - $messageManagerClass = 'Magento\Framework\Message\Manager' + $messageManagerClass = \Magento\Framework\Message\Manager::class ) { parent::assertSessionMessages($constraint, $messageType, $messageManagerClass); } - public function testAclHasAccess() { if ($this->uri === null) { @@ -102,7 +101,7 @@ public function testAclNoAccess() if ($this->resource === null) { $this->markTestIncomplete('Acl test is not complete'); } - $this->_objectManager->get('Magento\Framework\Acl\Builder') + $this->_objectManager->get(\Magento\Framework\Acl\Builder::class) ->getAcl() ->deny(null, $this->resource); $this->dispatch($this->uri); diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php index 57285b4183b36..f0aa054e1a1d9 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php @@ -44,12 +44,12 @@ public function setUp() $xmlFiles = $this->getXmlConfigFiles(); if (!empty($xmlFiles)) { $this->_fileResolverMock = $this->getMockBuilder( - 'Magento\Framework\App\Arguments\FileResolver\Primary' + \Magento\Framework\App\Arguments\FileResolver\Primary::class )->disableOriginalConstructor()->getMock(); /* Enable Validation regardles of MAGE_MODE */ $validateStateMock = $this->getMockBuilder( - 'Magento\Framework\Config\ValidationStateInterface' + \Magento\Framework\Config\ValidationStateInterface::class )->disableOriginalConstructor()->getMock(); $validateStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); @@ -79,7 +79,13 @@ public function testXmlConfigFile($file, $skip = false) if ($skip) { $this->markTestSkipped('There are no xml files in the system for this test.'); } - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(false); $domConfig = new \Magento\Framework\Config\Dom($file, $validationStateMock); @@ -139,9 +145,9 @@ public function getXmlConfigFiles() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var $moduleDirSearch \Magento\Framework\Component\DirSearch */ - $moduleDirSearch = $objectManager->get('Magento\Framework\Component\DirSearch'); + $moduleDirSearch = $objectManager->get(\Magento\Framework\Component\DirSearch::class); - return $objectManager->get('Magento\Framework\Config\FileIteratorFactory') + return $objectManager->get(\Magento\Framework\Config\FileIteratorFactory::class) ->create($moduleDirSearch->collectFiles(ComponentRegistrar::MODULE, $this->_getConfigFilePathGlob())); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php index 85a8b25c71510..9e3e8ecdf81fc 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php @@ -59,8 +59,8 @@ protected function setUp() { $this->_assertSessionErrors = false; $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_objectManager->removeSharedInstance('Magento\Framework\App\ResponseInterface'); - $this->_objectManager->removeSharedInstance('Magento\Framework\App\RequestInterface'); + $this->_objectManager->removeSharedInstance(\Magento\Framework\App\ResponseInterface::class); + $this->_objectManager->removeSharedInstance(\Magento\Framework\App\RequestInterface::class); } protected function tearDown() @@ -103,7 +103,7 @@ public function dispatch($uri) public function getRequest() { if (!$this->_request) { - $this->_request = $this->_objectManager->get('Magento\Framework\App\RequestInterface'); + $this->_request = $this->_objectManager->get(\Magento\Framework\App\RequestInterface::class); } return $this->_request; } @@ -116,7 +116,7 @@ public function getRequest() public function getResponse() { if (!$this->_response) { - $this->_response = $this->_objectManager->get('Magento\Framework\App\ResponseInterface'); + $this->_response = $this->_objectManager->get(\Magento\Framework\App\ResponseInterface::class); } return $this->_response; } @@ -193,7 +193,7 @@ public function assertRedirect(\PHPUnit_Framework_Constraint $urlConstraint = nu public function assertSessionMessages( \PHPUnit_Framework_Constraint $constraint, $messageType = null, - $messageManagerClass = 'Magento\Framework\Message\Manager' + $messageManagerClass = \Magento\Framework\Message\Manager::class ) { $this->_assertSessionErrors = false; /** @var $messageManager \Magento\Framework\Message\ManagerInterface */ diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractIntegrity.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractIntegrity.php index ca502ef421bcf..9e5cefe8b1da7 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractIntegrity.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractIntegrity.php @@ -27,7 +27,7 @@ protected function _getEnabledModules() { if ($this->_enabledModules === null) { /** @var $helper \Magento\TestFramework\Helper\Config */ - $helper = \Magento\TestFramework\Helper\Factory::getHelper('Magento\TestFramework\Helper\Config'); + $helper = \Magento\TestFramework\Helper\Factory::getHelper(\Magento\TestFramework\Helper\Config::class); $enabledModules = $helper->getEnabledModules(); $this->_enabledModules = array_combine($enabledModules, $enabledModules); } @@ -62,7 +62,7 @@ protected function _getDesignThemes() $themeItems = []; /** @var $themeCollection \Magento\Theme\Model\Theme\Collection */ $themeCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Theme\Model\ResourceModel\Theme\Collection' + \Magento\Theme\Model\ResourceModel\Theme\Collection::class ); /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ foreach ($themeCollection as $theme) { diff --git a/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php b/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php index 7ba2fad517c6b..b866253c30609 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Workaround/Cleanup/StaticProperties.php @@ -34,13 +34,13 @@ class StaticProperties */ protected static $_classesToSkip = [ 'Mage', - 'Magento\Framework\App\ObjectManager', - 'Magento\TestFramework\Helper\Bootstrap', - 'Magento\TestFramework\Event\Magento', - 'Magento\TestFramework\Event\PhpUnit', - 'Magento\TestFramework\Annotation\AppIsolation', - 'Magento\TestFramework\Workaround\Cleanup\StaticProperties', - 'Magento\Framework\Phrase', + \Magento\Framework\App\ObjectManager::class, + \Magento\TestFramework\Helper\Bootstrap::class, + \Magento\TestFramework\Event\Magento::class, + \Magento\TestFramework\Event\PhpUnit::class, + \Magento\TestFramework\Annotation\AppIsolation::class, + \Magento\TestFramework\Workaround\Cleanup\StaticProperties::class, + \Magento\Framework\Phrase::class, ]; /** @@ -107,7 +107,6 @@ protected static function _isClassInCleanableFolders($classFile) return false; // File is not in an "include" directory } - /** * Restore static variables (after running controller test case) * @TODO: refactor all code where objects are stored to static variables to use object manager instead diff --git a/dev/tests/integration/framework/bootstrap.php b/dev/tests/integration/framework/bootstrap.php index 1cd1a63bdd91d..014f1fe81cabe 100644 --- a/dev/tests/integration/framework/bootstrap.php +++ b/dev/tests/integration/framework/bootstrap.php @@ -72,9 +72,9 @@ \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap)); $dirSearch = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Framework\Component\DirSearch'); + ->create(\Magento\Framework\Component\DirSearch::class); $themePackageList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Framework\View\Design\Theme\ThemePackageList'); + ->create(\Magento\Framework\View\Design\Theme\ThemePackageList::class); \Magento\Framework\App\Utility\Files::setInstance( new Magento\Framework\App\Utility\Files( new \Magento\Framework\Component\ComponentRegistrar(), diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AdminConfigFixtureTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AdminConfigFixtureTest.php index 5fa54cdea356f..67dc261b4b46b 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AdminConfigFixtureTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AdminConfigFixtureTest.php @@ -19,7 +19,7 @@ class AdminConfigFixtureTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_object = $this->getMock( - 'Magento\TestFramework\Annotation\AdminConfigFixture', + \Magento\TestFramework\Annotation\AdminConfigFixture::class, ['_getConfigValue', '_setConfigValue'] ); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppAreaTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppAreaTest.php index c04352fb72a33..2b5314f9676eb 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppAreaTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppAreaTest.php @@ -24,8 +24,8 @@ class AppAreaTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_testCaseMock = $this->getMock('PHPUnit_Framework_TestCase', [], [], '', false); - $this->_applicationMock = $this->getMock('Magento\TestFramework\Application', [], [], '', false); + $this->_testCaseMock = $this->getMock(\PHPUnit_Framework_TestCase::class, [], [], '', false); + $this->_applicationMock = $this->getMock(\Magento\TestFramework\Application::class, [], [], '', false); $this->_object = new \Magento\TestFramework\Annotation\AppArea($this->_applicationMock); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php index 004f9e780383d..6f4b1e4c336a1 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php @@ -24,7 +24,7 @@ class AppIsolationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_application = $this->getMock( - 'Magento\TestFramework\Application', + \Magento\TestFramework\Application::class, ['reinitialize'], [], '', @@ -73,7 +73,7 @@ public function testEndTestIsolationDefault() public function testEndTestIsolationController() { /** @var $controllerTest \Magento\TestFramework\TestCase\AbstractController */ - $controllerTest = $this->getMockForAbstractClass('Magento\TestFramework\TestCase\AbstractController'); + $controllerTest = $this->getMockForAbstractClass(\Magento\TestFramework\TestCase\AbstractController::class); $this->_application->expects($this->once())->method('reinitialize'); $this->_object->endTest($controllerTest); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/ConfigFixtureTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/ConfigFixtureTest.php index d6d33f9fdaeb8..db8c89212d8ef 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/ConfigFixtureTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/ConfigFixtureTest.php @@ -19,7 +19,7 @@ class ConfigFixtureTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_object = $this->getMock( - 'Magento\TestFramework\Annotation\ConfigFixture', + \Magento\TestFramework\Annotation\ConfigFixture::class, ['_getConfigValue', '_setConfigValue'] ); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/DataFixtureTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/DataFixtureTest.php index 22faec66ce4bf..84ab9d5c1e0af 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/DataFixtureTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/DataFixtureTest.php @@ -20,7 +20,7 @@ class DataFixtureTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_object = $this->getMock( - 'Magento\TestFramework\Annotation\DataFixture', + \Magento\TestFramework\Annotation\DataFixture::class, ['_applyOneFixture'], [__DIR__ . '/_files'] ); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php index 60a78ff1c28ab..a2a2e862170e3 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php @@ -17,8 +17,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase */ public function testConstructor() { - $shell = $this->getMock('\Magento\Framework\Shell', [], [], '', false); - $autoloadWrapper = $this->getMockBuilder('Magento\Framework\Autoload\ClassLoaderWrapper') + $shell = $this->getMock(\Magento\Framework\Shell::class, [], [], '', false); + $autoloadWrapper = $this->getMockBuilder(\Magento\Framework\Autoload\ClassLoaderWrapper::class) ->disableOriginalConstructor()->getMock(); $tempDir = '/temp/dir'; $appMode = \Magento\Framework\App\State::MODE_DEVELOPER; diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/DocBlockTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/DocBlockTest.php index 9c58ede65141c..b012a6956ec3a 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/DocBlockTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/DocBlockTest.php @@ -24,7 +24,7 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_object = new \Magento\TestFramework\Bootstrap\DocBlock(__DIR__); - $this->_application = $this->getMock('Magento\TestFramework\Application', [], [], '', false); + $this->_application = $this->getMock(\Magento\TestFramework\Application::class, [], [], '', false); } protected function tearDown() @@ -52,11 +52,11 @@ protected function _expectNoListenerCreation($listenerClass, $expectedExceptionM public function testRegisterAnnotations() { $this->_expectNoListenerCreation( - 'Magento\TestFramework\Event\PhpUnit', + \Magento\TestFramework\Event\PhpUnit::class, 'Instance of the event manager is required.' ); $this->_expectNoListenerCreation( - 'Magento\TestFramework\Event\Magento', + \Magento\TestFramework\Event\Magento::class, 'Instance of the "Magento\TestFramework\EventManager" is expected.' ); $this->_object->registerAnnotations($this->_application); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/MemoryTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/MemoryTest.php index 9967bf5721504..0bbd1770b57a3 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/MemoryTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/MemoryTest.php @@ -29,13 +29,13 @@ class MemoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_memoryLimit = $this->getMock( - 'Magento\TestFramework\MemoryLimit', + \Magento\TestFramework\MemoryLimit::class, ['printStats'], [], '', false ); - $this->_activationPolicy = $this->getMock('stdClass', ['register_shutdown_function']); + $this->_activationPolicy = $this->getMock(\stdClass::class, ['register_shutdown_function']); $this->_object = new \Magento\TestFramework\Bootstrap\Memory( $this->_memoryLimit, [$this->_activationPolicy, 'register_shutdown_function'] diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/ProfilerTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/ProfilerTest.php index 0a672a221d0d8..7b73b5be0fc4e 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/ProfilerTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/ProfilerTest.php @@ -24,7 +24,7 @@ class ProfilerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->expectOutputString(''); - $this->_driver = $this->getMock('Magento\Framework\Profiler\Driver\Standard', ['registerOutput']); + $this->_driver = $this->getMock(\Magento\Framework\Profiler\Driver\Standard::class, ['registerOutput']); $this->_object = new \Magento\TestFramework\Bootstrap\Profiler($this->_driver); } @@ -41,7 +41,7 @@ public function testRegisterFileProfiler() )->method( 'registerOutput' )->with( - $this->isInstanceOf('Magento\Framework\Profiler\Driver\Standard\Output\Csvfile') + $this->isInstanceOf(\Magento\Framework\Profiler\Driver\Standard\Output\Csvfile::class) ); $this->_object->registerFileProfiler('php://output'); } @@ -53,7 +53,7 @@ public function testRegisterBambooProfiler() )->method( 'registerOutput' )->with( - $this->isInstanceOf('Magento\TestFramework\Profiler\OutputBamboo') + $this->isInstanceOf(\Magento\TestFramework\Profiler\OutputBamboo::class) ); $this->_object->registerBambooProfiler('php://output', __DIR__ . '/_files/metrics.php'); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php index 084ef9307eb61..6957bd0bef36a 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php @@ -199,7 +199,7 @@ public function getAsConfigFileDataProvider() */ public function testGetAsConfigFileException($settingName, $expectedExceptionMsg) { - $this->setExpectedException('Magento\Framework\Exception\LocalizedException', $expectedExceptionMsg); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class, $expectedExceptionMsg); $this->_object->getAsConfigFile($settingName); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php index 437eca959d1f2..f2e5229d9a9ad 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php @@ -68,25 +68,25 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_integrationTestsDir = realpath(__DIR__ . '/../../../../../../'); - $this->_settings = $this->getMock('\Magento\TestFramework\Bootstrap\Settings', [], [], '', false); + $this->_settings = $this->getMock(\Magento\TestFramework\Bootstrap\Settings::class, [], [], '', false); $this->_envBootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap\Environment', + \Magento\TestFramework\Bootstrap\Environment::class, ['emulateHttpRequest', 'emulateSession'] ); $this->_docBlockBootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap\DocBlock', + \Magento\TestFramework\Bootstrap\DocBlock::class, ['registerAnnotations'], [__DIR__] ); - $profilerDriver = $this->getMock('Magento\Framework\Profiler\Driver\Standard', ['registerOutput']); + $profilerDriver = $this->getMock(\Magento\Framework\Profiler\Driver\Standard::class, ['registerOutput']); $this->_profilerBootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap\Profiler', + \Magento\TestFramework\Bootstrap\Profiler::class, ['registerFileProfiler', 'registerBambooProfiler'], [$profilerDriver] ); - $this->_shell = $this->getMock('Magento\Framework\Shell', ['execute'], [], '', false); - $this->application = $this->getMock('\Magento\TestFramework\Application', [], [], '', false); - $this->memoryFactory = $this->getMock('\Magento\TestFramework\Bootstrap\MemoryFactory', [], [], '', false); + $this->_shell = $this->getMock(\Magento\Framework\Shell::class, ['execute'], [], '', false); + $this->application = $this->getMock(\Magento\TestFramework\Application::class, [], [], '', false); + $this->memoryFactory = $this->getMock(\Magento\TestFramework\Bootstrap\MemoryFactory::class, [], [], '', false); $this->_object = new \Magento\TestFramework\Bootstrap( $this->_settings, $this->_envBootstrap, @@ -133,7 +133,7 @@ public function testRunBootstrap() ->method('get') ->will($this->returnValueMap($settingsMap)); $memoryBootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap\Memory', + \Magento\TestFramework\Bootstrap\Memory::class, ['activateStatsDisplaying', 'activateLimitValidation'], [], '', @@ -148,7 +148,7 @@ public function testRunBootstrap() $this->_docBlockBootstrap->expects($this->once()) ->method('registerAnnotations') - ->with($this->isInstanceOf('Magento\TestFramework\Application')); + ->with($this->isInstanceOf(\Magento\TestFramework\Application::class)); $this->_profilerBootstrap->expects($this->never())->method($this->anything()); @@ -158,7 +158,7 @@ public function testRunBootstrap() public function testRunBootstrapProfilerEnabled() { $memoryBootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap\Memory', + \Magento\TestFramework\Bootstrap\Memory::class, ['activateStatsDisplaying', 'activateLimitValidation'], [], '', diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php index 4e11c971ffff7..60f66bd7d73bb 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php @@ -82,7 +82,7 @@ public function transparentTransactionDataProvider() protected function _getConnectionMock($class) { $connection = $this->getMock($class, ['beginTransaction', 'rollback', 'commit'], [], '', false); - $this->assertInstanceOf('Magento\TestFramework\Db\Adapter\TransactionInterface', $connection); + $this->assertInstanceOf(\Magento\TestFramework\Db\Adapter\TransactionInterface::class, $connection); return $connection; } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php index 2359e34757cd0..98c79635f27b5 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php @@ -15,7 +15,7 @@ class EntityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = $this->getMock( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, ['load', 'save', 'delete', 'getIdFieldName', '__wakeup'], [], '', @@ -66,7 +66,10 @@ public function crudDataProvider() { return [ 'successful CRUD' => ['saveModelSuccessfully'], - 'cleanup on update error' => ['saveModelAndFailOnUpdate', 'Magento\Framework\Exception\LocalizedException'] + 'cleanup on update error' => [ + 'saveModelAndFailOnUpdate', + \Magento\Framework\Exception\LocalizedException::class + ] ]; } @@ -94,7 +97,7 @@ public function testTestCrud($saveCallback, $expectedException = null) $this->_model->expects($this->any())->method('getIdFieldName')->will($this->returnValue('id')); $test = $this->getMock( - 'Magento\TestFramework\Entity', + \Magento\TestFramework\Entity::class, ['_getEmptyModel'], [$this->_model, ['test' => 'test']] ); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/MagentoTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/MagentoTest.php index 394d15367a3c3..01eedfabc1d66 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/MagentoTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/MagentoTest.php @@ -24,7 +24,7 @@ class MagentoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_eventManager = $this->getMock( - 'Magento\TestFramework\EventManager', + \Magento\TestFramework\EventManager::class, ['fireEvent'], [[]] ); @@ -61,6 +61,6 @@ public function constructorExceptionDataProvider() public function testInitStoreAfter() { $this->_eventManager->expects($this->once())->method('fireEvent')->with('initStoreAfter'); - $this->_object->execute($this->getMock('\Magento\Framework\Event\Observer')); + $this->_object->execute($this->getMock(\Magento\Framework\Event\Observer::class)); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/PhpUnitTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/PhpUnitTest.php index 4117b65a97e8a..185aee918ab50 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/PhpUnitTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/PhpUnitTest.php @@ -24,7 +24,7 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_eventManager = $this->getMock( - 'Magento\TestFramework\EventManager', + \Magento\TestFramework\EventManager::class, ['fireEvent'], [[]] ); @@ -105,7 +105,7 @@ public function testStartTestDoNotFireEvent() { $this->_eventManager->expects($this->never())->method('fireEvent'); $this->_object->startTest(new \PHPUnit_Framework_Warning()); - $this->_object->startTest($this->getMock('PHPUnit_Framework_Test')); + $this->_object->startTest($this->getMock(\PHPUnit_Framework_Test::class)); } public function testEndTestFireEvent() @@ -118,6 +118,6 @@ public function testEndTestDoNotFireEvent() { $this->_eventManager->expects($this->never())->method('fireEvent'); $this->_object->endTest(new \PHPUnit_Framework_Warning(), 0); - $this->_object->endTest($this->getMock('PHPUnit_Framework_Test'), 0); + $this->_object->endTest($this->getMock(\PHPUnit_Framework_Test::class), 0); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php index 18d1d63d6d1e7..372d38feeaee2 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php @@ -29,19 +29,19 @@ class TransactionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_eventManager = $this->getMock( - 'Magento\TestFramework\EventManager', + \Magento\TestFramework\EventManager::class, ['fireEvent'], [[]] ); $this->_adapter = $this->getMock( - '\Magento\TestFramework\Db\Adapter\Mysql', + \Magento\TestFramework\Db\Adapter\Mysql::class, ['beginTransaction', 'rollBack'], [], '', false ); $this->_object = $this->getMock( - 'Magento\TestFramework\Event\Transaction', + \Magento\TestFramework\Event\Transaction::class, ['_getConnection'], [$this->_eventManager] ); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EventManagerTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EventManagerTest.php index ce1ef03c1e520..4b8c4a9dc2a6d 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EventManagerTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EventManagerTest.php @@ -28,8 +28,8 @@ class EventManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_subscriberOne = $this->getMock('stdClass', ['testEvent']); - $this->_subscriberTwo = $this->getMock('stdClass', ['testEvent']); + $this->_subscriberOne = $this->getMock(\stdClass::class, ['testEvent']); + $this->_subscriberTwo = $this->getMock(\stdClass::class, ['testEvent']); $this->_eventManager = new \Magento\TestFramework\EventManager( [$this->_subscriberOne, $this->_subscriberTwo] ); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php index 735e1733ae78c..f917971452e94 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/BootstrapTest.php @@ -44,14 +44,14 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_application = $this->getMock( - 'Magento\TestFramework\Application', + \Magento\TestFramework\Application::class, ['getTempDir', 'getInitParams', 'reinitialize', 'run'], [], '', false ); $this->_bootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap', + \Magento\TestFramework\Bootstrap::class, ['getApplication', 'getDbVendorName'], [], '', diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/FactoryTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/FactoryTest.php index f4a61a9657e90..8dc833c327977 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/FactoryTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/FactoryTest.php @@ -9,23 +9,23 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { public function testGetHelper() { - $helper = \Magento\TestFramework\Helper\Factory::getHelper('Magento\TestFramework\Helper\Config'); + $helper = \Magento\TestFramework\Helper\Factory::getHelper(\Magento\TestFramework\Helper\Config::class); $this->assertNotEmpty($helper); - $helperNew = \Magento\TestFramework\Helper\Factory::getHelper('Magento\TestFramework\Helper\Config'); + $helperNew = \Magento\TestFramework\Helper\Factory::getHelper(\Magento\TestFramework\Helper\Config::class); $this->assertSame($helper, $helperNew, 'Factory must cache instances of helpers.'); } public function testSetHelper() { $helper = new \stdClass(); - \Magento\TestFramework\Helper\Factory::setHelper('Magento\TestFramework\Helper\Config', $helper); - $helperGot = \Magento\TestFramework\Helper\Factory::getHelper('Magento\TestFramework\Helper\Config'); + \Magento\TestFramework\Helper\Factory::setHelper(\Magento\TestFramework\Helper\Config::class, $helper); + $helperGot = \Magento\TestFramework\Helper\Factory::getHelper(\Magento\TestFramework\Helper\Config::class); $this->assertSame($helper, $helperGot, 'The helper must be used, when requested again'); $helperNew = new \stdClass(); - \Magento\TestFramework\Helper\Factory::setHelper('Magento\TestFramework\Helper\Config', $helperNew); - $helperGot = \Magento\TestFramework\Helper\Factory::getHelper('Magento\TestFramework\Helper\Config'); + \Magento\TestFramework\Helper\Factory::setHelper(\Magento\TestFramework\Helper\Config::class, $helperNew); + $helperGot = \Magento\TestFramework\Helper\Factory::getHelper(\Magento\TestFramework\Helper\Config::class); $this->assertSame($helperNew, $helperGot, 'The helper must be changed upon new setHelper() method'); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/MemoryTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/MemoryTest.php index 56de9cde8dfa5..b7cec3775d670 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/MemoryTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/MemoryTest.php @@ -14,7 +14,7 @@ class MemoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_shell = $this->getMock('Magento\Framework\Shell', ['execute'], [], '', false); + $this->_shell = $this->getMock(\Magento\Framework\Shell::class, ['execute'], [], '', false); } public function testGetRealMemoryUsageUnix() diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/MemoryLimitTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/MemoryLimitTest.php index 26ab16031c9b7..b76eec7b02266 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/MemoryLimitTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/MemoryLimitTest.php @@ -54,7 +54,7 @@ public function testValidateUsageException() protected function _createObject($memCap, $leakCap) { $helper = $this->getMock( - 'Magento\TestFramework\Helper\Memory', + \Magento\TestFramework\Helper\Memory::class, ['getRealMemoryUsage'], [], '', diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php index ef967cca92a80..1c3e889631e37 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php @@ -9,6 +9,9 @@ */ namespace Magento\Test; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ObjectManagerTest extends \PHPUnit_Framework_TestCase { /** @@ -22,7 +25,7 @@ public function testClearCache() { $resource = new \stdClass(); - $configMock = $this->getMockBuilder('Magento\TestFramework\ObjectManager\Config') + $configMock = $this->getMockBuilder(\Magento\TestFramework\ObjectManager\Config::class) ->disableOriginalConstructor() ->setMethods(['getPreference', 'clean']) ->getMock(); @@ -35,49 +38,53 @@ function ($className) { } )); - $cache = $this->getMock('Magento\Framework\App\CacheInterface'); - $configLoader = $this->getMock('Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false); - $configCache = $this->getMock('Magento\Framework\App\ObjectManager\ConfigCache', [], [], '', false); + $cache = $this->getMock(\Magento\Framework\App\CacheInterface::class); + $configLoader = $this->getMock(\Magento\Framework\App\ObjectManager\ConfigLoader::class, [], [], '', false); + $configCache = $this->getMock(\Magento\Framework\App\ObjectManager\ConfigCache::class, [], [], '', false); $primaryLoaderMock = $this->getMock( - 'Magento\Framework\App\ObjectManager\ConfigLoader\Primary', + \Magento\Framework\App\ObjectManager\ConfigLoader\Primary::class, [], [], '', false ); - $factory = $this->getMock('Magento\Framework\ObjectManager\FactoryInterface'); + $factory = $this->getMock(\Magento\Framework\ObjectManager\FactoryInterface::class); $factory->expects($this->exactly(2))->method('create')->will( $this->returnCallback( function ($className) { - if ($className === 'Magento\Framework\DataObject') { - return $this->getMock('Magento\Framework\DataObject', [], [], '', false); + if ($className === \Magento\Framework\DataObject::class) { + return $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); } } ) ); - $connectionMock = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $connectionMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $sharedInstances = [ - 'Magento\Framework\App\Cache\Type\Config' => $cache, - 'Magento\Framework\App\ObjectManager\ConfigLoader' => $configLoader, - 'Magento\Framework\App\ObjectManager\ConfigCache' => $configCache, - 'Magento\Framework\Config\ReaderInterface' => $this->getMock( - 'Magento\Framework\Config\ReaderInterface' - ), - 'Magento\Framework\Config\ScopeInterface' => $this->getMock('Magento\Framework\Config\ScopeInterface'), - 'Magento\Framework\Config\CacheInterface' => $this->getMock('Magento\Framework\Config\CacheInterface'), - 'Magento\Framework\Cache\FrontendInterface' => - $this->getMock('Magento\Framework\Cache\FrontendInterface'), - 'Magento\Framework\App\ResourceConnection' => $connectionMock, - 'Magento\Framework\App\ResourceConnection\Config' => $this->getMock( - 'Magento\Framework\App\ResourceConnection\Config', - [], - [], - '', - false - ) + \Magento\Framework\App\Cache\Type\Config::class => $cache, + \Magento\Framework\App\ObjectManager\ConfigLoader::class => $configLoader, + \Magento\Framework\App\ObjectManager\ConfigCache::class => $configCache, + \Magento\Framework\Config\ReaderInterface::class => + $this->getMock( + \Magento\Framework\Config\ReaderInterface::class + ), + \Magento\Framework\Config\ScopeInterface::class => + $this->getMock(\Magento\Framework\Config\ScopeInterface::class), + \Magento\Framework\Config\CacheInterface::class => + $this->getMock(\Magento\Framework\Config\CacheInterface::class), + \Magento\Framework\Cache\FrontendInterface::class => + $this->getMock(\Magento\Framework\Cache\FrontendInterface::class), + \Magento\Framework\App\ResourceConnection::class => $connectionMock, + \Magento\Framework\App\ResourceConnection\Config::class => + $this->getMock( + \Magento\Framework\App\ResourceConnection\Config::class, + [], + [], + '', + false + ) ]; $model = new \Magento\TestFramework\ObjectManager( $factory, @@ -86,13 +93,13 @@ function ($className) { $primaryLoaderMock ); - $model->addSharedInstance($resource, 'Magento\Framework\App\ResourceConnection'); - $instance1 = $model->get('Magento\Framework\DataObject'); + $model->addSharedInstance($resource, \Magento\Framework\App\ResourceConnection::class); + $instance1 = $model->get(\Magento\Framework\DataObject::class); - $this->assertSame($instance1, $model->get('Magento\Framework\DataObject')); + $this->assertSame($instance1, $model->get(\Magento\Framework\DataObject::class)); $this->assertSame($model, $model->clearCache()); - $this->assertSame($model, $model->get('Magento\Framework\ObjectManagerInterface')); - $this->assertSame($resource, $model->get('Magento\Framework\App\ResourceConnection')); - $this->assertNotSame($instance1, $model->get('Magento\Framework\DataObject')); + $this->assertSame($model, $model->get(\Magento\Framework\ObjectManagerInterface::class)); + $this->assertSame($resource, $model->get(\Magento\Framework\App\ResourceConnection::class)); + $this->assertNotSame($instance1, $model->get(\Magento\Framework\DataObject::class)); } } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Profiler/OutputBambooTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Profiler/OutputBambooTest.php index ad3f7430a1bea..2f10a2c7762c4 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Profiler/OutputBambooTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Profiler/OutputBambooTest.php @@ -18,7 +18,7 @@ class OutputBambooTest extends \PHPUnit_Framework_TestCase public static function setUpBeforeClass() { - stream_filter_register('dataCollectorFilter', 'Magento\Test\Profiler\OutputBambooTestFilter'); + stream_filter_register('dataCollectorFilter', \Magento\Test\Profiler\OutputBambooTestFilter::class); } /** diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php index 7c4199ffba96c..5149a32425373 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php @@ -17,11 +17,11 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = new \Magento\TestFramework\Request( - $this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'), - $this->getMock('Magento\Framework\Stdlib\StringUtils'), - $this->getMock('Magento\Framework\App\Route\ConfigInterface\Proxy', [], [], '', false), - $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'), - $this->getMock('Magento\Framework\ObjectManagerInterface') + $this->getMock(\Magento\Framework\Stdlib\Cookie\CookieReaderInterface::class), + $this->getMock(\Magento\Framework\Stdlib\StringUtils::class), + $this->getMock(\Magento\Framework\App\Route\ConfigInterface\Proxy::class, [], [], '', false), + $this->getMock(\Magento\Framework\App\Request\PathInfoProcessorInterface::class), + $this->getMock(\Magento\Framework\ObjectManagerInterface::class) ); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php index ad396dd7a36ea..8e805bb4afb6d 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php @@ -19,11 +19,11 @@ protected function setUp() { $testObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', [], [], '', false); - $request = $testObjectManager->getObject('Magento\TestFramework\Request'); - $response = $testObjectManager->getObject('Magento\TestFramework\Response'); + $this->messageManager = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $request = $testObjectManager->getObject(\Magento\TestFramework\Request::class); + $response = $testObjectManager->getObject(\Magento\TestFramework\Response::class); $this->_objectManager = $this->getMock( - 'Magento\TestFramework\ObjectManager', + \Magento\TestFramework\ObjectManager::class, ['get', 'create'], [], '', @@ -34,9 +34,9 @@ protected function setUp() ->will( $this->returnValueMap( [ - ['Magento\Framework\App\RequestInterface', $request], - ['Magento\Framework\App\ResponseInterface', $response], - ['Magento\Framework\Message\Manager', $this->messageManager], + [\Magento\Framework\App\RequestInterface::class, $request], + [\Magento\Framework\App\ResponseInterface::class, $response], + [\Magento\Framework\Message\Manager::class, $this->messageManager], ] ) ); @@ -52,7 +52,7 @@ protected function _getBootstrap() { if (!$this->_bootstrap) { $this->_bootstrap = $this->getMock( - 'Magento\TestFramework\Bootstrap', + \Magento\TestFramework\Bootstrap::class, ['getAllOptions'], [], '', @@ -65,13 +65,13 @@ protected function _getBootstrap() public function testGetRequest() { $request = $this->getRequest(); - $this->assertInstanceOf('Magento\TestFramework\Request', $request); + $this->assertInstanceOf(\Magento\TestFramework\Request::class, $request); } public function testGetResponse() { $response = $this->getResponse(); - $this->assertInstanceOf('Magento\TestFramework\Response', $response); + $this->assertInstanceOf(\Magento\TestFramework\Response::class, $response); } /** @@ -112,7 +112,7 @@ public function testAssertRedirect() * which requires fully initialized application environment intentionally not available * for unit tests */ - $setRedirectMethod = new \ReflectionMethod('Magento\Framework\App\Response\Http', 'setRedirect'); + $setRedirectMethod = new \ReflectionMethod(\Magento\Framework\App\Response\Http::class, 'setRedirect'); $setRedirectMethod->invoke($this->getResponse(), 'http://magentocommerce.com'); $this->assertRedirect(); $this->assertRedirect($this->equalTo('http://magentocommerce.com')); @@ -127,7 +127,7 @@ public function testAssertSessionMessagesSuccess(array $expectedMessages, $messa { $this->addSessionMessages(); /** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_Constraint $constraint */ - $constraint = $this->getMock('PHPUnit_Framework_Constraint', ['toString', 'matches']); + $constraint = $this->getMock(\PHPUnit_Framework_Constraint::class, ['toString', 'matches']); $constraint->expects( $this->once() )->method('matches') diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Workaround/Cleanup/TestCasePropertiesTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Workaround/Cleanup/TestCasePropertiesTest.php index a3fa79631857d..37e9cb73d8a3a 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Workaround/Cleanup/TestCasePropertiesTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Workaround/Cleanup/TestCasePropertiesTest.php @@ -39,7 +39,7 @@ public function testEndTestSuiteDestruct() /** @var $testClass \Magento\Test\Workaround\Cleanup\TestCasePropertiesTest\DummyTestCase */ $testClass = $testSuite->testAt(0); - $propertyObjectMock = $this->getMock('stdClass', ['__destruct']); + $propertyObjectMock = $this->getMock(\stdClass::class, ['__destruct']); $propertyObjectMock->expects($this->atLeastOnce())->method('__destruct'); $testClass->setPropertyObject($propertyObjectMock); diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php index 78b5177d04562..054d95b7b0bf1 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php @@ -15,7 +15,7 @@ class CriticalTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Critical' + \Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Critical::class ); } diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php b/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php index 71ef5087c9efb..5fc224a159ae8 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php @@ -4,33 +4,33 @@ * See COPYING.txt for license details. */ $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity( \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Unread Critical 1' )->save(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity(\Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR) ->setTitle('Unread Major 1') ->save(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity( \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Unread Critical 2' )->save(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity( \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Unread Critical 3' )->save(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity( \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( @@ -39,12 +39,12 @@ 1 )->save(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity(\Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR) ->setTitle('Unread Major 2') ->save(); -$mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); +$mesasge = $om->create(\Magento\AdminNotification\Model\Inbox::class); $mesasge->setSeverity( \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( diff --git a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/CollectionTest.php index 21bedaad6f76e..da9679a63cc48 100644 --- a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/CollectionTest.php @@ -21,13 +21,13 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Authorization\Model\ResourceModel\Role\Collection' + \Magento\Authorization\Model\ResourceModel\Role\Collection::class ); } public function testSetUserFilter() { - $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); + $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\User\Model\User::class); $user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); $this->_collection->setUserFilter($user->getId(), UserContextInterface::USER_TYPE_ADMIN); diff --git a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/Grid/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/Grid/CollectionTest.php index 1a19e7520d151..70b3e1bc32d1d 100644 --- a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/Grid/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Role/Grid/CollectionTest.php @@ -18,7 +18,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Authorization\Model\ResourceModel\Role\Grid\Collection' + \Magento\Authorization\Model\ResourceModel\Role\Grid\Collection::class ); } diff --git a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/RoleTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/RoleTest.php index 5006e06ebaa60..37496a276e7f0 100644 --- a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/RoleTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/RoleTest.php @@ -14,9 +14,11 @@ class RoleTest extends \PHPUnit_Framework_TestCase { public function testGetRoleUsers() { - $role = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Authorization\Model\Role'); + $role = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Authorization\Model\Role::class + ); $roleResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Authorization\Model\ResourceModel\Role' + \Magento\Authorization\Model\ResourceModel\Role::class ); $this->assertEmpty($roleResource->getRoleUsers($role)); diff --git a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Rules/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Rules/CollectionTest.php index 3f191246952aa..8239aacc02244 100644 --- a/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Rules/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/ResourceModel/Rules/CollectionTest.php @@ -18,13 +18,13 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Authorization\Model\ResourceModel\Rules\Collection' + \Magento\Authorization\Model\ResourceModel\Rules\Collection::class ); } public function testGetByRoles() { - $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); + $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\User\Model\User::class); $user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); $this->_collection->getByRoles($user->getRole()->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.php index 0185ee0930793..df47908a22c04 100644 --- a/dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.php @@ -18,7 +18,7 @@ class RoleTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Authorization\Model\Role'); + ->create(\Magento\Authorization\Model\Role::class); } public function testGetRoleUsers() diff --git a/dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.php index 8a30f30edaa0e..8d0b594f37034 100644 --- a/dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.php @@ -18,7 +18,7 @@ class RulesTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Authorization\Model\Rules' + \Magento\Authorization\Model\Rules::class ); } diff --git a/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php b/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php index 3355b796991ce..ee671e3b00821 100644 --- a/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php @@ -7,6 +7,8 @@ /** * Class PlaceTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PlaceTest extends \Magento\TestFramework\TestCase\AbstractBackendController { @@ -20,44 +22,44 @@ public function testExecuteAuthorizenetDataReturning() $this->getRequest()->setParam('payment', ['method' => 'authorizenet_directpost']); $this->getRequest()->setParam('controller', 'order_create'); $orderCreateMock = $this->getOrderCreateMock($requestToAuthorizenetData); - $directpostMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + $directpostMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost::class) ->setMethods(['getCode']) ->disableOriginalConstructor() ->getMock(); $directpostMock->expects($this->once()) ->method('getCode') ->willReturn('authorizenet_directpost'); - $jsonHelper = $this->_objectManager->get('Magento\Framework\Json\Helper\Data'); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $jsonHelper = $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class); + $objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->setMethods(['create', 'get']) ->getMockForAbstractClass(); $objectManagerMock->expects($this->atLeastOnce()) ->method('create') - ->with('Magento\Authorizenet\Model\Directpost') + ->with(\Magento\Authorizenet\Model\Directpost::class) ->willReturn($directpostMock); - $authorizenetSessionMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + $authorizenetSessionMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost::class) ->disableOriginalConstructor() ->getMock(); - $urlMock = $this->getMockBuilder('Magento\Backend\Model\UrlInterface') + $urlMock = $this->getMockBuilder(\Magento\Backend\Model\UrlInterface::class) ->getMockForAbstractClass(); $objectManagerMock->expects($this->atLeastOnce()) ->method('get') ->willReturnMap([ - ['Magento\Sales\Model\AdminOrder\Create', $orderCreateMock], - ['Magento\Framework\Json\Helper\Data', $jsonHelper], - ['Magento\Authorizenet\Model\Directpost\Session', $authorizenetSessionMock], - ['Magento\Backend\Model\UrlInterface', $urlMock], + [\Magento\Sales\Model\AdminOrder\Create::class, $orderCreateMock], + [\Magento\Framework\Json\Helper\Data::class, $jsonHelper], + [\Magento\Authorizenet\Model\Directpost\Session::class, $authorizenetSessionMock], + [\Magento\Backend\Model\UrlInterface::class, $urlMock], ]); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'objectManager' => $objectManagerMock ] ); $controller = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment\PlaceTesting', + \Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment\PlaceTesting::class, ['context' => $context] ); $controller->execute(); @@ -70,10 +72,10 @@ public function testExecuteAuthorizenetDataReturning() */ private function getOrderCreateMock($requestToAuthorizenetData) { - $methodInstanceMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + $methodInstanceMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost::class) ->disableOriginalConstructor() ->getMock(); - $directpostRequestMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Request') + $directpostRequestMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost\Request::class) ->setMethods(['getData']) ->disableOriginalConstructor() ->getMock(); @@ -83,7 +85,7 @@ private function getOrderCreateMock($requestToAuthorizenetData) $methodInstanceMock->expects($this->once()) ->method('generateRequestFromOrder') ->willReturn($directpostRequestMock); - $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) ->setMethods(['getMethod', 'getMethodInstance']) ->disableOriginalConstructor() ->getMock(); @@ -93,28 +95,28 @@ private function getOrderCreateMock($requestToAuthorizenetData) $paymentMock->expects($this->once()) ->method('getMethodInstance') ->willReturn($methodInstanceMock); - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->setMethods(['getPayment', 'getStoreId']) ->disableOriginalConstructor() ->getMock(); $quoteMock->expects($this->any()) ->method('getPayment') ->willReturn($paymentMock); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods(['getPayment']) ->disableOriginalConstructor() ->getMock(); $orderMock->expects($this->any()) ->method('getPayment') ->willReturn($paymentMock); - $sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + $sessionQuoteMock = $this->getMockBuilder(\Magento\Backend\Model\Session\Quote::class) ->setMethods(['getOrder']) ->disableOriginalConstructor() ->getMock(); $sessionQuoteMock->expects($this->once()) ->method('getOrder') ->willReturn($orderMock); - $orderCreateMock = $this->getMockBuilder('Magento\Sales\Model\AdminOrder\Create') + $orderCreateMock = $this->getMockBuilder(\Magento\Sales\Model\AdminOrder\Create::class) ->setMethods(['getQuote', 'getSession', 'setIsValidate', 'importPostData', 'createOrder', 'setPaymentData']) ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php index fcd193f2fb07b..72834f82e9e13 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php @@ -20,14 +20,14 @@ public function testPreDispatchWithEmptyUrlRedirectsToStartupPage() { $this->markTestSkipped('Session destruction doesn\'t work'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\Config\ScopeInterface' + \Magento\Framework\Config\ScopeInterface::class )->setCurrentScope( \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE ); $this->dispatch('backend'); /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */ $backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class ); $url = $backendUrlModel->getStartupPageUrl(); $expected = $backendUrlModel->getUrl($url); @@ -47,7 +47,7 @@ public function testInitAuthentication() $this->_auth->logout(); /** @var \Magento\Framework\Data\Form\FormKey $formKey */ - $formKey = $this->_objectManager->get('Magento\Framework\Data\Form\FormKey'); + $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class); $postLogin = [ 'login' => [ 'username' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, @@ -75,7 +75,7 @@ public function testAclInNodes($blockName, $resource, $isLimitedAccess) { /** @var $noticeInbox \Magento\AdminNotification\Model\Inbox */ $noticeInbox = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\AdminNotification\Model\Inbox' + \Magento\AdminNotification\Model\Inbox::class ); if (!$noticeInbox->loadLatestNotice()->getId()) { $noticeInbox->addCritical('Test notice', 'Test description'); @@ -88,7 +88,7 @@ public function testAclInNodes($blockName, $resource, $isLimitedAccess) /** @var $acl \Magento\Framework\Acl */ $acl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\Acl\Builder') + ->get(\Magento\Framework\Acl\Builder::class) ->getAcl(); if ($isLimitedAccess) { $acl->deny(null, $resource); @@ -97,7 +97,7 @@ public function testAclInNodes($blockName, $resource, $isLimitedAccess) $this->dispatch('backend/admin/dashboard'); $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); $actualBlocks = $layout->getAllBlocks(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/App/RouterTest.php b/dev/tests/integration/testsuite/Magento/Backend/App/RouterTest.php index f9faabd2399b2..4e92d1538b0f8 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/App/RouterTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/App/RouterTest.php @@ -7,6 +7,7 @@ /** * @magentoAppArea adminhtml + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class RouterTest extends \PHPUnit_Framework_TestCase { @@ -23,15 +24,15 @@ class RouterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->model = $this->objectManager->create('Magento\Backend\App\Router'); + $this->model = $this->objectManager->create(\Magento\Backend\App\Router::class); } public function testRouterCanProcessRequestsWithProperPathInfo() { - $request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $request->expects($this->once())->method('getPathInfo')->will($this->returnValue('backend/admin/dashboard')); - $this->assertInstanceOf('Magento\Backend\Controller\Adminhtml\Dashboard', $this->model->match($request)); + $this->assertInstanceOf(\Magento\Backend\Controller\Adminhtml\Dashboard::class, $this->model->match($request)); } /** @@ -49,7 +50,7 @@ public function testGetControllerClassName($module, $controller, $className) public function getControllerClassNameDataProvider() { return [ - ['Magento_Module', 'controller', 'Magento\Module\Controller\Adminhtml\Controller'], + ['Magento_TestModule', 'controller', \Magento\TestModule\Controller\Adminhtml\Controller::class], ]; } @@ -68,13 +69,13 @@ public function testMatchCustomNoRouteAction() ]; $routeConfig = $this->getMock( - 'Magento\Framework\App\Route\Config', + \Magento\Framework\App\Route\Config::class, ['_getRoutes'], [ - 'reader' => $this->objectManager->get('Magento\Framework\App\Route\Config\Reader'), - 'cache' => $this->objectManager->get('Magento\Framework\Config\CacheInterface'), - 'configScope' => $this->objectManager->get('Magento\Framework\Config\ScopeInterface'), - 'areaList' => $this->objectManager->get('Magento\Framework\App\AreaList'), + 'reader' => $this->objectManager->get(\Magento\Framework\App\Route\Config\Reader::class), + 'cache' => $this->objectManager->get(\Magento\Framework\Config\CacheInterface::class), + 'configScope' => $this->objectManager->get(\Magento\Framework\Config\ScopeInterface::class), + 'areaList' => $this->objectManager->get(\Magento\Framework\App\AreaList::class), 'cacheId' => 'RoutesConfig' ] ); @@ -82,16 +83,16 @@ public function testMatchCustomNoRouteAction() $routeConfig->expects($this->any())->method('_getRoutes')->will($this->returnValue($routers)); $defaultRouter = $this->objectManager->create( - 'Magento\Backend\App\Router', + \Magento\Backend\App\Router::class, ['routeConfig' => $routeConfig] ); /** @var $request \Magento\TestFramework\Request */ - $request = $this->objectManager->get('Magento\TestFramework\Request'); + $request = $this->objectManager->get(\Magento\TestFramework\Request::class); $request->setPathInfo('backend/testfixture/test_controller'); $controller = $defaultRouter->match($request); - $this->assertInstanceOf('Magento\TestFixture\Controller\Adminhtml\Noroute', $controller); + $this->assertInstanceOf(\Magento\TestFixture\Controller\Adminhtml\Noroute::class, $controller); $this->assertEquals('noroute', $request->getActionName()); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Dashboard/GraphTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Dashboard/GraphTest.php index 48dd4c75093b3..7ef00b5209fec 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Dashboard/GraphTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Dashboard/GraphTest.php @@ -20,9 +20,9 @@ protected function setUp() parent::setUp(); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Framework\View\LayoutInterface $layout */ - $layout = $objectManager->get('Magento\Framework\View\LayoutInterface'); - $this->_block = $layout->createBlock('Magento\Backend\Block\Dashboard\Graph'); - $this->_block->setDataHelper($objectManager->get('Magento\Backend\Helper\Dashboard\Order')); + $layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class); + $this->_block = $layout->createBlock(\Magento\Backend\Block\Dashboard\Graph::class); + $this->_block->setDataHelper($objectManager->get(\Magento\Backend\Helper\Dashboard\Order::class)); } public function testGetChartUrl() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/MenuTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/MenuTest.php index 2348d27c62882..93c3bf10e35bb 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/MenuTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/MenuTest.php @@ -10,6 +10,8 @@ /** * Test class for \Magento\Backend\Block\Menu + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class MenuTest extends \PHPUnit_Framework_TestCase { @@ -29,15 +31,15 @@ class MenuTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configCacheType = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\App\Cache\Type\Config' + \Magento\Framework\App\Cache\Type\Config::class ); $this->configCacheType->save('', \Magento\Backend\Model\Menu\Config::CACHE_MENU_OBJECT); $this->blockMenu = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Block\Menu' + \Magento\Backend\Block\Menu::class ); - $reflection = new \ReflectionClass('Magento\Framework\Component\ComponentRegistrar'); + $reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class); $paths = $reflection->getProperty('paths'); $paths->setAccessible(true); $this->backupRegistrar = $paths->getValue(); @@ -83,7 +85,7 @@ protected function prepareMenuConfig() $componentRegistrar = new \Magento\Framework\Component\ComponentRegistrar(); $libraryPath = $componentRegistrar->getPath(ComponentRegistrar::LIBRARY, 'magento/framework'); - $reflection = new \ReflectionClass('Magento\Framework\Component\ComponentRegistrar'); + $reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class); $paths = $reflection->getProperty('paths'); $paths->setAccessible(true); @@ -107,18 +109,18 @@ protected function prepareMenuConfig() /* @var $validationState \Magento\Framework\App\Arguments\ValidationState */ $validationState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\App\Arguments\ValidationState', + \Magento\Framework\App\Arguments\ValidationState::class, ['appMode' => State::MODE_DEFAULT] ); /* @var $configReader \Magento\Backend\Model\Menu\Config\Reader */ $configReader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Model\Menu\Config\Reader', + \Magento\Backend\Model\Menu\Config\Reader::class, ['validationState' => $validationState] ); return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Model\Menu\Config', + \Magento\Backend\Model\Menu\Config::class, [ 'configReader' => $configReader, 'configCacheType' => $this->configCacheType @@ -132,10 +134,10 @@ protected function prepareMenuConfig() protected function loginAdminUser() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\UrlInterface') + ->get(\Magento\Backend\Model\UrlInterface::class) ->turnOffSecretKey(); - $auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth'); + $auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Auth::class); $auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD); } @@ -145,7 +147,7 @@ protected function loginAdminUser() protected function tearDown() { $this->configCacheType->save('', \Magento\Backend\Model\Menu\Config::CACHE_MENU_OBJECT); - $reflection = new \ReflectionClass('Magento\Framework\Component\ComponentRegistrar'); + $reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class); $paths = $reflection->getProperty('paths'); $paths->setAccessible(true); $paths->setValue($this->backupRegistrar); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Page/FooterTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Page/FooterTest.php index 84e863b3bb09b..ae6cc09ee1c79 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Page/FooterTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Page/FooterTest.php @@ -24,7 +24,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase protected function setUp() { parent::setUp(); - $productMetadataMock = $this->getMockBuilder('Magento\Framework\App\ProductMetadata') + $productMetadataMock = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class) ->setMethods(['getVersion']) ->disableOriginalConstructor() ->getMock(); @@ -32,9 +32,9 @@ protected function setUp() ->method('getVersion') ->willReturn($this::TEST_PRODUCT_VERSION); $this->block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Page\Footer', + \Magento\Backend\Block\Page\Footer::class, '', ['productMetadata' => $productMetadataMock] ); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Page/HeaderTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Page/HeaderTest.php index 33aa10a9a9726..498f42128db23 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Page/HeaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Page/HeaderTest.php @@ -20,16 +20,16 @@ protected function setUp() { parent::setUp(); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Page\Header' + \Magento\Backend\Block\Page\Header::class ); } public function testGetHomeLink() { $expected = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->getHomePageUrl(); $this->assertEquals($expected, $this->_block->getHomeLink()); } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Account/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Account/Edit/FormTest.php index 136d32777c209..de20c8bfabbf1 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Account/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Account/Edit/FormTest.php @@ -13,29 +13,29 @@ class FormTest extends \PHPUnit_Framework_TestCase public function testPrepareForm() { $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\User' + \Magento\User\Model\User::class )->loadByUsername( \Magento\TestFramework\Bootstrap::ADMIN_NAME ); /** @var $session \Magento\Backend\Model\Auth\Session */ $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\Auth\Session' + \Magento\Backend\Model\Auth\Session::class ); $session->setUser($user); /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var \Magento\Backend\Block\System\Account\Edit\Form */ - $block = $layout->createBlock('Magento\Backend\Block\System\Account\Edit\Form'); + $block = $layout->createBlock(\Magento\Backend\Block\System\Account\Edit\Form::class); $block->toHtml(); $form = $block->getForm(); - $this->assertInstanceOf('Magento\Framework\Data\Form', $form); + $this->assertInstanceOf(\Magento\Framework\Data\Form::class, $form); $this->assertEquals('post', $form->getData('method')); $this->assertEquals($block->getUrl('adminhtml/system_account/save'), $form->getData('action')); $this->assertEquals('edit_form', $form->getId()); @@ -73,7 +73,7 @@ public function testPrepareForm() foreach ($expectedFieldset as $fieldId => $field) { $element = $form->getElement($fieldId); - $this->assertInstanceOf('Magento\Framework\Data\Form\Element\AbstractElement', $element); + $this->assertInstanceOf(\Magento\Framework\Data\Form\Element\AbstractElement::class, $element); $this->assertEquals($field['name'], $element->getName(), 'Wrong \'' . $fieldId . '\' field name'); $this->assertEquals($field['type'], $element->getType(), 'Wrong \'' . $fieldId . ' field type'); $this->assertEquals( diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Design/Edit/Tab/GeneralTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Design/Edit/Tab/GeneralTest.php index 23b4b68f7c915..85dc4b45c2d97 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Design/Edit/Tab/GeneralTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Design/Edit/Tab/GeneralTest.php @@ -18,20 +18,20 @@ public function testPrepareForm() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get( - 'Magento\Framework\View\DesignInterface' + \Magento\Framework\View\DesignInterface::class )->setArea( \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE )->setDefaultDesignTheme(); $objectManager->get( - 'Magento\Framework\Registry' + \Magento\Framework\Registry::class )->register( 'design', - $objectManager->create('Magento\Framework\App\DesignInterface') + $objectManager->create(\Magento\Framework\App\DesignInterface::class) ); - $layout = $objectManager->create('Magento\Framework\View\Layout'); - $block = $layout->addBlock('Magento\Backend\Block\System\Design\Edit\Tab\General'); + $layout = $objectManager->create(\Magento\Framework\View\Layout::class); + $block = $layout->addBlock(\Magento\Backend\Block\System\Design\Edit\Tab\General::class); $prepareFormMethod = new \ReflectionMethod( - 'Magento\Backend\Block\System\Design\Edit\Tab\General', + \Magento\Backend\Block\System\Design\Edit\Tab\General::class, '_prepareForm' ); $prepareFormMethod->setAccessible(true); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/DeleteTest.php index 5c42d8cf19b17..0a47c7a032046 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/DeleteTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/DeleteTest.php @@ -14,10 +14,10 @@ public function testGetHeaderText() { /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\System\Store\Delete */ - $block = $layout->createBlock('Magento\Backend\Block\System\Store\Delete', 'block'); + $block = $layout->createBlock(\Magento\Backend\Block\System\Store\Delete::class, 'block'); $dataObject = new \Magento\Framework\DataObject(); $form = $block->getChildBlock('form'); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/GroupTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/GroupTest.php index 45bdd3a48921a..c6959a4278aba 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/GroupTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/GroupTest.php @@ -23,20 +23,20 @@ protected function setUp() $registryData = [ 'store_type' => 'group', 'store_data' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Store\Model\Store' + \Magento\Store\Model\Store::class ), 'store_action' => 'add', ]; /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); foreach ($registryData as $key => $value) { - $objectManager->get('Magento\Framework\Registry')->register($key, $value); + $objectManager->get(\Magento\Framework\Registry::class)->register($key, $value); } /** @var $layout \Magento\Framework\View\Layout */ - $layout = $objectManager->get('Magento\Framework\View\LayoutInterface'); + $layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class); - $this->_block = $layout->createBlock('Magento\Backend\Block\System\Store\Edit\Form\Group'); + $this->_block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit\Form\Group::class); $this->_block->toHtml(); } @@ -45,9 +45,9 @@ protected function tearDown() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->unregister('store_type'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_data'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_action'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action'); } public function testPrepareForm() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/StoreTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/StoreTest.php index 2b12d59fd379e..c0d290b6880b8 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/StoreTest.php @@ -23,20 +23,20 @@ protected function setUp() $registryData = [ 'store_type' => 'store', 'store_data' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Store\Model\Store' + \Magento\Store\Model\Store::class ), 'store_action' => 'add', ]; /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); foreach ($registryData as $key => $value) { - $objectManager->get('Magento\Framework\Registry')->register($key, $value); + $objectManager->get(\Magento\Framework\Registry::class)->register($key, $value); } /** @var $layout \Magento\Framework\View\Layout */ - $layout = $objectManager->get('Magento\Framework\View\LayoutInterface'); + $layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class); - $this->_block = $layout->createBlock('Magento\Backend\Block\System\Store\Edit\Form\Store'); + $this->_block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit\Form\Store::class); $this->_block->toHtml(); } @@ -45,9 +45,9 @@ protected function tearDown() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->unregister('store_type'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_data'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_action'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action'); } public function testPrepareForm() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/WebsiteTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/WebsiteTest.php index 81132d4e3a207..d8ab2666e34d3 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/WebsiteTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/Edit/Form/WebsiteTest.php @@ -24,17 +24,17 @@ protected function setUp() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $registryData = [ 'store_type' => 'website', - 'store_data' => $objectManager->create('Magento\Store\Model\Website'), + 'store_data' => $objectManager->create(\Magento\Store\Model\Website::class), 'store_action' => 'add', ]; foreach ($registryData as $key => $value) { - $objectManager->get('Magento\Framework\Registry')->register($key, $value); + $objectManager->get(\Magento\Framework\Registry::class)->register($key, $value); } /** @var $layout \Magento\Framework\View\Layout */ - $layout = $objectManager->get('Magento\Framework\View\LayoutInterface'); + $layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class); - $this->_block = $layout->createBlock('Magento\Backend\Block\System\Store\Edit\Form\Website'); + $this->_block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit\Form\Website::class); $this->_block->toHtml(); } @@ -43,9 +43,9 @@ protected function tearDown() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->unregister('store_type'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_data'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_action'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action'); } public function testPrepareForm() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/EditTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/EditTest.php index 15be165cd150e..cb7f601969070 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/System/Store/EditTest.php @@ -14,9 +14,9 @@ protected function tearDown() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->unregister('store_type'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_data'); - $objectManager->get('Magento\Framework\Registry')->unregister('store_action'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data'); + $objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action'); } /** @@ -30,7 +30,7 @@ protected function _initStoreTypesInRegistry($registryData) if ($key == 'store_data') { $value = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($value); } - $objectManager->get('Magento\Framework\Registry')->register($key, $value); + $objectManager->get(\Magento\Framework\Registry::class)->register($key, $value); } } @@ -46,10 +46,10 @@ public function testStoreTypeFormCreated($registryData, $expected) /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\System\Store\Edit */ - $block = $layout->createBlock('Magento\Backend\Block\System\Store\Edit', 'block'); + $block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit::class, 'block'); $block->setArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->assertInstanceOf($expected, $block->getChildBlock('form')); @@ -62,16 +62,16 @@ public function getStoreTypesForLayout() { return [ [ - ['store_type' => 'website', 'store_data' => 'Magento\Store\Model\Website'], - 'Magento\Backend\Block\System\Store\Edit\Form\Website', + ['store_type' => 'website', 'store_data' => \Magento\Store\Model\Website::class], + \Magento\Backend\Block\System\Store\Edit\Form\Website::class, ], [ - ['store_type' => 'group', 'store_data' => 'Magento\Store\Model\Store'], - 'Magento\Backend\Block\System\Store\Edit\Form\Group' + ['store_type' => 'group', 'store_data' => \Magento\Store\Model\Store::class], + \Magento\Backend\Block\System\Store\Edit\Form\Group::class ], [ - ['store_type' => 'store', 'store_data' => 'Magento\Store\Model\Store'], - 'Magento\Backend\Block\System\Store\Edit\Form\Store' + ['store_type' => 'store', 'store_data' => \Magento\Store\Model\Store::class], + \Magento\Backend\Block\System\Store\Edit\Form\Store::class ] ]; } @@ -88,10 +88,10 @@ public function testGetHeaderText($registryData, $expected) /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\System\Store\Edit */ - $block = $layout->createBlock('Magento\Backend\Block\System\Store\Edit', 'block'); + $block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit::class, 'block'); $block->setArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->assertEquals($expected, $block->getHeaderText()); @@ -106,7 +106,7 @@ public function getStoreDataForBlock() [ [ 'store_type' => 'website', - 'store_data' => 'Magento\Store\Model\Website', + 'store_data' => \Magento\Store\Model\Website::class, 'store_action' => 'add', ], 'New Web Site', @@ -114,25 +114,25 @@ public function getStoreDataForBlock() [ [ 'store_type' => 'website', - 'store_data' => 'Magento\Store\Model\Website', + 'store_data' => \Magento\Store\Model\Website::class, 'store_action' => 'edit', ], 'Edit Web Site' ], [ - ['store_type' => 'group', 'store_data' => 'Magento\Store\Model\Store', 'store_action' => 'add'], + ['store_type' => 'group', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'add'], 'New Store' ], [ - ['store_type' => 'group', 'store_data' => 'Magento\Store\Model\Store', 'store_action' => 'edit'], + ['store_type' => 'group', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'edit'], 'Edit Store' ], [ - ['store_type' => 'store', 'store_data' => 'Magento\Store\Model\Store', 'store_action' => 'add'], + ['store_type' => 'store', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'add'], 'New Store View' ], [ - ['store_type' => 'store', 'store_data' => 'Magento\Store\Model\Store', 'store_action' => 'edit'], + ['store_type' => 'store', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'edit'], 'Edit Store View' ] ]; diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php index 573bc832cc80f..9bb03d6734202 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php @@ -21,9 +21,9 @@ protected function setUp() { parent::setUp(); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Template' + \Magento\Backend\Block\Template::class ); } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/ContainerTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/ContainerTest.php index 10409ee516671..1c0f58a06f896 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/ContainerTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/ContainerTest.php @@ -17,9 +17,9 @@ public function testPseudoConstruct() { /** @var $block \Magento\Backend\Block\Widget\Container */ $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Widget\Container', + \Magento\Backend\Block\Widget\Container::class, '', [ 'data' => [ @@ -76,10 +76,10 @@ protected function _buildBlock($titles, $blockName = 'block') { /** @var $layout \Magento\Framework\View\LayoutInterface */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\Widget\Container */ - $block = $layout->createBlock('Magento\Backend\Block\Widget\Container', $blockName); + $block = $layout->createBlock(\Magento\Backend\Block\Widget\Container::class, $blockName); foreach ($titles as $id => $title) { $block->addButton($id, ['title' => $title], 0, 0, 'header'); } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php index 1672295c742ac..466a1314907fe 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php @@ -15,18 +15,18 @@ public function testGetFormHtml() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); // Create block with blocking _prepateLayout(), which is used by block to instantly add 'form' child /** @var $block \Magento\Backend\Block\Widget\Form\Container */ $block = $this->getMock( - 'Magento\Backend\Block\Widget\Form\Container', + \Magento\Backend\Block\Widget\Form\Container::class, ['_prepareLayout'], - [$objectManager->create('Magento\Backend\Block\Widget\Context')] + [$objectManager->create(\Magento\Backend\Block\Widget\Context::class)] ); $layout->addBlock($block, 'block'); - $form = $layout->addBlock('Magento\Framework\View\Element\Text', 'form', 'block'); + $form = $layout->addBlock(\Magento\Framework\View\Element\Text::class, 'form', 'block'); $expectedHtml = 'html'; $this->assertNotEquals($expectedHtml, $block->getFormHtml()); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/FormTest.php index 2d4cc3ebb5f78..54d0c7b155620 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/FormTest.php @@ -18,13 +18,13 @@ public function testSetFieldset() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get( - 'Magento\Framework\View\DesignInterface' + \Magento\Framework\View\DesignInterface::class )->setArea( \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE )->setDefaultDesignTheme(); - $layout = $objectManager->create('Magento\Framework\View\Layout'); - $formBlock = $layout->addBlock('Magento\Backend\Block\Widget\Form'); - $fieldSet = $objectManager->create('Magento\Framework\Data\Form\Element\Fieldset'); + $layout = $objectManager->create(\Magento\Framework\View\Layout::class); + $formBlock = $layout->addBlock(\Magento\Backend\Block\Widget\Form::class); + $fieldSet = $objectManager->create(\Magento\Framework\Data\Form\Element\Fieldset::class); $arguments = [ 'data' => [ 'attribute_code' => 'date', @@ -33,14 +33,14 @@ public function testSetFieldset() 'frontend_label' => 'Date', ], ]; - $attributes = [$objectManager->create('Magento\Eav\Model\Entity\Attribute', $arguments)]; - $method = new \ReflectionMethod('Magento\Backend\Block\Widget\Form', '_setFieldset'); + $attributes = [$objectManager->create(\Magento\Eav\Model\Entity\Attribute::class, $arguments)]; + $method = new \ReflectionMethod(\Magento\Backend\Block\Widget\Form::class, '_setFieldset'); $method->setAccessible(true); $method->invoke($formBlock, $attributes, $fieldSet); $fields = $fieldSet->getElements(); $this->assertEquals(1, count($fields)); - $this->assertInstanceOf('Magento\Framework\Data\Form\Element\Date', $fields[0]); + $this->assertInstanceOf(\Magento\Framework\Data\Form\Element\Date::class, $fields[0]); $this->assertNotEmpty($fields[0]->getDateFormat()); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ColumnSetTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ColumnSetTest.php index 47917f2873e7e..86847eddb2c04 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ColumnSetTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ColumnSetTest.php @@ -30,13 +30,13 @@ protected function setUp() parent::setUp(); $this->_columnMock = $this->getMock( - 'Magento\Backend\Block\Widget\Grid\Column', + \Magento\Backend\Block\Widget\Grid\Column::class, ['setSortable', 'setRendererType', 'setFilterType', 'addHeaderCssClass', 'setGrid'], [], '', false ); - $this->_layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->_layoutMock->expects( $this->any() )->method( @@ -46,13 +46,13 @@ protected function setUp() ); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, ['layout' => $this->_layoutMock] ); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Widget\Grid\ColumnSet', + \Magento\Backend\Block\Widget\Grid\ColumnSet::class, '', ['context' => $context] ); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ContainerTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ContainerTest.php index b5c2fbc53e038..06cbc6da3ed25 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ContainerTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ContainerTest.php @@ -14,9 +14,9 @@ public function testPseudoConstruct() { /** @var $block \Magento\Backend\Block\Widget\Grid\Container */ $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Widget\Grid\Container', + \Magento\Backend\Block\Widget\Grid\Container::class, '', [ 'data' => [ @@ -30,7 +30,7 @@ public function testPseudoConstruct() ); $this->assertStringEndsWith('widget', $block->getHeaderCssClass()); $this->assertContains('two', $block->getHeaderText()); - $this->assertInstanceOf('Magento\Backend\Block\Widget\Grid', $block->getChildBlock('grid')); + $this->assertInstanceOf(\Magento\Backend\Block\Widget\Grid::class, $block->getChildBlock('grid')); $this->assertEquals('four', $block->getAddButtonLabel()); $this->assertEquals('five', $block->getBackButtonLabel()); } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ExtendedTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ExtendedTest.php index 6e7786850ee8a..9df6f3c47010d 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ExtendedTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ExtendedTest.php @@ -25,14 +25,14 @@ protected function setUp() parent::setUp(); $this->_layoutMock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $this->_layoutMock] ); $this->_block = $this->_layoutMock->createBlock( - 'Magento\Backend\Block\Widget\Grid\Extended', + \Magento\Backend\Block\Widget\Grid\Extended::class, 'grid', ['context' => $context] ); @@ -47,7 +47,7 @@ protected function setUp() public function testAddColumnAddsChildToColumnSet() { $this->assertInstanceOf( - 'Magento\Backend\Block\Widget\Grid\Column', + \Magento\Backend\Block\Widget\Grid\Column::class, $this->_block->getColumnSet()->getChildBlock('column1') ); $this->assertCount(2, $this->_block->getColumnSet()->getChildNames()); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ItemTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ItemTest.php index 2f3f926b34204..9fdb13a5168da 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ItemTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ItemTest.php @@ -14,11 +14,11 @@ public function testGetAdditionalActionBlock() { /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\Widget\Grid\Massaction\Item */ - $block = $layout->createBlock('Magento\Backend\Block\Widget\Grid\Massaction\Item', 'block'); - $expected = $layout->addBlock('Magento\Framework\View\Element\Template', 'additional_action', 'block'); + $block = $layout->createBlock(\Magento\Backend\Block\Widget\Grid\Massaction\Item::class, 'block'); + $expected = $layout->addBlock(\Magento\Framework\View\Element\Template::class, 'additional_action', 'block'); $this->assertSame($expected, $block->getAdditionalActionBlock()); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/Massaction/AdditionalTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/Massaction/AdditionalTest.php index 4adef697c7b73..0ab7e52e90449 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/Massaction/AdditionalTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/Massaction/AdditionalTest.php @@ -13,7 +13,7 @@ class AdditionalTest extends \PHPUnit_Framework_TestCase public function testToHtml() { $interpreter = $this->getMock( - 'Magento\Framework\View\Layout\Argument\Interpreter\Options', + \Magento\Framework\View\Layout\Argument\Interpreter\Options::class, [], [], '', @@ -23,10 +23,10 @@ public function testToHtml() * @var Additional $block */ $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Backend\Block\Widget\Grid\Massaction\Additional', + \Magento\Backend\Block\Widget\Grid\Massaction\Additional::class, ['optionsInterpreter' => $interpreter] ); - $modelClass = 'Magento\Backend\Block\Widget\Grid\Massaction'; + $modelClass = \Magento\Backend\Block\Widget\Grid\Massaction::class; $data = [ 'fields' => [ 'field1' => ['type' => 'select', 'values' => $modelClass, 'class' => 'custom_class'], diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php index ba37593de9860..1bbf40ca6dc72 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php @@ -33,11 +33,11 @@ protected function setUp() $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Theme\Model\Theme\Registration $registration */ - $registration = $objectManager->get('Magento\Theme\Model\Theme\Registration'); + $registration = $objectManager->get(\Magento\Theme\Model\Theme\Registration::class); $registration->register(); - $objectManager->get('Magento\Framework\View\DesignInterface')->setDesignTheme('BackendTest/test_default'); + $objectManager->get(\Magento\Framework\View\DesignInterface::class)->setDesignTheme('BackendTest/test_default'); $this->_layout = $objectManager->create( - 'Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, ['area' => 'adminhtml'] ); $this->_layout->getUpdate()->load('layout_test_grid_handle'); @@ -58,9 +58,9 @@ public function testMassactionDefaultValues() { /** @var $blockEmpty \Magento\Backend\Block\Widget\Grid\Massaction */ $blockEmpty = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Widget\Grid\Massaction' + \Magento\Backend\Block\Widget\Grid\Massaction::class ); $this->assertEmpty($blockEmpty->getItems()); $this->assertEquals(0, $blockEmpty->getCount()); @@ -164,7 +164,7 @@ public function testGridContainsMassactionColumn() ); $this->assertNotNull($gridMassactionColumn, 'Massaction column does not exist in the grid column set'); $this->assertInstanceOf( - 'Magento\Backend\Block\Widget\Grid\Column', + \Magento\Backend\Block\Widget\Grid\Column::class, $gridMassactionColumn, 'Massaction column is not an instance of \Magento\Backend\Block\Widget\Column' ); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php index 064eab6e34859..4a08e9ce4e096 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php @@ -7,6 +7,7 @@ /** * @magentoAppArea adminhtml + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class GridTest extends \PHPUnit_Framework_TestCase { @@ -27,7 +28,7 @@ class GridTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->_columnSetMock = $this->_getColumnSetMock(); $returnValueMap = [ @@ -56,13 +57,13 @@ protected function setUp() )->method( 'createBlock' )->with( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->will( $this->returnValue( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class ) ) ); @@ -71,17 +72,19 @@ protected function setUp() )->method( 'helper' )->with( - 'Magento\Framework\Json\Helper\Data' + \Magento\Framework\Json\Helper\Data::class )->will( $this->returnValue( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Json\Helper\Data') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Framework\Json\Helper\Data::class + ) ) ); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->createBlock( - 'Magento\Backend\Block\Widget\Grid' + \Magento\Backend\Block\Widget\Grid::class ); $this->_block->setLayout($this->_layoutMock); $this->_block->setNameInLayout('grid'); @@ -96,25 +99,25 @@ protected function _getColumnSetMock() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $directoryList = $objectManager->create( - 'Magento\Framework\App\Filesystem\DirectoryList', + \Magento\Framework\App\Filesystem\DirectoryList::class, ['root' => __DIR__] ); return $this->getMock( - 'Magento\Backend\Block\Widget\Grid\ColumnSet', + \Magento\Backend\Block\Widget\Grid\ColumnSet::class, [], [ $objectManager->create( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [ 'filesystem' => $objectManager->create( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['directoryList' => $directoryList] ) ] ), - $objectManager->create('Magento\Backend\Model\Widget\Grid\Row\UrlGeneratorFactory'), - $objectManager->create('Magento\Backend\Model\Widget\Grid\SubTotals'), - $objectManager->create('Magento\Backend\Model\Widget\Grid\Totals') + $objectManager->create(\Magento\Backend\Model\Widget\Grid\Row\UrlGeneratorFactory::class), + $objectManager->create(\Magento\Backend\Model\Widget\Grid\SubTotals::class), + $objectManager->create(\Magento\Backend\Model\Widget\Grid\Totals::class) ] ); } @@ -140,11 +143,11 @@ public function testGetMassactionBlock() { /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\Widget\Grid */ - $block = $layout->createBlock('Magento\Backend\Block\Widget\Grid\Extended', 'block'); - $child = $layout->addBlock('Magento\Framework\View\Element\Template', 'massaction', 'block'); + $block = $layout->createBlock(\Magento\Backend\Block\Widget\Grid\Extended::class, 'block'); + $child = $layout->addBlock(\Magento\Framework\View\Element\Template::class, 'massaction', 'block'); $this->assertSame($child, $block->getMassactionBlock()); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/TabsTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/TabsTest.php index 0d482314592c6..b8ad783d8a5aa 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/TabsTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/TabsTest.php @@ -17,19 +17,19 @@ public function testAddTab() { /** @var $widgetInstance \Magento\Widget\Model\Widget\Instance */ $widgetInstance = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Widget\Model\Widget\Instance' + \Magento\Widget\Model\Widget\Instance::class ); /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\Registry')->register('current_widget_instance', $widgetInstance); + $objectManager->get(\Magento\Framework\Registry::class)->register('current_widget_instance', $widgetInstance); /** @var $layout \Magento\Framework\View\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); /** @var $block \Magento\Backend\Block\Widget\Tabs */ - $block = $layout->createBlock('Magento\Backend\Block\Widget\Tabs', 'block'); - $layout->addBlock('Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Main', 'child_tab', 'block'); + $block = $layout->createBlock(\Magento\Backend\Block\Widget\Tabs::class, 'block'); + $layout->addBlock(\Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Main::class, 'child_tab', 'block'); $block->addTab('tab_id', 'child_tab'); $this->assertEquals(['tab_id'], $block->getTabsIds()); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/WidgetTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/WidgetTest.php index 8da59b1cb831c..973a7c0147ae1 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/WidgetTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/WidgetTest.php @@ -18,13 +18,13 @@ class WidgetTest extends \PHPUnit_Framework_TestCase public function testGetButtonHtml() { $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE] ); $layout->getUpdate()->load(); $layout->generateXml()->generateElements(); - $widget = $layout->createBlock('Magento\Backend\Block\Widget'); + $widget = $layout->createBlock(\Magento\Backend\Block\Widget::class); $this->assertRegExp( '/[\s\S]*Button Label[\s\S]*<\/button>/iu', @@ -40,13 +40,13 @@ public function testGetButtonHtml() public function testGetButtonHtmlForTwoButtonsInOneBlock() { $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE] ); $layout->getUpdate()->load(); $layout->generateXml()->generateElements(); - $widget = $layout->createBlock('Magento\Backend\Block\Widget'); + $widget = $layout->createBlock(\Magento\Backend\Block\Widget::class); $this->assertRegExp( '/[\s\S]*Button Label[\s\S]*<\/button>/iu', @@ -61,7 +61,8 @@ public function testGetButtonHtmlForTwoButtonsInOneBlock() public function testGetSuffixId() { - $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Backend\Block\Widget'); + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Backend\Block\Widget::class); $this->assertStringEndsNotWith('_test', $block->getSuffixId('suffix')); $this->assertStringEndsWith('_test', $block->getSuffixId('test')); } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php index 0b506d1c770df..d22c42be44cfa 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php @@ -5,5 +5,5 @@ */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class )->turnOffSecretKey(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php index 00b7ec1c13119..c26aad7c6a28f 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php @@ -5,5 +5,5 @@ */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class )->turnOnSecretKey(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php index ca2d96de66aae..3cd95cb69c265 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php @@ -37,10 +37,12 @@ protected function tearDown() protected function _login() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class )->turnOffSecretKey(); - $this->_auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth'); + $this->_auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Backend\Model\Auth::class + ); $this->_auth->login( \Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD @@ -55,7 +57,7 @@ protected function _logout() { $this->_auth->logout(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class )->turnOnSecretKey(); } @@ -68,7 +70,7 @@ public function testNotLoggedLoginAction() $this->dispatch('backend/admin/auth/login'); /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */ $backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class ); $backendUrlModel->turnOffSecretKey(); $url = $backendUrlModel->getUrl('admin'); @@ -87,7 +89,7 @@ public function testLoggedLoginAction() $this->dispatch('backend/admin/auth/login'); /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */ $backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\UrlInterface' + \Magento\Backend\Model\UrlInterface::class ); $url = $backendUrlModel->getStartupPageUrl(); $expected = $backendUrlModel->getUrl($url); @@ -102,7 +104,7 @@ public function testLoggedLoginAction() public function testNotLoggedLoginActionWithRedirect() { /** @var \Magento\Framework\Data\Form\FormKey $formKey */ - $formKey = $this->_objectManager->get('Magento\Framework\Data\Form\FormKey'); + $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class); $this->getRequest()->setPostValue( [ 'login' => [ @@ -116,13 +118,13 @@ public function testNotLoggedLoginActionWithRedirect() $this->dispatch('backend/admin/index/index'); $response = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\ResponseInterface'); + ->get(\Magento\Framework\App\ResponseInterface::class); $code = $response->getHttpResponseCode(); $this->assertTrue($code >= 300 && $code < 400, 'Incorrect response code'); $this->assertTrue( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Model\Auth' + \Magento\Backend\Model\Auth::class )->isLoggedIn() ); } @@ -138,7 +140,7 @@ public function testLogoutAction() $this->assertRedirect( $this->equalTo( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->getHomePageUrl() ) ); @@ -157,7 +159,7 @@ public function testDeniedJsonAction() $data = [ 'ajaxExpired' => 1, 'ajaxRedirect' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->getHomePageUrl(), ]; $expected = json_encode($data); @@ -175,7 +177,7 @@ public function testDeniedIframeAction() $this->_login(); $this->dispatch('backend/admin/auth/deniedIframe'); $homeUrl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->getHomePageUrl(); $expected = ''; $this->_validateButton = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( [ 'label' => __('Validate VAT Number'), diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index 6a03614ba5b5f..5e0e9cb3b077f 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -182,7 +182,7 @@ protected function extractAddress() $this->dataObjectHelper->populateWithArray( $addressDataObject, $addressData, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); $addressDataObject->setRegion($regionDataObject); diff --git a/app/code/Magento/Customer/Controller/Account/Edit.php b/app/code/Magento/Customer/Controller/Account/Edit.php index db54956742ffb..a29237469e869 100644 --- a/app/code/Magento/Customer/Controller/Account/Edit.php +++ b/app/code/Magento/Customer/Controller/Account/Edit.php @@ -73,7 +73,7 @@ public function execute() $this->dataObjectHelper->populateWithArray( $customerDataObject, $data, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); } $this->session->setCustomerData($customerDataObject); diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php index 174ac97ec29c2..a8c566e3b7890 100644 --- a/app/code/Magento/Customer/Controller/Account/LoginPost.php +++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php @@ -76,7 +76,7 @@ private function getScopeConfig() { if (!($this->scopeConfig instanceof \Magento\Framework\App\Config\ScopeConfigInterface)) { return \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); } else { return $this->scopeConfig; diff --git a/app/code/Magento/Customer/Controller/Address.php b/app/code/Magento/Customer/Controller/Address.php index c6d9c8eab60c6..a71ed79a73bda 100644 --- a/app/code/Magento/Customer/Controller/Address.php +++ b/app/code/Magento/Customer/Controller/Address.php @@ -136,7 +136,7 @@ public function dispatch(RequestInterface $request) protected function _buildUrl($route = '', $params = []) { /** @var \Magento\Framework\UrlInterface $urlBuilder */ - $urlBuilder = $this->_objectManager->create('Magento\Framework\UrlInterface'); + $urlBuilder = $this->_objectManager->create(\Magento\Framework\UrlInterface::class); return $urlBuilder->getUrl($route, $params); } } diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index 095fec3511c71..12f318f098128 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -94,7 +94,11 @@ protected function _extractAddress() $existingAddressData = $this->getExistingAddressData(); /** @var \Magento\Customer\Model\Metadata\Form $addressForm */ - $addressForm = $this->_formFactory->create('customer_address', 'customer_address_edit', $existingAddressData); + $addressForm = $this->_formFactory->create( + 'customer_address', + 'customer_address_edit', + $existingAddressData + ); $addressData = $addressForm->extractData($this->getRequest()); $attributeValues = $addressForm->compactData($addressData); @@ -104,7 +108,7 @@ protected function _extractAddress() $this->dataObjectHelper->populateWithArray( $addressDataObject, array_merge($existingAddressData, $attributeValues), - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); $addressDataObject->setCustomerId($this->_getSession()->getCustomerId()) ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false)) @@ -129,7 +133,7 @@ protected function getExistingAddressData() } $existingAddressData = $this->_dataProcessor->buildOutputDataArray( $existingAddress, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); $existingAddressData['region_code'] = $existingAddress->getRegion()->getRegionCode(); $existingAddressData['region'] = $existingAddress->getRegion()->getRegion(); @@ -164,7 +168,7 @@ protected function updateRegionData(&$attributeValues) $this->dataObjectHelper->populateWithArray( $region, $regionData, - '\Magento\Customer\Api\Data\RegionInterface' + \Magento\Customer\Api\Data\RegionInterface::class ); $attributeValues['region'] = $region; } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php index 76119e92f7711..985fb70d0845d 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php @@ -90,7 +90,7 @@ protected function _initData() $this->_quote = $this->quoteFactory->create(); } $this->_quote->setWebsite( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) + $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getWebsite($websiteId) ); $this->_quoteItem = $this->_quote->getItemById($quoteItemId); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Configure.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Configure.php index 65bfd91b08385..e4c320a27795e 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Configure.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Configure.php @@ -22,7 +22,7 @@ public function execute() $quoteItem = $this->_quoteItem; $optionCollection = $this->_objectManager->create( - 'Magento\Quote\Model\Quote\Item\Option' + \Magento\Quote\Model\Quote\Item\Option::class )->getCollection()->addItemFilter( $quoteItem ); @@ -38,7 +38,7 @@ public function execute() $configureResult->setMessage($e->getMessage()); } - return $this->_objectManager->get('Magento\Catalog\Helper\Product\Composite') + return $this->_objectManager->get(\Magento\Catalog\Helper\Product\Composite::class) ->renderConfigureResult($configureResult); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Update.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Update.php index 8093019eb8fa0..42ed2bc30b2db 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Update.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart/Update.php @@ -31,7 +31,7 @@ public function execute() } $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname')); - $this->_objectManager->get('Magento\Backend\Model\Session')->setCompositeProductResult($updateResult); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setCompositeProductResult($updateResult); return $this->resultRedirectFactory->create()->setPath('catalog/product/showUpdateResult'); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php b/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php index aa1cc28382244..cce3adefa3c2f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php @@ -49,7 +49,7 @@ public function execute() ); } - $resultPage->getLayout()->addBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'group', 'content') + $resultPage->getLayout()->addBlock(\Magento\Customer\Block\Adminhtml\Group\Edit::class, 'group', 'content') ->setEditMode((bool)$groupId); return $resultPage; diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php index 40c4d1d8ade15..675a0b830d588 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php @@ -99,7 +99,7 @@ public function execute() $this->storeCustomerGroupDataToSession( $this->dataObjectProcessor->buildOutputDataArray( $customerGroup, - '\Magento\Customer\Api\Data\GroupInterface' + \Magento\Customer\Api\Data\GroupInterface::class ) ); } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php index e8009dd8687a3..f7b15451d2c78 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php @@ -23,15 +23,15 @@ public function execute() $deleteItemId = $this->getRequest()->getPost('delete'); if ($deleteItemId) { /** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ - $quoteRepository = $this->_objectManager->create('Magento\Quote\Api\CartRepositoryInterface'); + $quoteRepository = $this->_objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class); /** @var \Magento\Quote\Model\Quote $quote */ try { $quote = $quoteRepository->getForCustomer($customerId); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $quote = $this->_objectManager->create('\Magento\Quote\Model\QuoteFactory')->create(); + $quote = $this->_objectManager->create(\Magento\Quote\Model\QuoteFactory::class)->create(); } $quote->setWebsite( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) + $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getWebsite($websiteId) ); $item = $quote->getItemById($deleteItemId); if ($item && $item->getId()) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php index b3591cbc79aad..083b975c8ec5f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php @@ -163,7 +163,7 @@ protected function updateCustomer(array $data) $this->dataObjectHelper->populateWithArray( $customer, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); } @@ -182,7 +182,7 @@ protected function updateDefaultBilling(array $data) $this->dataObjectHelper->populateWithArray( $address, $this->processAddressData($data), - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); break; } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Newsletter.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Newsletter.php index 5ee804c5e095e..d3b2df21fb2d2 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Newsletter.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Newsletter.php @@ -17,7 +17,7 @@ public function execute() $customerId = $this->initCurrentCustomer(); /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ $subscriber = $this->_objectManager - ->create('Magento\Newsletter\Model\Subscriber') + ->create(\Magento\Newsletter\Model\Subscriber::class) ->loadByCustomerId($customerId); $this->_coreRegistry->register('subscriber', $subscriber); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php index 26006bfa8dfc8..72b6fd91cde59 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php @@ -211,7 +211,7 @@ public function execute() $this->dataObjectHelper->populateWithArray( $customer, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $addresses = []; foreach ($addressesData as $addressData) { @@ -225,7 +225,7 @@ public function execute() $this->dataObjectHelper->populateWithArray( $addressDataObject, $addressData, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); $addresses[] = $addressDataObject; } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php index 7c1f23881ec3d..c3e925be56ea7 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php @@ -26,12 +26,12 @@ protected function _validateCustomer($response) $customer = $this->customerDataFactory->create(); $customerForm = $this->_formFactory->create( - 'customer', + \customer::class, 'adminhtml_customer', $this->_extensibleDataObjectConverter->toFlatArray( $customer, [], - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ), true ); @@ -46,7 +46,7 @@ protected function _validateCustomer($response) $this->dataObjectHelper->populateWithArray( $customer, $data, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $errors = $this->customerAccountManagement->validate($customer)->getMessages(); } catch (\Magento\Framework\Validator\Exception $exception) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php index af512f7fa9f91..0b437a8857ee0 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php @@ -149,12 +149,12 @@ public function execute() } /** @var \Magento\Framework\Filesystem $filesystem */ - $filesystem = $this->_objectManager->get('Magento\Framework\Filesystem'); + $filesystem = $this->_objectManager->get(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryRead(DirectoryList::MEDIA); $fileName = 'customer' . '/' . ltrim($file, '/'); $path = $directory->getAbsolutePath($fileName); if (!$directory->isFile($fileName) - && !$this->_objectManager->get('Magento\MediaStorage\Helper\File\Storage')->processStorageFile($path) + && !$this->_objectManager->get(\Magento\MediaStorage\Helper\File\Storage::class)->processStorageFile($path) ) { throw new NotFoundException(__('Page not found.')); } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Wishlist.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Wishlist.php index c4a4f7b53baf6..be379e810fc3f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Wishlist.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Wishlist.php @@ -18,9 +18,9 @@ public function execute() $itemId = (int)$this->getRequest()->getParam('delete'); if ($customerId && $itemId) { try { - $this->_objectManager->create('Magento\Wishlist\Model\Item')->load($itemId)->delete(); + $this->_objectManager->create(\Magento\Wishlist\Model\Item::class)->load($itemId)->delete(); } catch (\Exception $exception) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($exception); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($exception); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php index c94f5723f5a08..fdc2f56e73831 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php @@ -19,7 +19,7 @@ abstract class Validatevat extends \Magento\Backend\App\Action */ protected function _validate() { - return $this->_objectManager->get('Magento\Customer\Model\Vat') + return $this->_objectManager->get(\Magento\Customer\Model\Vat::class) ->checkVatNumber( $this->getRequest()->getParam('country'), $this->getRequest()->getParam('vat') diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php index 603dc46a3d956..e3647ad87a058 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php @@ -42,7 +42,7 @@ public function execute() $storeId = (int)$storeId; } - $groupId = $this->_objectManager->get('Magento\Customer\Model\Vat') + $groupId = $this->_objectManager->get(\Magento\Customer\Model\Vat::class) ->getCustomerGroupIdBasedOnVatNumber( $this->getRequest()->getParam('country'), $result, diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php index 60538b010e15d..1c3323d0dd845 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php @@ -47,13 +47,15 @@ protected function _initData() } /* @var $wishlistItem \Magento\Wishlist\Model\Item */ - $wishlistItem = $this->_objectManager->create('Magento\Wishlist\Model\Item')->loadWithOptions($wishlistItemId); + $wishlistItem = $this->_objectManager->create( + \Magento\Wishlist\Model\Item::class + )->loadWithOptions($wishlistItemId); if (!$wishlistItem->getWishlistId()) { throw new CoreException(__('Please load Wish List item.')); } - $this->_wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist') + $this->_wishlist = $this->_objectManager->create(\Magento\Wishlist\Model\Wishlist::class) ->load($wishlistItem->getWishlistId()); $this->_wishlistItem = $wishlistItem; diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Configure.php b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Configure.php index 05874b24b1445..c546bf4416109 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Configure.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Configure.php @@ -32,7 +32,7 @@ public function execute() $configureResult->setMessage($e->getMessage()); } - return $this->_objectManager->get('Magento\Catalog\Helper\Product\Composite') + return $this->_objectManager->get(\Magento\Catalog\Helper\Product\Composite::class) ->renderConfigureResult($configureResult); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Update.php b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Update.php index c275c97d5b026..9f6572c0fcc35 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Update.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist/Update.php @@ -32,7 +32,7 @@ public function execute() $updateResult->setMessage($e->getMessage()); } $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname')); - $this->_objectManager->get('Magento\Backend\Model\Session')->setCompositeProductResult($updateResult); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setCompositeProductResult($updateResult); return $this->resultRedirectFactory->create()->setPath('catalog/product/showUpdateResult'); } } diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php index 2429e45d64341..7292018a6c870 100644 --- a/app/code/Magento/Customer/Model/AccountManagement.php +++ b/app/code/Magento/Customer/Model/AccountManagement.php @@ -837,7 +837,7 @@ protected function createPasswordHash($password) public function validate(CustomerInterface $customer) { $customerData = $this->extensibleDataObjectConverter - ->toFlatArray($customer, [], '\Magento\Customer\Api\Data\CustomerInterface'); + ->toFlatArray($customer, [], \Magento\Customer\Api\Data\CustomerInterface::class); $customerErrors = $this->validator->validateData($customerData, [], 'customer'); $validationResults = $this->validationResultsDataFactory->create(); @@ -1262,7 +1262,7 @@ protected function getFullCustomerObject($customer) // object passed for events $mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId()); $customerData = $this->dataProcessor - ->buildOutputDataArray($customer, '\Magento\Customer\Api\Data\CustomerInterface'); + ->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class); $mergedCustomerData->addData($customerData); $mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer)); return $mergedCustomerData; diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index 0d7638a37196a..fb761e2ac174d 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -124,7 +124,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Customer\Model\ResourceModel\Address'); + $this->_init(\Magento\Customer\Model\ResourceModel\Address::class); } /** @@ -138,7 +138,7 @@ public function updateData(AddressInterface $address) { // Set all attributes $attributes = $this->dataProcessor - ->buildOutputDataArray($address, '\Magento\Customer\Api\Data\AddressInterface'); + ->buildOutputDataArray($address, \Magento\Customer\Api\Data\AddressInterface::class); foreach ($attributes as $attributeCode => $attributeData) { if (AddressInterface::REGION === $attributeCode) { diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 1851f858b992f..340ee38b8d298 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -532,7 +532,7 @@ public function getDataModel($defaultBillingAddressId = null, $defaultShippingAd $this->dataObjectHelper->populateWithArray( $addressDataObject, $addressData, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); if ($addressId) { $addressDataObject->setId($addressId); diff --git a/app/code/Magento/Customer/Model/Address/Config.php b/app/code/Magento/Customer/Model/Address/Config.php index 52f66ee09df8b..cd76fd253f499 100644 --- a/app/code/Magento/Customer/Model/Address/Config.php +++ b/app/code/Magento/Customer/Model/Address/Config.php @@ -16,7 +16,7 @@ */ class Config extends ConfigData { - const DEFAULT_ADDRESS_RENDERER = 'Magento\Customer\Block\Address\Renderer\DefaultRenderer'; + const DEFAULT_ADDRESS_RENDERER = \Magento\Customer\Block\Address\Renderer\DefaultRenderer::class; const XML_PATH_ADDRESS_TEMPLATE = 'customer/address_templates/'; diff --git a/app/code/Magento/Customer/Model/Address/Mapper.php b/app/code/Magento/Customer/Model/Address/Mapper.php index d41cc900d7ae4..2090c6d0f96b7 100644 --- a/app/code/Magento/Customer/Model/Address/Mapper.php +++ b/app/code/Magento/Customer/Model/Address/Mapper.php @@ -39,7 +39,7 @@ public function __construct(ExtensibleDataObjectConverter $extensibleDataObjectC */ public function toFlatArray($addressDataObject) { - $flatAddressArray = $this->extensibleDataObjectConverter->toFlatArray($addressDataObject, [], '\Magento\Customer\Api\Data\AddressInterface'); + $flatAddressArray = $this->extensibleDataObjectConverter->toFlatArray($addressDataObject, [], \Magento\Customer\Api\Data\AddressInterface::class); //preserve street $street = $addressDataObject->getStreet(); if (!empty($street) && is_array($street)) { diff --git a/app/code/Magento/Customer/Model/Attribute.php b/app/code/Magento/Customer/Model/Attribute.php index 751f0ce5212aa..e9df7f6527d62 100644 --- a/app/code/Magento/Customer/Model/Attribute.php +++ b/app/code/Magento/Customer/Model/Attribute.php @@ -118,7 +118,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Customer\Model\ResourceModel\Attribute'); + $this->_init(\Magento\Customer\Model\ResourceModel\Attribute::class); } /** diff --git a/app/code/Magento/Customer/Model/AttributeMetadataConverter.php b/app/code/Magento/Customer/Model/AttributeMetadataConverter.php index 37f6445ed9e16..911a0626589e0 100644 --- a/app/code/Magento/Customer/Model/AttributeMetadataConverter.php +++ b/app/code/Magento/Customer/Model/AttributeMetadataConverter.php @@ -33,6 +33,7 @@ class AttributeMetadataConverter * @var \Magento\Framework\Api\DataObjectHelper */ protected $dataObjectHelper; + /** * Initialize the Converter * @@ -74,7 +75,7 @@ public function createMetadataAttribute($attribute) $this->dataObjectHelper->populateWithArray( $optionObject, $optionArrayValues, - '\Magento\Customer\Api\Data\OptionInterface' + \Magento\Customer\Api\Data\OptionInterface::class ); $optionArray[] = $optionObject; } @@ -92,7 +93,6 @@ public function createMetadataAttribute($attribute) $validationRules[] = $validationRule; } - return $this->attributeMetadataFactory->create()->setAttributeCode($attribute->getAttributeCode()) ->setFrontendInput($attribute->getFrontendInput()) ->setInputFilter((string)$attribute->getInputFilter()) diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index eda08e6574ba8..828632d8c6418 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -284,7 +284,7 @@ public function __construct( */ public function _construct() { - $this->_init('Magento\Customer\Model\ResourceModel\Customer'); + $this->_init(\Magento\Customer\Model\ResourceModel\Customer::class); } /** @@ -304,7 +304,7 @@ public function getDataModel() $this->dataObjectHelper->populateWithArray( $customerDataObject, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $customerDataObject->setAddresses($addressesData) ->setId($this->getId()); @@ -321,7 +321,7 @@ public function updateData($customer) { $customerDataAttributes = $this->dataObjectProcessor->buildOutputDataArray( $customer, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); foreach ($customerDataAttributes as $attributeCode => $attributeData) { diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 8c9811dfd0fed..96d7b3224a743 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -126,7 +126,9 @@ public function __construct( protected function getSession() { if ($this->session === null) { - $this->session = ObjectManager::getInstance()->get('Magento\Framework\Session\SessionManagerInterface'); + $this->session = ObjectManager::getInstance()->get( + \Magento\Framework\Session\SessionManagerInterface::class + ); } return $this->session; } diff --git a/app/code/Magento/Customer/Model/Customer/Mapper.php b/app/code/Magento/Customer/Model/Customer/Mapper.php index 55ca61f088b06..e7671319b00a2 100644 --- a/app/code/Magento/Customer/Model/Customer/Mapper.php +++ b/app/code/Magento/Customer/Model/Customer/Mapper.php @@ -38,7 +38,7 @@ public function __construct(ExtensibleDataObjectConverter $extensibleDataObjectC */ public function toFlatArray(CustomerInterface $customer) { - $flatArray = $this->extensibleDataObjectConverter->toNestedArray($customer, [], '\Magento\Customer\Api\Data\CustomerInterface'); + $flatArray = $this->extensibleDataObjectConverter->toNestedArray($customer, [], \Magento\Customer\Api\Data\CustomerInterface::class); unset($flatArray["addresses"]); return ConvertArray::toFlatArray($flatArray); } diff --git a/app/code/Magento/Customer/Model/CustomerExtractor.php b/app/code/Magento/Customer/Model/CustomerExtractor.php index 56e127def199e..204ca0c2622dd 100644 --- a/app/code/Magento/Customer/Model/CustomerExtractor.php +++ b/app/code/Magento/Customer/Model/CustomerExtractor.php @@ -73,7 +73,7 @@ public function extract($formCode, RequestInterface $request) $this->dataObjectHelper->populateWithArray( $customerDataObject, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $store = $this->storeManager->getStore(); if ($isGroupIdEmpty) { diff --git a/app/code/Magento/Customer/Model/Group.php b/app/code/Magento/Customer/Model/Group.php index 6128e3f7e6f52..b3f7716868e00 100644 --- a/app/code/Magento/Customer/Model/Group.php +++ b/app/code/Magento/Customer/Model/Group.php @@ -96,7 +96,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Customer\Model\ResourceModel\Group'); + $this->_init(\Magento\Customer\Model\ResourceModel\Group::class); } /** diff --git a/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php b/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php index 7237cce2352e1..599d3a863c9b8 100644 --- a/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php @@ -88,7 +88,7 @@ protected function convert(array $attributes, array $fieldset) if ($attribute->getData('is_used_in_grid')) { $fields[$attribute->getName()] = [ 'name' => $attribute->getName(), - 'handler' => 'Magento\Framework\Indexer\Handler\AttributeHandler', + 'handler' => \Magento\Framework\Indexer\Handler\AttributeHandler::class, 'origin' => $attribute->getName(), 'type' => $this->getType($attribute), 'dataType' => $attribute->getBackendType(), diff --git a/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php b/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php index dafe03454131e..173f4badfdae3 100644 --- a/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php +++ b/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php @@ -123,7 +123,7 @@ public function getCustomAttributesMetadata($dataObjectClassName = AddressMetada if (!$this->addressDataObjectMethods) { $dataObjectMethods = array_flip(get_class_methods($dataObjectClassName)); $baseClassDataObjectMethods = array_flip( - get_class_methods('Magento\Framework\Api\AbstractExtensibleObject') + get_class_methods(\Magento\Framework\Api\AbstractExtensibleObject::class) ); $this->addressDataObjectMethods = array_diff_key($dataObjectMethods, $baseClassDataObjectMethods); } diff --git a/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php b/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php index 26ca809a5945e..77d1cc6a0ca7e 100644 --- a/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php +++ b/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php @@ -124,7 +124,7 @@ public function getCustomAttributesMetadata($dataObjectClassName = self::DATA_IN if (!$this->customerDataObjectMethods) { $dataObjectMethods = array_flip(get_class_methods($dataObjectClassName)); $baseClassDataObjectMethods = array_flip( - get_class_methods('Magento\Framework\Api\AbstractExtensibleObject') + get_class_methods(\Magento\Framework\Api\AbstractExtensibleObject::class) ); $this->customerDataObjectMethods = array_diff_key($dataObjectMethods, $baseClassDataObjectMethods); } diff --git a/app/code/Magento/Customer/Model/Metadata/ElementFactory.php b/app/code/Magento/Customer/Model/Metadata/ElementFactory.php index 32773e67cdff5..160676342136a 100644 --- a/app/code/Magento/Customer/Model/Metadata/ElementFactory.php +++ b/app/code/Magento/Customer/Model/Metadata/ElementFactory.php @@ -69,8 +69,8 @@ public function create( 'attribute' => $attribute, ]; /** TODO fix when Validation is implemented MAGETWO-17341 */ - if ($dataModelClass == 'Magento\Customer\Model\Attribute\Data\Postcode') { - $dataModelClass = 'Magento\Customer\Model\Metadata\Form\Postcode'; + if ($dataModelClass == \Magento\Customer\Model\Attribute\Data\Postcode::class) { + $dataModelClass = \Magento\Customer\Model\Metadata\Form\Postcode::class; } if (!empty($dataModelClass)) { $dataModel = $this->_objectManager->create($dataModelClass, $params); diff --git a/app/code/Magento/Customer/Model/Metadata/FormFactory.php b/app/code/Magento/Customer/Model/Metadata/FormFactory.php index d21091bc1a7ee..b2d924553cb38 100644 --- a/app/code/Magento/Customer/Model/Metadata/FormFactory.php +++ b/app/code/Magento/Customer/Model/Metadata/FormFactory.php @@ -49,6 +49,6 @@ public function create( 'filterAttributes' => $filterAttributes, 'isAjax' => $isAjax, ]; - return $this->_objectManager->create('Magento\Customer\Model\Metadata\Form', $params); + return $this->_objectManager->create(\Magento\Customer\Model\Metadata\Form::class, $params); } } diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php index acddd55d0e5c1..b9ced0ac408a2 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php @@ -19,7 +19,7 @@ class Collection extends \Magento\Eav\Model\Entity\Collection\VersionControl\Abs */ protected function _construct() { - $this->_init('Magento\Customer\Model\Address', 'Magento\Customer\Model\ResourceModel\Address'); + $this->_init(\Magento\Customer\Model\Address::class, \Magento\Customer\Model\ResourceModel\Address::class); } /** diff --git a/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php b/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php index ed9b8cd25c2a6..9a7079f08bd7f 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php @@ -154,7 +154,10 @@ public function getList(SearchCriteriaInterface $searchCriteria) /** @var Collection $collection */ $collection = $this->addressCollectionFactory->create(); - $this->extensionAttributesJoinProcessor->process($collection, 'Magento\Customer\Api\Data\AddressInterface'); + $this->extensionAttributesJoinProcessor->process( + $collection, + \Magento\Customer\Api\Data\AddressInterface::class + ); // Add filters from root filter group to the collection foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php index b696992ef56fe..7c9201f64ebb4 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php @@ -16,7 +16,7 @@ class Collection extends \Magento\Eav\Model\Entity\Collection\VersionControl\Abs /** * Name of collection model */ - const CUSTOMER_MODEL_NAME = 'Magento\Customer\Model\Customer'; + const CUSTOMER_MODEL_NAME = \Magento\Customer\Model\Customer::class; /** * @var \Magento\Framework\DataObject\Copy\Config @@ -84,7 +84,7 @@ public function __construct( */ protected function _construct() { - $this->_init($this->_modelName, 'Magento\Customer\Model\ResourceModel\Customer'); + $this->_init($this->_modelName, \Magento\Customer\Model\ResourceModel\Customer::class); } /** diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php index aa57f70439716..4e2bfc8191217 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php @@ -156,7 +156,7 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa $customerData = $this->extensibleDataObjectConverter->toNestedArray( $customer, [], - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $customer->setAddresses($origAddresses); @@ -261,7 +261,10 @@ public function getList(SearchCriteriaInterface $searchCriteria) $searchResults->setSearchCriteria($searchCriteria); /** @var \Magento\Customer\Model\ResourceModel\Customer\Collection $collection */ $collection = $this->customerFactory->create()->getCollection(); - $this->extensionAttributesJoinProcessor->process($collection, 'Magento\Customer\Api\Data\CustomerInterface'); + $this->extensionAttributesJoinProcessor->process( + $collection, + \Magento\Customer\Api\Data\CustomerInterface::class + ); // This is needed to make sure all the attributes are properly loaded foreach ($this->customerMetadata->getAllAttributesMetadata() as $metadata) { $collection->addAttributeToSelect($metadata->getAttributeCode()); diff --git a/app/code/Magento/Customer/Model/ResourceModel/Form/Attribute/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Form/Attribute/Collection.php index 96eb7897f7d14..7715633d253ec 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Form/Attribute/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Form/Attribute/Collection.php @@ -34,7 +34,7 @@ class Collection extends \Magento\Eav\Model\ResourceModel\Form\Attribute\Collect protected function _construct() { parent::_construct(); - $this->_init('Magento\Eav\Model\Attribute', 'Magento\Customer\Model\ResourceModel\Form\Attribute'); + $this->_init(\Magento\Eav\Model\Attribute::class, \Magento\Customer\Model\ResourceModel\Form\Attribute::class); } /** diff --git a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php index 9808f5c0b4186..97c095656c56f 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php @@ -35,7 +35,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'customer_grid_flat', - $resourceModel = '\Magento\Customer\Model\ResourceModel\Customer' + $resourceModel = \Magento\Customer\Model\ResourceModel\Customer::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php index 3c6b7ee168902..fa57ece536983 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php @@ -19,7 +19,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Customer\Model\Group', 'Magento\Customer\Model\ResourceModel\Group'); + $this->_init(\Magento\Customer\Model\Group::class, \Magento\Customer\Model\ResourceModel\Group::class); } /** diff --git a/app/code/Magento/Customer/Model/ResourceModel/Group/Grid/ServiceCollection.php b/app/code/Magento/Customer/Model/ResourceModel/Group/Grid/ServiceCollection.php index 718b8bb87705c..30ed17dce342f 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Group/Grid/ServiceCollection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Group/Grid/ServiceCollection.php @@ -71,7 +71,7 @@ public function loadData($printQuery = false, $logQuery = false) $groups = $searchResults->getItems(); foreach ($groups as $group) { $groupItem = new \Magento\Framework\DataObject(); - $groupItem->addData($this->simpleDataObjectConverter->toFlatArray($group, '\Magento\Customer\Api\Data\GroupInterface')); + $groupItem->addData($this->simpleDataObjectConverter->toFlatArray($group, \Magento\Customer\Api\Data\GroupInterface::class)); $this->_addItem($groupItem); } $this->_setIsLoaded(); diff --git a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php index ca3487ba36ad8..f1cda28c67aea 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php @@ -114,7 +114,7 @@ public function save(\Magento\Customer\Api\Data\GroupInterface $group) $groupModel = $this->groupRegistry->retrieve($group->getId()); $groupDataAttributes = $this->dataObjectProcessor->buildOutputDataArray( $group, - '\Magento\Customer\Api\Data\GroupInterface' + \Magento\Customer\Api\Data\GroupInterface::class ); foreach ($groupDataAttributes as $attributeCode => $attributeData) { $groupModel->setDataUsingMethod($attributeCode, $attributeData); @@ -175,7 +175,7 @@ public function getList(SearchCriteriaInterface $searchCriteria) /** @var \Magento\Customer\Model\ResourceModel\Group\Collection $collection */ $collection = $this->groupFactory->create()->getCollection(); - $groupInterfaceName = 'Magento\Customer\Api\Data\GroupInterface'; + $groupInterfaceName = \Magento\Customer\Api\Data\GroupInterface::class; $this->extensionAttributesJoinProcessor->process($collection, $groupInterfaceName); $collection->addTaxClass(); diff --git a/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php index 44dfa260f06db..9e3f8fab30aaf 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php @@ -14,6 +14,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Customer\Model\Visitor', 'Magento\Customer\Model\ResourceModel\Visitor'); + $this->_init(\Magento\Customer\Model\Visitor::class, \Magento\Customer\Model\ResourceModel\Visitor::class); } } diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php index 6b5898cd6a01b..9337ae482ba8d 100644 --- a/app/code/Magento/Customer/Model/Visitor.php +++ b/app/code/Magento/Customer/Model/Visitor.php @@ -114,7 +114,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Customer\Model\ResourceModel\Visitor'); + $this->_init(\Magento\Customer\Model\ResourceModel\Visitor::class); $userAgent = $this->httpHeader->getHttpUserAgent(); if ($this->ignoredUserAgents) { if (in_array($userAgent, $this->ignoredUserAgents)) { diff --git a/app/code/Magento/Customer/Setup/CustomerSetup.php b/app/code/Magento/Customer/Setup/CustomerSetup.php index dc99278f670c4..c45ace3863f38 100644 --- a/app/code/Magento/Customer/Setup/CustomerSetup.php +++ b/app/code/Magento/Customer/Setup/CustomerSetup.php @@ -16,6 +16,7 @@ /** * @codeCoverageIgnore + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CustomerSetup extends EavSetup { @@ -126,19 +127,19 @@ public function getDefaultEntities() { $entities = [ 'customer' => [ - 'entity_model' => 'Magento\Customer\Model\ResourceModel\Customer', - 'attribute_model' => 'Magento\Customer\Model\Attribute', + 'entity_model' => \Magento\Customer\Model\ResourceModel\Customer::class, + 'attribute_model' => \Magento\Customer\Model\Attribute::class, 'table' => 'customer_entity', - 'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue', + 'increment_model' => \Magento\Eav\Model\Entity\Increment\NumericValue::class, 'additional_attribute_table' => 'customer_eav_attribute', - 'entity_attribute_collection' => 'Magento\Customer\Model\ResourceModel\Attribute\Collection', + 'entity_attribute_collection' => \Magento\Customer\Model\ResourceModel\Attribute\Collection::class, 'attributes' => [ 'website_id' => [ 'type' => 'static', 'label' => 'Associate to Website', 'input' => 'select', - 'source' => 'Magento\Customer\Model\Customer\Attribute\Source\Website', - 'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Website', + 'source' => \Magento\Customer\Model\Customer\Attribute\Source\Website::class, + 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Website::class, 'sort_order' => 10, 'position' => 10, 'adminhtml_only' => 1, @@ -147,8 +148,8 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Create In', 'input' => 'select', - 'source' => 'Magento\Customer\Model\Customer\Attribute\Source\Store', - 'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Store', + 'source' => \Magento\Customer\Model\Customer\Attribute\Source\Store::class, + 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Store::class, 'sort_order' => 20, 'visible' => false, 'adminhtml_only' => 1, @@ -221,7 +222,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Group', 'input' => 'select', - 'source' => 'Magento\Customer\Model\Customer\Attribute\Source\Group', + 'source' => \Magento\Customer\Model\Customer\Attribute\Source\Group::class, 'sort_order' => 25, 'position' => 25, 'adminhtml_only' => 1, @@ -231,8 +232,8 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Date of Birth', 'input' => 'date', - 'frontend' => 'Magento\Eav\Model\Entity\Attribute\Frontend\Datetime', - 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', + 'frontend' => \Magento\Eav\Model\Entity\Attribute\Frontend\Datetime::class, + 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class, 'required' => false, 'sort_order' => 90, 'visible' => false, @@ -245,7 +246,7 @@ public function getDefaultEntities() 'password_hash' => [ 'type' => 'static', 'input' => 'hidden', - 'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Password', + 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Password::class, 'required' => false, 'sort_order' => 81, 'visible' => false, @@ -269,7 +270,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Default Billing Address', 'input' => 'text', - 'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Billing', + 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Billing::class, 'required' => false, 'sort_order' => 82, 'visible' => false, @@ -278,7 +279,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Default Shipping Address', 'input' => 'text', - 'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Shipping', + 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Shipping::class, 'required' => false, 'sort_order' => 83, 'visible' => false, @@ -316,7 +317,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Gender', 'input' => 'select', - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Table', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Table::class, 'required' => false, 'sort_order' => 110, 'visible' => false, @@ -330,7 +331,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Disable Automatic Group Change Based on VAT ID', 'input' => 'boolean', - 'backend' => 'Magento\Customer\Model\Attribute\Backend\Data\Boolean', + 'backend' => \Magento\Customer\Model\Attribute\Backend\Data\Boolean::class, 'position' => 28, 'required' => false, 'adminhtml_only' => true @@ -338,11 +339,12 @@ public function getDefaultEntities() ], ], 'customer_address' => [ - 'entity_model' => 'Magento\Customer\Model\ResourceModel\Address', - 'attribute_model' => 'Magento\Customer\Model\Attribute', + 'entity_model' => \Magento\Customer\Model\ResourceModel\Address::class, + 'attribute_model' => \Magento\Customer\Model\Attribute::class, 'table' => 'customer_address_entity', 'additional_attribute_table' => 'customer_eav_attribute', - 'entity_attribute_collection' => 'Magento\Customer\Model\ResourceModel\Address\Attribute\Collection', + 'entity_attribute_collection' => + \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class, 'attributes' => [ 'prefix' => [ 'type' => 'static', @@ -403,7 +405,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Street Address', 'input' => 'multiline', - 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend', + 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend::class, 'sort_order' => 70, 'multiline_count' => 2, 'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}', @@ -421,7 +423,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Country', 'input' => 'select', - 'source' => 'Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country', + 'source' => \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::class, 'sort_order' => 90, 'position' => 90, ], @@ -429,7 +431,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'State/Province', 'input' => 'text', - 'backend' => 'Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region', + 'backend' => \Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region::class, 'required' => false, 'sort_order' => 100, 'position' => 100, @@ -438,7 +440,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'State/Province', 'input' => 'hidden', - 'source' => 'Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region', + 'source' => \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::class, 'required' => false, 'sort_order' => 100, 'position' => 100, @@ -449,7 +451,7 @@ public function getDefaultEntities() 'input' => 'text', 'sort_order' => 110, 'validate_rules' => 'a:0:{}', - 'data' => 'Magento\Customer\Model\Attribute\Data\Postcode', + 'data' => \Magento\Customer\Model\Attribute\Data\Postcode::class, 'position' => 110, 'required' => false, ], diff --git a/app/code/Magento/Customer/Setup/InstallData.php b/app/code/Magento/Customer/Setup/InstallData.php index 3c87be901389e..1e931be36fcf5 100644 --- a/app/code/Magento/Customer/Setup/InstallData.php +++ b/app/code/Magento/Customer/Setup/InstallData.php @@ -125,7 +125,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'customer_address', 'street', 'backend_model', - 'Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend' + \Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend::class ); $migrationSetup = $setup->createMigrationSetup(); diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php index 4ba511a0c8788..0a84c3992b5b3 100644 --- a/app/code/Magento/Customer/Setup/UpgradeData.php +++ b/app/code/Magento/Customer/Setup/UpgradeData.php @@ -15,6 +15,7 @@ /** * @codeCoverageIgnore + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpgradeData implements UpgradeDataInterface { @@ -370,45 +371,45 @@ private function upgradeVersionTwoZeroSix($customerSetup) $customerSetup->updateEntityType( \Magento\Customer\Model\Customer::ENTITY, 'entity_model', - 'Magento\Customer\Model\ResourceModel\Customer' + \Magento\Customer\Model\ResourceModel\Customer::class ); $customerSetup->updateEntityType( \Magento\Customer\Model\Customer::ENTITY, 'increment_model', - 'Magento\Eav\Model\Entity\Increment\NumericValue' + \Magento\Eav\Model\Entity\Increment\NumericValue::class ); $customerSetup->updateEntityType( \Magento\Customer\Model\Customer::ENTITY, 'entity_attribute_collection', - 'Magento\Customer\Model\ResourceModel\Attribute\Collection' + \Magento\Customer\Model\ResourceModel\Attribute\Collection::class ); $customerSetup->updateEntityType( 'customer_address', 'entity_model', - 'Magento\Customer\Model\ResourceModel\Address' + \Magento\Customer\Model\ResourceModel\Address::class ); $customerSetup->updateEntityType( 'customer_address', 'entity_attribute_collection', - 'Magento\Customer\Model\ResourceModel\Address\Attribute\Collection' + \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class ); $customerSetup->updateAttribute( 'customer_address', 'country_id', 'source_model', - 'Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country' + \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::class ); $customerSetup->updateAttribute( 'customer_address', 'region', 'backend_model', - 'Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region' + \Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region::class ); $customerSetup->updateAttribute( 'customer_address', 'region_id', 'source_model', - 'Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region' + \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::class ); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php index da82f7896a24f..ed639e51b5758 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php @@ -33,18 +33,18 @@ class AuthorizationLinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->httpContext = $this->getMockBuilder('\Magento\Framework\App\Http\Context') + $this->httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); - $this->_customerUrl = $this->getMockBuilder('Magento\Customer\Model\Url') + $this->_customerUrl = $this->getMockBuilder(\Magento\Customer\Model\Url::class) ->disableOriginalConstructor() ->setMethods(['getLogoutUrl', 'getLoginUrl']) ->getMock(); - $context = $this->_objectManager->getObject('Magento\Framework\View\Element\Template\Context'); + $context = $this->_objectManager->getObject(\Magento\Framework\View\Element\Template\Context::class); $this->_block = $this->_objectManager->getObject( - 'Magento\Customer\Block\Account\AuthorizationLink', + \Magento\Customer\Block\Account\AuthorizationLink::class, [ 'context' => $context, 'httpContext' => $this->httpContext, diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php index 41b297d2f48c6..e29f8dea18e41 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php @@ -15,11 +15,11 @@ class CustomerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->httpContext = $this->getMockBuilder('\Magento\Framework\App\Http\Context') + $this->httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->disableOriginalConstructor()->getMock(); $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('\Magento\Customer\Block\Account\Customer', ['httpContext' => $this->httpContext]); + ->getObject(\Magento\Customer\Block\Account\Customer::class, ['httpContext' => $this->httpContext]); } public function customerLoggedInDataProvider() diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php index 3b10c04f80358..5c4fa5db5328c 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php @@ -13,6 +13,7 @@ /** * Test class for \Magento\Customer\Block\Account\Dashboard\Info. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InfoTest extends \PHPUnit_Framework_TestCase { @@ -57,49 +58,49 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->currentCustomer = $this->getMock( - 'Magento\Customer\Helper\Session\CurrentCustomer', + \Magento\Customer\Helper\Session\CurrentCustomer::class, [], [], '', false ); - $urlBuilder = $this->getMockForAbstractClass('Magento\Framework\UrlInterface', [], '', false); + $urlBuilder = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class, [], '', false); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue(self::CHANGE_PASSWORD_URL)); - $layout = $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface', [], '', false); - $this->_formRegister = $this->getMock('Magento\Customer\Block\Form\Register', [], [], '', false); + $layout = $this->getMockForAbstractClass(\Magento\Framework\View\LayoutInterface::class, [], '', false); + $this->_formRegister = $this->getMock(\Magento\Customer\Block\Form\Register::class, [], [], '', false); $layout->expects( - $this->any() - )->method( + $this->any() + )->method( 'getBlockSingleton' )->with( - 'Magento\Customer\Block\Form\Register' + \Magento\Customer\Block\Form\Register::class )->will( $this->returnValue($this->_formRegister) ); - $this->_context = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $this->_context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor()->getMock(); $this->_context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); $this->_context->expects($this->once())->method('getLayout')->will($this->returnValue($layout)); - $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->_customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->_customerSession->expects($this->any())->method('getId')->will($this->returnValue(self::CUSTOMER_ID)); - $this->_customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->_customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->_customer->expects($this->any())->method('getEmail')->will($this->returnValue(self::EMAIL_ADDRESS)); $this->_helperView = $this->getMockBuilder( - '\Magento\Customer\Helper\View' + \Magento\Customer\Helper\View::class )->disableOriginalConstructor()->getMock(); $this->_subscriberFactory = $this->getMock( - 'Magento\Newsletter\Model\SubscriberFactory', + \Magento\Newsletter\Model\SubscriberFactory::class, ['create'], [], '', false ); - $this->_subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); + $this->_subscriber = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); $this->_subscriber->expects($this->any())->method('loadByEmail')->will($this->returnSelf()); $this->_subscriberFactory->expects( $this->any() diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php index 0484a5ecb2033..50f28e1816352 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php @@ -11,18 +11,18 @@ public function testGetHref() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $helper = $this->getMockBuilder( - 'Magento\Customer\Model\Url' + \Magento\Customer\Model\Url::class )->disableOriginalConstructor()->setMethods( ['getAccountUrl'] )->getMock(); $layout = $this->getMockBuilder( - 'Magento\Framework\View\Layout' + \Magento\Framework\View\Layout::class )->disableOriginalConstructor()->setMethods( ['helper'] )->getMock(); $block = $objectManager->getObject( - 'Magento\Customer\Block\Account\Link', + \Magento\Customer\Block\Account\Link::class, ['layout' => $layout, 'customerUrl' => $helper] ); $helper->expects($this->any())->method('getAccountUrl')->will($this->returnValue('account url')); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php index d00e6ae705521..d94640e4b7fae 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php @@ -31,9 +31,9 @@ protected function setUp() */ public function testToHtml($isAuthenticated, $isRegistrationAllowed, $result) { - $context = $this->_objectManager->getObject('Magento\Framework\View\Element\Template\Context'); + $context = $this->_objectManager->getObject(\Magento\Framework\View\Element\Template\Context::class); - $httpContext = $this->getMockBuilder('Magento\Framework\App\Http\Context') + $httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -42,7 +42,7 @@ public function testToHtml($isAuthenticated, $isRegistrationAllowed, $result) ->with(Context::CONTEXT_AUTH) ->will($this->returnValue($isAuthenticated)); - $registrationMock = $this->getMockBuilder('Magento\Customer\Model\Registration') + $registrationMock = $this->getMockBuilder(\Magento\Customer\Model\Registration::class) ->disableOriginalConstructor() ->setMethods(['isAllowed']) ->getMock(); @@ -52,7 +52,7 @@ public function testToHtml($isAuthenticated, $isRegistrationAllowed, $result) /** @var \Magento\Customer\Block\Account\RegisterLink $link */ $link = $this->_objectManager->getObject( - 'Magento\Customer\Block\Account\RegisterLink', + \Magento\Customer\Block\Account\RegisterLink::class, [ 'context' => $context, 'httpContext' => $httpContext, @@ -80,17 +80,17 @@ public function testGetHref() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $helper = $this->getMockBuilder( - 'Magento\Customer\Model\Url' + \Magento\Customer\Model\Url::class )->disableOriginalConstructor()->setMethods( ['getRegisterUrl'] )->getMock(); $helper->expects($this->any())->method('getRegisterUrl')->will($this->returnValue('register url')); - $context = $this->_objectManager->getObject('Magento\Framework\View\Element\Template\Context'); + $context = $this->_objectManager->getObject(\Magento\Framework\View\Element\Template\Context::class); $block = $this->_objectManager->getObject( - 'Magento\Customer\Block\Account\RegisterLink', + \Magento\Customer\Block\Account\RegisterLink::class, ['context' => $context, 'customerUrl' => $helper] ); $this->assertEquals('register url', $block->getHref()); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php index 44110b1d00cb7..82809ee47a7d4 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php @@ -38,7 +38,7 @@ public function setUp() /** @var \Magento\Framework\View\Element\Template\Context | \PHPUnit_Framework_MockObject_MockObject $context */ $context = $this->getMock( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [], [], '', @@ -51,7 +51,7 @@ public function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $objectManager->getObject( - '\Magento\Customer\Block\Account\Resetpassword', + \Magento\Customer\Block\Account\Resetpassword::class, ['context' => $context] ); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php b/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php index d419d159fc9a7..be5c12a647682 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Customer\Test\Unit\Block\Address; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EditTest extends \PHPUnit_Framework_TestCase { /** @@ -56,36 +59,36 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMock(); - $this->addressRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\AddressRepositoryInterface') + $this->addressRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\AddressRepositoryInterface::class) ->getMock(); - $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getAddressFormData', 'getCustomerId']) ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->addressDataFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterfaceFactory') + $this->addressDataFactoryMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterfaceFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->currentCustomerMock = $this->getMockBuilder('Magento\Customer\Helper\Session\CurrentCustomer') + $this->currentCustomerMock = $this->getMockBuilder(\Magento\Customer\Helper\Session\CurrentCustomer::class) ->disableOriginalConstructor() ->getMock(); $this->model = $this->objectManager->getObject( - 'Magento\Customer\Block\Address\Edit', + \Magento\Customer\Block\Address\Edit::class, [ 'request' => $this->requestMock, 'addressRepository' => $this->addressRepositoryMock, @@ -110,7 +113,7 @@ public function testSetLayoutWithOwnAddressAndPostedData() $newPostedData = $postedData; $newPostedData['region'] = $postedData; - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->getMock(); $this->requestMock->expects($this->once()) @@ -118,7 +121,7 @@ public function testSetLayoutWithOwnAddressAndPostedData() ->with('id', null) ->willReturn($addressId); - $addressMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $addressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMock(); $this->addressRepositoryMock->expects($this->once()) ->method('getById') @@ -137,7 +140,7 @@ public function testSetLayoutWithOwnAddressAndPostedData() ->method('getId') ->willReturn($addressId); - $pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $this->pageConfigMock->expects($this->once()) @@ -159,7 +162,7 @@ public function testSetLayoutWithOwnAddressAndPostedData() ->with( $addressMock, $newPostedData, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class )->willReturnSelf(); $this->assertEquals($this->model, $this->model->setLayout($layoutMock)); @@ -181,7 +184,7 @@ public function testSetLayoutWithAlienAddress() $customerSuffix = 'suffix'; $title = __('Add New Address'); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->getMock(); $this->requestMock->expects($this->once()) @@ -189,7 +192,7 @@ public function testSetLayoutWithAlienAddress() ->with('id', null) ->willReturn($addressId); - $addressMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $addressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMock(); $this->addressRepositoryMock->expects($this->once()) ->method('getById') @@ -204,13 +207,13 @@ public function testSetLayoutWithAlienAddress() ->method('getCustomerId') ->willReturn($customerId + 1); - $newAddressMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $newAddressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMock(); $this->addressDataFactoryMock->expects($this->once()) ->method('create') ->willReturn($newAddressMock); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $this->currentCustomerMock->expects($this->once()) ->method('getCustomer') @@ -257,7 +260,7 @@ public function testSetLayoutWithAlienAddress() ->method('getId') ->willReturn(null); - $pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $this->pageConfigMock->expects($this->once()) @@ -282,7 +285,7 @@ public function testSetLayoutWithoutAddressId() $customerSuffix = 'suffix'; $title = 'title'; - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->getMock(); $this->requestMock->expects($this->once()) @@ -290,13 +293,13 @@ public function testSetLayoutWithoutAddressId() ->with('id', null) ->willReturn(''); - $newAddressMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $newAddressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMock(); $this->addressDataFactoryMock->expects($this->once()) ->method('create') ->willReturn($newAddressMock); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $this->currentCustomerMock->expects($this->once()) ->method('getCustomer') @@ -339,7 +342,7 @@ public function testSetLayoutWithoutAddressId() ->with($customerSuffix) ->willReturnSelf(); - $pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $this->pageConfigMock->expects($this->once()) @@ -367,7 +370,7 @@ public function testSetLayoutWithoutAddress() $customerSuffix = 'suffix'; $title = 'title'; - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->getMock(); $this->requestMock->expects($this->once()) @@ -382,13 +385,13 @@ public function testSetLayoutWithoutAddress() \Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', $addressId) ); - $newAddressMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $newAddressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMock(); $this->addressDataFactoryMock->expects($this->once()) ->method('create') ->willReturn($newAddressMock); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $this->currentCustomerMock->expects($this->once()) ->method('getCustomer') @@ -431,7 +434,7 @@ public function testSetLayoutWithoutAddress() ->with($customerSuffix) ->willReturnSelf(); - $pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $this->pageConfigMock->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php index 6304d8a7d1b04..8ef4b576d2cc1 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php @@ -11,6 +11,9 @@ use Magento\Backend\Model\Session; use Magento\Customer\Controller\RegistryConstants; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class NewsletterTest extends \PHPUnit_Framework_TestCase { /** @@ -55,25 +58,25 @@ class NewsletterTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->contextMock = $this->getMock('\Magento\Backend\Block\Template\Context', [], [], '', false); - $this->registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); - $this->formFactoryMock = $this->getMock('\Magento\Framework\Data\FormFactory', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\Block\Template\Context::class, [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->formFactoryMock = $this->getMock(\Magento\Framework\Data\FormFactory::class, [], [], '', false); $this->subscriberFactoryMock = $this->getMock( - '\Magento\Newsletter\Model\SubscriberFactory', + \Magento\Newsletter\Model\SubscriberFactory::class, ['create'], [], '', false ); $this->accountManagementMock = $this->getMock( - '\Magento\Customer\Api\AccountManagementInterface', + \Magento\Customer\Api\AccountManagementInterface::class, [], [], '', false ); - $this->urlBuilderMock = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false); - $this->backendSessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->backendSessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->setMethods(['getCustomerFormData']) ->disableOriginalConstructor() ->getMock(); @@ -100,11 +103,17 @@ public function testInitForm() { $customerId = 1; - $subscriberMock = $this->getMock('\Magento\Newsletter\Model\Subscriber', [], [], '', false); - $fieldsetMock = $this->getMock('\Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false); - $elementMock = $this->getMock('Magento\Framework\Data\Form\Element\Checkbox', ['setIsChecked'], [], '', false); + $subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $fieldsetMock = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false); + $elementMock = $this->getMock( + \Magento\Framework\Data\Form\Element\Checkbox::class, + ['setIsChecked'], + [], + '', + false + ); $formMock = $this->getMock( - '\Magento\Framework\Data\Form', + \Magento\Framework\Data\Form::class, ['setHtmlIdPrefix', 'addFieldset', 'setValues', 'getElement', 'setForm', 'setParent', 'setBaseUrl'], [], '', @@ -151,11 +160,17 @@ public function testInitFormWithCustomerFormData() { $customerId = 1; - $subscriberMock = $this->getMock('\Magento\Newsletter\Model\Subscriber', [], [], '', false); - $fieldsetMock = $this->getMock('\Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false); - $elementMock = $this->getMock('Magento\Framework\Data\Form\Element\Checkbox', ['setIsChecked'], [], '', false); + $subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $fieldsetMock = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false); + $elementMock = $this->getMock( + \Magento\Framework\Data\Form\Element\Checkbox::class, + ['setIsChecked'], + [], + '', + false + ); $formMock = $this->getMock( - '\Magento\Framework\Data\Form', + \Magento\Framework\Data\Form::class, ['setHtmlIdPrefix', 'addFieldset', 'setValues', 'getElement', 'setForm', 'setParent', 'setBaseUrl'], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php index 53771c35d33f8..1b867d854af90 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php @@ -24,7 +24,7 @@ public function configure($amountOption, $withoutOptions = false) ]; } - $product = $this->getMock('Magento\Catalog\Model\Product', ['getTypeId', 'getName'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getTypeId', 'getName'], [], '', false); $product ->expects($this->once()) ->method('getTypeId') @@ -34,17 +34,29 @@ public function configure($amountOption, $withoutOptions = false) ->method('getName') ->will($this->returnValue('testProductName')); - $this->item = $this->getMock('Magento\Wishlist\Model\Item', ['getProduct'], [], '', false); + $this->item = $this->getMock(\Magento\Wishlist\Model\Item::class, ['getProduct'], [], '', false); $this->item ->expects($this->atLeastOnce()) ->method('getProduct') ->will($this->returnValue($product)); - $productConfig = $this->getMock('Magento\Catalog\Helper\Product\Configuration', null, [], '', false); - $productConfigPool = $this->getMock('Magento\Catalog\Helper\Product\ConfigurationPool', ['get'], [], '', false); + $productConfig = $this->getMock(\Magento\Catalog\Helper\Product\Configuration::class, null, [], '', false); + $productConfigPool = $this->getMock( + \Magento\Catalog\Helper\Product\ConfigurationPool::class, + ['get'], + [], + '', + false + ); - $helper = $this->getMock('Magento\Bundle\Helper\Catalog\Product\Configuration', ['getOptions'], [], '', false); - $escaper = $this->getMock('Magento\Framework\Escaper', ['escapeHtml'], [], '', false); + $helper = $this->getMock( + \Magento\Bundle\Helper\Catalog\Product\Configuration::class, + ['getOptions'], + [], + '', + false + ); + $escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); if ($withoutOptions) { $helper ->expects($this->once()) @@ -74,7 +86,7 @@ public function configure($amountOption, $withoutOptions = false) } } - $context = $this->getMock('Magento\Backend\Block\Context', ['getEscaper'], [], '', false); + $context = $this->getMock(\Magento\Backend\Block\Context::class, ['getEscaper'], [], '', false); $context ->expects($this->once()) ->method('getEscaper') @@ -83,7 +95,7 @@ public function configure($amountOption, $withoutOptions = false) $productConfigPool ->expects($this->once()) ->method('get') - ->with('Magento\Catalog\Helper\Product\Configuration') + ->with(\Magento\Catalog\Helper\Product\Configuration::class) ->will($this->returnValue($helper)); $this->itemBlock = new \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer\Item( diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php index 0feeba3669c10..f0d56d5b09925 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php @@ -10,6 +10,8 @@ /** * Customer personal information template block test. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PersonalInfoTest extends \PHPUnit_Framework_TestCase { @@ -60,7 +62,7 @@ class PersonalInfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $customer = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', @@ -70,7 +72,7 @@ protected function setUp() $customer->expects($this->any())->method('getStoreId')->willReturn(1); $customerDataFactory = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create'], [], '', @@ -79,7 +81,7 @@ protected function setUp() $customerDataFactory->expects($this->any())->method('create')->willReturn($customer); $backendSession = $this->getMock( - 'Magento\Backend\Model\Session', + \Magento\Backend\Model\Session::class, ['getCustomerData'], [], '', @@ -88,7 +90,7 @@ protected function setUp() $backendSession->expects($this->any())->method('getCustomerData')->willReturn(['account' => []]); $this->customerLog = $this->getMock( - 'Magento\Customer\Model\Log', + \Magento\Customer\Model\Log::class, ['getLastLoginAt', 'getLastVisitAt', 'getLastLogoutAt'], [], '', @@ -97,7 +99,7 @@ protected function setUp() $this->customerLog->expects($this->any())->method('loadByCustomer')->willReturnSelf(); $customerLogger = $this->getMock( - 'Magento\Customer\Model\Logger', + \Magento\Customer\Model\Logger::class, ['get'], [], '', @@ -106,7 +108,7 @@ protected function setUp() $customerLogger->expects($this->any())->method('get')->willReturn($this->customerLog); $dateTime = $this->getMock( - 'Magento\Framework\Stdlib\DateTime', + \Magento\Framework\Stdlib\DateTime::class, ['now'], [], '', @@ -115,7 +117,7 @@ protected function setUp() $dateTime->expects($this->any())->method('now')->willReturn('2015-03-04 12:00:00'); $this->localeDate = $this->getMock( - 'Magento\Framework\Stdlib\DateTime\Timezone', + \Magento\Framework\Stdlib\DateTime\Timezone::class, ['scopeDate', 'formatDateTime', 'getDefaultTimezonePath'], [], '', @@ -127,21 +129,21 @@ protected function setUp() ->willReturn($this->pathToDefaultTimezone); $this->scopeConfig = $this->getMock( - 'Magento\Framework\App\Config', + \Magento\Framework\App\Config::class, ['getValue'], [], '', false ); $this->customerRegistry = $this->getMock( - 'Magento\Customer\Model\CustomerRegistry', + \Magento\Customer\Model\CustomerRegistry::class, ['retrieve'], [], '', false ); $this->customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['isCustomerLocked'], [], '', @@ -151,7 +153,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $objectManagerHelper->getObject( - 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo', + \Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo::class, [ 'customerDataFactory' => $customerDataFactory, 'dateTime' => $dateTime, diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php index 03fa064970086..108ed908514f4 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php @@ -20,11 +20,11 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $registry = $this->getMock('Magento\Framework\Registry'); + $registry = $this->getMock(\Magento\Framework\Registry::class); $objectManagerHelper = new ObjectManagerHelper($this); $this->view = $objectManagerHelper->getObject( - 'Magento\Customer\Block\Adminhtml\Edit\Tab\View', + \Magento\Customer\Block\Adminhtml\Edit\Tab\View::class, [ 'registry' => $registry ] diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php index fe25b36f700fa..7cd1d79f2c948 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php @@ -48,35 +48,35 @@ class UnlockButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Backend\Block\Widget\Context', + \Magento\Backend\Block\Widget\Context::class, [], [], '', false ); $this->customerRegistryMock = $this->getMock( - 'Magento\Customer\Model\CustomerRegistry', + \Magento\Customer\Model\CustomerRegistry::class, ['retrieve'], [], '', false ); $this->customerModelMock = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, [], [], '', false ); $this->registryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, ['registry'], [], '', false ); - $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->setMethods(['getUrl']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -84,7 +84,7 @@ protected function setUp() $objectManagerHelper = new ObjectManagerHelper($this); $this->block = $objectManagerHelper->getObject( - 'Magento\Customer\Block\Adminhtml\Edit\UnlockButton', + \Magento\Customer\Block\Adminhtml\Edit\UnlockButton::class, [ 'context' => $this->contextMock, 'customerRegistry' => $this->customerRegistryMock, diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php index fe5158991f284..37bcdb5a5ae2c 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php @@ -28,14 +28,14 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->backendHelperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->backendHelperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface') + $this->urlEncoder = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); $this->image = $objectManager->getObject( - 'Magento\Customer\Block\Adminhtml\Form\Element\Image', + \Magento\Customer\Block\Adminhtml\Form\Element\Image::class, [ 'adminhtmlData' => $this->backendHelperMock, 'urlEncoder' => $this->urlEncoder, @@ -47,7 +47,7 @@ public function testGetPreviewFile() { $value = 'image.jpg'; $url = 'http://example.com/backend/customer/index/viewfile/' . $value; - $formMock = $this->getMockBuilder('Magento\Framework\Data\Form') + $formMock = $this->getMockBuilder(\Magento\Framework\Data\Form::class) ->disableOriginalConstructor() ->getMock(); $this->image->setForm($formMock); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php index 8ed052bffd432..dd1fa910aa493 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php @@ -35,7 +35,7 @@ public function setUp() /** @var \Magento\Framework\View\Element\Template\Context | \PHPUnit_Framework_MockObject_MockObject $context */ $context = $this->getMock( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [], [], '', @@ -48,7 +48,7 @@ public function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $objectManager->getObject( - '\Magento\Customer\Block\Form\Edit', + \Magento\Customer\Block\Form\Edit::class, ['context' => $context] ); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php index def45459ac1da..078613f2cac8d 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php @@ -30,23 +30,23 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerUrl = $this->getMockBuilder( - 'Magento\Customer\Model\Url' + \Magento\Customer\Model\Url::class )->disableOriginalConstructor()->setMethods( ['getRegisterUrl'] )->getMock(); $this->checkoutData = $this->getMockBuilder( - 'Magento\Checkout\Helper\Data' + \Magento\Checkout\Helper\Data::class )->disableOriginalConstructor()->setMethods( ['isContextCheckout'] )->getMock(); $this->coreUrl = $this->getMockBuilder( - 'Magento\Framework\Url\Helper\Data' + \Magento\Framework\Url\Helper\Data::class )->disableOriginalConstructor()->setMethods( ['addRequestParam'] )->getMock(); $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Customer\Block\Form\Login\Info', + \Magento\Customer\Block\Form\Login\Info::class, [ 'customerUrl' => $this->customerUrl, 'checkoutData' => $this->checkoutData, diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php index 2fa52d6552865..c1cb0da772cf9 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php @@ -10,6 +10,8 @@ /** * Test class for \Magento\Customer\Block\Form\Register. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class RegisterTest extends \PHPUnit_Framework_TestCase { @@ -48,27 +50,27 @@ class RegisterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->_moduleManager = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); - $this->directoryHelperMock = $this->getMock('Magento\Directory\Helper\Data', [], [], '', false); - $this->_customerUrl = $this->getMock('Magento\Customer\Model\Url', [], [], '', false); + $this->_scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_moduleManager = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); + $this->directoryHelperMock = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false); + $this->_customerUrl = $this->getMock(\Magento\Customer\Model\Url::class, [], [], '', false); $this->_customerSession = $this->getMock( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, ['getCustomerFormData'], [], '', false ); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any())->method('getScopeConfig')->will($this->returnValue($this->_scopeConfig)); $this->_block = new \Magento\Customer\Block\Form\Register( $context, $this->directoryHelperMock, - $this->getMockForAbstractClass('Magento\Framework\Json\EncoderInterface', [], '', false), - $this->getMock('Magento\Framework\App\Cache\Type\Config', [], [], '', false), - $this->getMock('Magento\Directory\Model\ResourceModel\Region\CollectionFactory', [], [], '', false), - $this->getMock('Magento\Directory\Model\ResourceModel\Country\CollectionFactory', [], [], '', false), + $this->getMockForAbstractClass(\Magento\Framework\Json\EncoderInterface::class, [], '', false), + $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false), + $this->getMock(\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class, [], [], '', false), + $this->getMock(\Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class, [], [], '', false), $this->_moduleManager, $this->_customerSession, $this->_customerUrl @@ -320,8 +322,8 @@ public function testRestoreSessionData() )->will( $this->returnValue($customerFormData) ); - $form = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false); - $request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface', [], '', false); + $form = $this->getMock(\Magento\Customer\Model\Metadata\Form::class, [], [], '', false); + $request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false); $formData = $this->_block->getFormData(); $form->expects( $this->once() diff --git a/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php b/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php index 943165fe33c5e..64b8e78e010da 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php @@ -21,9 +21,12 @@ class NewsletterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilder = $this->getMock('\Magento\Framework\UrlInterface'); + $this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $helper->getObject('Magento\Customer\Block\Newsletter', ['urlBuilder' => $this->urlBuilder]); + $this->block = $helper->getObject( + \Magento\Customer\Block\Newsletter::class, + ['urlBuilder' => $this->urlBuilder] + ); } public function testGetAction() diff --git a/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php b/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php index 0f802752cadf5..844dd3b19267d 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php @@ -26,13 +26,13 @@ class SectionConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->sectionConfig = $this->getMock('Magento\Framework\Config\DataInterface'); - $this->encoder = $this->getMock('Magento\Framework\Json\EncoderInterface'); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->sectionConfig = $this->getMock(\Magento\Framework\Config\DataInterface::class); + $this->encoder = $this->getMock(\Magento\Framework\Json\EncoderInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->block = $this->objectManagerHelper->getObject( - 'Magento\Customer\Block\SectionConfig', + \Magento\Customer\Block\SectionConfig::class, [ 'context' => $this->context, 'sectionConfig' => $this->sectionConfig diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php index 9bfb3799eaacb..9e8c94262f8c8 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php @@ -26,12 +26,12 @@ class AbstractWidgetTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_addressHelper = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); + $this->_addressHelper = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); $this->_block = new \Magento\Customer\Block\Widget\AbstractWidget( - $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false), + $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false), $this->_addressHelper, - $this->getMockBuilder('\Magento\Customer\Api\CustomerMetadataInterface')->getMockForAbstractClass() + $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class)->getMockForAbstractClass() ); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php index ec39a2dcea529..77ea6137d7498 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php @@ -12,6 +12,9 @@ use Magento\Customer\Block\Widget\Dob; use Magento\Framework\Locale\Resolver; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DobTest extends \PHPUnit_Framework_TestCase { /** Constants used in the unit tests */ @@ -62,31 +65,31 @@ protected function setUp() $zendCacheCore->setBackend(new \Zend_Cache_Backend_BlackHole()); $frontendCache = $this->getMockForAbstractClass( - 'Magento\Framework\Cache\FrontendInterface', + \Magento\Framework\Cache\FrontendInterface::class, [], '', false ); $frontendCache->expects($this->any())->method('getLowLevelFrontend')->will($this->returnValue($zendCacheCore)); - $cache = $this->getMock('Magento\Framework\App\CacheInterface'); + $cache = $this->getMock(\Magento\Framework\App\CacheInterface::class); $cache->expects($this->any())->method('getFrontend')->will($this->returnValue($frontendCache)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $localeResolver = $this->getMock('\Magento\Framework\Locale\ResolverInterface'); + $localeResolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); $localeResolver->expects($this->any()) ->method('getLocale') ->willReturn(Resolver::DEFAULT_LOCALE); $timezone = $objectManager->getObject( - 'Magento\Framework\Stdlib\DateTime\Timezone', + \Magento\Framework\Stdlib\DateTime\Timezone::class, ['localeResolver' => $localeResolver] ); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timezone)); - $this->attribute = $this->getMockBuilder('\Magento\Customer\Api\Data\AttributeMetadataInterface') + $this->attribute = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); - $this->customerMetadata = $this->getMockBuilder('\Magento\Customer\Api\CustomerMetadataInterface') + $this->customerMetadata = $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class) ->getMockForAbstractClass(); $this->customerMetadata->expects($this->any()) ->method('getAttributeMetadata') @@ -94,15 +97,15 @@ protected function setUp() date_default_timezone_set('America/Los_Angeles'); - $this->filterFactory = $this->getMockBuilder('Magento\Framework\Data\Form\FilterFactory') + $this->filterFactory = $this->getMockBuilder(\Magento\Framework\Data\Form\FilterFactory::class) ->disableOriginalConstructor() ->getMock(); $this->_block = new \Magento\Customer\Block\Widget\Dob( $context, - $this->getMock('Magento\Customer\Helper\Address', [], [], '', false), + $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false), $this->customerMetadata, - $this->getMock('Magento\Framework\View\Element\Html\Date', [], [], '', false), + $this->getMock(\Magento\Framework\View\Element\Html\Date::class, [], [], '', false), $this->filterFactory ); } @@ -208,7 +211,7 @@ public function testSetDateWithFilter() ->method('getInputFilter') ->willReturn($filterCode); - $filterMock = $this->getMockBuilder('Magento\Framework\Data\Form\Filter\Date') + $filterMock = $this->getMockBuilder(\Magento\Framework\Data\Form\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $filterMock->expects($this->once()) @@ -346,12 +349,12 @@ public function testGetMinDateRange($validationRules, $expectedValue) */ public function getMinDateRangeDataProvider() { - $emptyValidationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $emptyValidationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); - $validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); @@ -416,12 +419,12 @@ public function testGetMaxDateRange($validationRules, $expectedValue) */ public function getMaxDateRangeDataProvider() { - $emptyValidationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $emptyValidationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); - $validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php index 3a42e62a1d364..0c86298a1848f 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php @@ -38,10 +38,10 @@ class GenderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attribute = $this->getMockBuilder('\Magento\Customer\Api\Data\AttributeMetadataInterface') + $this->attribute = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); - $this->customerMetadata = $this->getMockBuilder('\Magento\Customer\Api\CustomerMetadataInterface') + $this->customerMetadata = $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class) ->getMockForAbstractClass(); $this->customerMetadata->expects($this->any()) ->method('getAttributeMetadata') @@ -49,13 +49,13 @@ protected function setUp() ->will($this->returnValue($this->attribute)); $this->customerRepository = $this - ->getMockBuilder('\Magento\Customer\Api\CustomerRepositoryInterface') + ->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->block = new \Magento\Customer\Block\Widget\Gender( - $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false), - $this->getMock('Magento\Customer\Helper\Address', [], [], '', false), + $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false), + $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false), $this->customerMetadata, $this->customerRepository, $this->customerSession @@ -150,7 +150,7 @@ public function testIsRequiredWithException() */ public function testGetCustomer() { - $customerData = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerData = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue(1)); $this->customerRepository diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php index 5e11d60040d19..500896b921a9e 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php @@ -14,6 +14,8 @@ /** * Test class for \Magento\Customer\Block\Widget\Name. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class NameTest extends \PHPUnit_Framework_TestCase { @@ -72,17 +74,17 @@ class NameTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_escaper = $this->getMock('Magento\Framework\Escaper', [], [], '', false); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $this->_escaper = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->_escaper)); - $addressHelper = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); + $addressHelper = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); - $this->_options = $this->getMock('Magento\Customer\Model\Options', [], [], '', false); + $this->_options = $this->getMock(\Magento\Customer\Model\Options::class, [], [], '', false); - $this->attribute = $this->getMockBuilder('\Magento\Customer\Api\Data\AttributeMetadataInterface') + $this->attribute = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); - $this->customerMetadata = $this->getMockBuilder('\Magento\Customer\Api\CustomerMetadataInterface') + $this->customerMetadata = $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class) ->getMockForAbstractClass(); $this->customerMetadata->expects($this->any()) ->method('getAttributeMetadata') @@ -92,7 +94,7 @@ protected function setUp() ->method('getCustomAttributesMetadata') ->will($this->returnValue([])); - $this->addressMetadata = $this->getMockBuilder('\Magento\Customer\Api\AddressMetadataInterface') + $this->addressMetadata = $this->getMockBuilder(\Magento\Customer\Api\AddressMetadataInterface::class) ->getMockForAbstractClass(); $this->addressMetadata->expects($this->any()) ->method('getAttributeMetadata') @@ -208,7 +210,9 @@ public function testGetPrefixOptionsNotEmpty() * Added some padding so that the trim() call on Customer::getPrefix() will remove it. Also added * special characters so that the escapeHtml() method returns a htmlspecialchars translated value. */ - $customer = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customer = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterface::class)->getMockForAbstractClass( + ); $customer->expects($this->once())->method('getPrefix')->willReturn(' <' . self::PREFIX . '> '); $this->_block->setObject($customer); @@ -233,7 +237,9 @@ public function testGetPrefixOptionsNotEmpty() public function testGetPrefixOptionsEmpty() { - $customer = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customer = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterface::class)->getMockForAbstractClass( + ); $this->_block->setObject($customer); $this->_options->expects( @@ -253,7 +259,9 @@ public function testGetSuffixOptionsNotEmpty() * Added padding and special characters to show that trim() works on Customer::getSuffix() and that * a properly htmlspecialchars translated value is returned. */ - $customer = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customer = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterface::class)->getMockForAbstractClass( + ); $customer->expects($this->once())->method('getSuffix')->willReturn(' <' . self::SUFFIX . '> '); $this->_block->setObject($customer); @@ -277,7 +285,9 @@ public function testGetSuffixOptionsNotEmpty() public function testGetSuffixOptionsEmpty() { - $customer = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customer = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterface::class)->getMockForAbstractClass( + ); $this->_block->setObject($customer); $this->_options->expects( @@ -414,7 +424,7 @@ public function testGetStoreLabelWithException() */ private function _setUpShowAttribute(array $data) { - $customer = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); /** diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php index dc685adf2d5de..4f411ce2118cb 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php @@ -31,9 +31,9 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attribute = $this->getMockBuilder('\Magento\Customer\Api\Data\AttributeMetadataInterface') + $this->attribute = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); - $this->customerMetadata = $this->getMockBuilder('\Magento\Customer\Api\CustomerMetadataInterface') + $this->customerMetadata = $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class) ->getMockForAbstractClass(); $this->customerMetadata->expects( $this->any() @@ -46,8 +46,8 @@ protected function setUp() ); $this->_block = new \Magento\Customer\Block\Widget\Taxvat( - $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false), - $this->getMock('Magento\Customer\Helper\Address', [], [], '', false), + $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false), + $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false), $this->customerMetadata ); } diff --git a/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php b/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php index 01fb316feb273..537c481b2327e 100644 --- a/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php +++ b/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php @@ -29,7 +29,7 @@ class UpgradeHashAlgorithmCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerCollectionFactory = $this->getMockBuilder( - 'Magento\Customer\Model\ResourceModel\Customer\CollectionFactory' + \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class )->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -37,7 +37,7 @@ protected function setUp() $this->objectManager = new ObjectManager($this); $this->command = $this->objectManager->getObject( - 'Magento\Customer\Console\Command\UpgradeHashAlgorithmCommand', + \Magento\Customer\Console\Command\UpgradeHashAlgorithmCommand::class, [ 'customerCollectionFactory' => $this->customerCollectionFactory ] diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php index 280de574814f8..4911187bff631 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php @@ -100,37 +100,43 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); $this->responseMock = $this->getMock( - 'Magento\Framework\App\Response\Http', ['setRedirect', '__wakeup'], [], '', false + \Magento\Framework\App\Response\Http::class, ['setRedirect', '__wakeup'], [], '', false ); - $viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); + $viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->urlMock = $this->getMock('Magento\Framework\Url', [], [], '', false); - $urlFactoryMock = $this->getMock('Magento\Framework\UrlFactory', [], [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); + $urlFactoryMock = $this->getMock(\Magento\Framework\UrlFactory::class, [], [], '', false); $urlFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->urlMock)); $this->customerAccountManagementMock = - $this->getMockForAbstractClass('Magento\Customer\Api\AccountManagementInterface'); + $this->getMockForAbstractClass(\Magento\Customer\Api\AccountManagementInterface::class); $this->customerDataMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterface', [], [], '', false + \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false ); $this->customerRepositoryMock = - $this->getMockForAbstractClass('Magento\Customer\Api\CustomerRepositoryInterface'); - - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); - $this->addressHelperMock = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $this->redirectResultMock = $this->getMock('Magento\Framework\Controller\Result\Redirect', [], [], '', false); + $this->getMockForAbstractClass(\Magento\Customer\Api\CustomerRepositoryInterface::class); + + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->redirectResultMock = $this->getMock( + \Magento\Framework\Controller\Result\Redirect::class, + [], + [], + '', + false + ); $resultFactoryMock = $this->getMock( - 'Magento\Framework\Controller\ResultFactory', + \Magento\Framework\Controller\ResultFactory::class, ['create'], [], '', @@ -141,8 +147,8 @@ protected function setUp() ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($this->redirectResultMock); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->contextMock = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $this->contextMock->expects($this->any()) ->method('getRequest') ->willReturn($this->requestMock); @@ -165,7 +171,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Customer\Controller\Account\Confirm', + \Magento\Customer\Controller\Account\Confirm::class, [ 'context' => $this->contextMock, 'customerSession' => $this->customerSessionMock, @@ -190,7 +196,7 @@ public function testIsLoggedIn() ->with('*/*/') ->willReturnSelf(); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->model->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $this->model->execute()); } /** @@ -232,7 +238,7 @@ public function testNoCustomerIdInRequest($customerId, $key) ->with($this->equalTo($testUrl)) ->willReturnSelf(); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->model->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $this->model->execute()); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php index fd23bda52c170..99f3b546eca71 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php @@ -8,6 +8,9 @@ use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CreatePasswordTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Controller\Account\CreatePassword */ @@ -36,26 +39,26 @@ class CreatePasswordTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['setRpToken', 'setRpCustomerId', 'getRpToken', 'getRpCustomerId']) ->getMock(); - $this->pageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->pageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->accountManagementMock = $this->getMockBuilder('Magento\Customer\Api\AccountManagementInterface') + $this->accountManagementMock = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class) ->getMockForAbstractClass(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMockForAbstractClass(); - $this->redirectFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->redirectFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RedirectFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( - 'Magento\Customer\Controller\Account\CreatePassword', + \Magento\Customer\Controller\Account\CreatePassword::class, [ 'customerSession' => $this->sessionMock, 'resultPageFactory' => $this->pageFactoryMock, @@ -94,7 +97,7 @@ public function testExecuteWithLink() ->with($customerId); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -138,7 +141,7 @@ public function testExecuteWithSession() ->willReturn(true); /** @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject $pageMock */ - $pageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $pageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); @@ -148,7 +151,7 @@ public function testExecuteWithSession() ->willReturn($pageMock); /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject $layoutMock */ - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->getMock(); @@ -157,7 +160,7 @@ public function testExecuteWithSession() ->willReturn($layoutMock); /** @var \Magento\Customer\Block\Account\Resetpassword|\PHPUnit_Framework_MockObject_MockObject $layoutMock */ - $blockMock = $this->getMockBuilder('Magento\Customer\Block\Account\Resetpassword') + $blockMock = $this->getMockBuilder(\Magento\Customer\Block\Account\Resetpassword::class) ->disableOriginalConstructor() ->setMethods(['setCustomerId', 'setResetPasswordLinkToken']) ->getMock(); @@ -211,7 +214,7 @@ public function testExecuteWithException() ->willReturnSelf(); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php index a267c07241420..ab6bf9ac5ff96 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php @@ -140,72 +140,79 @@ protected function setUp() * For now the \Magento\Customer\Test\Unit\Controller\AccountTest sufficiently covers the SUT */ $this->markTestSkipped('Cannot be unit tested with the auto generated builder dependencies'); - $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); - $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); - $this->responseMock = $this->getMock('Magento\Framework\Webapi\Response'); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->responseMock = $this->getMock(\Magento\Framework\Webapi\Response::class); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\Url', [], [], '', false); - $urlFactoryMock = $this->getMock('Magento\Framework\UrlFactory', [], [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); + $urlFactoryMock = $this->getMock(\Magento\Framework\UrlFactory::class, [], [], '', false); $urlFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->urlMock)); - $this->customerMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterface', + $this->customerMock = $this->getMock( + \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false ); - $this->customerDetailsMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterface', [], [], '', false + $this->customerDetailsMock = $this->getMock( + \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false ); - $this->customerDetailsFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', [], [], '', false + $this->customerDetailsFactoryMock = $this->getMock( + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, [], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->customerRepository = $this->getMock('Magento\Customer\Api\CustomerRepositoryInterface'); - $this->accountManagement = $this->getMock('Magento\Customer\Api\AccountManagementInterface'); - $this->addressHelperMock = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); - $formFactoryMock = $this->getMock('Magento\Customer\Model\Metadata\FormFactory', [], [], '', false); + $this->customerRepository = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->accountManagement = $this->getMock(\Magento\Customer\Api\AccountManagementInterface::class); + $this->addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $formFactoryMock = $this->getMock(\Magento\Customer\Model\Metadata\FormFactory::class, [], [], '', false); - $this->subscriberMock = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); - $subscriberFactoryMock = $this->getMock( - 'Magento\Newsletter\Model\SubscriberFactory', ['create'], [], '', false + $this->subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $subscriberFactoryMock = $this->getMock( + \Magento\Newsletter\Model\SubscriberFactory::class, ['create'], [], '', false ); $subscriberFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->subscriberMock)); - $regionFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\RegionInterfaceFactory', [], [], '', false + $regionFactoryMock = $this->getMock( + \Magento\Customer\Api\Data\RegionInterfaceFactory::class, [], [], '', false ); - $addressFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\AddressInterfaceFactory', [], [], '', false + $addressFactoryMock = $this->getMock( + \Magento\Customer\Api\Data\AddressInterfaceFactory::class, [], [], '', false ); - $this->customerUrl = $this->getMock('Magento\Customer\Model\Url', [], [], '', false); - $this->registration = $this->getMock('Magento\Customer\Model\Registration', [], [], '', false); - $escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); - $this->customerExtractorMock = $this->getMock('Magento\Customer\Model\CustomerExtractor', [], [], '', false); - $this->dataObjectHelperMock = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->customerUrl = $this->getMock(\Magento\Customer\Model\Url::class, [], [], '', false); + $this->registration = $this->getMock(\Magento\Customer\Model\Registration::class, [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $this->customerExtractorMock = $this->getMock( + \Magento\Customer\Model\CustomerExtractor::class, + [], + [], + '', + false + ); + $this->dataObjectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); - $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Framework\Controller\Result\RedirectFactory::class) ->setMethods(['create']) ->getMock(); $this->resultRedirectFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->redirectMock); - $contextMock = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $contextMock->expects($this->any()) ->method('getRequest') ->willReturn($this->requestMock); @@ -225,8 +232,8 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); - $this->model = $objectManager->getObject( - 'Magento\Customer\Controller\Account\CreatePost', + $this->model = $objectManager->getObject( + \Magento\Customer\Controller\Account\CreatePost::class, [ 'context' => $contextMock, 'customerSession' => $this->customerSessionMock, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php index 13e5bd69f466e..185764c05461e 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php @@ -59,26 +59,33 @@ class CreateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerSession = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); - $this->registrationMock = $this->getMock('\Magento\Customer\Model\Registration', [], [], '', false); - $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface'); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->registrationMock = $this->getMock(\Magento\Customer\Model\Registration::class, [], [], '', false); + $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class); + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->redirectResultMock = $this->getMock('Magento\Framework\Controller\Result\Redirect', [], [], '', false); + $this->redirectResultMock = $this->getMock( + \Magento\Framework\Controller\Result\Redirect::class, + [], + [], + '', + false + ); - $this->redirectFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\RedirectFactory', + $this->redirectFactoryMock = $this->getMock( + \Magento\Framework\Controller\Result\RedirectFactory::class, ['create'], [], '', false ); - $this->resultPageMock = $this->getMock('Magento\Framework\View\Result\Page', [], [], '', false ); - $this->pageFactoryMock = $this->getMock('Magento\Framework\View\Result\PageFactory', [], [], '', false); + $this->resultPageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false ); + $this->pageFactoryMock = $this->getMock(\Magento\Framework\View\Result\PageFactory::class, [], [], '', false); - $this->object = $objectManager->getObject('Magento\Customer\Controller\Account\Create', + $this->object = $objectManager->getObject( + \Magento\Customer\Controller\Account\Create::class, [ 'request' => $this->request, 'response' => $this->response, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php index cdad131d06453..658fde722c38a 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php @@ -98,23 +98,23 @@ protected function setUp() { $this->prepareContext(); - $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getCustomerId', 'setCustomerFormData', 'logout', 'start']) ->getMock(); - $this->customerAccountManagement = $this->getMockBuilder('Magento\Customer\Model\AccountManagement') + $this->customerAccountManagement = $this->getMockBuilder(\Magento\Customer\Model\AccountManagement::class) ->disableOriginalConstructor() ->getMock(); - $this->customerRepository = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepository = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); - $this->validator = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->validator = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->customerExtractor = $this->getMockBuilder('Magento\Customer\Model\CustomerExtractor') + $this->customerExtractor = $this->getMockBuilder(\Magento\Customer\Model\CustomerExtractor::class) ->disableOriginalConstructor() ->getMock(); @@ -193,7 +193,7 @@ public function testGeneralSave() $currentPassword = '1234567'; $customerEmail = 'customer@example.com'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $currentCustomerMock = $this->getCurrentCustomerMock($customerId, $address); @@ -295,7 +295,7 @@ public function testChangeEmailException($testNumber, $exceptionClass, $errorMes $customerId = 1; $password = '1234567'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $currentCustomerMock = $this->getCurrentCustomerMock($customerId, $address); @@ -375,12 +375,12 @@ public function changeEmailExceptionDataProvider() return [ [ 'testNumber' => 1, - 'exceptionClass' => '\Magento\Framework\Exception\InvalidEmailOrPasswordException', + 'exceptionClass' => \Magento\Framework\Exception\InvalidEmailOrPasswordException::class, 'errorMessage' => __('The password doesn\'t match this account.') ], [ 'testNumber' => 2, - 'exceptionClass' => '\Magento\Framework\Exception\State\UserLockedException', + 'exceptionClass' => \Magento\Framework\Exception\State\UserLockedException::class, 'errorMessage' => __('The account is locked. Please wait and try again or contact %1.', 'test@host.com') ] ]; @@ -403,7 +403,7 @@ public function testChangePassword( $customerId = 1; $customerEmail = 'user1@example.com'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $currentCustomerMock = $this->getCurrentCustomerMock($customerId, $address); @@ -525,7 +525,7 @@ public function changePasswordDataProvider() 'errors' => [ 'counter' => 1, 'message' => 'AuthenticationException', - 'exception' => '\Magento\Framework\Exception\AuthenticationException', + 'exception' => \Magento\Framework\Exception\AuthenticationException::class, ] ], [ @@ -553,7 +553,7 @@ public function testGeneralException( ) { $customerId = 1; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $currentCustomerMock = $this->getCurrentCustomerMock($customerId, $address); @@ -621,7 +621,7 @@ public function exceptionDataProvider() return [ [ 'message' => 'LocalizedException', - 'exception' => '\Magento\Framework\Exception\LocalizedException', + 'exception' => \Magento\Framework\Exception\LocalizedException::class, ], [ 'message' => 'Exception', @@ -632,24 +632,26 @@ public function exceptionDataProvider() protected function prepareContext() { - $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->resultRedirectFactory = $this->getMockBuilder( + \Magento\Framework\Controller\Result\RedirectFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->resultRedirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->any()) @@ -664,7 +666,7 @@ protected function prepareContext() ->method('getMessageManager') ->willReturn($this->messageManager); - $this->eventManager = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->any()) @@ -683,7 +685,7 @@ protected function prepareContext() */ protected function getNewCustomerMock($customerId, $address) { - $newCustomerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $newCustomerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $newCustomerMock->expects($this->once()) @@ -708,7 +710,7 @@ protected function getNewCustomerMock($customerId, $address) */ protected function getCurrentCustomerMock($customerId, $address) { - $currentCustomerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $currentCustomerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $currentCustomerMock->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php index 8d176fe42628a..18de7a0e88a02 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php @@ -71,14 +71,14 @@ protected function setUp() { $this->prepareContext(); - $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->accountManagement = $this->getMockBuilder('Magento\Customer\Api\AccountManagementInterface') + $this->accountManagement = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class) ->getMockForAbstractClass(); - $this->escaper = $this->getMockBuilder('Magento\Framework\Escaper') + $this->escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->getMock(); @@ -212,26 +212,28 @@ public function testExecuteException() protected function prepareContext() { - $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->resultRedirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->resultRedirectFactory = $this->getMockBuilder( + \Magento\Framework\Controller\Result\RedirectFactory::class + ) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([ 'getPost', ]) ->getMock(); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); $this->resultRedirectFactory->expects($this->any()) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php index d9d690bb559c2..568b068415235 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php @@ -90,7 +90,7 @@ protected function setUp() { $this->prepareContext(); - $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -100,22 +100,22 @@ protected function setUp() ]) ->getMock(); - $this->accountManagement = $this->getMockBuilder('Magento\Customer\Api\AccountManagementInterface') + $this->accountManagement = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class) ->getMockForAbstractClass(); - $this->url = $this->getMockBuilder('Magento\Customer\Model\Url') + $this->url = $this->getMockBuilder(\Magento\Customer\Model\Url::class) ->disableOriginalConstructor() ->getMock(); - $this->formkeyValidator = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->formkeyValidator = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->accountRedirect = $this->getMockBuilder('Magento\Customer\Model\Account\Redirect') + $this->accountRedirect = $this->getMockBuilder(\Magento\Customer\Model\Account\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); $this->controller = new LoginPost( @@ -327,7 +327,7 @@ public function testExecuteSuccess() 'password' => $password, ]); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $this->scopeConfig->expects($this->once()) @@ -411,13 +411,13 @@ public function exceptionDataProvider() [ [ 'message' => 'EmailNotConfirmedException', - 'exception' => '\Magento\Framework\Exception\EmailNotConfirmedException', + 'exception' => \Magento\Framework\Exception\EmailNotConfirmedException::class, ], ], [ [ 'message' => 'AuthenticationException', - 'exception' => '\Magento\Framework\Exception\AuthenticationException', + 'exception' => \Magento\Framework\Exception\AuthenticationException::class, ], ], [ @@ -429,7 +429,7 @@ public function exceptionDataProvider() [ [ 'message' => 'UserLockedException', - 'exception' => '\Magento\Framework\Exception\State\UserLockedException', + 'exception' => \Magento\Framework\Exception\State\UserLockedException::class, ], ], ]; @@ -437,11 +437,11 @@ public function exceptionDataProvider() protected function prepareContext() { - $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([ 'isPost', @@ -453,7 +453,7 @@ protected function prepareContext() ->disableOriginalConstructor() ->getMock(); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -495,7 +495,7 @@ protected function mockExceptions($exception, $username) $email = 'hello@example.com'; switch ($exception) { - case '\Magento\Framework\Exception\EmailNotConfirmedException': + case \Magento\Framework\Exception\EmailNotConfirmedException::class: $this->url->expects($this->once()) ->method('getEmailConfirmationUrl') ->with($username) @@ -517,7 +517,7 @@ protected function mockExceptions($exception, $username) ->willReturnSelf(); break; - case '\Magento\Framework\Exception\AuthenticationException': + case \Magento\Framework\Exception\AuthenticationException::class: $this->messageManager->expects($this->once()) ->method('addError') ->with(__('Invalid login or password.')) @@ -536,7 +536,7 @@ protected function mockExceptions($exception, $username) ->willReturnSelf(); break; - case '\Magento\Framework\Exception\State\UserLockedException': + case \Magento\Framework\Exception\State\UserLockedException::class: $this->scopeConfig->expects($this->once())->method('getValue')->willReturn($email); $message = __( 'The account is locked. Please wait and try again or contact %1.', diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php index cdd70bc5e4745..6d2e06c4ddcbe 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php @@ -8,6 +8,9 @@ use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ResetPasswordPostTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Controller\Account\ResetPasswordPost */ @@ -39,29 +42,29 @@ class ResetPasswordPostTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['unsRpToken', 'unsRpCustomerId']) ->getMock(); - $this->pageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->pageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->accountManagementMock = $this->getMockBuilder('Magento\Customer\Api\AccountManagementInterface') + $this->accountManagementMock = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class) ->getMockForAbstractClass(); - $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['getQuery', 'getPost']) ->getMockForAbstractClass(); - $this->redirectFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->redirectFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RedirectFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( - 'Magento\Customer\Controller\Account\ResetPasswordPost', + \Magento\Customer\Controller\Account\ResetPasswordPost::class, [ 'customerSession' => $this->sessionMock, 'resultPageFactory' => $this->pageFactoryMock, @@ -100,7 +103,7 @@ public function testExecute() ); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $this->customerRepositoryMock->expects($this->once()) @@ -128,7 +131,7 @@ public function testExecute() ->willReturnSelf(); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -171,7 +174,7 @@ public function testExecuteWithException() ); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $this->customerRepositoryMock->expects($this->once()) @@ -194,7 +197,7 @@ public function testExecuteWithException() ->willReturnSelf(); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -240,7 +243,7 @@ public function testExecuteWithInputException() ); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $this->customerRepositoryMock->expects($this->once()) @@ -263,7 +266,7 @@ public function testExecuteWithInputException() ->willReturnSelf(); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -310,7 +313,7 @@ public function testExecuteWithWrongConfirmation() ->willReturnSelf(); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -357,7 +360,7 @@ public function testExecuteWithEmptyPassword() ->willReturnSelf(); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php index dea40e2769e0f..6695a6c18cf53 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php @@ -161,7 +161,7 @@ protected function setUp() { $this->prepareContext(); - $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods([ 'setAddressFormData', @@ -169,7 +169,7 @@ protected function setUp() ]) ->getMock(); - $this->formKeyValidator = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->formKeyValidator = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); @@ -177,23 +177,23 @@ protected function setUp() $this->prepareAddress(); $this->prepareRegion(); - $this->dataProcessor = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $this->dataProcessor = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectHelper = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelper = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\ForwardFactory') + $this->resultForwardFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\ForwardFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->helperData = $this->getMockBuilder('Magento\Directory\Helper\Data') + $this->helperData = $this->getMockBuilder(\Magento\Directory\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); @@ -216,11 +216,11 @@ protected function setUp() protected function prepareContext() { - $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods([ 'isPost', 'getPostValue', @@ -232,19 +232,19 @@ protected function prepareContext() ->method('getRequest') ->willReturn($this->request); - $this->redirect = $this->getMockBuilder('Magento\Framework\App\Response\RedirectInterface') + $this->redirect = $this->getMockBuilder(\Magento\Framework\App\Response\RedirectInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->any()) ->method('getRedirect') ->willReturn($this->redirect); - $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') - ->disableOriginalConstructor() - ->getMock(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->resultRedirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); + $this->resultRedirectFactory = $this->getMockBuilder( + \Magento\Framework\Controller\Result\RedirectFactory::class + )->disableOriginalConstructor()->getMock(); $this->resultRedirectFactory->expects($this->any()) ->method('create') ->willReturn($this->resultRedirect); @@ -253,14 +253,14 @@ protected function prepareContext() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactory); - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->any()) ->method('getObjectManager') ->willReturn($this->objectManager); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->any()) @@ -270,13 +270,13 @@ protected function prepareContext() protected function prepareAddress() { - $this->addressRepository = $this->getMockBuilder('Magento\Customer\Api\AddressRepositoryInterface') + $this->addressRepository = $this->getMockBuilder(\Magento\Customer\Api\AddressRepositoryInterface::class) ->getMockForAbstractClass(); - $this->addressData = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $this->addressData = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); - $this->addressDataFactory = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterfaceFactory') + $this->addressDataFactory = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods([ 'create', @@ -289,7 +289,7 @@ protected function prepareAddress() protected function prepareRegion() { - $this->region = $this->getMockBuilder('Magento\Directory\Model\Region') + $this->region = $this->getMockBuilder(\Magento\Directory\Model\Region::class) ->disableOriginalConstructor() ->setMethods([ 'load', @@ -298,17 +298,17 @@ protected function prepareRegion() ]) ->getMock(); - $this->regionFactory = $this->getMockBuilder('Magento\Directory\Model\RegionFactory') + $this->regionFactory = $this->getMockBuilder(\Magento\Directory\Model\RegionFactory::class) ->disableOriginalConstructor() ->getMock(); $this->regionFactory->expects($this->any()) ->method('create') ->willReturn($this->region); - $this->regionData = $this->getMockBuilder('Magento\Customer\Api\Data\RegionInterface') + $this->regionData = $this->getMockBuilder(\Magento\Customer\Api\Data\RegionInterface::class) ->getMockForAbstractClass(); - $this->regionDataFactory = $this->getMockBuilder('Magento\Customer\Api\Data\RegionInterfaceFactory') + $this->regionDataFactory = $this->getMockBuilder(\Magento\Customer\Api\Data\RegionInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods([ 'create', @@ -321,11 +321,11 @@ protected function prepareRegion() protected function prepareForm() { - $this->form = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form') + $this->form = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form::class) ->disableOriginalConstructor() ->getMock(); - $this->formFactory = $this->getMockBuilder('Magento\Customer\Model\Metadata\FormFactory') + $this->formFactory = $this->getMockBuilder(\Magento\Customer\Model\Metadata\FormFactory::class) ->disableOriginalConstructor() ->getMock(); } @@ -367,7 +367,7 @@ public function testExecuteNoPostData() ->with($postValue) ->willReturnSelf(); - $urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->getMockForAbstractClass(); $urlBuilder->expects($this->once()) ->method('getUrl') @@ -376,7 +376,7 @@ public function testExecuteNoPostData() $this->objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\UrlInterface') + ->with(\Magento\Framework\UrlInterface::class) ->willReturn($urlBuilder); $this->redirect->expects($this->once()) @@ -460,7 +460,7 @@ public function testExecute( $this->dataProcessor->expects($this->once()) ->method('buildOutputDataArray') - ->with($this->addressData, '\Magento\Customer\Api\Data\AddressInterface') + ->with($this->addressData, \Magento\Customer\Api\Data\AddressInterface::class) ->willReturn($existingAddressData); $this->addressData->expects($this->any()) @@ -510,14 +510,13 @@ public function testExecute( ->willReturnMap([ [ $this->regionData, - $regionData, - '\Magento\Customer\Api\Data\RegionInterface', + $regionData, \Magento\Customer\Api\Data\RegionInterface::class, $this->dataObjectHelper, ], [ $this->addressData, array_merge($existingAddressData, $newAddressData), - '\Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, $this->dataObjectHelper, ], ]); @@ -547,7 +546,7 @@ public function testExecute( ->with(__('You saved the address.')) ->willReturnSelf(); - $urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->getMockForAbstractClass(); $urlBuilder->expects($this->once()) ->method('getUrl') @@ -556,7 +555,7 @@ public function testExecute( $this->objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\UrlInterface') + ->with(\Magento\Framework\UrlInterface::class) ->willReturn($urlBuilder); $this->redirect->expects($this->once()) @@ -640,7 +639,7 @@ public function testExecuteInputException() ->with($postValue) ->willReturnSelf(); - $urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->getMockForAbstractClass(); $urlBuilder->expects($this->once()) ->method('getUrl') @@ -649,7 +648,7 @@ public function testExecuteInputException() $this->objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\UrlInterface') + ->with(\Magento\Framework\UrlInterface::class) ->willReturn($urlBuilder); $this->redirect->expects($this->once()) @@ -703,7 +702,7 @@ public function testExecuteException() ->with($postValue) ->willReturnSelf(); - $urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->getMockForAbstractClass(); $urlBuilder->expects($this->once()) ->method('getUrl') @@ -712,7 +711,7 @@ public function testExecuteException() $this->objectManager->expects($this->once()) ->method('create') - ->with('Magento\Framework\UrlInterface') + ->with(\Magento\Framework\UrlInterface::class) ->willReturn($urlBuilder); $this->redirect->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php index 64fbf29843235..380602529d259 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php @@ -62,43 +62,45 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb']) ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['unsCustomerData', 'unsCustomerFormData']) ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $objectManager->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'request' => $this->requestMock, 'session' => $this->sessionMock ] ); $this->indexController = $objectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\Index', + \Magento\Customer\Controller\Adminhtml\Index\Index::class, [ 'context' => $this->context, 'resultForwardFactory' => $this->resultForwardFactoryMock, @@ -141,7 +143,7 @@ public function testExecute() ->method('unsCustomerFormData'); $this->assertInstanceOf( - 'Magento\Framework\View\Result\Page', + \Magento\Framework\View\Result\Page::class, $this->indexController->execute() ); } @@ -162,7 +164,7 @@ public function testExecuteAjax() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Forward', + \Magento\Backend\Model\View\Result\Forward::class, $this->indexController->execute() ); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php index 5c1651661be4e..6aaa19b562087 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php @@ -9,6 +9,7 @@ /** * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InlineEditTest extends \PHPUnit_Framework_TestCase { @@ -73,77 +74,77 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface', [], '', false); + $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false); $this->messageManager = $this->getMockForAbstractClass( - 'Magento\Framework\Message\ManagerInterface', + \Magento\Framework\Message\ManagerInterface::class, [], '', false ); $this->customerData = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false ); $this->address = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], 'address', false ); - $this->addressMapper = $this->getMock('Magento\Customer\Model\Address\Mapper', [], [], '', false); - $this->customerMapper = $this->getMock('Magento\Customer\Model\Customer\Mapper', [], [], '', false); + $this->addressMapper = $this->getMock(\Magento\Customer\Model\Address\Mapper::class, [], [], '', false); + $this->customerMapper = $this->getMock(\Magento\Customer\Model\Customer\Mapper::class, [], [], '', false); $this->resultJsonFactory = $this->getMock( - 'Magento\Framework\Controller\Result\JsonFactory', + \Magento\Framework\Controller\Result\JsonFactory::class, ['create'], [], '', false ); - $this->resultJson = $this->getMock('Magento\Framework\Controller\Result\Json', [], [], '', false); + $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); $this->customerRepository = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false ); - $this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $this->addressDataFactory = $this->getMock( - 'Magento\Customer\Api\Data\AddressInterfaceFactory', + \Magento\Customer\Api\Data\AddressInterfaceFactory::class, ['create'], [], '', false ); $this->addressRepository = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AddressRepositoryInterface', + \Magento\Customer\Api\AddressRepositoryInterface::class, [], '', false ); - $this->messageCollection = $this->getMock('Magento\Framework\Message\Collection', [], [], '', false); + $this->messageCollection = $this->getMock(\Magento\Framework\Message\Collection::class, [], [], '', false); $this->message = $this->getMockForAbstractClass( - 'Magento\Framework\Message\MessageInterface', + \Magento\Framework\Message\MessageInterface::class, [], '', false ); - $this->logger = $this->getMockForAbstractClass('Psr\Log\LoggerInterface', [], '', false); + $this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class, [], '', false); $this->emailNotification = $this->getMockBuilder(EmailNotificationInterface::class) ->disableOriginalConstructor() ->getMock(); $this->context = $objectManager->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'request' => $this->request, 'messageManager' => $this->messageManager, ] ); $this->controller = $objectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\InlineEdit', + \Magento\Customer\Controller\Adminhtml\Index\InlineEdit::class, [ 'context' => $this->context, 'resultJsonFactory' => $this->resultJsonFactory, @@ -198,7 +199,7 @@ protected function prepareMocksForTesting($populateSequence = 0) 'name' => 'Firstname Lastname', 'email' => 'test@test.ua', ], - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $this->customerData->expects($this->any()) ->method('getId') @@ -224,7 +225,7 @@ protected function prepareMocksForUpdateDefaultBilling() ->with( $this->address, $addressData, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php index 5bc85fe677b63..0ebd13671cea6 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php @@ -74,38 +74,38 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); $this->customerCollectionMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->customerCollectionFactoryMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\CollectionFactory') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) @@ -113,7 +113,7 @@ protected function setUp() ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -130,7 +130,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) @@ -138,10 +138,10 @@ protected function setUp() $this->customerCollectionFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->customerCollectionMock); - $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\MassAssignGroup', + \Magento\Customer\Controller\Adminhtml\Index\MassAssignGroup::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, @@ -154,7 +154,9 @@ protected function setUp() public function testExecute() { $customersIds = [10, 11, 12]; - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customerMock = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterface::class + )->getMockForAbstractClass(); $this->customerCollectionMock->expects($this->any()) ->method('getAllIds') ->willReturn($customersIds); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php index e4967daf85a5c..41d35aa32406d 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php @@ -74,38 +74,38 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); $this->customerCollectionMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->customerCollectionFactoryMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\CollectionFactory') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) @@ -113,7 +113,7 @@ protected function setUp() ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -130,7 +130,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) @@ -138,10 +138,10 @@ protected function setUp() $this->customerCollectionFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->customerCollectionMock); - $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\MassDelete', + \Magento\Customer\Controller\Adminhtml\Index\MassDelete::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php index 6c8207a750c22..1a3c47dbc7545 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php @@ -79,47 +79,47 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); $this->customerCollectionMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->customerCollectionFactoryMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\CollectionFactory') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) ->method('create') ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->subscriberMock = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); - $subscriberFactoryMock = $this->getMockBuilder('Magento\Newsletter\Model\SubscriberFactory') + $this->subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -127,7 +127,13 @@ protected function setUp() ->method('create') ->willReturn($this->subscriberMock); - $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->resultRedirectMock = $this->getMock( + \Magento\Backend\Model\View\Result\Redirect::class, + [], + [], + '', + false + ); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -141,7 +147,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) @@ -149,10 +155,10 @@ protected function setUp() $this->customerCollectionFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->customerCollectionMock); - $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\MassSubscribe', + \Magento\Customer\Controller\Adminhtml\Index\MassSubscribe::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php index e12e703878ebb..bd47341f2c4fa 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php @@ -79,47 +79,47 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); $this->customerCollectionMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->customerCollectionFactoryMock = - $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\CollectionFactory') + $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) ->method('create') ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->subscriberMock = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); - $subscriberFactoryMock = $this->getMockBuilder('Magento\Newsletter\Model\SubscriberFactory') + $this->subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -127,7 +127,13 @@ protected function setUp() ->method('create') ->willReturn($this->subscriberMock); - $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->resultRedirectMock = $this->getMock( + \Magento\Backend\Model\View\Result\Redirect::class, + [], + [], + '', + false + ); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -141,7 +147,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) @@ -149,10 +155,10 @@ protected function setUp() $this->customerCollectionFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->customerCollectionMock); - $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\MassUnsubscribe', + \Magento\Customer\Controller\Adminhtml\Index\MassUnsubscribe::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php index 513243b73eea0..6a3226c442102 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php @@ -7,6 +7,8 @@ /** * Unit test for \Magento\Customer\Controller\Adminhtml\Index controller + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class NewsletterTest extends \PHPUnit_Framework_TestCase { @@ -100,11 +102,11 @@ class NewsletterTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->_request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->_response = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->_response = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods(['setRedirect', 'getHeader', '__wakeup']) ->getMock(); @@ -120,33 +122,33 @@ protected function setUp() ); $this->_objectManager = $this->getMockBuilder( - 'Magento\Framework\App\ObjectManager' + \Magento\Framework\App\ObjectManager::class )->disableOriginalConstructor()->setMethods( ['get', 'create'] )->getMock(); $frontControllerMock = $this->getMockBuilder( - 'Magento\Framework\App\FrontController' + \Magento\Framework\App\FrontController::class )->disableOriginalConstructor()->getMock(); - $actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); $this->_session = $this->getMockBuilder( - 'Magento\Backend\Model\Session' + \Magento\Backend\Model\Session::class )->disableOriginalConstructor()->setMethods( ['setIsUrlNotice', '__wakeup'] )->getMock(); $this->_session->expects($this->any())->method('setIsUrlNotice'); $this->_helper = $this->getMockBuilder( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->disableOriginalConstructor()->setMethods( ['getUrl'] )->getMock(); $this->messageManager = $this->getMockBuilder( - 'Magento\Framework\Message\Manager' + \Magento\Framework\Message\Manager::class )->disableOriginalConstructor()->setMethods( ['addSuccess', 'addMessage', 'addException'] )->getMock(); @@ -168,7 +170,7 @@ protected function setUp() 'getView' ]; $contextMock = $this->getMockBuilder( - '\Magento\Backend\App\Action\Context' + \Magento\Backend\App\Action\Context::class )->disableOriginalConstructor()->setMethods( $contextArgs )->getMock(); @@ -199,25 +201,25 @@ protected function setUp() )->will( $this->returnValue($this->messageManager) ); - $this->titleMock = $this->getMockBuilder('\Magento\Framework\View\Page\Title') + $this->titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor()->getMock(); $contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock)); - $this->viewInterfaceMock = $this->getMockBuilder('\Magento\Framework\App\ViewInterface') + $this->viewInterfaceMock = $this->getMockBuilder(\Magento\Framework\App\ViewInterface::class) ->disableOriginalConstructor() ->getMock(); $this->viewInterfaceMock->expects($this->any())->method('loadLayout')->will($this->returnSelf()); $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewInterfaceMock)); - $this->resultLayoutMock = $this->getMockBuilder('Magento\Framework\View\Result\Layout') + $this->resultLayoutMock = $this->getMockBuilder(\Magento\Framework\View\Result\Layout::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); $this->customerAccountManagement = $this->getMockBuilder( - 'Magento\Customer\Api\AccountManagementInterface' + \Magento\Customer\Api\AccountManagementInterface::class )->getMock(); - $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\LayoutFactory') + $this->resultLayoutFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\LayoutFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -229,7 +231,7 @@ protected function setUp() $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_testedObject = $helperObjectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\Newsletter', + \Magento\Customer\Controller\Adminhtml\Index\Newsletter::class, $args ); } @@ -237,7 +239,7 @@ protected function setUp() public function testNewsletterAction() { $subscriberMock = $this->getMock( - '\Magento\Newsletter\Model\Subscriber', + \Magento\Newsletter\Model\Subscriber::class, [], [], '', @@ -251,11 +253,11 @@ public function testNewsletterAction() $this->_objectManager ->expects($this->any()) ->method('create') - ->with('Magento\Newsletter\Model\Subscriber') + ->with(\Magento\Newsletter\Model\Subscriber::class) ->willReturn($subscriberMock); $this->assertInstanceOf( - 'Magento\Framework\View\Result\Layout', + \Magento\Framework\View\Result\Layout::class, $this->_testedObject->execute() ); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php index 6202455a41c4d..b07437bd3b7d4 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -14,6 +14,8 @@ /** * Unit test for \Magento\Customer\Controller\Adminhtml\Index controller + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ResetPasswordTest extends \PHPUnit_Framework_TestCase { @@ -92,12 +94,12 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->_request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $this->_response = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' + \Magento\Framework\App\Response\Http::class )->disableOriginalConstructor()->setMethods( ['setRedirect', 'getHeader', '__wakeup'] )->getMock(); @@ -113,42 +115,43 @@ protected function setUp() ); $this->_objectManager = $this->getMockBuilder( - 'Magento\Framework\App\ObjectManager' + \Magento\Framework\App\ObjectManager::class )->disableOriginalConstructor()->setMethods( ['get', 'create'] )->getMock(); $frontControllerMock = $this->getMockBuilder( - 'Magento\Framework\App\FrontController' + \Magento\Framework\App\FrontController::class )->disableOriginalConstructor()->getMock(); - $actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); $this->_session = $this->getMockBuilder( - 'Magento\Backend\Model\Session' + \Magento\Backend\Model\Session::class )->disableOriginalConstructor()->setMethods( ['setIsUrlNotice', '__wakeup'] )->getMock(); $this->_session->expects($this->any())->method('setIsUrlNotice'); $this->_helper = $this->getMockBuilder( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->disableOriginalConstructor()->setMethods( ['getUrl'] )->getMock(); $this->messageManager = $this->getMockBuilder( - 'Magento\Framework\Message\Manager' + \Magento\Framework\Message\Manager::class )->disableOriginalConstructor()->setMethods( ['addSuccess', 'addMessage', 'addException'] )->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -169,12 +172,11 @@ protected function setUp() 'getEventManager', 'getRequest', 'getResponse', - 'getTitle', 'getView', 'getResultRedirectFactory' ]; $contextMock = $this->getMockBuilder( - '\Magento\Backend\App\Action\Context' + \Magento\Backend\App\Action\Context::class )->disableOriginalConstructor()->setMethods( $contextArgs )->getMock(); @@ -186,9 +188,7 @@ protected function setUp() $contextMock->expects($this->any())->method('getHelper')->willReturn($this->_helper); $contextMock->expects($this->any())->method('getSession')->willReturn($this->_session); $contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManager); - $titleMock = $this->getMockBuilder('\Magento\Framework\App\Action\Title')->getMock(); - $contextMock->expects($this->any())->method('getTitle')->willReturn($titleMock); - $viewMock = $this->getMockBuilder('\Magento\Framework\App\ViewInterface')->getMock(); + $viewMock = $this->getMockBuilder(\Magento\Framework\App\ViewInterface::class)->getMock(); $viewMock->expects($this->any())->method('loadLayout')->willReturnSelf(); $contextMock->expects($this->any())->method('getView')->willReturn($viewMock); $contextMock->expects($this->any()) @@ -196,11 +196,11 @@ protected function setUp() ->willReturn($this->resultRedirectFactoryMock); $this->_customerAccountManagementMock = $this->getMockBuilder( - 'Magento\Customer\Api\AccountManagementInterface' + \Magento\Customer\Api\AccountManagementInterface::class )->getMock(); $this->_customerRepositoryMock = $this->getMockBuilder( - 'Magento\Customer\Api\CustomerRepositoryInterface' + \Magento\Customer\Api\CustomerRepositoryInterface::class )->getMock(); $args = [ @@ -211,7 +211,7 @@ protected function setUp() $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_testedObject = $helperObjectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\ResetPassword', + \Magento\Customer\Controller\Adminhtml\Index\ResetPassword::class, $args ); } @@ -235,7 +235,7 @@ public function testResetPasswordActionNoCustomer() ->with($this->equalTo($redirectLink)); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->_testedObject->execute() ); } @@ -289,7 +289,7 @@ public function testResetPasswordActionInvalidCustomerId() ->with($this->equalTo($redirectLink)); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->_testedObject->execute() ); } @@ -421,7 +421,7 @@ public function testResetPasswordActionSendEmail() ); $customer = $this->getMockForAbstractClass( - '\Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, ['getId', 'getEmail', 'getWebsiteId'] ); @@ -478,7 +478,7 @@ public function testResetPasswordActionSendEmail() ); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->_testedObject->execute() ); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php index 574f54cea931c..c49a684f7340d 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php @@ -142,75 +142,79 @@ class SaveTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb']) ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['unsCustomerFormData', 'setCustomerFormData']) ->getMock(); - $this->formFactoryMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\FormFactory') + $this->formFactoryMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\FormFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->objectFactoryMock = $this->getMockBuilder('Magento\Framework\DataObjectFactory') + $this->objectFactoryMock = $this->getMockBuilder(\Magento\Framework\DataObjectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->customerDataFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterfaceFactory') + $this->customerDataFactoryMock = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->customerMapperMock = $this->getMockBuilder('Magento\Customer\Model\Customer\Mapper') + $this->customerMapperMock = $this->getMockBuilder(\Magento\Customer\Model\Customer\Mapper::class) ->disableOriginalConstructor() ->getMock(); - $this->dataHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->authorizationMock = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') + $this->authorizationMock = $this->getMockBuilder(\Magento\Framework\AuthorizationInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->subscriberFactoryMock = $this->getMockBuilder('Magento\Newsletter\Model\SubscriberFactory') + $this->subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->redirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->redirectFactoryMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->managementMock = $this->getMockBuilder('Magento\Customer\Model\AccountManagement') + $this->managementMock = $this->getMockBuilder(\Magento\Customer\Model\AccountManagement::class) ->disableOriginalConstructor() ->setMethods(['createAccount']) ->getMock(); - $this->addressDataFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterfaceFactory') + $this->addressDataFactoryMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -221,7 +225,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\Save', + \Magento\Customer\Controller\Adminhtml\Index\Save::class, [ 'resultForwardFactory' => $this->resultForwardFactoryMock, 'resultPageFactory' => $this->resultPageFactoryMock, @@ -328,7 +332,7 @@ public function testExecuteWithExistentCustomer() ]; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->exactly(2)) @@ -353,7 +357,7 @@ public function testExecuteWithExistentCustomer() ); /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $formMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form') + $formMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form::class) ->disableOriginalConstructor() ->getMock(); @@ -392,7 +396,7 @@ public function testExecuteWithExistentCustomer() ); /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */ - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); @@ -415,7 +419,7 @@ public function testExecuteWithExistentCustomer() ->willReturn($attributes); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -433,7 +437,7 @@ public function testExecuteWithExistentCustomer() ->with($customerMock) ->willReturn($savedData); - $addressMock = $this->getMockBuilder('\Magento\Customer\Api\Data\AddressInterface') + $addressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -447,14 +451,12 @@ public function testExecuteWithExistentCustomer() [ [ $customerMock, - $mergedData, - '\Magento\Customer\Api\Data\CustomerInterface', + $mergedData, \Magento\Customer\Api\Data\CustomerInterface::class, $this->dataHelperMock ], [ $addressMock, - $mergedAddressData, - '\Magento\Customer\Api\Data\AddressInterface', + $mergedAddressData, \Magento\Customer\Api\Data\AddressInterface::class, $this->dataHelperMock ], ] @@ -484,7 +486,7 @@ public function testExecuteWithExistentCustomer() ->willReturn(true); /** @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject $subscriberMock */ - $subscriberMock = $this->getMockBuilder('Magento\Newsletter\Model\Subscriber') + $subscriberMock = $this->getMockBuilder(\Magento\Newsletter\Model\Subscriber::class) ->disableOriginalConstructor() ->getMock(); @@ -517,7 +519,7 @@ public function testExecuteWithExistentCustomer() ->willReturn(true); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -596,7 +598,7 @@ public function testExecuteWithNewCustomer() ]; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->exactly(2)) @@ -621,7 +623,7 @@ public function testExecuteWithNewCustomer() ); /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $formMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form') + $formMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form::class) ->disableOriginalConstructor() ->getMock(); @@ -660,7 +662,7 @@ public function testExecuteWithNewCustomer() ); /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */ - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); @@ -683,7 +685,7 @@ public function testExecuteWithNewCustomer() ->willReturn($attributes); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -691,7 +693,7 @@ public function testExecuteWithNewCustomer() ->method('create') ->willReturn($customerMock); - $addressMock = $this->getMockBuilder('\Magento\Customer\Api\Data\AddressInterface') + $addressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -705,14 +707,12 @@ public function testExecuteWithNewCustomer() [ [ $customerMock, - $mergedData, - '\Magento\Customer\Api\Data\CustomerInterface', + $mergedData, \Magento\Customer\Api\Data\CustomerInterface::class, $this->dataHelperMock ], [ $addressMock, - $mergedAddressData, - '\Magento\Customer\Api\Data\AddressInterface', + $mergedAddressData, \Magento\Customer\Api\Data\AddressInterface::class, $this->dataHelperMock ], ] @@ -733,7 +733,7 @@ public function testExecuteWithNewCustomer() ->willReturn(true); /** @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject $subscriberMock */ - $subscriberMock = $this->getMockBuilder('Magento\Newsletter\Model\Subscriber') + $subscriberMock = $this->getMockBuilder(\Magento\Newsletter\Model\Subscriber::class) ->disableOriginalConstructor() ->getMock(); @@ -766,7 +766,7 @@ public function testExecuteWithNewCustomer() ->willReturn(false); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -802,7 +802,7 @@ public function testExecuteWithNewCustomerAndValidationException() ]; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->once()) @@ -826,7 +826,7 @@ public function testExecuteWithNewCustomerAndValidationException() ); /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $formMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form') + $formMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form::class) ->disableOriginalConstructor() ->getMock(); @@ -846,7 +846,7 @@ public function testExecuteWithNewCustomerAndValidationException() ->willReturn($filteredData); /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */ - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); @@ -865,7 +865,7 @@ public function testExecuteWithNewCustomerAndValidationException() ->willReturn($attributes); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -905,7 +905,7 @@ public function testExecuteWithNewCustomerAndValidationException() ->with($postValue); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -942,7 +942,7 @@ public function testExecuteWithNewCustomerAndLocalizedException() ]; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->once()) @@ -966,7 +966,7 @@ public function testExecuteWithNewCustomerAndLocalizedException() ); /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $formMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form') + $formMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form::class) ->disableOriginalConstructor() ->getMock(); @@ -986,7 +986,7 @@ public function testExecuteWithNewCustomerAndLocalizedException() ->willReturn($filteredData); /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */ - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); @@ -1005,7 +1005,7 @@ public function testExecuteWithNewCustomerAndLocalizedException() ->willReturn($attributes); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -1045,7 +1045,7 @@ public function testExecuteWithNewCustomerAndLocalizedException() ->with($postValue); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -1082,7 +1082,7 @@ public function testExecuteWithNewCustomerAndException() ]; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->once()) @@ -1106,7 +1106,7 @@ public function testExecuteWithNewCustomerAndException() ); /** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject $formMock */ - $formMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form') + $formMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form::class) ->disableOriginalConstructor() ->getMock(); @@ -1126,7 +1126,7 @@ public function testExecuteWithNewCustomerAndException() ->willReturn($filteredData); /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */ - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); @@ -1145,7 +1145,7 @@ public function testExecuteWithNewCustomerAndException() ->willReturn($attributes); /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */ - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -1186,7 +1186,7 @@ public function testExecuteWithNewCustomerAndException() ->with($postValue); /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php index 979d41c13bfc5..f6ebde3c46f5e 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php @@ -6,6 +6,9 @@ namespace Magento\Customer\Test\Unit\Controller\Adminhtml\Index; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ValidateTest extends \PHPUnit_Framework_TestCase { /** @@ -68,7 +71,7 @@ protected function setUp() $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } $this->customer = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false, @@ -77,7 +80,7 @@ protected function setUp() ); $this->customer->expects($this->once())->method('getWebsiteId')->willReturn(2); $this->customerDataFactory = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create'], [], '', @@ -85,14 +88,14 @@ protected function setUp() ); $this->customerDataFactory->expects($this->once())->method('create')->willReturn($this->customer); $this->form = $this->getMock( - 'Magento\Customer\Model\Metadata\Form', + \Magento\Customer\Model\Metadata\Form::class, [], [], '', false ); $this->request = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -101,34 +104,40 @@ protected function setUp() ['getPost'] ); $this->response = $this->getMockForAbstractClass( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, + [], + '', + false + ); + $this->formFactory = $this->getMock( + \Magento\Customer\Model\Metadata\FormFactory::class, + ['create'], [], '', false ); - $this->formFactory = $this->getMock('Magento\Customer\Model\Metadata\FormFactory', ['create'], [], '', false); $this->formFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->form); $this->extensibleDataObjectConverter = $this->getMock( - 'Magento\Framework\Api\ExtensibleDataObjectConverter', + \Magento\Framework\Api\ExtensibleDataObjectConverter::class, [], [], '', false ); - $this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $this->dataObjectHelper->expects($this->once())->method('populateWithArray'); $this->customerAccountManagement = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AccountManagementInterface', + \Magento\Customer\Api\AccountManagementInterface::class, [], '', false, true, true ); - $this->resultJson = $this->getMock('Magento\Framework\Controller\Result\Json', [], [], '', false); + $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); $this->resultJson->expects($this->once())->method('setData'); $this->resultJsonFactory = $this->getMock( - 'Magento\Framework\Controller\Result\JsonFactory', + \Magento\Framework\Controller\Result\JsonFactory::class, ['create'], [], '', @@ -138,7 +147,7 @@ protected function setUp() $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectHelper->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\Validate', + \Magento\Customer\Controller\Adminhtml\Index\Validate::class, [ 'request' => $this->request, 'response' => $this->response, @@ -164,7 +173,7 @@ public function testExecute() $this->form->expects($this->once())->method('setInvisibleIgnored'); $this->form->expects($this->atLeastOnce())->method('extractData')->willReturn([]); - $error = $this->getMock('Magento\Framework\Message\Error', [], [], '', false); + $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); $this->form->expects($this->once()) ->method('validateData') ->willReturn([$error]); @@ -174,7 +183,7 @@ public function testExecute() ->willReturn([]); $validationResult = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\ValidationResultsInterface', + \Magento\Customer\Api\Data\ValidationResultsInterface::class, [], '', false, @@ -203,7 +212,7 @@ public function testExecuteWithoutAddresses() ->method('extractData') ->willReturn([]); - $error = $this->getMock('Magento\Framework\Message\Error', [], [], '', false); + $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); $this->form->expects($this->never()) ->method('validateData') ->willReturn([$error]); @@ -213,7 +222,7 @@ public function testExecuteWithoutAddresses() ->willReturn([]); $validationResult = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\ValidationResultsInterface', + \Magento\Customer\Api\Data\ValidationResultsInterface::class, [], '', false, @@ -250,19 +259,19 @@ public function testExecuteWithException() ->willReturn([]); $validationResult = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\ValidationResultsInterface', + \Magento\Customer\Api\Data\ValidationResultsInterface::class, [], '', false, true, true ); - $error = $this->getMock('Magento\Framework\Message\Error', [], [], '', false); + $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); $error->expects($this->once()) ->method('getText') ->willReturn('Error text'); - $exception = $this->getMock('Magento\Framework\Validator\Exception', [], [], '', false); + $exception = $this->getMock(\Magento\Framework\Validator\Exception::class, [], [], '', false); $exception->expects($this->once()) ->method('getMessages') ->willReturn([$error]); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php index 3586651d269d0..09fe53a2999ba 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php @@ -69,29 +69,29 @@ class ViewfileTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); $this->directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\ReadInterface', + \Magento\Framework\Filesystem\Directory\ReadInterface::class, [], [], '', false ); - $this->fileSystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->storage = $this->getMock('Magento\MediaStorage\Helper\File\Storage', [], [], '', false); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $this->fileSystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->storage = $this->getMock(\Magento\MediaStorage\Helper\File\Storage::class, [], [], '', false); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock); $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); - $this->urlDecoderMock = $this->getMock('Magento\Framework\Url\DecoderInterface', [], [], '', false); - $this->resultRawMock = $this->getMock('Magento\Framework\Controller\Result\Raw', [], [], '', false); + $this->urlDecoderMock = $this->getMock(\Magento\Framework\Url\DecoderInterface::class, [], [], '', false); + $this->resultRawMock = $this->getMock(\Magento\Framework\Controller\Result\Raw::class, [], [], '', false); $this->resultRawFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\RawFactory', + \Magento\Framework\Controller\Result\RawFactory::class, ['create'], [], '', @@ -106,7 +106,7 @@ protected function setUp() public function testExecuteNoParamsShouldThrowException() { /** @var \Magento\Customer\Controller\Adminhtml\Index\Viewfile $controller */ - $controller = $this->objectManager->getObject('Magento\Customer\Controller\Adminhtml\Index\Viewfile'); + $controller = $this->objectManager->getObject(\Magento\Customer\Controller\Adminhtml\Index\Viewfile::class); $controller->execute(); } @@ -130,15 +130,15 @@ public function testExecuteParamFile() $this->objectManagerMock->expects($this->any())->method('get') ->willReturnMap( [ - ['Magento\Framework\Filesystem', $this->fileSystemMock], - ['Magento\MediaStorage\Helper\File\Storage', $this->storage] + [\Magento\Framework\Filesystem::class, $this->fileSystemMock], + [\Magento\MediaStorage\Helper\File\Storage::class, $this->storage] ] ); $this->urlDecoderMock->expects($this->once())->method('decode')->with($decodedFile)->willReturn($file); - $fileResponse = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $fileFactoryMock = $this->getMock('Magento\Framework\App\Response\Http\FileFactory', [], [], '', false); + $fileResponse = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $fileFactoryMock = $this->getMock(\Magento\Framework\App\Response\Http\FileFactory::class, [], [], '', false); $fileFactoryMock->expects($this->once())->method('create')->with( $path, ['type' => 'filename', 'value' => $fileName], @@ -147,7 +147,7 @@ public function testExecuteParamFile() /** @var \Magento\Customer\Controller\Adminhtml\Index\Viewfile $controller */ $controller = $this->objectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\Viewfile', + \Magento\Customer\Controller\Adminhtml\Index\Viewfile::class, [ 'context' => $this->contextMock, 'urlDecoder' => $this->urlDecoderMock, @@ -180,8 +180,8 @@ public function testExecuteGetParamImage() $this->objectManagerMock->expects($this->any())->method('get') ->willReturnMap( [ - ['Magento\Framework\Filesystem', $this->fileSystemMock], - ['Magento\MediaStorage\Helper\File\Storage', $this->storage] + [\Magento\Framework\Filesystem::class, $this->fileSystemMock], + [\Magento\MediaStorage\Helper\File\Storage::class, $this->storage] ] ); @@ -199,7 +199,7 @@ public function testExecuteGetParamImage() ); $this->resultRawFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\RawFactory', + \Magento\Framework\Controller\Result\RawFactory::class, ['create'], [], '', @@ -209,7 +209,7 @@ public function testExecuteGetParamImage() /** @var \Magento\Customer\Controller\Adminhtml\Index\Viewfile $controller */ $controller = $this->objectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\Index\Viewfile', + \Magento\Customer\Controller\Adminhtml\Index\Viewfile::class, [ 'context' => $this->contextMock, 'urlDecoder' => $this->urlDecoderMock, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php index ed5609f40091d..ef9a3c8a7c89b 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php @@ -71,39 +71,39 @@ class UnlockTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->objectManager = new ObjectManager($this); - $this->contextMock = $this->getMockBuilder('\Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $this->authenticationMock = $this->getMockBuilder(AuthenticationInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['getParam']) ->getMockForAbstractClass(); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); $this->resultFactoryMock = $this->getMock( - 'Magento\Framework\Controller\ResultFactory', + \Magento\Framework\Controller\ResultFactory::class, ['create'], [], '', false ); $this->redirectMock = $this->getMock( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, ['setPath'], [], '', false ); $this->customerDataMock = $this->getMock( - 'Magento\Customer\Model\Data\Customer', + \Magento\Customer\Model\Data\Customer::class, [], [], '', false ); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->setMethods(['getObjectManager', 'getResultFactory', 'getMessageManager', 'getRequest']) ->disableOriginalConstructor() ->getMock(); @@ -116,7 +116,7 @@ public function setUp() $this->resultFactoryMock->expects($this->once())->method('create')->willReturn($this->redirectMock); $this->controller = $this->objectManager->getObject( - '\Magento\Customer\Controller\Adminhtml\Locks\Unlock', + \Magento\Customer\Controller\Adminhtml\Locks\Unlock::class, [ 'context' => $this->contextMock, 'authentication' => $this->authenticationMock, @@ -140,7 +140,7 @@ public function testExecute() ->method('setPath') ->with($this->equalTo('customer/index/edit')) ->willReturnSelf(); - $this->assertInstanceOf('\Magento\Backend\Model\View\Result\Redirect', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute()); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php index db8bccf2ec24c..4463736c30ec1 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php @@ -36,23 +36,23 @@ protected function setUp() { $resultJsonFactory = $this->mockResultJson(); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMockForAbstractClass(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $objectManager->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'request' => $this->request, 'objectManager' => $this->objectManager, ] ); $this->controller = $objectManager->getObject( - 'Magento\Customer\Controller\Adminhtml\System\Config\Validatevat\Validate', + \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat\Validate::class, [ 'context' => $this->context, 'resultJsonFactory' => $resultJsonFactory, @@ -82,7 +82,7 @@ public function testExecute() ['vat', null, $vat], ]); - $vatMock = $this->getMockBuilder('Magento\Customer\Model\Vat') + $vatMock = $this->getMockBuilder(\Magento\Customer\Model\Vat::class) ->disableOriginalConstructor() ->getMock(); @@ -93,7 +93,7 @@ public function testExecute() $this->objectManager->expects($this->once()) ->method('get') - ->with('Magento\Customer\Model\Vat') + ->with(\Magento\Customer\Model\Vat::class) ->willReturn($vatMock); $this->resultJson->expects($this->once()) @@ -112,11 +112,11 @@ public function testExecute() */ protected function mockResultJson() { - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $this->resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); - $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php index 6dd341a4cc795..d678ac0eaf763 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php @@ -75,17 +75,17 @@ class LoginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + $this->response = $this->getMock( + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse', 'representJson', 'setHttpResponseCode'], [], '', false ); - $this->customerSession = $this->getMock( - '\Magento\Customer\Model\Session', + $this->customerSession = $this->getMock( + \Magento\Customer\Model\Session::class, [ 'isLoggedIn', 'getLastCustomerId', @@ -98,42 +98,42 @@ protected function setUp() '', false ); - $this->objectManager = $this->getMock( - '\Magento\Framework\ObjectManager\ObjectManager', + $this->objectManager = $this->getMock( + \Magento\Framework\ObjectManager\ObjectManager::class, ['get'], [], '', false ); $this->customerAccountManagementMock = - $this->getMock( - '\Magento\Customer\Model\AccountManagement', + $this->getMock( + \Magento\Customer\Model\AccountManagement::class, ['authenticate'], [], '', false ); - $this->jsonHelperMock = $this->getMock( - '\Magento\Framework\Json\Helper\Data', + $this->jsonHelperMock = $this->getMock( + \Magento\Framework\Json\Helper\Data::class, ['jsonDecode'], [], '', false ); - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $this->resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); - $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRaw = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') + $this->resultRaw = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class) ->disableOriginalConstructor() ->getMock(); - $resultRawFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') + $resultRawFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -147,8 +147,8 @@ protected function setUp() $contextMock->expects($this->atLeastOnce())->method('getRequest')->willReturn($this->request); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->object = $objectManager->getObject( - 'Magento\Customer\Controller\Ajax\Login', + $this->object = $objectManager->getObject( + \Magento\Customer\Controller\Ajax\Login::class, [ 'context' => $contextMock, 'customerSession' => $this->customerSession, @@ -192,7 +192,7 @@ public function testLogin() ->with($jsonRequest) ->willReturn(['username' => 'customer@example.com', 'password' => 'password']); - $customerMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\CustomerInterface'); + $customerMock = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerAccountManagementMock ->expects($this->any()) ->method('authenticate') @@ -262,7 +262,7 @@ public function testLoginFailure() ->with($jsonRequest) ->willReturn(['username' => 'invalid@example.com', 'password' => 'invalid']); - $customerMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\CustomerInterface'); + $customerMock = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerAccountManagementMock ->expects($this->any()) ->method('authenticate') diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php index 6d5eb076b491e..b175e55f1d3be 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php @@ -50,7 +50,7 @@ class AccountTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods([ 'setNoReferer', @@ -59,7 +59,7 @@ protected function setUp() ]) ->getMock(); - $this->subject = $this->getMockBuilder('Magento\Framework\App\ActionInterface') + $this->subject = $this->getMockBuilder(\Magento\Framework\App\ActionInterface::class) ->setMethods([ 'getActionFlag', ]) @@ -69,14 +69,14 @@ protected function setUp() return self::EXPECTED_VALUE; }; - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([ 'getActionName', ]) ->getMock(); - $this->actionFlag = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlag = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php index 2d7b70a44ff3c..7e8531e0f591c 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php @@ -27,7 +27,13 @@ class IdentifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cookieManMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PhpCookieManager', [], [], '', false); + $this->cookieManMock = $this->getMock( + \Magento\Framework\Stdlib\Cookie\PhpCookieManager::class, + [], + [], + '', + false + ); $this->cookieMarkId = '123456'; $this->model = new Identifier( $this->cookieManMock diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php index ca121c173d442..b14cb50122629 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php @@ -24,7 +24,7 @@ protected function setUp() $this->source = new \DOMDocument(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->converter = $this->objectManagerHelper->getObject( - 'Magento\Customer\CustomerData\SectionConfigConverter' + \Magento\Customer\CustomerData\SectionConfigConverter::class ); } diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php index 6236e3e11eed5..452573454ba55 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php @@ -32,8 +32,14 @@ class SectionPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface', [], [], '', false); - $this->identifierMock = $this->getMock('\Magento\Customer\CustomerData\Section\Identifier', [], [], '', false); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->identifierMock = $this->getMock( + \Magento\Customer\CustomerData\Section\Identifier::class, + [], + [], + '', + false + ); $this->sectionSourceMap = ['section1' => 'b']; $this->model = new SectionPool( $this->objectManagerMock, @@ -54,7 +60,13 @@ public function testGetSectionsDataAllSections() ]; $identifierResult = [1, 2, 3]; - $sectionSourceMock = $this->getMock('\Magento\Customer\CustomerData\SectionSourceInterface', [], [], '', false); + $sectionSourceMock = $this->getMock( + \Magento\Customer\CustomerData\SectionSourceInterface::class, + [], + [], + '', + false + ); $this->objectManagerMock->expects($this->once()) ->method('get') ->with('b') diff --git a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php index 10c61358b143a..d9ceb372acdd7 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php @@ -9,6 +9,9 @@ use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Api\CustomerMetadataInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AddressTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject */ @@ -38,7 +41,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $className = 'Magento\Customer\Helper\Address'; + $className = \Magento\Customer\Helper\Address::class; $arguments = $objectManagerHelper->getConstructArguments($className); /** @var \Magento\Framework\App\Helper\Context $context */ $this->context = $arguments['context']; @@ -60,7 +63,7 @@ protected function setUp() public function testGetStreetLines($numLines, $expectedNumLines) { $attributeMock = $this->getMockBuilder( - 'Magento\Customer\Api\Data\AttributeMetadataInterface' + \Magento\Customer\Api\Data\AttributeMetadataInterface::class )->getMock(); $attributeMock->expects($this->any())->method('getMultilineCount')->will($this->returnValue($numLines)); @@ -69,7 +72,7 @@ public function testGetStreetLines($numLines, $expectedNumLines) ->method('getAttributeMetadata') ->will($this->returnValue($attributeMock)); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->assertEquals($expectedNumLines, $this->helper->getStreetLines()); @@ -113,9 +116,9 @@ public function testGetRenderer($renderer, $blockFactory, $result) */ public function getRendererDataProvider() { - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface')->getMock(); + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class)->getMock(); $blockFactory = $this->getMockBuilder( - 'Magento\Framework\View\Element\BlockFactory' + \Magento\Framework\View\Element\BlockFactory::class )->disableOriginalConstructor()->getMock(); $blockFactory->expects($this->once()) ->method('createBlock') @@ -130,7 +133,7 @@ public function getRendererDataProvider() public function testGetConfigCanShowConfig() { $result = ['key1' => 'value1', 'key2' => 'value2']; - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->any()) ->method('getWebsiteId') ->will($this->returnValue('1')); @@ -156,10 +159,12 @@ public function testGetConfigCanShowConfig() */ public function testGetAttributeValidationClass($attrCode, $attrClass, $customAttrClass, $result) { - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface')->getMock(); + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class)->getMock(); $attributeMock->expects($this->any())->method('getFrontendClass')->will($this->returnValue($attrClass)); - $customAttrMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface')->getMock(); + $customAttrMock = $this->getMockBuilder( + \Magento\Customer\Api\Data\AttributeMetadataInterface::class + )->getMock(); $customAttrMock->expects($this->any())->method('isVisible')->will($this->returnValue(true)); $customAttrMock->expects($this->any())->method('getFrontendClass')->will($this->returnValue($customAttrClass)); @@ -333,7 +338,7 @@ public function testGetFormatTypeRenderer($code, $result) public function getFormatTypeRendererDataProvider() { - $renderer = $this->getMockBuilder('Magento\Customer\Block\Address\Renderer\RendererInterface') + $renderer = $this->getMockBuilder(\Magento\Customer\Block\Address\Renderer\RendererInterface::class) ->disableOriginalConstructor()->getMock(); return [ ['valid_code', $renderer], @@ -349,7 +354,7 @@ public function getFormatTypeRendererDataProvider() public function testGetFormat($code, $result) { if ($result) { - $renderer = $this->getMockBuilder('Magento\Customer\Block\Address\Renderer\RendererInterface') + $renderer = $this->getMockBuilder(\Magento\Customer\Block\Address\Renderer\RendererInterface::class) ->disableOriginalConstructor()->getMock(); $renderer->expects($this->once()) ->method('getFormatArray') diff --git a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php index 372aeca7a8407..c6b067cf661b4 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php @@ -37,12 +37,12 @@ class CurrentCustomerAddressTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->currentCustomerMock = $this->getMockBuilder('Magento\Customer\Helper\Session\CurrentCustomer') - ->disableOriginalConstructor() - ->getMock(); - $this->customerAccountManagementMock = $this->getMockBuilder('Magento\Customer\Api\AccountManagementInterface') + $this->currentCustomerMock = $this->getMockBuilder(\Magento\Customer\Helper\Session\CurrentCustomer::class) ->disableOriginalConstructor() ->getMock(); + $this->customerAccountManagementMock = $this->getMockBuilder( + \Magento\Customer\Api\AccountManagementInterface::class + )->disableOriginalConstructor()->getMock(); $this->currentCustomerAddress = new \Magento\Customer\Helper\Session\CurrentCustomerAddress( $this->currentCustomerMock, diff --git a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php index 3f390e2e34667..6ef8cb67751e1 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php @@ -70,32 +70,32 @@ class CurrentCustomerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->customerInterfaceFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->customerInterfaceFactoryMock = $this->getMock( + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create', 'setGroupId'], [], '', false ); - $this->customerDataMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterface', + $this->customerDataMock = $this->getMock( + \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false ); - $this->customerRepositoryMock = $this->getMock( - 'Magento\Customer\Api\CustomerRepositoryInterface', + $this->customerRepositoryMock = $this->getMock( + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], [], '', false ); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->moduleManagerMock = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\View', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->moduleManagerMock = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\View::class, [], [], '', false); $this->currentCustomer = new \Magento\Customer\Helper\Session\CurrentCustomer( $this->customerSessionMock, diff --git a/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php b/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php index b23e5bf4d7a20..c4617559d15db 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php @@ -20,12 +20,12 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->customerMetadataService = $this->getMock('Magento\Customer\Api\CustomerMetadataInterface'); + $this->customerMetadataService = $this->getMock(\Magento\Customer\Api\CustomerMetadataInterface::class); - $attributeMetadata = $this->getMock('Magento\Customer\Api\Data\AttributeMetadataInterface'); + $attributeMetadata = $this->getMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); $attributeMetadata->expects($this->any())->method('isVisible')->will($this->returnValue(true)); $this->customerMetadataService->expects($this->any()) ->method('getAttributeMetadata') @@ -39,7 +39,7 @@ protected function setUp() */ public function testGetCustomerName($prefix, $firstName, $middleName, $lastName, $suffix, $result) { - $customerData = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerData = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); $customerData->expects($this->any()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php index 2410bb894ce20..5d512bcc6bda1 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php @@ -16,6 +16,9 @@ use Magento\Store\Model\ScopeInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RedirectTest extends \PHPUnit_Framework_TestCase { /** @@ -80,9 +83,9 @@ class RedirectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface'); + $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); - $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods([ 'getLastCustomerId', @@ -101,39 +104,39 @@ protected function setUp() ]) ->getMock(); - $this->scopeConfig = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfig = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $this->storeManager->expects($this->once()) ->method('getStore') ->willReturn($this->store); - $this->url = $this->getMockForAbstractClass('Magento\Framework\UrlInterface'); - $this->urlDecoder = $this->getMockForAbstractClass('Magento\Framework\Url\DecoderInterface'); + $this->url = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class); + $this->urlDecoder = $this->getMockForAbstractClass(\Magento\Framework\Url\DecoderInterface::class); - $this->customerUrl = $this->getMockBuilder('Magento\Customer\Model\Url') + $this->customerUrl = $this->getMockBuilder(\Magento\Customer\Model\Url::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->resultRedirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForward = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward') + $this->resultForward = $this->getMockBuilder(\Magento\Framework\Controller\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Customer\Model\Account\Redirect', + \Magento\Customer\Model\Account\Redirect::class, [ 'request' => $this->request, 'customerSession' => $this->customerSession, diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php index 1bfcac2c81ff8..3e0c0f7ef1204 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php @@ -119,53 +119,59 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->customerFactory = $this->getMock('Magento\Customer\Model\CustomerFactory', ['create'], [], '', false); - $this->manager = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + $this->customerFactory = $this->getMock( + \Magento\Customer\Model\CustomerFactory::class, + ['create'], + [], + '', + false + ); + $this->manager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->random = $this->getMock('Magento\Framework\Math\Random'); - $this->validator = $this->getMock('Magento\Customer\Model\Metadata\Validator', [], [], '', false); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->random = $this->getMock(\Magento\Framework\Math\Random::class); + $this->validator = $this->getMock(\Magento\Customer\Model\Metadata\Validator::class, [], [], '', false); $this->validationResultsInterfaceFactory = $this->getMock( - 'Magento\Customer\Api\Data\ValidationResultsInterfaceFactory', + \Magento\Customer\Api\Data\ValidationResultsInterfaceFactory::class, [], [], '', false ); - $this->addressRepository = $this->getMock('Magento\Customer\Api\AddressRepositoryInterface'); - $this->customerMetadata = $this->getMock('Magento\Customer\Api\CustomerMetadataInterface'); - $this->customerRegistry = $this->getMock('Magento\Customer\Model\CustomerRegistry', [], [], '', false); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->encryptor = $this->getMock('Magento\Framework\Encryption\EncryptorInterface'); - $this->share = $this->getMock('Magento\Customer\Model\Config\Share', [], [], '', false); - $this->string = $this->getMock('Magento\Framework\Stdlib\StringUtils'); - $this->customerRepository = $this->getMock('Magento\Customer\Api\CustomerRepositoryInterface'); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->addressRepository = $this->getMock(\Magento\Customer\Api\AddressRepositoryInterface::class); + $this->customerMetadata = $this->getMock(\Magento\Customer\Api\CustomerMetadataInterface::class); + $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->encryptor = $this->getMock(\Magento\Framework\Encryption\EncryptorInterface::class); + $this->share = $this->getMock(\Magento\Customer\Model\Config\Share::class, [], [], '', false); + $this->string = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class); + $this->customerRepository = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $this->transportBuilder = $this->getMock( - 'Magento\Framework\Mail\Template\TransportBuilder', + \Magento\Framework\Mail\Template\TransportBuilder::class, [], [], '', false ); $this->dataObjectProcessor = $this->getMock( - 'Magento\Framework\Reflection\DataObjectProcessor', + \Magento\Framework\Reflection\DataObjectProcessor::class, [], [], '', false ); - $this->registry = $this->getMock('Magento\Framework\Registry'); - $this->customerViewHelper = $this->getMock('Magento\Customer\Helper\View', [], [], '', false); - $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); - $this->customer = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); - $this->objectFactory = $this->getMock('Magento\Framework\DataObjectFactory', [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->customerViewHelper = $this->getMock(\Magento\Customer\Helper\View::class, [], [], '', false); + $this->dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime::class); + $this->customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $this->objectFactory = $this->getMock(\Magento\Framework\DataObjectFactory::class, [], [], '', false); $this->extensibleDataObjectConverter = $this->getMock( - 'Magento\Framework\Api\ExtensibleDataObjectConverter', + \Magento\Framework\Api\ExtensibleDataObjectConverter::class, [], [], '', @@ -178,13 +184,13 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $this->customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->accountManagement = $this->objectManagerHelper->getObject( - 'Magento\Customer\Model\AccountManagement', + \Magento\Customer\Model\AccountManagement::class, [ 'customerFactory' => $this->customerFactory, 'eventManager' => $this->manager, @@ -231,11 +237,11 @@ public function testCreateAccountWithPasswordHashWithExistingCustomer() $customerEmail = 'email@email.com'; $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; - $website = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock(); $website->expects($this->once()) ->method('getStoreIds') ->willReturn([1, 2, 3]); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer->expects($this->once()) ->method('getId') ->willReturn($customerId); @@ -277,21 +283,21 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId() $customerEmail = 'email@email.com'; $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once()) ->method('getId') ->willReturn($defaultStoreId); - $website = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock(); $website->expects($this->once()) ->method('getStoreIds') ->willReturn([1, 2, 3]); $website->expects($this->once()) ->method('getDefaultStore') ->willReturn($store); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); @@ -353,21 +359,21 @@ public function testCreateAccountWithPasswordHashWithLocalizedException() $customerEmail = 'email@email.com'; $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once()) ->method('getId') ->willReturn($defaultStoreId); - $website = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock(); $website->expects($this->once()) ->method('getStoreIds') ->willReturn([1, 2, 3]); $website->expects($this->once()) ->method('getDefaultStore') ->willReturn($store); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); @@ -429,24 +435,24 @@ public function testCreateAccountWithPasswordHashWithAddressException() $customerEmail = 'email@email.com'; $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); $address->expects($this->once()) ->method('setCustomerId') ->with($customerId); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once()) ->method('getId') ->willReturn($defaultStoreId); - $website = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock(); $website->expects($this->once()) ->method('getStoreIds') ->willReturn([1, 2, 3]); $website->expects($this->once()) ->method('getDefaultStore') ->willReturn($store); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); @@ -514,7 +520,7 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce $storeName = 'store_name'; $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $customerMock->expects($this->atLeastOnce()) @@ -535,7 +541,7 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce ->with(null) ->willReturnSelf(); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); @@ -572,24 +578,24 @@ public function testCreateAccountWithoutPassword() $customerEmail = 'email@email.com'; $newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu'; - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); $address->expects($this->once()) ->method('setCustomerId') ->with($customerId); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once()) ->method('getId') ->willReturn($defaultStoreId); - $website = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock(); $website->expects($this->atLeastOnce()) ->method('getStoreIds') ->willReturn([1, 2, 3]); $website->expects($this->once()) ->method('getDefaultStore') ->willReturn($store); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); @@ -636,7 +642,7 @@ public function testCreateAccountWithoutPassword() $this->random->expects($this->once()) ->method('getUniqueHash') ->willReturn($newLinkToken); - $customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->disableOriginalConstructor() ->getMock(); $customerSecure->expects($this->any()) @@ -720,20 +726,20 @@ public function testCreateAccountWithPasswordInputException( if ($testNumber == 1) { $this->setExpectedException( - '\Magento\Framework\Exception\InputException', + \Magento\Framework\Exception\InputException::class, 'Please enter a password with at least ' . $minPasswordLength . ' characters.' ); } if ($testNumber == 2) { $this->setExpectedException( - '\Magento\Framework\Exception\InputException', + \Magento\Framework\Exception\InputException::class, 'Minimum of different classes of characters in password is ' . $minCharacterSetsNum . '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.' ); } - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $this->accountManagement->createAccount($customer, $password); } @@ -749,11 +755,11 @@ public function testCreateAccountInputExceptionExtraLongPassword() ->willReturn(iconv_strlen($password, 'UTF-8')); $this->setExpectedException( - '\Magento\Framework\Exception\InputException', + \Magento\Framework\Exception\InputException::class, 'Please enter a password with at most 256 characters.' ); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $this->accountManagement->createAccount($customer, $password); } @@ -812,24 +818,24 @@ public function testCreateAccountWithPassword() ->method('getHash') ->with($password, true) ->willReturn($hash); - $address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); $address->expects($this->once()) ->method('setCustomerId') ->with($customerId); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once()) ->method('getId') ->willReturn($defaultStoreId); - $website = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock(); $website->expects($this->atLeastOnce()) ->method('getStoreIds') ->willReturn([1, 2, 3]); $website->expects($this->once()) ->method('getDefaultStore') ->willReturn($store); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); @@ -876,7 +882,7 @@ public function testCreateAccountWithPassword() $this->random->expects($this->once()) ->method('getUniqueHash') ->willReturn($newLinkToken); - $customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash']) ->disableOriginalConstructor() ->getMock(); @@ -911,7 +917,7 @@ public function testSendPasswordReminderEmail() $templateIdentifier = 'Template Identifier'; $sender = 'Sender'; - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $customer->expects($this->any()) ->method('getStoreId') @@ -943,7 +949,7 @@ public function testSendPasswordReminderEmail() $this->dataObjectProcessor->expects($this->once()) ->method('buildOutputDataArray') - ->with($customer, '\Magento\Customer\Api\Data\CustomerInterface') + ->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelper->expects($this->any()) @@ -969,7 +975,7 @@ public function testSendPasswordReminderEmail() ->with(AccountManagement::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId) ->willReturn($sender); - $transport = $this->getMockBuilder('Magento\Framework\Mail\TransportInterface') + $transport = $this->getMockBuilder(\Magento\Framework\Mail\TransportInterface::class) ->getMock(); $this->transportBuilder->expects($this->once()) @@ -1030,7 +1036,7 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se ->method('getStore') ->willReturn($this->store); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $customer->expects($this->any()) ->method('getEmail') @@ -1084,7 +1090,7 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se $this->dataObjectProcessor->expects($this->any()) ->method('buildOutputDataArray') - ->with($customer, '\Magento\Customer\Api\Data\CustomerInterface') + ->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class) ->willReturn($customerData); $this->prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName); @@ -1099,7 +1105,7 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se */ protected function prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName) { - $transport = $this->getMockBuilder('Magento\Framework\Mail\TransportInterface') + $transport = $this->getMockBuilder(\Magento\Framework\Mail\TransportInterface::class) ->getMock(); $this->transportBuilder->expects($this->any()) @@ -1266,7 +1272,7 @@ public function testValidateResetPasswordToken() */ private function reInitModel() { - $this->customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $this->customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->disableOriginalConstructor() ->setMethods(['getRpToken', 'getRpTokenCreatedAt']) ->getMock(); @@ -1283,14 +1289,14 @@ private function reInitModel() ->method('getRpTokenCreatedAt') ->willReturn($date); - $this->customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $this->customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->setMethods(['getResetPasswordLinkExpirationPeriod']) ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->accountManagement = $this->objectManagerHelper->getObject( - 'Magento\Customer\Model\AccountManagement', + \Magento\Customer\Model\AccountManagement::class, [ 'customerFactory' => $this->customerFactory, 'customerRegistry' => $this->customerRegistry, @@ -1315,7 +1321,7 @@ public function testChangePassword() $newPassword = 'abcdefg'; $passwordHash = '1a2b3f4c'; - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $customer->expects($this->any()) ->method('getId') @@ -1330,7 +1336,7 @@ public function testChangePassword() $this->authenticationMock->expects($this->once()) ->method('authenticate'); - $customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash']) ->disableOriginalConstructor() ->getMock(); @@ -1399,7 +1405,7 @@ public function testChangePasswordException() ->willThrowException($exception); $this->setExpectedException( - '\Magento\Framework\Exception\InvalidEmailOrPasswordException', + \Magento\Framework\Exception\InvalidEmailOrPasswordException::class, 'Invalid login or password.' ); @@ -1415,10 +1421,10 @@ public function testAuthenticate() $password = '1234567'; $passwordHash = '1a2b3f4c'; - $customerData = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerData = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); - $customerModel = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customerModel = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $customerModel->expects($this->once()) @@ -1434,7 +1440,7 @@ public function testAuthenticate() $this->authenticationMock->expects($this->once()) ->method('authenticate'); - $customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->setMethods(['getPasswordHash']) ->disableOriginalConstructor() ->getMock(); @@ -1482,7 +1488,7 @@ public function testGetConfirmationStatus( $customerId = 1; $customerEmail = 'test1@example.com'; - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); $customerMock->expects($this->once()) @@ -1540,7 +1546,7 @@ public function testCreateAccountWithPasswordHashForGuest() $websiteId = 1; $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $storeMock->expects($this->once()) @@ -1557,7 +1563,7 @@ public function testCreateAccountWithPasswordHashForGuest() ->method('getStore') ->willReturn($storeMock); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); $customerMock->expects($this->exactly(2)) ->method('getId') diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php index 4b60508b384b5..4e0922721de5c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php @@ -6,6 +6,9 @@ namespace Magento\Customer\Test\Unit\Model\Address; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractAddressTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ @@ -40,27 +43,27 @@ class AbstractAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->directoryDataMock = $this->getMock('Magento\Directory\Helper\Data', [], [], '', false); - $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); - $this->addressConfigMock = $this->getMock('Magento\Customer\Model\Address\Config', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->directoryDataMock = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false); + $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->addressConfigMock = $this->getMock(\Magento\Customer\Model\Address\Config::class, [], [], '', false); $this->regionFactoryMock = $this->getMock( - 'Magento\Directory\Model\RegionFactory', + \Magento\Directory\Model\RegionFactory::class, ['create'], [], '', false ); $this->countryFactoryMock = $this->getMock( - 'Magento\Directory\Model\CountryFactory', + \Magento\Directory\Model\CountryFactory::class, ['create'], [], '', false ); $regionCollectionMock = $this->getMock( - 'Magento\Directory\Model\ResourceModel\Region\Collection', + \Magento\Directory\Model\ResourceModel\Region\Collection::class, [], [], '', @@ -69,7 +72,7 @@ protected function setUp() $regionCollectionMock->expects($this->any()) ->method('getSize') ->will($this->returnValue(0)); - $countryMock = $this->getMock('Magento\Directory\Model\Country', [], [], '', false); + $countryMock = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); $countryMock->expects($this->any()) ->method('getRegionCollection') ->will($this->returnValue($regionCollectionMock)); @@ -77,13 +80,13 @@ protected function setUp() ->method('create') ->will($this->returnValue($countryMock)); - $this->resourceMock = $this->getMock('Magento\Customer\Model\ResourceModel\Customer', [], [], '', false); - $this->resourceCollectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $this->resourceMock = $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); + $this->resourceCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Customer\Model\Address\AbstractAddress', + \Magento\Customer\Model\Address\AbstractAddress::class, [ 'context' => $this->contextMock, 'registry' => $this->registryMock, @@ -180,7 +183,7 @@ public function testGetRegionCodeWithoutRegion() protected function prepareGetRegion($countryId, $regionName = 'RegionName') { $region = $this->getMock( - 'Magento\Directory\Model\Region', + \Magento\Directory\Model\Region::class, ['getCountryId', 'getName', '__wakeup', 'load'], [], '', @@ -203,7 +206,7 @@ protected function prepareGetRegion($countryId, $regionName = 'RegionName') protected function prepareGetRegionCode($countryId, $regionCode = 'UK') { $region = $this->getMock( - 'Magento\Directory\Model\Region', + \Magento\Directory\Model\Region::class, ['getCountryId', 'getCode', '__wakeup', 'load'], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php index 3215e44546c16..8c31fcaec7297 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php @@ -34,7 +34,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); + $this->_fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); $this->_fileResolverMock->expects( $this->once() )->method( @@ -51,10 +51,10 @@ protected function setUp() ) ); - $this->_converter = $this->getMock('Magento\Customer\Model\Address\Config\Converter', ['convert']); + $this->_converter = $this->getMock(\Magento\Customer\Model\Address\Config\Converter::class, ['convert']); $moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['getModuleDir'], [], '', @@ -73,7 +73,7 @@ protected function setUp() ); $this->_schemaLocator = new \Magento\Customer\Model\Address\Config\SchemaLocator($moduleReader); - $this->_validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->_validationState = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->_validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(false); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php index 3e50b5f955506..c5acccc755052 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php @@ -31,7 +31,7 @@ protected function setUp() { $this->_xsdFile = $this->_xsdDir . '/address_formats.xsd'; $this->_moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['getModuleDir'], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php index a128b8e6de698..c0b0cd8fc92f4 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php @@ -30,7 +30,13 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php index 9dbec230b4321..5c2aeec636cec 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php @@ -49,18 +49,18 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $this->_scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->_storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_readerMock = $this->getMock( - 'Magento\Customer\Model\Address\Config\Reader', + \Magento\Customer\Model\Address\Config\Reader::class, [], [], '', false ); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); + $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $this->_storeManagerMock->expects( $this->once() )->method( @@ -69,7 +69,7 @@ protected function setUp() $this->returnValue($this->_storeMock) ); - $this->_addressHelperMock = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); + $this->_addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); $this->_cacheMock->expects( $this->once() @@ -123,7 +123,7 @@ public function testGetFormats() $this->_scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue('someValue')); - $rendererMock = $this->getMock('Magento\Framework\DataObject'); + $rendererMock = $this->getMock(\Magento\Framework\DataObject::class); $this->_addressHelperMock->expects( $this->any() diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php index fd9d91eaa5186..cea1bc43001fc 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php @@ -21,12 +21,12 @@ class MapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->extensibleObjectConverter = $this->getMockBuilder('Magento\Framework\Api\ExtensibleDataObjectConverter') - ->disableOriginalConstructor() - ->getMock(); + $this->extensibleObjectConverter = $this->getMockBuilder( + \Magento\Framework\Api\ExtensibleDataObjectConverter::class + )->disableOriginalConstructor()->getMock(); $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->addressMapper = $this->_objectManager->getObject( - 'Magento\Customer\Model\Address\Mapper', + \Magento\Customer\Model\Address\Mapper::class, [ 'extensibleDataObjectConverter' => $this->extensibleObjectConverter ] @@ -67,12 +67,17 @@ public function testToFlatArray() protected function createAddressMock() { /** @var \Magento\Customer\Api\Data\RegionInterface|\PHPUnit_Framework_MockObject_MockObject $regionMock */ - $regionMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\RegionInterface', [], '', false); + $regionMock = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\RegionInterface::class, [], '', false); $regionMock->expects($this->any())->method('getRegion')->willReturn('Texas'); $regionMock->expects($this->any())->method('getRegionId')->willReturn(1); $regionMock->expects($this->any())->method('getRegionCode')->willReturn('TX'); /** @var \Magento\Customer\Api\Data\AddressInterface|\PHPUnit_Framework_MockObject_MockObject $regionMock */ - $addressMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $addressMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $addressMock->expects($this->any())->method('getId')->willReturn('1'); $addressMock->expects($this->any())->method('getDefaultBilling')->willReturn(true); $addressMock->expects($this->any())->method('getDefaultShipping')->willReturn(false); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php index fa5252f0680b0..c03fe817b10fd 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php @@ -16,7 +16,7 @@ public function testIsValid() { $countryUs = 'US'; $countryUa = 'UK'; - $helperMock = $this->getMockBuilder('Magento\Directory\Helper\Data') + $helperMock = $this->getMockBuilder(\Magento\Directory\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php b/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php index 9662a48de3857..11bed26ad970c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php @@ -21,7 +21,7 @@ class AddressRegistryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->addressFactory = $this->getMockBuilder('\Magento\Customer\Model\AddressFactory') + $this->addressFactory = $this->getMockBuilder(\Magento\Customer\Model\AddressFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -31,7 +31,7 @@ protected function setUp() public function testRetrieve() { $addressId = 1; - $address = $this->getMockBuilder('\Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', '__wakeup']) ->getMock(); @@ -57,7 +57,7 @@ public function testRetrieve() public function testRetrieveException() { $addressId = 1; - $address = $this->getMockBuilder('\Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->setMethods(['load', 'getId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -77,7 +77,7 @@ public function testRetrieveException() public function testRemove() { $addressId = 1; - $address = $this->getMockBuilder('\Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php index ecdbecce9946c..c8776211ff52a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php @@ -40,7 +40,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $this->customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $this->customer->expects($this->any()) @@ -50,7 +50,7 @@ protected function setUp() ->method('load') ->will($this->returnSelf()); - $this->customerFactory = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory') + $this->customerFactory = $this->getMockBuilder(\Magento\Customer\Model\CustomerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -58,12 +58,12 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->customer)); - $this->resource = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Address') + $this->resource = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Address::class) ->disableOriginalConstructor() ->getMock(); $this->address = $this->objectManager->getObject( - 'Magento\Customer\Model\Address', + \Magento\Customer\Model\Address::class, [ 'customerFactory' => $this->customerFactory, 'resource' => $this->resource, @@ -91,7 +91,7 @@ public function testCustomer() $this->assertEquals(self::ORIG_CUSTOMER_ID, $customer->getId()); /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $customer->expects($this->any()) @@ -124,7 +124,7 @@ public function testRegionId() public function testGetEntityTypeId() { - $mockEntityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $mockEntityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); $mockEntityType->expects($this->any()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php b/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php index 2063c756fda1e..c5ab448f97647 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php @@ -49,14 +49,14 @@ class ContextPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerSessionMock = $this->getMock( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, [], [], '', false ); $this->httpContextMock = $this->getMock( - 'Magento\Framework\App\Http\Context', + \Magento\Framework\App\Http\Context::class, [], [], '', @@ -65,8 +65,8 @@ protected function setUp() $this->closureMock = function () { return 'ExpectedValue'; }; - $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->subjectMock = $this->getMock(\Magento\Framework\App\Action\Action::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->plugin = new \Magento\Customer\Model\App\Action\ContextPlugin( $this->customerSessionMock, $this->httpContextMock diff --git a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php index 51653c0acf318..9c5e7ad697d7a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php @@ -27,11 +27,11 @@ protected function setUp() */ public function testBeforeSave($value, $defaultValue, $result) { - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['getName', 'getDefaultValue']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $customerMock = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customerMock = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php index 31cadf5bb6f77..2001cf0d898ba 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php @@ -38,16 +38,16 @@ class PostcodeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); - $this->directoryHelperMock = $this->getMockBuilder('Magento\Directory\Helper\Data') + $this->directoryHelperMock = $this->getMockBuilder(\Magento\Directory\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $this->attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods(['getStoreLabel']) ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php index dae3fb2c453fc..cad1c6d88f567 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php @@ -129,56 +129,58 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->getMock(); - $this->extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + $this->extensionAttributesFactory = $this->getMockBuilder( + \Magento\Framework\Api\ExtensionAttributesFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->typeFactoryMock = $this->getMockBuilder('Magento\Eav\Model\Entity\TypeFactory') + $this->typeFactoryMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\TypeFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Helper') + $this->helperMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Helper::class) ->disableOriginalConstructor() ->getMock(); - $this->universalFactoryMock = $this->getMockBuilder('Magento\Framework\Validator\UniversalFactory') + $this->universalFactoryMock = $this->getMockBuilder(\Magento\Framework\Validator\UniversalFactory::class) ->disableOriginalConstructor() ->getMock(); $this->attributeOptionFactoryMock = - $this->getMockBuilder('Magento\Eav\Api\Data\AttributeOptionInterfaceFactory') + $this->getMockBuilder(\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $this->dataObjectProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); - $this->reservedAttributeListMock = $this->getMockBuilder('Magento\Catalog\Model\Product\ReservedAttributeList') + $this->reservedAttributeListMock = $this->getMockBuilder( + \Magento\Catalog\Model\Product\ReservedAttributeList::class) ->disableOriginalConstructor() ->getMock(); - $this->resolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->resolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); - $this->dateTimeFormatter = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface'); + $this->dateTimeFormatter = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->setMethods(['_construct', 'getConnection', 'getIdFieldName', 'saveInSetIncluding']) ->getMockForAbstractClass(); - $this->cacheManager = $this->getMockBuilder('Magento\Framework\App\CacheInterface') + $this->cacheManager = $this->getMockBuilder(\Magento\Framework\App\CacheInterface::class) ->getMock(); - $this->eventDispatcher = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->getMock(); $this->contextMock @@ -190,7 +192,7 @@ protected function setUp() ->method('getEventDispatcher') ->willReturn($this->eventDispatcher); - $this->indexerRegistryMock = $this->getMockBuilder('Magento\Framework\Indexer\IndexerRegistry') + $this->indexerRegistryMock = $this->getMockBuilder(\Magento\Framework\Indexer\IndexerRegistry::class) ->disableOriginalConstructor() ->getMock(); @@ -243,7 +245,7 @@ public function testAfterDeleteEavCache() public function testInvalidate() { /** @var IndexerInterface|\PHPUnit_Framework_MockObject_MockObject $indexerMock */ - $indexerMock = $this->getMockBuilder('Magento\Framework\Indexer\IndexerInterface') + $indexerMock = $this->getMockBuilder(\Magento\Framework\Indexer\IndexerInterface::class) ->getMockForAbstractClass(); $this->indexerRegistryMock->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php b/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php index f444162880427..cb0565e317364 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php @@ -47,12 +47,12 @@ class AuthenticationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->backendConfigMock = $this->getMockBuilder('Magento\Backend\App\ConfigInterface') + $this->backendConfigMock = $this->getMockBuilder(\Magento\Backend\App\ConfigInterface::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMockForAbstractClass(); $this->customerRegistryMock = $this->getMock( - 'Magento\Customer\Model\CustomerRegistry', + \Magento\Customer\Model\CustomerRegistry::class, ['retrieveSecureData', 'retrieve'], [], '', @@ -65,7 +65,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->customerSecure = $this->getMock( - 'Magento\Customer\Model\Data\CustomerSecure', + \Magento\Customer\Model\Data\CustomerSecure::class, [ 'getId', 'getPasswordHash', @@ -257,7 +257,7 @@ public function testValidateCustomerPassword($result) $hash = '1b2af329dd0'; $customerMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', @@ -308,7 +308,7 @@ public function testValidateCustomerPassword($result) ->method('save') ->willReturn($customerMock); - $this->setExpectedException('\Magento\Framework\Exception\InvalidEmailOrPasswordException'); + $this->setExpectedException(\Magento\Framework\Exception\InvalidEmailOrPasswordException::class); $this->authentication->authenticate($customerId, $password); } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php b/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php index 48b81bb83f00a..5255ee1b4cabd 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php @@ -32,13 +32,13 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); $this->customerSessionUserContext = $this->objectManager->getObject( - 'Magento\Customer\Model\Authorization\CustomerSessionUserContext', + \Magento\Customer\Model\Authorization\CustomerSessionUserContext::class, ['customerSession' => $this->customerSession] ); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php index 9513fbb6a3361..9c423183922f7 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php @@ -24,10 +24,10 @@ class CustomerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $this->_storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $helper->getObject( - 'Magento\Customer\Model\Backend\Customer', + \Magento\Customer\Model\Backend\Customer::class, ['storeManager' => $this->_storeManager] ); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php index f17936c66daa7..c74eaf54549f5 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php @@ -44,25 +44,25 @@ class ConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->storeManager = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false ); $this->urlBuilder = $this->getMockForAbstractClass( - 'Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, [], '', false ); $this->scopeConfig = $this->getMockForAbstractClass( - 'Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false ); $this->store = $this->getMockForAbstractClass( - 'Magento\Store\Api\Data\StoreInterface', + \Magento\Store\Api\Data\StoreInterface::class, [], '', false, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php index a1a4fd2005e2e..08eb3ec761a20 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php @@ -19,13 +19,13 @@ class DisableAutoGroupAssignDefaultTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eavConfigMock = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Customer\Model\Config\Backend\CreateAccount\DisableAutoGroupAssignDefault', + \Magento\Customer\Model\Config\Backend\CreateAccount\DisableAutoGroupAssignDefault::class, [ 'eavConfig' => $this->eavConfigMock, ] @@ -36,7 +36,7 @@ public function testAfterSave() { $value = true; - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['save', 'setData']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php index 64da980b20486..3b8bea594ed52 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php @@ -25,8 +25,8 @@ class MultiselectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupServiceMock = $this->getMock('\Magento\Customer\Api\GroupManagementInterface'); - $this->converterMock = $this->getMock('\Magento\Framework\Convert\DataObject', [], [], '', false); + $this->groupServiceMock = $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class); + $this->converterMock = $this->getMock(\Magento\Framework\Convert\DataObject::class, [], [], '', false); $this->model = new \Magento\Customer\Model\Config\Source\Group\Multiselect($this->groupServiceMock, $this->converterMock); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php index 8430eef88e7df..edb3405451eca 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php @@ -25,8 +25,8 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupServiceMock = $this->getMock('\Magento\Customer\Api\GroupManagementInterface'); - $this->converterMock = $this->getMock('\Magento\Framework\Convert\DataObject', [], [], '', false); + $this->groupServiceMock = $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class); + $this->converterMock = $this->getMock(\Magento\Framework\Convert\DataObject::class, [], [], '', false); $this->model = new \Magento\Customer\Model\Config\Source\Group($this->groupServiceMock, $this->converterMock); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php index 931fe19922254..4d7a9b96919cf 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php @@ -16,14 +16,14 @@ class BillingTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); /** @var \Psr\Log\LoggerInterface $logger */ $this->testable = new \Magento\Customer\Model\Customer\Attribute\Backend\Billing($logger); } public function testBeforeSave() { - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getDefaultBilling', 'unsetDefaultBilling']) ->getMock(); @@ -40,22 +40,22 @@ public function testAfterSave() $addressId = 1; $attributeCode = 'attribute_code'; $defaultBilling = 'default billing address'; - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getDefaultBilling', 'getAddresses', 'setDefaultBilling']) ->getMock(); - $address = $this->getMockBuilder('Magento\Framework\DataObject') + $address = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getPostIndex', 'getId']) ->getMock(); - $attribute = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['__wakeup', 'getEntity', 'getAttributeCode']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $entity = $this->getMockBuilder('Magento\Eav\Model\Entity\AbstractEntity') + $entity = $this->getMockBuilder(\Magento\Eav\Model\Entity\AbstractEntity::class) ->setMethods(['saveAttribute']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php index f6d6a32dccaf2..b65965cfb3e90 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php @@ -25,7 +25,7 @@ protected function setUp() public function testValidatePositive() { $password = 'password'; - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getPassword', 'getPasswordConfirm']) ->getMock(); @@ -52,7 +52,7 @@ public function passwordNegativeDataProvider() */ public function testBeforeSaveNegative($password) { - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getPassword']) ->getMock(); @@ -67,7 +67,7 @@ public function testBeforeSavePositive() { $password = 'more-then-6'; $passwordHash = 'password-hash'; - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getPassword', 'setPasswordHash', 'hashPassword']) ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php index d363c62e89af4..fb2b212ab722b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php @@ -17,14 +17,14 @@ class ShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); /** @var \Psr\Log\LoggerInterface $logger */ $this->testable = new \Magento\Customer\Model\Customer\Attribute\Backend\Shipping($logger); } public function testBeforeSave() { - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getDefaultShipping', 'unsetDefaultShipping']) ->getMock(); @@ -41,22 +41,22 @@ public function testAfterSave() $addressId = 1; $attributeCode = 'attribute_code'; $defaultShipping = 'default Shipping address'; - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getDefaultShipping', 'getAddresses', 'setDefaultShipping']) ->getMock(); - $address = $this->getMockBuilder('Magento\Framework\DataObject') + $address = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getPostIndex', 'getId']) ->getMock(); - $attribute = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['__wakeup', 'getEntity', 'getAttributeCode']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $entity = $this->getMockBuilder('Magento\Eav\Model\Entity\AbstractEntity') + $entity = $this->getMockBuilder(\Magento\Eav\Model\Entity\AbstractEntity::class) ->setMethods(['saveAttribute']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php index 8fe7a6c0595a7..120f87acc0299 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php @@ -22,7 +22,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ $this->testable = new \Magento\Customer\Model\Customer\Attribute\Backend\Store($storeManager); @@ -30,7 +30,7 @@ protected function setUp() public function testBeforeSaveWithId() { - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); @@ -39,7 +39,7 @@ public function testBeforeSaveWithId() /** @var \Magento\Framework\DataObject $object */ $this->assertInstanceOf( - 'Magento\Customer\Model\Customer\Attribute\Backend\Store', + \Magento\Customer\Model\Customer\Attribute\Backend\Store::class, $this->testable->beforeSave($object) ); } @@ -48,12 +48,14 @@ public function testBeforeSave() { $storeId = 1; $storeName = 'store'; - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getId', 'hasStoreId', 'setStoreId', 'hasData', 'setData', 'getStoreId']) ->getMock(); - $store = $this->getMockBuilder('Magento\Framework\DataObject')->setMethods(['getId', 'getName'])->getMock(); + $store = $this->getMockBuilder( + \Magento\Framework\DataObject::class + )->setMethods(['getId', 'getName'])->getMock(); $store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); $store->expects($this->once())->method('getName')->will($this->returnValue($storeName)); @@ -73,7 +75,7 @@ public function testBeforeSave() /** @var \Magento\Framework\DataObject $object */ $this->assertInstanceOf( - 'Magento\Customer\Model\Customer\Attribute\Backend\Store', + \Magento\Customer\Model\Customer\Attribute\Backend\Store::class, $this->testable->beforeSave($object) ); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php index 040a79d99cc97..e3a26819688dc 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php @@ -22,7 +22,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ $this->testable = new \Magento\Customer\Model\Customer\Attribute\Backend\Website($storeManager); @@ -30,7 +30,7 @@ protected function setUp() public function testBeforeSaveWithId() { - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); @@ -39,7 +39,7 @@ public function testBeforeSaveWithId() /** @var \Magento\Framework\DataObject $object */ $this->assertInstanceOf( - 'Magento\Customer\Model\Customer\Attribute\Backend\Website', + \Magento\Customer\Model\Customer\Attribute\Backend\Website::class, $this->testable->beforeSave($object) ); } @@ -47,12 +47,12 @@ public function testBeforeSaveWithId() public function testBeforeSave() { $websiteId = 1; - $object = $this->getMockBuilder('Magento\Framework\DataObject') + $object = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['hasData', 'setData']) ->getMock(); - $store = $this->getMockBuilder('Magento\Framework\DataObject')->setMethods(['getWebsiteId'])->getMock(); + $store = $this->getMockBuilder(\Magento\Framework\DataObject::class)->setMethods(['getWebsiteId'])->getMock(); $store->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId)); $this->storeManager->expects($this->once()) @@ -67,7 +67,7 @@ public function testBeforeSave() /** @var \Magento\Framework\DataObject $object */ $this->assertInstanceOf( - 'Magento\Customer\Model\Customer\Attribute\Backend\Website', + \Magento\Customer\Model\Customer\Attribute\Backend\Website::class, $this->testable->beforeSave($object) ); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php index 052c54e19b68f..32dfc277fa4c4 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php @@ -25,14 +25,14 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->collectionFactoryMock = - $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory') + $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory::class) ->disableOriginalConstructor() ->getMock(); $this->optionFactoryMock = - $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory') + $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->storeMock = $this->getMockBuilder('Magento\Store\Model\System\Store') + $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\System\Store::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 8627a4737d614..a2f29fafe1abb 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -18,6 +18,8 @@ * Class DataProviderTest * * Test for class \Magento\Customer\Model\Customer\DataProvider + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DataProviderTest extends \PHPUnit_Framework_TestCase { @@ -51,22 +53,22 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->eavConfigMock = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); $this->customerCollectionFactoryMock = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Customer\CollectionFactory', + \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, ['create'], [], '', false ); $this->eavValidationRulesMock = $this - ->getMockBuilder('Magento\Ui\DataProvider\EavValidationRules') + ->getMockBuilder(\Magento\Ui\DataProvider\EavValidationRules::class) ->disableOriginalConstructor() ->getMock(); $this->sessionMock = $this - ->getMockBuilder('Magento\Framework\Session\SessionManagerInterface') + ->getMockBuilder(\Magento\Framework\Session\SessionManagerInterface::class) ->setMethods(['getCustomerFormData', 'unsCustomerFormData']) ->getMockForAbstractClass(); } @@ -83,7 +85,7 @@ public function testGetAttributesMetaWithOptions(array $expected) { $helper = new ObjectManager($this); $dataProvider = $helper->getObject( - '\Magento\Customer\Model\Customer\DataProvider', + \Magento\Customer\Model\Customer\DataProvider::class, [ 'name' => 'test-name', 'primaryFieldName' => 'primary-field-name', @@ -212,7 +214,7 @@ public function getAttributesMetaDataProvider() */ protected function getCustomerCollectionFactoryMock() { - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -249,7 +251,7 @@ protected function getEavConfigMock() */ protected function getTypeCustomerMock() { - $typeCustomerMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $typeCustomerMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); @@ -265,7 +267,7 @@ protected function getTypeCustomerMock() */ protected function getTypeAddressMock() { - $typeAddressMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $typeAddressMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); @@ -281,11 +283,11 @@ protected function getTypeAddressMock() */ protected function getAttributeMock() { - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['getAttributeCode', 'getDataUsingMethod', 'usesSource', 'getSource']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $sourceMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Source\AbstractSource') + $sourceMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -311,7 +313,7 @@ function ($origName) { ->method('getSource') ->willReturn($sourceMock); - $attributeBooleanMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeBooleanMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['getAttributeCode', 'getDataUsingMethod', 'usesSource', 'getFrontendInput']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -344,13 +346,13 @@ function ($origName) { public function testGetData() { - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->getMock(); - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -392,7 +394,7 @@ public function testGetData() $helper = new ObjectManager($this); $dataProvider = $helper->getObject( - '\Magento\Customer\Model\Customer\DataProvider', + \Magento\Customer\Model\Customer\DataProvider::class, [ 'name' => 'test-name', 'primaryFieldName' => 'primary-field-name', @@ -462,13 +464,13 @@ public function testGetDataWithCustomerFormData() ], ]; - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->getMock(); - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -513,7 +515,7 @@ public function testGetDataWithCustomerFormData() $helper = new ObjectManager($this); $dataProvider = $helper->getObject( - '\Magento\Customer\Model\Customer\DataProvider', + \Magento\Customer\Model\Customer\DataProvider::class, [ 'name' => 'test-name', 'primaryFieldName' => 'primary-field-name', diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php index c414d648b2172..836bdf35b68ff 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php @@ -45,7 +45,7 @@ class CustomerExtractorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->formFactory = $this->getMockForAbstractClass( - 'Magento\Customer\Model\Metadata\FormFactory', + \Magento\Customer\Model\Metadata\FormFactory::class, [], '', false, @@ -54,7 +54,7 @@ protected function setUp() ['create'] ); $this->customerFactory = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, [], '', false, @@ -63,34 +63,34 @@ protected function setUp() ['create'] ); $this->storeManager = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false ); $this->customerGroupManagement = $this->getMockForAbstractClass( - 'Magento\Customer\Api\GroupManagementInterface', + \Magento\Customer\Api\GroupManagementInterface::class, [], '', false ); - $this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); - $this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface', [], '', false); - $this->customerForm = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false); + $this->customerForm = $this->getMock(\Magento\Customer\Model\Metadata\Form::class, [], [], '', false); $this->customerData = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false ); $this->store = $this->getMockForAbstractClass( - 'Magento\Store\Api\Data\StoreInterface', + \Magento\Store\Api\Data\StoreInterface::class, [], '', false ); $this->customerGroup = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\GroupInterface', + \Magento\Customer\Api\Data\GroupInterface::class, [], '', false @@ -128,7 +128,7 @@ public function testExtract() ->willReturn($this->customerData); $this->dataObjectHelper->expects($this->once()) ->method('populateWithArray') - ->with($this->customerData, $customerData, '\Magento\Customer\Api\Data\CustomerInterface') + ->with($this->customerData, $customerData, \Magento\Customer\Api\Data\CustomerInterface::class) ->willReturn($this->customerData); $this->storeManager->expects($this->once()) ->method('getStore') diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php index 7253448df068f..d65535dabf3bb 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php @@ -20,7 +20,7 @@ class CustomerManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customersFactoryMock = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Customer\CollectionFactory', + \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, ['create'], [], '', @@ -33,7 +33,13 @@ protected function setUp() public function testGetCount() { - $customersMock = $this->getMock('\Magento\Customer\Model\ResourceModel\Customer\Collection', [], [], '', false); + $customersMock = $this->getMock( + \Magento\Customer\Model\ResourceModel\Customer\Collection::class, + [], + [], + '', + false + ); $this->customersFactoryMock ->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php index 029f73b3e30df..91227f8609d03 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php @@ -38,16 +38,16 @@ class CustomerRegistryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerFactory = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory') + $this->customerFactory = $this->getMockBuilder(\Magento\Customer\Model\CustomerFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManager($this); $this->customerRegistry = $objectManager->getObject( - 'Magento\Customer\Model\CustomerRegistry', + \Magento\Customer\Model\CustomerRegistry::class, ['customerFactory' => $this->customerFactory] ); - $this->customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $this->customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->setMethods( [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php index 47bccc6c4b448..81756913e1d7d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php @@ -60,42 +60,42 @@ class CustomerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_website = $this->getMock('Magento\Store\Model\Website', [], [], '', false); - $this->_config = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); - $this->_attribute = $this->getMock('Magento\Eav\Model\Attribute', [], [], '', false); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $this->_storetMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->_scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->_website = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $this->_config = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->_attribute = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $this->_storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->_storetMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_transportBuilderMock = $this->getMock( - '\Magento\Framework\Mail\Template\TransportBuilder', + \Magento\Framework\Mail\Template\TransportBuilder::class, [], [], '', false ); $this->_transportMock = $this->getMock( - 'Magento\Framework\Mail\TransportInterface', + \Magento\Framework\Mail\TransportInterface::class, [], [], '', false ); $this->attributeFactoryMock = $this->getMock( - 'Magento\Customer\Model\AttributeFactory', + \Magento\Customer\Model\AttributeFactory::class, ['create'], [], '', false ); $this->attributeCustomerMock = $this->getMock( - 'Magento\Customer\Model\Attribute', + \Magento\Customer\Model\Attribute::class, [], [], '', false ); $this->resourceMock = $this->getMock( - '\Magento\Customer\Model\ResourceModel\Customer', //'\Magento\Framework\DataObject', + \Magento\Customer\Model\ResourceModel\Customer::class, // \Magento\Framework\DataObject::class, ['getIdFieldName'], [], '', @@ -105,11 +105,11 @@ protected function setUp() $this->resourceMock->expects($this->any()) ->method('getIdFieldName') ->will($this->returnValue('id')); - $this->registryMock = $this->getMock('Magento\Framework\Registry', ['registry'], [], '', false); - $this->_encryptor = $this->getMock('Magento\Framework\Encryption\EncryptorInterface'); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, ['registry'], [], '', false); + $this->_encryptor = $this->getMock(\Magento\Framework\Encryption\EncryptorInterface::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $helper->getObject( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, [ 'storeManager' => $this->_storeManager, 'config' => $this->_config, @@ -192,8 +192,8 @@ public function testSendNewAccountEmailException() public function testSendNewAccountEmailWithoutStoreId() { - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $website = $this->getMock('Magento\Store\Model\Website', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $website = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $website->expects($this->once()) ->method('getStoreIds') ->will($this->returnValue([1, 2, 3, 4])); @@ -226,7 +226,7 @@ public function testSendNewAccountEmailWithoutStoreId() ->method($method) ->will($this->returnSelf()); } - $transportMock = $this->getMock('Magento\Framework\Mail\TransportInterface', [], [], '', false); + $transportMock = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false); $transportMock->expects($this->once()) ->method('sendMessage') ->will($this->returnSelf()); diff --git a/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php b/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php index 4fe2efed4c0f1..3211eb7e511bc 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php @@ -22,7 +22,7 @@ class GroupRegistryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupFactory = $this->getMockBuilder('\Magento\Customer\Model\GroupFactory') + $this->groupFactory = $this->getMockBuilder(\Magento\Customer\Model\GroupFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -37,7 +37,7 @@ protected function setUp() public function testRetrieve() { $groupId = 1; - $group = $this->getMockBuilder('Magento\Customer\Model\Group') + $group = $this->getMockBuilder(\Magento\Customer\Model\Group::class) ->setMethods(['load', 'getId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -66,7 +66,7 @@ public function testRetrieve() public function testRetrieveException() { $groupId = 1; - $group = $this->getMockBuilder('Magento\Customer\Model\Group') + $group = $this->getMockBuilder(\Magento\Customer\Model\Group::class) ->setMethods(['load', 'getId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -91,7 +91,7 @@ public function testRetrieveException() public function testRemove() { $groupId = 1; - $group = $this->getMockBuilder('Magento\Customer\Model\Group') + $group = $this->getMockBuilder(\Magento\Customer\Model\Group::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php b/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php index 3069daec55ec3..3762a48ec3588 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php @@ -33,23 +33,33 @@ class FilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->connection = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false ); $this->flatScopeResolver = $this->getMock( - 'Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver', + \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class, [], [], '', false ); - $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); - $this->indexer = $this->getMockForAbstractClass('Magento\Framework\Indexer\IndexerInterface', [], '', false); - $this->indexerState = $this->getMockForAbstractClass('Magento\Framework\Indexer\StateInterface', [], '', false); + $this->indexerRegistry = $this->getMock(\Magento\Framework\Indexer\IndexerRegistry::class, [], [], '', false); + $this->indexer = $this->getMockForAbstractClass( + \Magento\Framework\Indexer\IndexerInterface::class, + [], + '', + false + ); + $this->indexerState = $this->getMockForAbstractClass( + \Magento\Framework\Indexer\StateInterface::class, + [], + '', + false + ); $this->model = new Filter( $this->resource, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php index 5671a6f4ac3a7..b29a61c5748f6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php @@ -23,7 +23,7 @@ class AttributeProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eavConfig = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); $this->object = new AttributeProvider( @@ -51,19 +51,19 @@ public function testAddDynamicData() $attrFrontendInput = 'int'; /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */ - $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $entityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ - $collectionMock = $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */ - $entity = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer') + $entity = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ - $attribute = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $attribute = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->setMethods( [ @@ -123,7 +123,7 @@ public function testAddDynamicData() $existentName => $existentField, $attrName => [ 'name' => $attrName, - 'handler' => 'Magento\Framework\Indexer\Handler\AttributeHandler', + 'handler' => \Magento\Framework\Indexer\Handler\AttributeHandler::class, 'origin' => $attrName, 'type' => 'virtual', 'filters' => [], @@ -154,19 +154,19 @@ public function testAddDynamicDataWithStaticAndSearchable() $attrFrontendInput = 'text'; /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */ - $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $entityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ - $collectionMock = $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */ - $entity = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer') + $entity = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ - $attribute = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $attribute = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->setMethods( [ @@ -253,19 +253,19 @@ public function testAddDynamicDataWithStaticAndFilterable() $attrFrontendInput = 'text'; /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */ - $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $entityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ - $collectionMock = $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */ - $entity = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer') + $entity = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ - $attribute = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $attribute = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->setMethods( [ @@ -324,7 +324,7 @@ public function testAddDynamicDataWithStaticAndFilterable() [ $attrName => [ 'name' => $attrName, - 'handler' => 'Magento\Framework\Indexer\Handler\AttributeHandler', + 'handler' => \Magento\Framework\Indexer\Handler\AttributeHandler::class, 'origin' => $attrName, 'type' => 'filterable', 'filters' => [], diff --git a/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 54e2a5434cdf8..6f9c7f0854a99 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -57,41 +57,41 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->sessionMock = $this->getMock( - 'Magento\Framework\Session\Generic', + \Magento\Framework\Session\Generic::class, ['clearStorage', 'setData', 'getData'], [], '', false ); $this->customerSessionMock = $this->getMock( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, ['getCustomerGroupId', 'setCustomerGroupId', 'clearStorage', 'setCustomer'], [], '', false ); $this->customerFactoryMock = $this->getMock( - 'Magento\Customer\Model\CustomerFactory', + \Magento\Customer\Model\CustomerFactory::class, ['create'], [], '', false ); $this->customerMock = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['setGroupId', '__wakeup'], [], '', false ); - $this->visitorMock = $this->getMock('Magento\Customer\Model\Visitor', [], [], '', false); + $this->visitorMock = $this->getMock(\Magento\Customer\Model\Visitor::class, [], [], '', false); $this->customerFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->customerMock)); $this->depersonalizeCheckerMock = $this->getMock( - 'Magento\PageCache\Model\DepersonalizeChecker', + \Magento\PageCache\Model\DepersonalizeChecker::class, [], [], '', @@ -132,7 +132,7 @@ public function testBeforeGenerateXmlNoDepersonalize() public function testAfterGenerateXml() { - $expectedResult = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(true); $this->visitorMock->expects($this->once())->method('setSkipRequestLogging')->with($this->equalTo(true)); $this->visitorMock->expects($this->once())->method('unsetData'); @@ -157,7 +157,7 @@ public function testAfterGenerateXml() public function testAfterGenerateXmlNoDepersonalize() { - $expectedResult = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $this->visitorMock->expects($this->never())->method('setSkipRequestLogging'); $this->visitorMock->expects($this->never())->method('unsetData'); diff --git a/app/code/Magento/Customer/Test/Unit/Model/LogTest.php b/app/code/Magento/Customer/Test/Unit/Model/LogTest.php index 2b3aba03a1176..be4bd4027d1ad 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/LogTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/LogTest.php @@ -35,7 +35,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->log = $objectManagerHelper->getObject( - 'Magento\Customer\Model\Log', + \Magento\Customer\Model\Log::class, [ 'customerId' => $this->logData['customer_id'], 'lastLoginAt' => $this->logData['last_login_at'], diff --git a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php index a1f1afa15c76c..4022aa3327d35 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php @@ -44,19 +44,19 @@ class LoggerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'insertOnDuplicate', 'fetchRow'], [], '', false ); - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->logFactory = $this->getMock('\Magento\Customer\Model\LogFactory', ['create'], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->logFactory = $this->getMock(\Magento\Customer\Model\LogFactory::class, ['create'], [], '', false); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->logger = $objectManagerHelper->getObject( - '\Magento\Customer\Model\Logger', + \Magento\Customer\Model\Logger::class, [ 'resource' => $this->resource, 'logFactory' => $this->logFactory @@ -121,7 +121,7 @@ public function testGet($customerId, $data) 'lastVisitAt' => $data['last_visit_at'] ]; - $select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $select->expects($this->any())->method('from')->willReturnSelf(); $select->expects($this->any())->method('joinLeft')->willReturnSelf(); @@ -142,7 +142,7 @@ public function testGet($customerId, $data) ->willReturn($data); $log = $this->getMock( - 'Magento\Customer\Model\Log', + \Magento\Customer\Model\Log::class, [], $logArguments ); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php index 5ea532deaa64c..0ecff45b6bdd4 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php @@ -20,7 +20,7 @@ class AddressMetadataManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeResolverMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\AttributeResolver') + $this->attributeResolverMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\AttributeResolver::class) ->disableOriginalConstructor() ->getMock(); @@ -32,11 +32,11 @@ protected function setUp() public function testCanBeSearchableInGrid() { /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ - $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); @@ -55,11 +55,11 @@ public function testCanBeSearchableInGrid() public function testCanBeFilterableInGrid() { /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ - $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php index e1975970b084d..1b1eadc5083d0 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php @@ -27,10 +27,12 @@ class AddressMetadataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeConverterMock = $this->getMockBuilder('Magento\Customer\Model\AttributeMetadataConverter') + $this->attributeConverterMock = $this->getMockBuilder(\Magento\Customer\Model\AttributeMetadataConverter::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeProviderMock = $this->getMockBuilder('Magento\Customer\Model\AttributeMetadataDataProvider') + $this->attributeProviderMock = $this->getMockBuilder( + \Magento\Customer\Model\AttributeMetadataDataProvider::class + ) ->disableOriginalConstructor() ->getMock(); @@ -46,13 +48,13 @@ public function testGetAttributes() $attributeCode = 'attr'; /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); $attributes = [$attributeMock]; /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Form\Attribute\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Form\Attribute\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -70,7 +72,7 @@ public function testGetAttributes() ->willReturn($attributeCode); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $result = [$attributeCode => $metadataMock]; @@ -93,7 +95,7 @@ public function testGetAttributesWithException() $attributes = []; /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Form\Attribute\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Form\Attribute\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -115,7 +117,7 @@ public function testGetAttributeMetadata() $attributeId = 12; /** @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMockForAbstractClass(); @@ -130,7 +132,7 @@ public function testGetAttributeMetadata() ->willReturn($attributeId); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -147,7 +149,7 @@ public function testGetAttributeMetadataWithCodeId() $attributeCode = 'id'; /** @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -157,7 +159,7 @@ public function testGetAttributeMetadataWithCodeId() ->willReturn($attributeMock); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -196,7 +198,7 @@ public function testGetAllAttributesMetadata() ->willReturn($attributeCodes); /** @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -206,7 +208,7 @@ public function testGetAllAttributesMetadata() ->willReturn($attributeMock); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $result = [$metadataMock]; @@ -251,7 +253,7 @@ public function testGetCustomAttributesMetadata() ->willReturn($attributeCodes); /** @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMockForAbstractClass(); @@ -266,7 +268,7 @@ public function testGetCustomAttributesMetadata() ->willReturn($attributeId); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $result = [$metadataMock]; @@ -298,7 +300,7 @@ public function testGetCustomAttributesMetadataWithSystemAttribute() ->willReturn($attributeCodes); /** @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMockForAbstractClass(); @@ -313,7 +315,7 @@ public function testGetCustomAttributesMetadataWithSystemAttribute() ->willReturn($attributeId); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $result = []; @@ -344,7 +346,7 @@ public function testGetCustomAttributesMetadataWithoutAttributes() ->willReturn($attributeCodes); /** @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -354,7 +356,7 @@ public function testGetCustomAttributesMetadataWithoutAttributes() ->willReturn($attributeMock); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $metadataMock */ - $metadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $metadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $result = []; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php index bf05a9b87d334..04159f95140ef 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php @@ -20,9 +20,9 @@ class AttributeResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->metadataDataProviderMock = $this->getMockBuilder('Magento\Customer\Model\AttributeMetadataDataProvider') - ->disableOriginalConstructor() - ->getMock(); + $this->metadataDataProviderMock = $this->getMockBuilder( + \Magento\Customer\Model\AttributeMetadataDataProvider::class + )->disableOriginalConstructor()->getMock(); $this->model = new AttributeResolver( $this->metadataDataProviderMock @@ -35,7 +35,7 @@ public function testGetModelByAttribute() $attributeCode = 'code'; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->once()) @@ -43,7 +43,7 @@ public function testGetModelByAttribute() ->willReturn($attributeCode); /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ - $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); @@ -65,7 +65,7 @@ public function testGetModelByAttributeWithoutModel() $attributeCode = 'code'; /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->exactly(2)) diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php index 1b5b5d5ee0c25..66ae16c0c4019 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php @@ -19,7 +19,7 @@ class CustomerMetadataManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeResolverMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\AttributeResolver') + $this->attributeResolverMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\AttributeResolver::class) ->disableOriginalConstructor() ->getMock(); @@ -31,11 +31,11 @@ protected function setUp() public function testCanBeSearchableInGrid() { /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ - $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); @@ -54,11 +54,11 @@ public function testCanBeSearchableInGrid() public function testCanBeFilterableInGrid() { /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ - $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ - $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php index bb74afe09eb10..d5dd4dc4acea9 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php @@ -23,9 +23,9 @@ class ElementFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_attributeMetadata = $this->getMock( - 'Magento\Customer\Model\Data\AttributeMetadata', + \Magento\Customer\Model\Data\AttributeMetadata::class, [], [], '', @@ -42,10 +42,10 @@ public function testAttributePostcodeDataModelClass() )->method( 'getDataModel' )->will( - $this->returnValue('Magento\Customer\Model\Attribute\Data\Postcode') + $this->returnValue(\Magento\Customer\Model\Attribute\Data\Postcode::class) ); - $dataModel = $this->getMock('Magento\Customer\Model\Metadata\Form\Text', [], [], '', false); + $dataModel = $this->getMock(\Magento\Customer\Model\Metadata\Form\Text::class, [], [], '', false); $this->_objectManager->expects($this->once())->method('create')->will($this->returnValue($dataModel)); $actual = $this->_elementFactory->create($this->_attributeMetadata, '95131', $this->_entityTypeCode); @@ -63,7 +63,7 @@ public function testAttributeEmptyDataModelClass() $this->returnValue('text') ); - $dataModel = $this->getMock('Magento\Customer\Model\Metadata\Form\Text', [], [], '', false); + $dataModel = $this->getMock(\Magento\Customer\Model\Metadata\Form\Text::class, [], [], '', false); $params = [ 'entityTypeCode' => $this->_entityTypeCode, 'value' => 'Some Text', @@ -75,7 +75,7 @@ public function testAttributeEmptyDataModelClass() )->method( 'create' )->with( - 'Magento\Customer\Model\Metadata\Form\Text', + \Magento\Customer\Model\Metadata\Form\Text::class, $params )->will( $this->returnValue($dataModel) diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php index b6a81bf466133..2e0f538e09385 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php @@ -7,6 +7,9 @@ */ namespace Magento\Customer\Test\Unit\Model\Metadata\Form; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractDataTest extends \PHPUnit_Framework_TestCase { const MODEL = 'MODEL'; @@ -38,13 +41,13 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_localeMock = $this->getMockBuilder( - 'Magento\Framework\Stdlib\DateTime\TimezoneInterface' + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class )->disableOriginalConstructor()->getMock(); $this->_localeResolverMock = $this->getMockBuilder( - 'Magento\Framework\Locale\ResolverInterface' + \Magento\Framework\Locale\ResolverInterface::class )->disableOriginalConstructor()->getMock(); - $this->_loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->_attributeMock = $this->getMock('Magento\Customer\Api\Data\AttributeMetadataInterface'); + $this->_loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $this->_attributeMock = $this->getMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); $this->_value = 'VALUE'; $this->_entityTypeCode = 'ENTITY_TYPE_CODE'; $this->_isAjax = false; @@ -201,7 +204,7 @@ public function applyOutputFilterDataProvider() */ public function testValidateInputRule($value, $label, $inputValidation, $expectedOutput) { - $validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); @@ -319,7 +322,7 @@ public function testGetRequestValue($request, $attributeCode, $requestScope, $re public function getRequestValueDataProvider() { $expectedValue = 'EXPECTED_VALUE'; - $requestMockOne = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')->getMock(); + $requestMockOne = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock(); $requestMockOne->expects( $this->any() )->method( @@ -330,7 +333,7 @@ public function getRequestValueDataProvider() $this->returnValue($expectedValue) ); - $requestMockTwo = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')->getMock(); + $requestMockTwo = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock(); $requestMockTwo->expects( $this->at(0) )->method( @@ -351,7 +354,7 @@ public function getRequestValueDataProvider() ); $requestMockThree = $this->getMockBuilder( - '\Magento\Framework\App\Request\Http' + \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->getMock(); $requestMockThree->expects( $this->once() diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php index be6427a1a13dc..a1d466e19017f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php @@ -22,9 +22,11 @@ abstract class AbstractFormTestCase extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')->getMock(); - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->attributeMetadataMock = $this->getMock('Magento\Customer\Api\Data\AttributeMetadataInterface'); + $this->localeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) + ->getMock(); + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) + ->getMock(); + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $this->attributeMetadataMock = $this->getMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php index cef0e9df44620..c244940de4e79 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php @@ -49,7 +49,7 @@ protected function setUp() public function testExtractValue() { - $requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->getMock(); $requestMock->expects($this->once())->method('getParam')->will($this->returnValue('1999-1-2')); @@ -70,7 +70,7 @@ public function testExtractValue() public function testValidateValue($value, $validation, $required, $expected) { $validationRules = []; - $validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); @@ -84,7 +84,7 @@ public function testValidateValue($value, $validation, $required, $expected) $validationRules[] = $validationRule; if (is_array($validation)) { foreach ($validation as $ruleName => $ruleValue) { - $validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php index 7a5b08fa531cb..f5ac86890b0f2 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php @@ -13,6 +13,7 @@ class FileTest extends AbstractFormTestCase { const ENTITY_TYPE = 0; + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Url\EncoderInterface */ protected $urlEncode; @@ -33,16 +34,16 @@ class FileTest extends AbstractFormTestCase protected function setUp() { parent::setUp(); - $this->urlEncode = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface') + $this->urlEncode = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class) ->disableOriginalConstructor()->getMock(); $this->fileValidatorMock = $this->getMockBuilder( - 'Magento\MediaStorage\Model\File\Validator\NotProtectedExtension' + \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class )->disableOriginalConstructor()->getMock(); - $this->fileSystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->fileSystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor()->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->uploaderFactoryMock = $this->getMock('Magento\Framework\File\UploaderFactory', [], [], '', false); + $this->uploaderFactoryMock = $this->getMock(\Magento\Framework\File\UploaderFactory::class, [], [], '', false); } /** @@ -263,7 +264,7 @@ public function testCompactValueDelete() { $fileForm = $this->getClass('value', false); $this->attributeMetadataMock->expects($this->any())->method('isRequired')->will($this->returnValue(false)); - $mediaDirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $mediaDirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $mediaDirMock->expects($this->once()) ->method('delete') ->with(self::ENTITY_TYPE . 'value'); @@ -280,7 +281,7 @@ public function testCompactValueTmpFile() $expected = 'saved.file'; $fileForm = $this->getClass(null, false); - $mediaDirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $mediaDirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->fileSystemMock->expects($this->once()) ->method('getDirectoryWrite') ->with(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA) @@ -288,7 +289,7 @@ public function testCompactValueTmpFile() $mediaDirMock->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnArgument(0)); - $uploaderMock = $this->getMock('\Magento\Framework\File\Uploader', [], [], '', false); + $uploaderMock = $this->getMock(\Magento\Framework\File\Uploader::class, [], [], '', false); $this->uploaderFactoryMock->expects($this->once()) ->method('create') ->with(['fileId' => $value]) @@ -368,7 +369,7 @@ public function testOutputValueJson() protected function getClass($value, $isAjax) { $fileForm = $this->getMock( - 'Magento\Customer\Model\Metadata\Form\File', + \Magento\Customer\Model\Metadata\Form\File::class, ['_isUploadedFile'], [ $this->localeMock, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/ImageTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/ImageTest.php index f002a5cb1e4a5..9bbc633d7a14f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/ImageTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/ImageTest.php @@ -19,7 +19,7 @@ class ImageTest extends FileTest protected function getClass($value, $isAjax) { $imageForm = $this->getMock( - 'Magento\Customer\Model\Metadata\Form\Image', + \Magento\Customer\Model\Metadata\Form\Image::class, ['_isUploadedFile'], [ $this->localeMock, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultiselectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultiselectTest.php index 9c3a6984f3067..66c7945060ab5 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultiselectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultiselectTest.php @@ -44,13 +44,13 @@ public function testExtractValue($value, $expected) { /** @var \PHPUnit_Framework_MockObject_MockObject | Multiselect $multiselect */ $multiselect = $this->getMockBuilder( - 'Magento\Customer\Model\Metadata\Form\Multiselect' + \Magento\Customer\Model\Metadata\Form\Multiselect::class )->disableOriginalConstructor()->setMethods( ['_getRequestValue'] )->getMock(); $multiselect->expects($this->once())->method('_getRequestValue')->will($this->returnValue($value)); - $request = $this->getMockBuilder('Magento\Framework\App\RequestInterface')->getMock(); + $request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock(); $actual = $multiselect->extractValue($request); $this->assertEquals($expected, $actual); } @@ -186,7 +186,7 @@ public function outputValueJsonDataProvider() */ protected function runOutputValueTest($value, $expected, $format) { - $option1 = $this->getMockBuilder('Magento\Customer\Api\Data\OptionInterface') + $option1 = $this->getMockBuilder(\Magento\Customer\Api\Data\OptionInterface::class) ->disableOriginalConstructor() ->setMethods(['getLabel', 'getValue']) ->getMockForAbstractClass(); @@ -197,7 +197,7 @@ protected function runOutputValueTest($value, $expected, $format) ->method('getValue') ->will($this->returnValue('14')); - $option2 = $this->getMockBuilder('Magento\Customer\Api\Data\OptionInterface') + $option2 = $this->getMockBuilder(\Magento\Customer\Api\Data\OptionInterface::class) ->disableOriginalConstructor() ->setMethods(['getLabel', 'getValue']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/PostcodeTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/PostcodeTest.php index 5aecbc09a834a..44157bfae0200 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/PostcodeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/PostcodeTest.php @@ -20,7 +20,7 @@ protected function setUp() { parent::setUp(); - $this->directoryHelper = $this->getMockBuilder('Magento\Directory\Helper\Data') + $this->directoryHelper = $this->getMockBuilder(\Magento\Directory\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php index 657739de2c36d..d90f63fdb8a1f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php @@ -94,7 +94,7 @@ public function validateValueRequiredDataProvider() */ public function testOutputValue($value, $expected) { - $option1 = $this->getMockBuilder('Magento\Customer\Api\Data\OptionInterface') + $option1 = $this->getMockBuilder(\Magento\Customer\Api\Data\OptionInterface::class) ->disableOriginalConstructor() ->setMethods(['getLabel', 'getValue']) ->getMockForAbstractClass(); @@ -105,7 +105,7 @@ public function testOutputValue($value, $expected) ->method('getValue') ->will($this->returnValue('14')); - $option2 = $this->getMockBuilder('Magento\Customer\Api\Data\OptionInterface') + $option2 = $this->getMockBuilder(\Magento\Customer\Api\Data\OptionInterface::class) ->disableOriginalConstructor() ->setMethods(['getLabel', 'getValue']) ->getMockForAbstractClass(); @@ -116,7 +116,7 @@ public function testOutputValue($value, $expected) ->method('getValue') ->will($this->returnValue('some key')); - $option3 = $this->getMockBuilder('Magento\Customer\Api\Data\OptionInterface') + $option3 = $this->getMockBuilder(\Magento\Customer\Api\Data\OptionInterface::class) ->disableOriginalConstructor() ->setMethods(['getLabel', 'getValue']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php index 08a0bdb252233..1e36f5cce6400 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php @@ -105,7 +105,7 @@ public function validateValueRequiredDataProvider() */ public function testValidateValueLength($value, $expected) { - $minTextLengthRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $minTextLengthRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); @@ -116,7 +116,7 @@ public function testValidateValueLength($value, $expected) ->method('getValue') ->will($this->returnValue(4)); - $maxTextLengthRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $maxTextLengthRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getValue']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php index ccd05a111c8c9..39e0396dfa9a7 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php @@ -22,7 +22,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->attrDataFactoryMock = $this->getMockBuilder( - '\Magento\Customer\Model\Metadata\ElementFactory' + \Magento\Customer\Model\Metadata\ElementFactory::class )->disableOriginalConstructor()->getMock(); $this->validator = new \Magento\Customer\Model\Metadata\Validator($this->attrDataFactoryMock); @@ -31,7 +31,7 @@ protected function setUp() public function testValidateDataWithNoDataModel() { $attribute = $this->getMockBuilder( - '\Magento\Customer\Api\Data\AttributeMetadataInterface' + \Magento\Customer\Api\Data\AttributeMetadataInterface::class )->disableOriginalConstructor()->getMock(); $this->attrDataFactoryMock->expects($this->never())->method('create'); $this->assertTrue($this->validator->validateData([], [$attribute], 'ENTITY_TYPE')); @@ -51,7 +51,7 @@ public function testValidateData($isValid) public function testIsValidWithNoModel() { $attribute = $this->getMockBuilder( - '\Magento\Customer\Api\Data\AttributeMetadataInterface' + \Magento\Customer\Api\Data\AttributeMetadataInterface::class )->disableOriginalConstructor()->getMock(); $this->attrDataFactoryMock->expects($this->never())->method('create'); $this->validator->setAttributes([$attribute]); @@ -90,7 +90,7 @@ public function trueFalseDataProvider() protected function getMockAttribute() { $attribute = $this->getMockBuilder( - '\Magento\Customer\Model\Data\AttributeMetadata' + \Magento\Customer\Model\Data\AttributeMetadata::class )->disableOriginalConstructor()->setMethods( ['__wakeup', 'getAttributeCode', 'getDataModel'] )->getMock(); @@ -107,7 +107,7 @@ protected function getMockAttribute() protected function mockDataModel($isValid, AttributeMetadata $attribute) { $dataModel = $this->getMockBuilder( - '\Magento\Customer\Model\Metadata\Form\Text' + \Magento\Customer\Model\Metadata\Form\Text::class )->disableOriginalConstructor()->getMock(); $dataModel->expects($this->any())->method('validateValue')->will($this->returnValue($isValid)); $this->attrDataFactoryMock->expects( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php index 89dbff8b0a7f0..588c36c0e2452 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php @@ -46,9 +46,15 @@ class TransactionWrapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMock('Magento\Customer\Model\ResourceModel\Customer', [], [], '', false); - $this->subjectMock = $this->getMock('Magento\Customer\Api\CustomerRepositoryInterface', [], [], '', false); - $this->customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); + $this->subjectMock = $this->getMock( + \Magento\Customer\Api\CustomerRepositoryInterface::class, + [], + [], + '', + false + ); + $this->customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $customerMock = $this->customerMock; $this->closureMock = function () use ($customerMock) { return $customerMock; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php b/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php index f81da3f0cb693..4005ce0c42cb7 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php @@ -14,49 +14,49 @@ class RegionTest extends \PHPUnit_Framework_TestCase public function testRender($regionCollection) { $countryFactoryMock = $this->getMock( - 'Magento\Directory\Model\CountryFactory', + \Magento\Directory\Model\CountryFactory::class, ['create'], [], '', false ); $directoryHelperMock = $this->getMock( - 'Magento\Directory\Helper\Data', + \Magento\Directory\Helper\Data::class, ['isRegionRequired'], [], '', false ); - $escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $elementMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\AbstractElement', + \Magento\Framework\Data\Form\Element\AbstractElement::class, ['getForm', 'getHtmlAttributes'], [], '', false ); $countryMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\AbstractElement', + \Magento\Framework\Data\Form\Element\AbstractElement::class, ['getValue'], [], '', false ); $regionMock = $this->getMock( - 'Magento\Framework\Data\Form\Element\AbstractElement', + \Magento\Framework\Data\Form\Element\AbstractElement::class, [], [], '', false ); $countryModelMock = $this->getMock( - 'Magento\Directory\Model\Country', + \Magento\Directory\Model\Country::class, ['setId', 'getLoadedRegionCollection', 'toOptionArray', '__wakeup'], [], '', false ); - $formMock = $this->getMock('Magento\Framework\Data\Form', ['getElement'], [], '', false); + $formMock = $this->getMock(\Magento\Framework\Data\Form::class, ['getElement'], [], '', false); $elementMock->expects($this->any())->method('getForm')->will($this->returnValue($formMock)); $elementMock->expects( @@ -100,7 +100,7 @@ public function testRender($regionCollection) $model = new \Magento\Customer\Model\Renderer\Region($countryFactoryMock, $directoryHelperMock, $escaperMock); - $static = new \ReflectionProperty('Magento\Customer\Model\Renderer\Region', '_regionCollections'); + $static = new \ReflectionProperty(\Magento\Customer\Model\Renderer\Region::class, '_regionCollections'); $static->setAccessible(true); $static->setValue([]); diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php index 5855e004a09d8..dc88f925d9584 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php @@ -24,9 +24,9 @@ class RegionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->regionFactory = $this->getMock('Magento\Directory\Model\RegionFactory', ['create'], [], '', false); + $this->regionFactory = $this->getMock(\Magento\Directory\Model\RegionFactory::class, ['create'], [], '', false); $this->region = $this->getMock( - 'Magento\Directory\Model\Region', + \Magento\Directory\Model\Region::class, ['load', 'getId', 'getCountryId', 'getName'], [], '', @@ -34,7 +34,7 @@ protected function setUp() ); $this->model = new Region($this->regionFactory); $this->object = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getData', 'getCountryId', 'setRegionId', 'setRegion'], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php index 6a2c7ac2c32af..4818f16365dd0 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php @@ -21,14 +21,14 @@ class RelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerFactoryMock = $this->getMock( - 'Magento\Customer\Model\CustomerFactory', + \Magento\Customer\Model\CustomerFactory::class, ['create'], [], '', false ); $this->relation = (new ObjectManagerHelper($this))->getObject( - 'Magento\Customer\Model\ResourceModel\Address\Relation', + \Magento\Customer\Model\ResourceModel\Address\Relation::class, [ 'customerFactory' => $this->customerFactoryMock ] @@ -44,7 +44,7 @@ protected function setUp() public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShipping) { $addressModel = $this->getMock( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [ '__wakeup', 'getId', @@ -62,14 +62,14 @@ public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShi false ); $customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['__wakeup', 'setDefaultBilling', 'setDefaultShipping', 'save', 'load', 'getResource', 'getId'], [], '', false ); $customerResource = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -78,7 +78,7 @@ public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShi ['getConnection', 'getTable'] ); $connectionMock = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false, diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php index 50bf0985caf7d..9742c7240e9bc 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Customer\Test\Unit\Model\ResourceModel; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -64,34 +67,46 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->addressFactory = $this->getMock('Magento\Customer\Model\AddressFactory', ['create'], [], '', false); - $this->addressRegistry = $this->getMock('Magento\Customer\Model\AddressRegistry', [], [], '', false); - $this->customerRegistry = $this->getMock('Magento\Customer\Model\CustomerRegistry', [], [], '', false); - $this->addressResourceModel = $this->getMock('Magento\Customer\Model\ResourceModel\Address', [], [], '', false); - $this->directoryData = $this->getMock('Magento\Directory\Helper\Data', [], [], '', false); + $this->addressFactory = $this->getMock( + \Magento\Customer\Model\AddressFactory::class, + ['create'], + [], + '', + false + ); + $this->addressRegistry = $this->getMock(\Magento\Customer\Model\AddressRegistry::class, [], [], '', false); + $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); + $this->addressResourceModel = $this->getMock( + \Magento\Customer\Model\ResourceModel\Address::class, + [], + [], + '', + false + ); + $this->directoryData = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false); $this->addressSearchResultsFactory = $this->getMock( - 'Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory', + \Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory::class, ['create'], [], '', false ); $this->addressCollectionFactory = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Address\CollectionFactory', + \Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class, ['create'], [], '', false ); $this->extensionAttributesJoinProcessor = $this->getMockForAbstractClass( - 'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, [], '', false ); - $this->customer = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $this->customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); $this->address = $this->getMock( - 'Magento\Customer\Model\Address', + \Magento\Customer\Model\Address::class, [ 'getId', 'getCountryId', @@ -131,9 +146,14 @@ public function testSave() { $customerId = 34; $addressId = 53; - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $addressCollection = - $this->getMock('Magento\Customer\Model\ResourceModel\Address\Collection', [], [], '', false); + $this->getMock(\Magento\Customer\Model\ResourceModel\Address\Collection::class, [], [], '', false); $customerAddress->expects($this->atLeastOnce()) ->method('getCustomerId') ->willReturn($customerId); @@ -189,7 +209,12 @@ public function testSaveWithException() { $customerId = 34; $addressId = 53; - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $customerAddress->expects($this->atLeastOnce()) ->method('getCustomerId') ->willReturn($customerId); @@ -220,7 +245,12 @@ public function testSaveWithInvalidRegion() { $customerId = 34; $addressId = 53; - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $customerAddress->expects($this->atLeastOnce()) ->method('getCustomerId') ->willReturn($customerId); @@ -238,9 +268,9 @@ public function testSaveWithInvalidRegion() $this->address->expects($this->once()) ->method('updateData') ->with($customerAddress); - $countryModel = $this->getMock('Magento\Directory\Model\Country', [], [], '', false); + $countryModel = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); $regionCollection = $this->getMock( - 'Magento\Directory\Model\ResourceModel\Region\Collection', + \Magento\Directory\Model\ResourceModel\Region\Collection::class, [], [], '', @@ -304,7 +334,12 @@ public function testSaveWithInvalidRegionId() { $customerId = 34; $addressId = 53; - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $customerAddress->expects($this->atLeastOnce()) ->method('getCustomerId') ->willReturn($customerId); @@ -322,9 +357,9 @@ public function testSaveWithInvalidRegionId() $this->address->expects($this->once()) ->method('updateData') ->with($customerAddress); - $countryModel = $this->getMock('Magento\Directory\Model\Country', [], [], '', false); + $countryModel = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); $regionCollection = $this->getMock( - 'Magento\Directory\Model\ResourceModel\Region\Collection', + \Magento\Directory\Model\ResourceModel\Region\Collection::class, [], [], '', @@ -385,9 +420,9 @@ public function testSaveWithInvalidRegionId() protected function prepareMocksForInvalidAddressValidation() { - $countryModel = $this->getMock('Magento\Directory\Model\Country', [], [], '', false); + $countryModel = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); $regionCollection = $this->getMock( - 'Magento\Directory\Model\ResourceModel\Region\Collection', + \Magento\Directory\Model\ResourceModel\Region\Collection::class, [], [], '', @@ -434,7 +469,12 @@ protected function prepareMocksForInvalidAddressValidation() public function testGetById() { - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $this->addressRegistry->expects($this->once()) ->method('retrieve') ->with(12) @@ -448,55 +488,45 @@ public function testGetById() public function testGetList() { - $filterGroup = $this->getMock('Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $filter = $this->getMock('Magento\Framework\Api\Filter', [], [], '', false); - $collection = $this->getMock('Magento\Customer\Model\ResourceModel\Address\Collection', [], [], '', false); + $filterGroup = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); + $filter = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $collection = $this->getMock( + \Magento\Customer\Model\ResourceModel\Address\Collection::class, + [], + [], + '', + false + ); $searchResults = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressSearchResultsInterface', + \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, [], '', false ); $searchCriteria = $this->getMockForAbstractClass( - 'Magento\Framework\Api\SearchCriteriaInterface', + \Magento\Framework\Api\SearchCriteriaInterface::class, [], '', false ); - $this->addressSearchResultsFactory->expects($this->once()) - ->method('create') - ->willReturn($searchResults); - $this->addressCollectionFactory->expects($this->once()) - ->method('create') - ->willReturn($collection); + $this->addressSearchResultsFactory->expects($this->once())->method('create')->willReturn($searchResults); + $this->addressCollectionFactory->expects($this->once())->method('create')->willReturn($collection); $this->extensionAttributesJoinProcessor->expects($this->once()) ->method('process') - ->with($collection, 'Magento\Customer\Api\Data\AddressInterface'); - $searchCriteria->expects($this->once()) - ->method('getFilterGroups') - ->willReturn([$filterGroup]); - $filterGroup->expects($this->once()) - ->method('getFilters') - ->willReturn([$filter]); - $filter->expects($this->once()) - ->method('getConditionType') - ->willReturn(false); - $filter->expects($this->once()) - ->method('getField') - ->willReturn('Field'); - $filter->expects($this->atLeastOnce()) - ->method('getValue') - ->willReturn('Value'); + ->with($collection, \Magento\Customer\Api\Data\AddressInterface::class); + $searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]); + $filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]); + $filter->expects($this->once())->method('getConditionType')->willReturn(false); + $filter->expects($this->once())->method('getField')->willReturn('Field'); + $filter->expects($this->atLeastOnce())->method('getValue')->willReturn('Value'); $collection->expects($this->once()) ->method('addFieldToFilter') ->with([['attribute' => 'Field', 'eq' => 'Value']], [['eq' => 'Value']]); - $collection->expects($this->once()) - ->method('getSize') - ->willReturn(23); + $collection->expects($this->once())->method('getSize')->willReturn(23); $searchResults->expects($this->once()) ->method('setTotalCount') ->with(23); - $sortOrder = $this->getMock('Magento\Framework\Api\SortOrder', [], [], '', false); + $sortOrder = $this->getMock(\Magento\Framework\Api\SortOrder::class, [], [], '', false); $searchCriteria->expects($this->once()) ->method('getSortOrders') ->willReturn([$sortOrder]); @@ -527,7 +557,12 @@ public function testGetList() $this->address->expects($this->once()) ->method('getId') ->willReturn(12); - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, + [], + '', + false + ); $this->addressRegistry->expects($this->once()) ->method('retrieve') ->with(12) @@ -551,13 +586,18 @@ public function testDelete() $customerId = 43; $addressCollection = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Address\Collection', + \Magento\Customer\Model\ResourceModel\Address\Collection::class, + [], [], + '', + false + ); + $customerAddress = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false ); - $customerAddress = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false); $customerAddress->expects($this->once()) ->method('getId') ->willReturn($addressId); @@ -598,7 +638,7 @@ public function testDeleteById() ->method('getCustomerId') ->willReturn($customerId); $addressCollection = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Address\Collection', + \Magento\Customer\Model\ResourceModel\Address\Collection::class, [], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php index 9b1863fd056a9..27358af372250 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php @@ -11,6 +11,9 @@ use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AddressTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Test\Unit\Model\ResourceModel\SubResourceModelAddress */ @@ -31,7 +34,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -40,7 +43,7 @@ protected function setUp() $this->entityRelationCompositeMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class, [], [], '', @@ -48,7 +51,7 @@ protected function setUp() ); $this->addressResource = (new ObjectManagerHelper($this))->getObject( - 'Magento\Customer\Test\Unit\Model\ResourceModel\SubResourceModelAddress', + \Magento\Customer\Test\Unit\Model\ResourceModel\SubResourceModelAddress::class, [ 'resource' => $this->prepareResource(), 'entitySnapshot' => $this->entitySnapshotMock, @@ -71,7 +74,7 @@ public function testSave($addressId, $isDefaultBilling, $isDefaultShipping) { /** @var $address \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject */ $address = $this->getMock( - 'Magento\Customer\Model\Address', + \Magento\Customer\Model\Address::class, [ '__wakeup', 'getId', @@ -100,7 +103,7 @@ public function testSave($addressId, $isDefaultBilling, $isDefaultShipping) $address->expects($this->any())->method('getIsDefaultBilling')->willReturn($isDefaultBilling); $this->addressResource->setType('customer_address'); - $attributeLoaderMock = $this->getMockBuilder('Magento\Eav\Model\Entity\AttributeLoaderInterface') + $attributeLoaderMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\AttributeLoaderInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -131,11 +134,11 @@ public function getSaveDataProvider() */ protected function prepareResource() { - $dbSelect = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $dbSelect = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $dbSelect->expects($this->any())->method('from')->willReturnSelf(); $dbSelect->expects($this->any())->method('where')->willReturnSelf(); - $dbAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $dbAdapter = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); @@ -156,7 +159,7 @@ protected function prepareResource() $dbAdapter->expects($this->any())->method('lastInsertId'); $dbAdapter->expects($this->any())->method('select')->willReturn($dbSelect); - $resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); @@ -174,7 +177,7 @@ protected function prepareResource() protected function prepareEavConfig() { $attributeMock = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getAttributeCode', 'getBackend', '__wakeup'], [], '', @@ -187,12 +190,12 @@ protected function prepareEavConfig() ->method('getBackend') ->willReturn( $this->getMock( - 'Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', [], [], '', false + \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, [], [], '', false ) ); $this->eavConfigType = $this->getMock( - 'Magento\Eav\Model\Entity\Type', + \Magento\Eav\Model\Entity\Type::class, ['getEntityIdField', 'getId', 'getEntityTable', '__wakeup'], [], '', @@ -203,7 +206,7 @@ protected function prepareEavConfig() $this->eavConfigType->expects($this->any())->method('getEntityTable')->willReturn('customer_address_entity'); $eavConfig = $this->getMock( - 'Magento\Eav\Model\Config', + \Magento\Eav\Model\Config::class, ['getEntityType', 'getEntityAttributeCodes', 'getAttribute'], [], '', @@ -249,13 +252,13 @@ protected function prepareEavConfig() */ protected function prepareValidatorFactory() { - $validatorMock = $this->getMock('Magento\Framework\Validator', ['isValid'], [], '', false); + $validatorMock = $this->getMock(\Magento\Framework\Validator::class, ['isValid'], [], '', false); $validatorMock->expects($this->any()) ->method('isValid') ->willReturn(true); $validatorFactory = $this->getMock( - 'Magento\Framework\Validator\Factory', + \Magento\Framework\Validator\Factory::class, ['createValidator'], [], '', @@ -271,7 +274,13 @@ protected function prepareValidatorFactory() protected function prepareCustomerFactory() { - $this->customerFactory = $this->getMock('Magento\Customer\Model\CustomerFactory', ['create'], [], '', false); + $this->customerFactory = $this->getMock( + \Magento\Customer\Model\CustomerFactory::class, + ['create'], + [], + '', + false + ); return $this->customerFactory; } diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php index e1e6a34ba4a81..8e67b5150d525 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php @@ -35,30 +35,30 @@ class GridTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->indexerRegistry = $this->getMock(\Magento\Framework\Indexer\IndexerRegistry::class, [], [], '', false); $this->flatScopeResolver = $this->getMock( - 'Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver', + \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class, [], [], '', false ); $this->indexer = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false ); $this->connection = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false ); - $this->select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $this->queryResult = $this->getMockForAbstractClass( - 'Zend_Db_Statement_Interface', + \Zend_Db_Statement_Interface::class, [], '', false diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php index 288644dc42c03..8bbc457144f82 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php @@ -91,12 +91,18 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerResourceModel = - $this->getMock('Magento\Customer\Model\ResourceModel\Customer', [], [], '', false); - $this->customerRegistry = $this->getMock('Magento\Customer\Model\CustomerRegistry', [], [], '', false); - $this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); - $this->customerFactory = $this->getMock('Magento\Customer\Model\CustomerFactory', ['create'], [], '', false); + $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); + $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $this->customerFactory = $this->getMock( + \Magento\Customer\Model\CustomerFactory::class, + ['create'], + [], + '', + false + ); $this->customerSecureFactory = $this->getMock( - 'Magento\Customer\Model\Data\CustomerSecureFactory', + \Magento\Customer\Model\Data\CustomerSecureFactory::class, ['create'], [], '', @@ -104,7 +110,7 @@ protected function setUp() ); $this->addressRepository = $this->getMock( - 'Magento\Customer\Model\ResourceModel\AddressRepository', + \Magento\Customer\Model\ResourceModel\AddressRepository::class, [], [], '', @@ -112,51 +118,51 @@ protected function setUp() ); $this->customerMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerMetadataInterface', + \Magento\Customer\Api\CustomerMetadataInterface::class, [], '', false ); $this->searchResultsFactory = $this->getMock( - 'Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory', + \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory::class, ['create'], [], '', false ); $this->eventManager = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false ); $this->storeManager = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false ); $this->extensibleDataObjectConverter = $this->getMock( - 'Magento\Framework\Api\ExtensibleDataObjectConverter', + \Magento\Framework\Api\ExtensibleDataObjectConverter::class, [], [], '', false ); $this->imageProcessor = $this->getMockForAbstractClass( - 'Magento\Framework\Api\ImageProcessorInterface', + \Magento\Framework\Api\ImageProcessorInterface::class, [], '', false ); $this->extensionAttributesJoinProcessor = $this->getMockForAbstractClass( - 'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, [], '', false ); $this->customer = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false @@ -185,7 +191,7 @@ protected function setUp() protected function prepareMocksForValidation($isValid = false) { $attributeMetaData = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], '', false @@ -226,9 +232,9 @@ public function testSave() $storeId = 2; $this->prepareMocksForValidation(true); - $region = $this->getMockForAbstractClass('Magento\Customer\Api\Data\RegionInterface', [], '', false); + $region = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\RegionInterface::class, [], '', false); $address = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false, @@ -242,7 +248,7 @@ public function testSave() ] ); $address2 = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false, @@ -256,7 +262,7 @@ public function testSave() ] ); $customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, [ 'getId', 'setId', @@ -278,7 +284,7 @@ public function testSave() false ); $customerAttributesMetaData = $this->getMockForAbstractClass( - 'Magento\Framework\Api\CustomAttributesDataInterface', + \Magento\Framework\Api\CustomAttributesDataInterface::class, [], '', false, @@ -293,7 +299,7 @@ public function testSave() ] ); $customerSecureData = $this->getMock( - 'Magento\Customer\Model\Data\CustomerSecure', + \Magento\Customer\Model\Data\CustomerSecure::class, [ 'getRpToken', 'getRpTokenCreatedAt', @@ -344,7 +350,7 @@ public function testSave() ->with([$address]); $this->extensibleDataObjectConverter->expects($this->once()) ->method('toNestedArray') - ->with($customerAttributesMetaData, [], '\Magento\Customer\Api\Data\CustomerInterface') + ->with($customerAttributesMetaData, [], \Magento\Customer\Api\Data\CustomerInterface::class) ->willReturn(['customerData']); $this->customerFactory->expects($this->once()) ->method('create') @@ -353,7 +359,7 @@ public function testSave() $customerModel->expects($this->once()) ->method('getStoreId') ->willReturn(null); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store->expects($this->once()) ->method('getId') ->willReturn($storeId); @@ -468,9 +474,9 @@ public function testSaveWithPasswordHash() $passwordHash = 'ukfa4sdfa56s5df02asdf4rt'; $this->prepareMocksForValidation(true); - $region = $this->getMockForAbstractClass('Magento\Customer\Api\Data\RegionInterface', [], '', false); + $region = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\RegionInterface::class, [], '', false); $address = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false, @@ -484,7 +490,7 @@ public function testSaveWithPasswordHash() ] ); $address2 = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false, @@ -498,7 +504,7 @@ public function testSaveWithPasswordHash() ] ); $customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, [ 'getId', 'setId', @@ -517,7 +523,7 @@ public function testSaveWithPasswordHash() false ); $customerAttributesMetaData = $this->getMockForAbstractClass( - 'Magento\Framework\Api\CustomAttributesDataInterface', + \Magento\Framework\Api\CustomAttributesDataInterface::class, [], '', false, @@ -569,7 +575,7 @@ public function testSaveWithPasswordHash() ->with([$address]); $this->extensibleDataObjectConverter->expects($this->once()) ->method('toNestedArray') - ->with($customerAttributesMetaData, [], '\Magento\Customer\Api\Data\CustomerInterface') + ->with($customerAttributesMetaData, [], \Magento\Customer\Api\Data\CustomerInterface::class) ->willReturn(['customerData']); $this->customerFactory->expects($this->once()) ->method('create') @@ -578,7 +584,7 @@ public function testSaveWithPasswordHash() $customerModel->expects($this->once()) ->method('getStoreId') ->willReturn(null); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store->expects($this->once()) ->method('getId') ->willReturn($storeId); @@ -649,24 +655,30 @@ public function testSaveWithException() */ public function testGetList() { - $sortOrder = $this->getMock('Magento\Framework\Api\SortOrder', [], [], '', false); - $filterGroup = $this->getMock('Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $filter = $this->getMock('Magento\Framework\Api\Filter', [], [], '', false); - $collection = $this->getMock('Magento\Customer\Model\ResourceModel\Customer\Collection', [], [], '', false); + $sortOrder = $this->getMock(\Magento\Framework\Api\SortOrder::class, [], [], '', false); + $filterGroup = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); + $filter = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $collection = $this->getMock( + \Magento\Customer\Model\ResourceModel\Customer\Collection::class, + [], + [], + '', + false + ); $searchResults = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressSearchResultsInterface', + \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, [], '', false ); $searchCriteria = $this->getMockForAbstractClass( - 'Magento\Framework\Api\SearchCriteriaInterface', + \Magento\Framework\Api\SearchCriteriaInterface::class, [], '', false ); $customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, [ 'getId', 'setId', @@ -685,7 +697,7 @@ public function testGetList() false ); $metadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], '', false @@ -705,7 +717,7 @@ public function testGetList() ->willReturn($collection); $this->extensionAttributesJoinProcessor->expects($this->once()) ->method('process') - ->with($collection, 'Magento\Customer\Api\Data\CustomerInterface'); + ->with($collection, \Magento\Customer\Api\Data\CustomerInterface::class); $this->customerMetadata->expects($this->once()) ->method('getAllAttributesMetadata') ->willReturn([$metadata]); @@ -806,7 +818,7 @@ public function testDeleteById() { $customerId = 14; $customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['delete'], [], '', @@ -830,7 +842,7 @@ public function testDelete() { $customerId = 14; $customerModel = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['delete'], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php index 6cf0ea9b80335..6ccce8857634d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php @@ -21,7 +21,9 @@ class AddressSnapshotTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->metadataMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata') + $this->metadataMock = $this->getMockBuilder( + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata::class + ) ->disableOriginalConstructor() ->getMock(); @@ -45,7 +47,7 @@ public function testIsModified( ) { $entityId = 1; - $dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $dataObjectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods([ 'getId', @@ -102,7 +104,7 @@ public function dataProviderIsModified() public function testIsModifiedBypass() { - $dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $dataObjectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods([ 'getId', diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php index 13afff437b450..6cfb5b94e74e7 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php @@ -39,22 +39,22 @@ class ServiceCollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->filterBuilder = $this->objectManager->getObject('Magento\Framework\Api\FilterBuilder'); + $this->filterBuilder = $this->objectManager->getObject(\Magento\Framework\Api\FilterBuilder::class); $filterGroupBuilder = $this->objectManager - ->getObject('Magento\Framework\Api\Search\FilterGroupBuilder'); + ->getObject(\Magento\Framework\Api\Search\FilterGroupBuilder::class); /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */ $this->searchCriteriaBuilder = $this->objectManager->getObject( - 'Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, ['filterGroupBuilder' => $filterGroupBuilder] ); $this->sortOrderBuilder = $this->objectManager->getObject( - 'Magento\Framework\Api\SortOrderBuilder' + \Magento\Framework\Api\SortOrderBuilder::class ); - $this->groupRepositoryMock = $this->getMockBuilder('\Magento\Customer\Api\GroupRepositoryInterface') + $this->groupRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\GroupRepositoryInterface::class) ->getMock(); $this->searchResults = $this->getMockForAbstractClass( - 'Magento\Framework\Api\SearchResultsInterface', + \Magento\Framework\Api\SearchResultsInterface::class, ['getTotalCount', 'getItems'] ); @@ -68,7 +68,7 @@ protected function setUp() $this->serviceCollection = $this->objectManager ->getObject( - 'Magento\Customer\Model\ResourceModel\Group\Grid\ServiceCollection', + \Magento\Customer\Model\ResourceModel\Group\Grid\ServiceCollection::class, [ 'filterBuilder' => $this->filterBuilder, 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php index 9d8abd104f443..64485815c855d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php @@ -74,21 +74,21 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->groupRegistry = $this->getMock( - 'Magento\Customer\Model\GroupRegistry', + \Magento\Customer\Model\GroupRegistry::class, [], [], '', false ); $this->groupFactory = $this->getMock( - 'Magento\Customer\Model\GroupFactory', + \Magento\Customer\Model\GroupFactory::class, ['create'], [], '', false ); $this->groupModel = $this->getMock( - 'Magento\Customer\Model\Group', + \Magento\Customer\Model\Group::class, [ 'getTaxClassId', 'getTaxClassName', @@ -107,49 +107,54 @@ protected function setUp() false ); $this->groupDataFactory = $this->getMock( - 'Magento\Customer\Api\Data\GroupInterfaceFactory', + \Magento\Customer\Api\Data\GroupInterfaceFactory::class, ['create'], [], '', false ); - $this->group = $this->getMockForAbstractClass('Magento\Customer\Api\Data\GroupInterface', [], 'group', false); + $this->group = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\GroupInterface::class, + [], + 'group', + false + ); $this->groupResourceModel = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Group', + \Magento\Customer\Model\ResourceModel\Group::class, [], [], '', false ); $this->dataObjectProcessor = $this->getMock( - 'Magento\Framework\Reflection\DataObjectProcessor', + \Magento\Framework\Reflection\DataObjectProcessor::class, [], [], '', false ); $this->searchResultsFactory = $this->getMock( - 'Magento\Customer\Api\Data\GroupSearchResultsInterfaceFactory', + \Magento\Customer\Api\Data\GroupSearchResultsInterfaceFactory::class, ['create'], [], '', false ); $this->searchResults = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\GroupSearchResultsInterface', + \Magento\Customer\Api\Data\GroupSearchResultsInterface::class, [], '', false ); $this->taxClassRepository = $this->getMockForAbstractClass( - 'Magento\Tax\Api\TaxClassRepositoryInterface', + \Magento\Tax\Api\TaxClassRepositoryInterface::class, [], '', false ); $this->extensionAttributesJoinProcessor = $this->getMockForAbstractClass( - 'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, [], '', false @@ -170,7 +175,7 @@ public function testSave() { $groupId = 23; - $taxClass = $this->getMockForAbstractClass('Magento\Tax\Api\Data\TaxClassInterface', [], '', false); + $taxClass = $this->getMockForAbstractClass(\Magento\Tax\Api\Data\TaxClassInterface::class, [], '', false); $this->group->expects($this->once()) ->method('getCode') @@ -225,7 +230,7 @@ public function testSave() ->willReturn($this->groupModel); $this->dataObjectProcessor->expects($this->once()) ->method('buildOutputDataArray') - ->with($this->group, '\Magento\Customer\Api\Data\GroupInterface') + ->with($this->group, \Magento\Customer\Api\Data\GroupInterface::class) ->willReturn(['attributeCode' => 'attributeData']); $this->groupModel->expects($this->once()) ->method('setDataUsingMethod') @@ -248,7 +253,7 @@ public function testSave() */ public function testSaveWithException() { - $taxClass = $this->getMockForAbstractClass('Magento\Tax\Api\Data\TaxClassInterface', [], '', false); + $taxClass = $this->getMockForAbstractClass(\Magento\Tax\Api\Data\TaxClassInterface::class, [], '', false); $this->groupFactory->expects($this->once()) ->method('create') @@ -345,19 +350,19 @@ public function testGetList() { $groupId = 86; - $groupExtension = $this->getMock('Magento\Customer\Api\Data\GroupExtensionInterface', [], [], '', false); - $filterGroup = $this->getMock('Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $filter = $this->getMock('Magento\Framework\Api\Filter', [], [], '', false); - $collection = $this->getMock('Magento\Customer\Model\ResourceModel\Group\Collection', [], [], '', false); - $sortOrder = $this->getMock('Magento\Framework\Api\SortOrder', [], [], '', false); + $groupExtension = $this->getMock(\Magento\Customer\Api\Data\GroupExtensionInterface::class, [], [], '', false); + $filterGroup = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); + $filter = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $collection = $this->getMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class, [], [], '', false); + $sortOrder = $this->getMock(\Magento\Framework\Api\SortOrder::class, [], [], '', false); $searchCriteria = $this->getMockForAbstractClass( - 'Magento\Framework\Api\SearchCriteriaInterface', + \Magento\Framework\Api\SearchCriteriaInterface::class, [], '', false ); $searchResults = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressSearchResultsInterface', + \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, [], '', false @@ -377,7 +382,7 @@ public function testGetList() ->willReturn($collection); $this->extensionAttributesJoinProcessor->expects($this->once()) ->method('process') - ->with($collection, 'Magento\Customer\Api\Data\GroupInterface'); + ->with($collection, \Magento\Customer\Api\Data\GroupInterface::class); $collection->expects($this->once()) ->method('addTaxClass'); $searchCriteria->expects($this->once()) @@ -464,7 +469,7 @@ public function testGetList() ->willReturn([]); $this->extensionAttributesJoinProcessor->expects($this->once()) ->method('extractExtensionAttributes') - ->with('Magento\Customer\Api\Data\GroupInterface', []) + ->with(\Magento\Customer\Api\Data\GroupInterface::class, []) ->willReturn(['extension_attributes' => $groupExtension]); $this->group->expects($this->once()) ->method('setExtensionAttributes') @@ -491,18 +496,18 @@ public function testGetListWithoutSortOrder() { $groupId = 86; - $groupExtension = $this->getMock('Magento\Customer\Api\Data\GroupExtensionInterface', [], [], '', false); - $filterGroup = $this->getMock('Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $filter = $this->getMock('Magento\Framework\Api\Filter', [], [], '', false); - $collection = $this->getMock('Magento\Customer\Model\ResourceModel\Group\Collection', [], [], '', false); + $groupExtension = $this->getMock(\Magento\Customer\Api\Data\GroupExtensionInterface::class, [], [], '', false); + $filterGroup = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); + $filter = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $collection = $this->getMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class, [], [], '', false); $searchCriteria = $this->getMockForAbstractClass( - 'Magento\Framework\Api\SearchCriteriaInterface', + \Magento\Framework\Api\SearchCriteriaInterface::class, [], '', false ); $searchResults = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressSearchResultsInterface', + \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, [], '', false @@ -522,7 +527,7 @@ public function testGetListWithoutSortOrder() ->willReturn($collection); $this->extensionAttributesJoinProcessor->expects($this->once()) ->method('process') - ->with($collection, 'Magento\Customer\Api\Data\GroupInterface'); + ->with($collection, \Magento\Customer\Api\Data\GroupInterface::class); $collection->expects($this->once()) ->method('addTaxClass'); $searchCriteria->expects($this->once()) @@ -598,7 +603,7 @@ public function testGetListWithoutSortOrder() ->willReturn([]); $this->extensionAttributesJoinProcessor->expects($this->once()) ->method('extractExtensionAttributes') - ->with('Magento\Customer\Api\Data\GroupInterface', []) + ->with(\Magento\Customer\Api\Data\GroupInterface::class, []) ->willReturn(['extension_attributes' => $groupExtension]); $this->group->expects($this->once()) ->method('setExtensionAttributes') diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php index 16bc353bf9fc4..6520556842a79 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php @@ -10,6 +10,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class GroupTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Model\ResourceModel\Group */ @@ -35,39 +38,41 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->customerVat = $this->getMock('Magento\Customer\Model\Vat', [], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->customerVat = $this->getMock(\Magento\Customer\Model\Vat::class, [], [], '', false); $this->customersFactory = $this->getMock( - 'Magento\Customer\Model\ResourceModel\Customer\CollectionFactory', + \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, ['create'], [], '', false ); $this->groupManagement = $this->getMock( - 'Magento\Customer\Api\GroupManagementInterface', + \Magento\Customer\Api\GroupManagementInterface::class, ['getDefaultGroup', 'getNotLoggedInGroup', 'isReadOnly', 'getLoggedInGroups', 'getAllCustomersGroup'], [], '', false); - $this->groupModel = $this->getMock('Magento\Customer\Model\Group', [], [], '', false); + $this->groupModel = $this->getMock(\Magento\Customer\Model\Group::class, [], [], '', false); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resource); $this->relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $transactionManagerMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface'); + $transactionManagerMock = $this->getMock( + \Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface::class + ); $transactionManagerMock->expects($this->once()) ->method('start') - ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface')); + ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); $contextMock->expects($this->once()) ->method('getTransactionManager') ->willReturn($transactionManagerMock); @@ -76,7 +81,7 @@ protected function setUp() ->willReturn($this->relationProcessorMock); $this->groupResourceModel = (new ObjectManagerHelper($this))->getObject( - 'Magento\Customer\Model\ResourceModel\Group', + \Magento\Customer\Model\ResourceModel\Group::class, [ 'context' => $contextMock, 'groupManagement' => $this->groupManagement, @@ -87,11 +92,11 @@ protected function setUp() public function testDelete() { - $dbAdapter = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); + $dbAdapter = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($dbAdapter)); $customer = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['__wakeup', 'load', 'getId', 'getStoreId', 'setGroupId', 'save'], [], '', @@ -101,7 +106,7 @@ public function testDelete() $customer->expects($this->once())->method('getId')->will($this->returnValue($customerId)); $customer->expects($this->once())->method('load')->with($customerId)->will($this->returnSelf()); $defaultCustomerGroup = $this->getMock( - 'Magento\Customer\Model\Group', + \Magento\Customer\Model\Group::class, ['getId'], [], '', @@ -112,7 +117,13 @@ public function testDelete() $defaultCustomerGroup->expects($this->once())->method('getId') ->will($this->returnValue(1)); $customer->expects($this->once())->method('setGroupId')->with(1); - $customerCollection = $this->getMock('Magento\Customer\Model\ResourceModel\Customer\Collection', [], [], '', false); + $customerCollection = $this->getMock( + \Magento\Customer\Model\ResourceModel\Customer\Collection::class, + [], + [], + '', + false + ); $customerCollection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf()); $customerCollection->expects($this->once())->method('load')->will($this->returnValue([$customer])); $this->customersFactory->expects($this->once())->method('create') diff --git a/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php b/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php index 9ddfbd93fad2b..48de976aec8cf 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php @@ -7,6 +7,9 @@ */ namespace Magento\Customer\Test\Unit\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SessionTest extends \PHPUnit_Framework_TestCase { /** @@ -52,30 +55,30 @@ class SessionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storageMock = $this->getMock( - 'Magento\Customer\Model\Session\Storage', + \Magento\Customer\Model\Session\Storage::class, ['getIsCustomerEmulated', 'getData', 'unsIsCustomerEmulated', '__sleep', '__wakeup'], [], '', false ); - $this->_eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $this->_httpContextMock = $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false); - $this->urlFactoryMock = $this->getMock('Magento\Framework\UrlFactory', [], [], '', false); - $this->customerFactoryMock = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory') + $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->_httpContextMock = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false); + $this->urlFactoryMock = $this->getMock(\Magento\Framework\UrlFactory::class, [], [], '', false); + $this->customerFactoryMock = $this->getMockBuilder(\Magento\Customer\Model\CustomerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->customerRepositoryMock = $this->getMock( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], [], '', false ); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $this->_model = $helper->getObject( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, [ 'customerFactory' => $this->customerFactoryMock, 'storage' => $this->_storageMock, @@ -90,8 +93,8 @@ protected function setUp() public function testSetCustomerAsLoggedIn() { - $customer = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); - $customerDto = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $customerDto = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $customer->expects($this->any()) ->method('getDataModel') ->will($this->returnValue($customerDto)); @@ -110,8 +113,8 @@ public function testSetCustomerAsLoggedIn() public function testSetCustomerDataAsLoggedIn() { - $customer = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); - $customerDto = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $customerDto = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->customerFactoryMock->expects($this->once()) ->method('create') @@ -134,7 +137,7 @@ public function testSetCustomerDataAsLoggedIn() public function testAuthenticate() { - $urlMock = $this->getMock('Magento\Framework\Url', [], [], '', false); + $urlMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); $urlMock->expects($this->exactly(2)) ->method('getUrl') ->will($this->returnValue('')); @@ -173,12 +176,12 @@ public function testLoginById() */ protected function prepareLoginDataMock($customerId) { - $customerDataMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerDataMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $customerDataMock->expects($this->once()) ->method('getId') ->will($this->returnValue($customerId)); - $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); $customerMock->expects($this->once()) ->method('getId') ->will($this->returnValue($customerId)); @@ -244,7 +247,7 @@ public function getIsLoggedInDataProvider() public function testSetCustomerRemovesFlagThatShowsIfCustomerIsEmulated() { - $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); $this->_storageMock->expects($this->once())->method('unsIsCustomerEmulated'); $this->_model->setCustomer($customerMock); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php b/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php index 530a5e70be2ba..dfeb2cb3612af 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php @@ -41,15 +41,15 @@ class VisitorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registry = $this->getMock('Magento\Framework\Registry'); - $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getSessionId', 'getVisitorData', 'setVisitorData']) ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->resource = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Visitor') + $this->resource = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Visitor::class) ->setMethods([ 'beginTransaction', '__sleep', @@ -64,7 +64,7 @@ protected function setUp() $this->resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); $arguments = $this->objectManagerHelper->getConstructArguments( - 'Magento\Customer\Model\Visitor', + \Magento\Customer\Model\Visitor::class, [ 'registry' => $this->registry, 'session' => $this->session, @@ -72,7 +72,7 @@ protected function setUp() ] ); - $this->visitor = $this->objectManagerHelper->getObject('Magento\Customer\Model\Visitor', $arguments); + $this->visitor = $this->objectManagerHelper->getObject(\Magento\Customer\Model\Visitor::class, $arguments); } public function testInitByRequest() @@ -96,7 +96,7 @@ public function testSaveByRequest() public function testIsModuleIgnored() { $this->visitor = $this->objectManagerHelper->getObject( - 'Magento\Customer\Model\Visitor', + \Magento\Customer\Model\Visitor::class, [ 'registry' => $this->registry, 'session' => $this->session, diff --git a/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php index 3d612132af5b8..5e9e532c8a5f3 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php @@ -81,36 +81,36 @@ class AfterAddressSaveObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->vat = $this->getMockBuilder('Magento\Customer\Model\Vat') + $this->vat = $this->getMockBuilder(\Magento\Customer\Model\Vat::class) ->disableOriginalConstructor() ->getMock(); - $this->helperAddress = $this->getMockBuilder('Magento\Customer\Helper\Address') + $this->helperAddress = $this->getMockBuilder(\Magento\Customer\Helper\Address::class) ->disableOriginalConstructor() ->getMock(); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->groupManagement = $this->getMockBuilder('Magento\Customer\Api\GroupManagementInterface') + $this->groupManagement = $this->getMockBuilder(\Magento\Customer\Api\GroupManagementInterface::class) ->getMockForAbstractClass(); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); - $this->escaper = $this->getMockBuilder('Magento\Framework\Escaper') + $this->escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->getMock(); - $this->appState = $this->getMockBuilder('Magento\Framework\App\State') + $this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); @@ -144,11 +144,11 @@ public function testAfterAddressSaveRestricted( $registeredAddressId, $configAddressType ) { - $store = $this->getMockBuilder('Magento\Store\Model\Store') + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $customer->expects($this->any()) @@ -161,7 +161,7 @@ public function testAfterAddressSaveRestricted( ->method('getDefaultShipping') ->willReturn(null); - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->getMock(); $address->expects($this->any()) @@ -186,7 +186,7 @@ public function testAfterAddressSaveRestricted( ->method('getIsDefaultShipping') ->willReturn($addressId); - $observer = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observer = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomerAddress', @@ -231,18 +231,18 @@ public function dataProviderAfterAddressSaveRestricted() public function testAfterAddressSaveException() { - $store = $this->getMockBuilder('Magento\Store\Model\Store') + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $customer->expects($this->any()) ->method('getStore') ->willReturn($store); - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomer', @@ -260,7 +260,7 @@ public function testAfterAddressSaveException() ->method('getVatId') ->willThrowException(new \Exception('Exception')); - $observer = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observer = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomerAddress', @@ -302,17 +302,17 @@ public function testAfterAddressSaveDefaultGroup( $isCountryInEU, $defaultGroupId ) { - $store = $this->getMockBuilder('Magento\Store\Model\Store') + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $dataGroup = $this->getMockBuilder('Magento\Customer\Api\Data\GroupInterface') + $dataGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class) ->getMockForAbstractClass(); $dataGroup->expects($this->any()) ->method('getId') ->willReturn($defaultGroupId); - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->setMethods([ 'getStore', @@ -339,7 +339,7 @@ public function testAfterAddressSaveDefaultGroup( ->method('save') ->willReturnSelf(); - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomer', @@ -361,7 +361,7 @@ public function testAfterAddressSaveDefaultGroup( ->method('getCountry') ->willReturn($countryId); - $observer = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observer = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomerAddress', @@ -426,11 +426,11 @@ public function testAfterAddressSaveNewGroup( $resultInvalidMessage, $resultErrorMessage ) { - $store = $this->getMockBuilder('Magento\Store\Model\Store') + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $validationResult = $this->getMockBuilder('Magento\Framework\DataObject') + $validationResult = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods([ 'getIsValid', @@ -444,7 +444,7 @@ public function testAfterAddressSaveNewGroup( ->method('getRequestSuccess') ->willReturn($resultRequestSuccess); - $customer = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->setMethods([ 'getStore', @@ -476,7 +476,7 @@ public function testAfterAddressSaveNewGroup( ->with($newGroupId) ->willReturnSelf(); - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomer', @@ -507,7 +507,7 @@ public function testAfterAddressSaveNewGroup( ->with($validationResult) ->willReturnSelf(); - $observer = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observer = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomerAddress', diff --git a/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php index 8874e7b3b64da..0a4ea7b95c9d1 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php @@ -36,11 +36,11 @@ class BeforeAddressSaveObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->helperAddress = $this->getMockBuilder('Magento\Customer\Helper\Address') + $this->helperAddress = $this->getMockBuilder(\Magento\Customer\Helper\Address::class) ->disableOriginalConstructor() ->getMock(); @@ -54,14 +54,14 @@ public function testBeforeAddressSaveWithCustomerAddressId() { $customerAddressId = 1; - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->getMock(); $address->expects($this->exactly(2)) ->method('getId') ->willReturn($customerAddressId); - $observer = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observer = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomerAddress', @@ -100,7 +100,7 @@ public function testBeforeAddressSaveWithoutCustomerAddressId( ) { $customerAddressId = null; - $address = $this->getMockBuilder('Magento\Customer\Model\Address') + $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() ->getMock(); $address->expects($this->once()) @@ -117,7 +117,7 @@ public function testBeforeAddressSaveWithoutCustomerAddressId( ->with(true) ->willReturnSelf(); - $observer = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observer = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods([ 'getCustomerAddress', diff --git a/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php index 3c23d73f5e63f..a715403f56a2d 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php @@ -45,7 +45,7 @@ public function setUp() ); $this->customerModelMock = $this->getMock( - 'Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['getId'], [], '', @@ -62,8 +62,8 @@ public function setUp() public function testExecute() { $customerId = 1; - $observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $eventMock = $this->getMock('Magento\Framework\Event', ['getData'], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getData'], [], '', false); $observerMock->expects($this->once()) ->method('getEvent') ->willReturn($eventMock); diff --git a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php index e49461074d168..29baf77ef972c 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php @@ -30,7 +30,7 @@ class LogLastLoginAtObserverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMock('Magento\Customer\Model\Logger', [], [], '', false); + $this->loggerMock = $this->getMock(\Magento\Customer\Model\Logger::class, [], [], '', false); $this->logLastLoginAtObserver = new LogLastLoginAtObserver($this->loggerMock); } @@ -41,9 +41,9 @@ public function testLogLastLoginAt() { $id = 1; - $observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $eventMock = $this->getMock('Magento\Framework\Event', ['getCustomer'], [], '', false); - $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getCustomer'], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); $observerMock->expects($this->once()) ->method('getEvent') diff --git a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php index 2fb3b27b5610a..93fce4eb07caa 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php @@ -30,7 +30,7 @@ class LogLastLogoutAtObserverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMock('Magento\Customer\Model\Logger', [], [], '', false); + $this->loggerMock = $this->getMock(\Magento\Customer\Model\Logger::class, [], [], '', false); $this->logLastLogoutAtObserver = new LogLastLogoutAtObserver($this->loggerMock); } @@ -41,9 +41,9 @@ public function testLogLastLogoutAt() { $id = 1; - $observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $eventMock = $this->getMock('Magento\Framework\Event', ['getCustomer'], [], '', false); - $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getCustomer'], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); $observerMock->expects($this->once()) ->method('getEvent') diff --git a/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php index 3ccdfe00cb37d..196254d8c6e6e 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php @@ -31,12 +31,12 @@ class UpgradeCustomerPasswordObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerRepository = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepository = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); - $this->customerRegistry = $this->getMockBuilder('Magento\Customer\Model\CustomerRegistry') + $this->customerRegistry = $this->getMockBuilder(\Magento\Customer\Model\CustomerRegistry::class) ->disableOriginalConstructor() ->getMock(); - $this->encryptorMock = $this->getMockBuilder('\Magento\Framework\Encryption\Encryptor') + $this->encryptorMock = $this->getMockBuilder(\Magento\Framework\Encryption\Encryptor::class) ->disableOriginalConstructor() ->getMock(); @@ -52,13 +52,13 @@ public function testUpgradeCustomerPassword() $customerId = '1'; $password = 'password'; $passwordHash = 'hash:salt:999'; - $model = $this->getMockBuilder('Magento\Customer\Model\Customer') + $model = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); - $customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->disableOriginalConstructor() ->setMethods(['getPasswordHash', 'setPasswordHash']) ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php index f1f91aa571364..dbe8080ff35d1 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -33,39 +33,39 @@ class ColumnFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', + \Magento\Framework\View\Element\UiComponent\ContextInterface::class, [], '', false ); $this->componentFactory = $this->getMock( - 'Magento\Framework\View\Element\UiComponentFactory', + \Magento\Framework\View\Element\UiComponentFactory::class, ['create'], [], '', false ); $this->attributeMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], '', false ); $this->column = $this->getMockForAbstractClass( - 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + \Magento\Ui\Component\Listing\Columns\ColumnInterface::class, [], '', false ); $this->attributeOption = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\OptionInterface', + \Magento\Customer\Api\Data\OptionInterface::class, [], '', false ); $this->inlineEditUpdater = $this->getMockBuilder( - 'Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater' + \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php index 34075f0af9a3c..409f9154781c3 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php @@ -12,6 +12,9 @@ use Magento\Framework\Api\Search\SearchCriteriaInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\Reporting; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DataProviderTest extends \PHPUnit_Framework_TestCase { const TEST_REQUEST_NAME = 'test_request_name'; @@ -48,22 +51,22 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->reporting = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\DataProvider\Reporting') - ->disableOriginalConstructor() - ->getMock(); + $this->reporting = $this->getMockBuilder( + \Magento\Framework\View\Element\UiComponent\DataProvider\Reporting::class + )->disableOriginalConstructor()->getMock(); $searchCriteriaBuilder = $this->mockSearchCriteria(); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMockForAbstractClass(); - $this->filterBuilder = $this->getMockBuilder('Magento\Framework\Api\FilterBuilder') + $this->filterBuilder = $this->getMockBuilder(\Magento\Framework\Api\FilterBuilder::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeRepository = $this->getMockBuilder('Magento\Customer\Ui\Component\Listing\AttributeRepository') - ->disableOriginalConstructor() - ->getMock(); + $this->attributeRepository = $this->getMockBuilder( + \Magento\Customer\Ui\Component\Listing\AttributeRepository::class + )->disableOriginalConstructor()->getMock(); $this->model = new DataProvider( self::TEST_REQUEST_NAME, @@ -95,7 +98,7 @@ public function testGetData() ], ]; - $attributeMock = $this->getMockBuilder('Magento\Framework\Api\AttributeInterface') + $attributeMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeInterface::class) ->getMockForAbstractClass(); $attributeMock->expects($this->once()) ->method('getAttributeCode') @@ -104,13 +107,13 @@ public function testGetData() ->method('getValue') ->willReturn('opt1_value'); - $searchDocumentMock = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface') + $searchDocumentMock = $this->getMockBuilder(\Magento\Framework\Api\Search\DocumentInterface::class) ->getMockForAbstractClass(); $searchDocumentMock->expects($this->once()) ->method('getCustomAttributes') ->willReturn([$attributeMock]); - $searchResultMock = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultInterface') + $searchResultMock = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchResultInterface::class) ->getMockForAbstractClass(); $searchResultMock->expects($this->once()) ->method('getTotalCount') @@ -148,10 +151,10 @@ public function testGetData() */ protected function mockSearchCriteria() { - $this->searchCriteria = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaInterface') + $this->searchCriteria = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchCriteriaInterface::class) ->getMockForAbstractClass(); - $searchCriteriaBuilder = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaBuilder') + $searchCriteriaBuilder = $this->getMockBuilder(\Magento\Framework\Api\Search\SearchCriteriaBuilder::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php index e6b631b1afcc3..d5af151efb0c0 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -30,32 +30,32 @@ class FilterFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', + \Magento\Framework\View\Element\UiComponent\ContextInterface::class, [], '', false ); $this->componentFactory = $this->getMock( - 'Magento\Framework\View\Element\UiComponentFactory', + \Magento\Framework\View\Element\UiComponentFactory::class, ['create'], [], '', false ); $this->attributeMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], '', false ); $this->filter = $this->getMockForAbstractClass( - 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + \Magento\Ui\Component\Listing\Columns\ColumnInterface::class, [], '', false ); $this->attributeOption = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\OptionInterface', + \Magento\Customer\Api\Data\OptionInterface::class, [], '', false diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php index e3106318edb61..4731c8f6352ba 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php @@ -36,38 +36,44 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerMetadataManagement = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerMetadataManagementInterface', + \Magento\Customer\Api\CustomerMetadataManagementInterface::class, [], '', false ); $this->addressMetadataManagement = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AddressMetadataManagementInterface', + \Magento\Customer\Api\AddressMetadataManagementInterface::class, [], '', false ); $this->customerMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerMetadataInterface', + \Magento\Customer\Api\CustomerMetadataInterface::class, [], '', false ); $this->addressMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AddressMetadataInterface', + \Magento\Customer\Api\AddressMetadataInterface::class, [], '', false ); $this->attribute = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], '', false ); - $this->option = $this->getMock('Magento\Customer\Api\Data\OptionInterface', [], [], '', false); + $this->option = $this->getMock(\Magento\Customer\Api\Data\OptionInterface::class, [], [], '', false); - $this->attributeFilter = $this->getMock('Magento\Customer\Model\Indexer\Attribute\Filter', [], [], '', false); + $this->attributeFilter = $this->getMock( + \Magento\Customer\Model\Indexer\Attribute\Filter::class, + [], + [], + '', + false + ); $this->component = new AttributeRepository( $this->customerMetadataManagement, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php index 6729c2bb1e26e..c72cf9fddd0b7 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php @@ -20,14 +20,14 @@ class AccountLockTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( - 'Magento\Framework\View\Element\UiComponentFactory', + \Magento\Framework\View\Element\UiComponentFactory::class, [], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 81532c4406ce3..9d5c1364091ce 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -23,21 +23,21 @@ class ActionsTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( - 'Magento\Framework\View\Element\UiComponentFactory', + \Magento\Framework\View\Element\UiComponentFactory::class, [], [], '', false ); $this->urlBuilder = $this->getMockForAbstractClass( - 'Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, [], '', false diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php index 0895e5b3b5d88..1f40026eb2107 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php @@ -27,28 +27,28 @@ class AttributeColumnTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( - 'Magento\Framework\View\Element\UiComponentFactory', + \Magento\Framework\View\Element\UiComponentFactory::class, [], [], '', false ); $this->attributeRepository = $this->getMock( - 'Magento\Customer\Ui\Component\Listing\AttributeRepository', + \Magento\Customer\Ui\Component\Listing\AttributeRepository::class, [], [], '', false ); $this->attributeMetadata = $this->getMockForAbstractClass( - '\Magento\Customer\Api\Data\AttributeMetadataInterface', + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], '', false diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php index 7fecd45617d3f..cd31a41c786e9 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php @@ -42,22 +42,22 @@ class ConfirmationTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $this->processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->once()) ->method('getProcessor') ->willReturn($this->processor); - $this->uiComponentFactory = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentFactory') + $this->uiComponentFactory = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); $this->confirmation = new Confirmation( diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php index 3102fa6b656b3..4af70e86a3210 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php @@ -25,15 +25,15 @@ class InlineEditUpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->validationRules = $this->getMockBuilder('Magento\Customer\Ui\Component\Listing\Column\ValidationRules') - ->disableOriginalConstructor() - ->getMock(); + $this->validationRules = $this->getMockBuilder( + \Magento\Customer\Ui\Component\Listing\Column\ValidationRules::class + )->disableOriginalConstructor()->getMock(); - $this->validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $this->validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->column = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + $this->column = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php index 90ccfa176487b..9a3ab3f030a42 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php @@ -18,11 +18,13 @@ class ValidationRulesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->validationRules = $this->getMockBuilder('Magento\Customer\Ui\Component\Listing\Column\ValidationRules') + $this->validationRules = $this->getMockBuilder( + \Magento\Customer\Ui\Component\Listing\Column\ValidationRules::class + ) ->disableOriginalConstructor() ->getMock(); - $this->validationRule = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $this->validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php index 160f046514415..86e3016d23754 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php @@ -32,42 +32,42 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->columnFactory = $this->getMock( - 'Magento\Customer\Ui\Component\ColumnFactory', + \Magento\Customer\Ui\Component\ColumnFactory::class, ['create'], [], '', false ); $this->attributeRepository = $this->getMock( - 'Magento\Customer\Ui\Component\Listing\AttributeRepository', + \Magento\Customer\Ui\Component\Listing\AttributeRepository::class, [], [], '', false ); $this->attribute = $this->getMock( - 'Magento\Customer\Model\Attribute', + \Magento\Customer\Model\Attribute::class, [], [], '', false ); $this->column = $this->getMockForAbstractClass( - 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + \Magento\Ui\Component\Listing\Columns\ColumnInterface::class, [], '', false ); $this->inlineEditUpdater = $this->getMockBuilder( - 'Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater' + \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater::class )->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml b/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml index 4f70d38e73f28..ac1732f7748af 100644 --- a/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml @@ -9,7 +9,7 @@ ?>
+ data-products="escapeHtml( + $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($block->getAssociatedProducts()) + ); ?>">
diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php index 0c10ca794a613..2f054b5a9c4d1 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php @@ -11,6 +11,7 @@ * Export filter block * * @author Magento Core Team + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Filter extends \Magento\Backend\Block\Widget\Grid\Extended { @@ -92,7 +93,7 @@ protected function _getDateFromToHtmlWithValue(Attribute $attribute, $value) ]; /** @var $selectBlock \Magento\Framework\View\Element\Html\Date */ $dateBlock = $this->_layout->createBlock( - 'Magento\Framework\View\Element\Html\Date', + \Magento\Framework\View\Element\Html\Date::class, '', ['data' => $arguments] ); @@ -157,7 +158,7 @@ protected function _getMultiSelectHtmlWithValue(Attribute $attribute, $value) ]; /** @var $selectBlock \Magento\Framework\View\Element\Html\Select */ $selectBlock = $this->_layout->createBlock( - 'Magento\Framework\View\Element\Html\Select', + \Magento\Framework\View\Element\Html\Select::class, '', ['data' => $arguments] ); @@ -240,7 +241,7 @@ protected function _getSelectHtmlWithValue(Attribute $attribute, $value) ]; /** @var $selectBlock \Magento\Framework\View\Element\Html\Select */ $selectBlock = $this->_layout->createBlock( - 'Magento\Framework\View\Element\Html\Select', + \Magento\Framework\View\Element\Html\Select::class, '', ['data' => $arguments] ); diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Frame/Result.php b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Frame/Result.php index 4cbb8a918d3f5..199aea7383105 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Frame/Result.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Frame/Result.php @@ -190,7 +190,7 @@ public function getMessages() public function getMessagesHtml() { /** @var $messagesBlock \Magento\Framework\View\Element\Messages */ - $messagesBlock = $this->_layout->createBlock('Magento\Framework\View\Element\Messages'); + $messagesBlock = $this->_layout->createBlock(\Magento\Framework\View\Element\Messages::class); foreach ($this->_messages as $priority => $messages) { $method = "add{$priority}"; diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php index 98d863d74796a..4981d9f7a201a 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php @@ -42,7 +42,7 @@ public function execute() if ($this->getRequest()->getPost(ExportModel::FILTER_ELEMENT_GROUP)) { try { /** @var $model \Magento\ImportExport\Model\Export */ - $model = $this->_objectManager->create('Magento\ImportExport\Model\Export'); + $model = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class); $model->setData($this->getRequest()->getParams()); return $this->fileFactory->create( @@ -54,7 +54,7 @@ public function execute() } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addError(__('Please correct the data sent value.')); } } else { diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/GetFilter.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/GetFilter.php index 5486a3aa9d6f1..ddf85f1fbec81 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/GetFilter.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/GetFilter.php @@ -25,7 +25,7 @@ public function execute() /** @var $attrFilterBlock \Magento\ImportExport\Block\Adminhtml\Export\Filter */ $attrFilterBlock = $resultLayout->getLayout()->getBlock('export.filter'); /** @var $export \Magento\ImportExport\Model\Export */ - $export = $this->_objectManager->create('Magento\ImportExport\Model\Export'); + $export = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class); $export->setData($data); $export->filterAttributeCollection( diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php index 1ee2c103bf31a..27d386a334904 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php @@ -42,7 +42,7 @@ public function execute() $fileName = $this->getRequest()->getParam('filename'); /** @var \Magento\ImportExport\Helper\Report $reportHelper */ - $reportHelper = $this->_objectManager->get('Magento\ImportExport\Helper\Report'); + $reportHelper = $this->_objectManager->get(\Magento\ImportExport\Helper\Report::class); if (!$reportHelper->importFileExists($fileName)) { /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Index.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Index.php index 3c7191ca95b98..95a67b7340ea9 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Index.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Index.php @@ -18,7 +18,7 @@ class Index extends ImportController public function execute() { $this->messageManager->addNotice( - $this->_objectManager->get('Magento\ImportExport\Helper\Data')->getMaxUploadSizeMessage() + $this->_objectManager->get(\Magento\ImportExport\Helper\Data::class)->getMaxUploadSizeMessage() ); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php index e6149227a2078..c23c706fd3aea 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php @@ -34,10 +34,10 @@ public function execute() ); /** @var $import \Magento\ImportExport\Model\Import */ - $import = $this->_objectManager->create('Magento\ImportExport\Model\Import')->setData($data); + $import = $this->_objectManager->create(\Magento\ImportExport\Model\Import::class)->setData($data); $source = ImportAdapter::findAdapterFor( $import->uploadSource(), - $this->_objectManager->create('Magento\Framework\Filesystem') + $this->_objectManager->create(\Magento\Framework\Filesystem::class) ->getDirectoryWrite(DirectoryList::ROOT), $data[$import::FIELD_FIELD_SEPARATOR] ); diff --git a/app/code/Magento/ImportExport/Model/Export.php b/app/code/Magento/ImportExport/Model/Export.php index 2adfe4cb9a532..2785327326e89 100644 --- a/app/code/Magento/ImportExport/Model/Export.php +++ b/app/code/Magento/ImportExport/Model/Export.php @@ -107,9 +107,7 @@ protected function _getEntityAdapter() ) { throw new \Magento\Framework\Exception\LocalizedException( __( - 'The entity adapter object must be an instance of %1 or %2.', - 'Magento\ImportExport\Model\Export\Entity\AbstractEntity', - 'Magento\ImportExport\Model\Export\AbstractEntity' + 'The entity adapter object must be an instance of %1 or %2.', \Magento\ImportExport\Model\Export\Entity\AbstractEntity::class, \Magento\ImportExport\Model\Export\AbstractEntity::class ) ); } @@ -151,8 +149,7 @@ protected function _getWriter() if (!$this->_writer instanceof \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter) { throw new \Magento\Framework\Exception\LocalizedException( __( - 'The adapter object must be an instance of %1.', - 'Magento\ImportExport\Model\Export\Adapter\AbstractAdapter' + 'The adapter object must be an instance of %1.', \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class ) ); } diff --git a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php index 69441c86a9557..e01d68e7d0f13 100644 --- a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php @@ -20,7 +20,7 @@ abstract class AbstractEntity /**#@+ * Attribute collection name */ - const ATTRIBUTE_COLLECTION_NAME = 'Magento\Framework\Data\Collection'; + const ATTRIBUTE_COLLECTION_NAME = \Magento\Framework\Data\Collection::class; /**#@-*/ diff --git a/app/code/Magento/ImportExport/Model/Export/Config/Reader.php b/app/code/Magento/ImportExport/Model/Export/Config/Reader.php index 9e64f993ba393..b41b0eb553cef 100644 --- a/app/code/Magento/ImportExport/Model/Export/Config/Reader.php +++ b/app/code/Magento/ImportExport/Model/Export/Config/Reader.php @@ -35,7 +35,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'export.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/ImportExport/Model/History.php b/app/code/Magento/ImportExport/Model/History.php index 6242059a68fdd..41569c232b8f6 100644 --- a/app/code/Magento/ImportExport/Model/History.php +++ b/app/code/Magento/ImportExport/Model/History.php @@ -75,7 +75,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\ImportExport\Model\ResourceModel\History'); + $this->_init(\Magento\ImportExport\Model\ResourceModel\History::class); } /** @@ -269,6 +269,7 @@ public function setErrorFile($errorFile) { return $this->setData(self::ERROR_FILE, $errorFile); } + /** * Set Execution Time * diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index 207cb96eaa99d..91be4e2378878 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -233,9 +233,7 @@ protected function _getEntityAdapter() ) { throw new \Magento\Framework\Exception\LocalizedException( __( - 'The entity adapter object must be an instance of %1 or %2.', - 'Magento\ImportExport\Model\Import\Entity\AbstractEntity', - 'Magento\ImportExport\Model\Import\AbstractEntity' + 'The entity adapter object must be an instance of %1 or %2.', \Magento\ImportExport\Model\Import\Entity\AbstractEntity::class, \Magento\ImportExport\Model\Import\AbstractEntity::class ) ); } diff --git a/app/code/Magento/ImportExport/Model/Import/Config/Reader.php b/app/code/Magento/ImportExport/Model/Import/Config/Reader.php index 0b790ebdad024..2858e874403a2 100644 --- a/app/code/Magento/ImportExport/Model/Import/Config/Reader.php +++ b/app/code/Magento/ImportExport/Model/Import/Config/Reader.php @@ -35,7 +35,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'import.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php index dc59fcc48aed1..ca3733d1cc35b 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php @@ -16,7 +16,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn /** * Attribute collection name */ - const ATTRIBUTE_COLLECTION_NAME = 'Magento\Framework\Data\Collection'; + const ATTRIBUTE_COLLECTION_NAME = \Magento\Framework\Data\Collection::class; /** * Store manager diff --git a/app/code/Magento/ImportExport/Model/ResourceModel/History/Collection.php b/app/code/Magento/ImportExport/Model/ResourceModel/History/Collection.php index a1feea358f91c..f463d719225ad 100644 --- a/app/code/Magento/ImportExport/Model/ResourceModel/History/Collection.php +++ b/app/code/Magento/ImportExport/Model/ResourceModel/History/Collection.php @@ -26,7 +26,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\ImportExport\Model\History', 'Magento\ImportExport\Model\ResourceModel\History'); + $this->_init( + \Magento\ImportExport\Model\History::class, + \Magento\ImportExport\Model\ResourceModel\History::class + ); $this->_linkTable = $this->getTable('admin_user'); } diff --git a/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Export/FilterTest.php b/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Export/FilterTest.php index 4445e6afa6aa9..9a76018193c81 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Export/FilterTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Export/FilterTest.php @@ -129,76 +129,82 @@ class FilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->modelContext = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->modelContext = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->extensionFactory = $this->getMock( - 'Magento\Framework\Api\ExtensionAttributesFactory', + \Magento\Framework\Api\ExtensionAttributesFactory::class, [], [], '', false ); $this->customAttributeFactory = $this->getMock( - 'Magento\Framework\Api\AttributeValueFactory', + \Magento\Framework\Api\AttributeValueFactory::class, + [], + [], + '', + false + ); + $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->eavTypeFactory = $this->getMock(\Magento\Eav\Model\Entity\TypeFactory::class, [], [], '', false); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->resourceHelper = $this->getMock(\Magento\Eav\Model\ResourceModel\Helper::class, [], [], '', false); + $this->universalFactory = $this->getMock( + \Magento\Framework\Validator\UniversalFactory::class, [], [], '', false ); - $this->eavConfig = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); - $this->eavTypeFactory = $this->getMock('Magento\Eav\Model\Entity\TypeFactory', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $this->resourceHelper = $this->getMock('Magento\Eav\Model\ResourceModel\Helper', [], [], '', false); - $this->universalFactory = $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false); $this->optionDataFactory = $this->getMock( - 'Magento\Eav\Api\Data\AttributeOptionInterfaceFactory', + \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class, [], [], '', false ); $this->dataObjectProcessor = $this->getMock( - 'Magento\Framework\Reflection\DataObjectProcessor', + \Magento\Framework\Reflection\DataObjectProcessor::class, [], [], '', false ); - $this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); - $this->localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\Timezone', [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $this->localeDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, [], [], '', false); $this->localeDate->expects($this->any())->method('getDateFormat')->will($this->returnValue('12-12-2012')); $this->reservedAttributeList = $this->getMock( - 'Magento\Catalog\Model\Product\ReservedAttributeList', + \Magento\Catalog\Model\Product\ReservedAttributeList::class, [], [], '', false ); - $this->localeResolver = $this->getMock('Magento\Framework\Locale\Resolver', [], [], '', false); - $this->resource = $this->getMock('Magento\Catalog\Model\ResourceModel\Product', [], [], '', false); + $this->localeResolver = $this->getMock(\Magento\Framework\Locale\Resolver::class, [], [], '', false); + $this->resource = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); $this->resourceCollection = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\AbstractDb', + \Magento\Framework\Data\Collection\AbstractDb::class, [], '', false ); $this->context = $this->getMock( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['getFileSystem', 'getEscaper', 'getLocaleDate', 'getLayout'], [], '', false ); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->context->expects($this->any())->method('getFileSystem')->will($this->returnValue($filesystem)); - $escaper = $this->getMock('Magento\Framework\Escaper', ['escapeHtml'], [], '', false); + $escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); $escaper->expects($this->any())->method('escapeHtml')->will($this->returnValue('')); $this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($escaper)); - $timeZone = $this->getMock('Magento\Framework\Stdlib\DateTime\TimeZone', [], [], '', false); + $timeZone = $this->getMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, [], [], '', false); $timeZone->expects($this->any())->method('getDateFormat')->will($this->returnValue('M/d/yy')); $this->context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timeZone)); $dateBlock = $this->getMock( - 'Magento\Framework\View\Element\Html\Date', + \Magento\Framework\View\Element\Html\Date::class, ['setValue', 'getHtml', 'setId', 'getId'], [], '', @@ -208,15 +214,15 @@ protected function setUp() $dateBlock->expects($this->any())->method('getHtml')->will($this->returnValue('')); $dateBlock->expects($this->any())->method('setId')->will($this->returnSelf()); $dateBlock->expects($this->any())->method('getId')->will($this->returnValue(1)); - $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $layout->expects($this->any())->method('createBlock')->will($this->returnValue($dateBlock)); $this->context->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); - $this->backendHelper = $this->getMock('Magento\Backend\Helper\Data', [], [], '', false); - $this->importExportData = $this->getMock('Magento\ImportExport\Helper\Data', [], [], '', false); - $this->dateTimeFormatter = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface'); + $this->backendHelper = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->importExportData = $this->getMock(\Magento\ImportExport\Helper\Data::class, [], [], '', false); + $this->dateTimeFormatter = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->filter = $this->objectManagerHelper->getObject( - 'Magento\ImportExport\Block\Adminhtml\Export\Filter', + \Magento\ImportExport\Block\Adminhtml\Export\Filter::class, [ 'context' => $this->context, 'backendHelper' => $this->backendHelper, diff --git a/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Grid/Column/Renderer/DownloadTest.php b/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Grid/Column/Renderer/DownloadTest.php index cd2c083f5bd64..d29dd681d8d2a 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Grid/Column/Renderer/DownloadTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Grid/Column/Renderer/DownloadTest.php @@ -30,7 +30,7 @@ class DownloadTest extends \PHPUnit_Framework_TestCase protected function setUp() { $urlModel = $this->getMock( - 'Magento\Backend\Model\Url', + \Magento\Backend\Model\Url::class, ['getUrl'], [], '', @@ -38,7 +38,7 @@ protected function setUp() ); $urlModel->expects($this->any())->method('getUrl')->willReturn('url'); $this->context = $this->getMock( - 'Magento\Backend\Block\Context', + \Magento\Backend\Block\Context::class, ['getUrlBuilder'], [], '', @@ -49,7 +49,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->download = $this->objectManagerHelper->getObject( - 'Magento\ImportExport\Block\Adminhtml\Grid\Column\Renderer\Download', + \Magento\ImportExport\Block\Adminhtml\Grid\Column\Renderer\Download::class, [ 'context' => $this->context, 'data' => $data diff --git a/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Import/Edit/FormTest.php b/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Import/Edit/FormTest.php index 9b0a84f2006aa..4fc1fe9876f67 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Import/Edit/FormTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Import/Edit/FormTest.php @@ -34,26 +34,26 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMockBuilder('\Magento\Backend\Block\Template\Context') + $context = $this->getMockBuilder(\Magento\Backend\Block\Template\Context::class) ->disableOriginalConstructor() ->getMock(); - $registry = $this->getMockBuilder('\Magento\Framework\Registry') + $registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $formFactory = $this->getMockBuilder('\Magento\Framework\Data\FormFactory') + $formFactory = $this->getMockBuilder(\Magento\Framework\Data\FormFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->_importModel = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + $this->_importModel = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->disableOriginalConstructor() ->getMock(); - $this->_entityFactory = $this->getMockBuilder('\Magento\ImportExport\Model\Source\Import\EntityFactory') - ->disableOriginalConstructor() - ->getMock(); - $this->_behaviorFactory = $this->getMockBuilder('\Magento\ImportExport\Model\Source\Import\Behavior\Factory') + $this->_entityFactory = $this->getMockBuilder(\Magento\ImportExport\Model\Source\Import\EntityFactory::class) ->disableOriginalConstructor() ->getMock(); + $this->_behaviorFactory = $this->getMockBuilder( + \Magento\ImportExport\Model\Source\Import\Behavior\Factory::class + )->disableOriginalConstructor()->getMock(); - $this->form = $this->getMockBuilder('\Magento\ImportExport\Block\Adminhtml\Import\Edit\Form') + $this->form = $this->getMockBuilder(\Magento\ImportExport\Block\Adminhtml\Import\Edit\Form::class) ->setConstructorArgs([ $context, $registry, diff --git a/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/DownloadTest.php b/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/DownloadTest.php index cf8d4074fa42b..2cbb47fa5f16b 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/DownloadTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/DownloadTest.php @@ -73,7 +73,7 @@ class DownloadTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->request = $this->getMock( - 'Magento\Framework\App\Request\Http', + \Magento\Framework\App\Request\Http::class, ['getParam'], [], '', @@ -81,7 +81,7 @@ protected function setUp() ); $this->request->expects($this->any())->method('getParam')->with('filename')->willReturn('filename'); $this->reportHelper = $this->getMock( - 'Magento\ImportExport\Helper\Report', + \Magento\ImportExport\Helper\Report::class, ['importFileExists', 'getReportSize', 'getReportOutput'], [], '', @@ -90,7 +90,7 @@ protected function setUp() $this->reportHelper->expects($this->any())->method('getReportSize')->willReturn(1); $this->reportHelper->expects($this->any())->method('getReportOutput')->willReturn('output'); $this->objectManager = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['get'], [], '', @@ -98,31 +98,31 @@ protected function setUp() ); $this->objectManager->expects($this->any()) ->method('get') - ->with('Magento\ImportExport\Helper\Report') + ->with(\Magento\ImportExport\Helper\Report::class) ->willReturn($this->reportHelper); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, ['getRequest', 'getObjectManager', 'getResultRedirectFactory'], [], '', false ); $this->fileFactory = $this->getMock( - 'Magento\Framework\App\Response\Http\FileFactory', + \Magento\Framework\App\Response\Http\FileFactory::class, ['create'], [], '', false ); $this->resultRaw = $this->getMock( - 'Magento\Framework\Controller\Result\Raw', + \Magento\Framework\Controller\Result\Raw::class, ['setContents'], [], '', false ); $this->resultRawFactory = $this->getMock( - '\Magento\Framework\Controller\Result\RawFactory', + \Magento\Framework\Controller\Result\RawFactory::class, ['create'], [], '', @@ -130,7 +130,7 @@ protected function setUp() ); $this->resultRawFactory->expects($this->any())->method('create')->willReturn($this->resultRaw); $this->redirect = $this->getMock( - '\Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, ['setPath'], [], '', @@ -138,7 +138,7 @@ protected function setUp() ); $this->resultRedirectFactory = $this->getMock( - 'Magento\Framework\Controller\Result\RedirectFactory', + \Magento\Framework\Controller\Result\RedirectFactory::class, ['create'], [], '', @@ -154,7 +154,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->downloadController = $this->objectManagerHelper->getObject( - 'Magento\ImportExport\Controller\Adminhtml\History\Download', + \Magento\ImportExport\Controller\Adminhtml\History\Download::class, [ 'context' => $this->context, 'fileFactory' => $this->fileFactory, diff --git a/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/IndexTest.php b/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/IndexTest.php index 6b56865defe81..c423d1716f992 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/IndexTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/History/IndexTest.php @@ -37,7 +37,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->resultPage = $this->getMock( - 'Magento\Backend\Model\View\Result\Page', + \Magento\Backend\Model\View\Result\Page::class, ['setActiveMenu', 'getConfig', 'getTitle', 'prepend', 'addBreadcrumb'], [], '', @@ -46,7 +46,7 @@ protected function setUp() $this->resultPage->expects($this->any())->method('getConfig')->willReturnSelf(); $this->resultPage->expects($this->any())->method('getTitle')->willReturnSelf(); $this->resultFactory = $this->getMock( - 'Magento\Framework\Controller\ResultFactory', + \Magento\Framework\Controller\ResultFactory::class, ['create'], [], '', @@ -54,7 +54,7 @@ protected function setUp() ); $this->resultFactory->expects($this->any())->method('create')->willReturn($this->resultPage); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, ['getResultFactory'], [], '', @@ -63,7 +63,7 @@ protected function setUp() $this->context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->indexController = $this->objectManagerHelper->getObject( - 'Magento\ImportExport\Controller\Adminhtml\History\Index', + \Magento\ImportExport\Controller\Adminhtml\History\Index::class, [ 'context' => $this->context, ] diff --git a/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php b/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php index b6de98deb1bcd..a2a578230e160 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php @@ -9,6 +9,8 @@ /** * Class ReportTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ReportTest extends \PHPUnit_Framework_TestCase { @@ -48,28 +50,28 @@ class ReportTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->context = $this->getMock( - 'Magento\Framework\App\Helper\Context', + \Magento\Framework\App\Helper\Context::class, [], [], '', false ); $this->timezone = $this->getMock( - 'Magento\Framework\Stdlib\DateTime\Timezone', + \Magento\Framework\Stdlib\DateTime\Timezone::class, ['date', 'getConfigTimezone', 'diff', 'format'], [], '', false ); $this->varDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, ['getRelativePath', 'readFile', 'isFile', 'stat'], [], '', false ); $this->filesystem = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryWrite'], [], '', @@ -82,7 +84,7 @@ protected function setUp() $this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->varDirectory); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->report = $this->objectManagerHelper->getObject( - 'Magento\ImportExport\Helper\Report', + \Magento\ImportExport\Helper\Report::class, [ 'context' => $this->context, 'timeZone' => $this->timezone, @@ -110,12 +112,12 @@ public function testGetExecutionTime() */ public function testGetSummaryStats() { - $logger = $this->getMock('Psr\Log\LoggerInterface', [], [], '', false); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $importExportData = $this->getMock('Magento\ImportExport\Helper\Data', [], [], '', false); - $coreConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $importExportData = $this->getMock(\Magento\ImportExport\Helper\Data::class, [], [], '', false); + $coreConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); $importConfig = $this->getMock( - 'Magento\ImportExport\Model\Import\Config', + \Magento\ImportExport\Model\Import\Config::class, ['getEntities'], [], '', @@ -125,14 +127,14 @@ public function testGetSummaryStats() ->method('getEntities') ->willReturn(['catalog_product' => ['model' => 'catalog_product']]); $entityFactory = $this->getMock( - 'Magento\ImportExport\Model\Import\Entity\Factory', + \Magento\ImportExport\Model\Import\Entity\Factory::class, ['create'], [], '', false ); $product = $this->getMock( - 'Magento\CatalogImportExport\Model\Import\Product', + \Magento\CatalogImportExport\Model\Import\Product::class, ['getEntityTypeCode', 'setParameters'], [], '', @@ -141,20 +143,20 @@ public function testGetSummaryStats() $product->expects($this->any())->method('getEntityTypeCode')->willReturn('catalog_product'); $product->expects($this->any())->method('setParameters')->willReturn(''); $entityFactory->expects($this->any())->method('create')->willReturn($product); - $importData = $this->getMock('Magento\ImportExport\Model\ResourceModel\Import\Data', [], [], '', false); - $csvFactory = $this->getMock('Magento\ImportExport\Model\Export\Adapter\CsvFactory', [], [], '', false); - $httpFactory = $this->getMock('Magento\Framework\HTTP\Adapter\FileTransferFactory', [], [], '', false); - $uploaderFactory = $this->getMock('Magento\MediaStorage\Model\File\UploaderFactory', [], [], '', false); + $importData = $this->getMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class, [], [], '', false); + $csvFactory = $this->getMock(\Magento\ImportExport\Model\Export\Adapter\CsvFactory::class, [], [], '', false); + $httpFactory = $this->getMock(\Magento\Framework\HTTP\Adapter\FileTransferFactory::class, [], [], '', false); + $uploaderFactory = $this->getMock(\Magento\MediaStorage\Model\File\UploaderFactory::class, [], [], '', false); $behaviorFactory = $this->getMock( - 'Magento\ImportExport\Model\Source\Import\Behavior\Factory', + \Magento\ImportExport\Model\Source\Import\Behavior\Factory::class, [], [], '', false ); - $indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); - $importHistoryModel = $this->getMock('Magento\ImportExport\Model\History', [], [], '', false); - $localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); + $indexerRegistry = $this->getMock(\Magento\Framework\Indexer\IndexerRegistry::class, [], [], '', false); + $importHistoryModel = $this->getMock(\Magento\ImportExport\Model\History::class, [], [], '', false); + $localeDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, [], [], '', false); $import = new \Magento\ImportExport\Model\Import( $logger, $filesystem, @@ -173,7 +175,7 @@ public function testGetSummaryStats() ); $import->setData('entity', 'catalog_product'); $message = $this->report->getSummaryStats($import); - $this->assertInstanceOf('Magento\Framework\Phrase', $message); + $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message); } public function testImportFileExists() diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php index f595a036a146e..745045f304e7c 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php @@ -25,10 +25,16 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->filePath = realpath(__DIR__) . '/_files/'; - $this->moduleManager = $this->getMock('Magento\Framework\Module\Manager', ['isOutputEnabled'], [], '', false); + $this->moduleManager = $this->getMock( + \Magento\Framework\Module\Manager::class, + ['isOutputEnabled'], + [], + '', + false + ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - '\Magento\ImportExport\Model\Export\Config\Converter', + \Magento\ImportExport\Model\Export\Config\Converter::class, [ 'moduleManager' => $this->moduleManager ] diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/SchemaLocatorTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/SchemaLocatorTest.php index c5296ee7898e9..abe81bb08a8c2 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/SchemaLocatorTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/SchemaLocatorTest.php @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleReaderMock = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->_moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->_moduleReaderMock->expects( $this->any() diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php index b67f1004073a2..797c9f7a1ae32 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php @@ -30,13 +30,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_readerMock = $this->getMock( - 'Magento\ImportExport\Model\Export\Config\Reader', + \Magento\ImportExport\Model\Export\Config\Reader::class, [], [], '', false ); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); } /** diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Entity/AbstractEavTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Entity/AbstractEavTest.php index 0cc5d4381442c..009bb5a82011b 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Entity/AbstractEavTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Entity/AbstractEavTest.php @@ -24,7 +24,7 @@ class AbstractEavTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Export\Entity\AbstractEav', + \Magento\ImportExport\Model\Export\Entity\AbstractEav::class, [], '', false, @@ -57,7 +57,7 @@ public function testAddAttributesToCollection() $method = new \ReflectionMethod($this->_model, '_addAttributesToCollection'); $method->setAccessible(true); $stubCollection = $this->getMock( - 'Magento\Eav\Model\Entity\Collection\AbstractCollection', + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, ['addAttributeToSelect'], [], '', @@ -80,7 +80,7 @@ public function testAddAttributeValuesToRow() $testAttributeOptions = ['value' => 'option']; /** @var $testAttribute \Magento\Eav\Model\Entity\Attribute */ $testAttribute = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [], '', false, @@ -108,7 +108,7 @@ public function testAddAttributeValuesToRow() /** @var $item \Magento\Framework\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject */ $item = $this->getMockForAbstractClass( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [], '', false, diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/EntityAbstractTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/EntityAbstractTest.php index e162b18c4955a..5526876e3701b 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/EntityAbstractTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/EntityAbstractTest.php @@ -21,7 +21,7 @@ public function testGetFileNameAndSetFileName() { /** @var $model \Magento\ImportExport\Model\Export\AbstractEntity */ $model = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Export\AbstractEntity', + \Magento\ImportExport\Model\Export\AbstractEntity::class, [], 'Stub_UnitTest_Magento_ImportExport_Model_Export_Entity_TestSetAndGet', false diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/ExportTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/ExportTest.php index 897d41afdc715..b77cbf62ebc61 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/ExportTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/ExportTest.php @@ -30,11 +30,11 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ protected function _getMageImportExportModelExportMock() { - $this->_exportConfigMock = $this->getMock('Magento\ImportExport\Model\Export\ConfigInterface'); + $this->_exportConfigMock = $this->getMock(\Magento\ImportExport\Model\Export\ConfigInterface::class); /** @var $abstractMockEntity \Magento\ImportExport\Model\Export\AbstractEntity */ $abstractMockEntity = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Export\AbstractEntity', + \Magento\ImportExport\Model\Export\AbstractEntity::class, [], '', false @@ -42,7 +42,7 @@ protected function _getMageImportExportModelExportMock() /** @var $mockAdapterTest \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter */ $mockAdapterTest = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Export\Adapter\AbstractAdapter', + \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class, [], '', false, @@ -58,17 +58,17 @@ protected function _getMageImportExportModelExportMock() $this->returnValue($this->_exportFileExtension) ); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $entityFactory = $this->getMock( - 'Magento\ImportExport\Model\Export\Entity\Factory', + \Magento\ImportExport\Model\Export\Entity\Factory::class, [], [], '', false ); $exportAdapterFac = $this->getMock( - 'Magento\ImportExport\Model\Export\Adapter\Factory', + \Magento\ImportExport\Model\Export\Adapter\Factory::class, [], [], '', @@ -76,7 +76,7 @@ protected function _getMageImportExportModelExportMock() ); /** @var $mockModelExport \Magento\ImportExport\Model\Export */ $mockModelExport = $this->getMock( - 'Magento\ImportExport\Model\Export', + \Magento\ImportExport\Model\Export::class, ['getEntityAdapter', '_getEntityAdapter', '_getWriter'], [$logger, $filesystem, $this->_exportConfigMock, $entityFactory, $exportAdapterFac] ); diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/AbstractImportTestCase.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/AbstractImportTestCase.php index f1a264536aa99..6e751509a3261 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/AbstractImportTestCase.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/AbstractImportTestCase.php @@ -29,15 +29,18 @@ protected function setUp() protected function getErrorAggregatorObject($methods = null) { $errorFactory = $this->getMockBuilder( - 'Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorFactory' + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorFactory::class )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $errorFactory->method('create')->willReturn( - $this->objectManagerHelper->getObject('Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError') + $this->objectManagerHelper->getObject( + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class + ) ); - return $this->getMockBuilder('Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator') - ->setMethods($methods) + return $this->getMockBuilder( + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class + )->setMethods($methods) ->setConstructorArgs(['errorFactory' => $errorFactory]) ->getMock(); } diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/AdapterTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/AdapterTest.php index a19a0cbb3ba52..2aa2df3dbc9ee 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/AdapterTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/AdapterTest.php @@ -17,7 +17,7 @@ class AdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->adapter = $this->getMock( - '\Magento\ImportExport\Model\Import\Adapter', + \Magento\ImportExport\Model\Import\Adapter::class, [], [], '', diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php index df036fc15f080..b315bd456ca49 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php @@ -25,10 +25,16 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->filePath = realpath(__DIR__) . '/_files/'; - $this->moduleManager = $this->getMock('Magento\Framework\Module\Manager', ['isOutputEnabled'], [], '', false); + $this->moduleManager = $this->getMock( + \Magento\Framework\Module\Manager::class, + ['isOutputEnabled'], + [], + '', + false + ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - '\Magento\ImportExport\Model\Import\Config\Converter', + \Magento\ImportExport\Model\Import\Config\Converter::class, [ 'moduleManager' => $this->moduleManager ] diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/SchemaLocatorTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/SchemaLocatorTest.php index b93e604114a30..a5fd1d3826df8 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/SchemaLocatorTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/SchemaLocatorTest.php @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleReaderMock = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->_moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->_moduleReaderMock->expects( $this->any() diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php index d57d3ac869a0f..1530c0b4a4d00 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php @@ -30,13 +30,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_readerMock = $this->getMock( - 'Magento\ImportExport\Model\Import\Config\Reader', + \Magento\ImportExport\Model\Import\Config\Reader::class, [], [], '', false ); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); } /** diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/AbstractTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/AbstractTest.php index 1aec1122937a2..fb41491d1047e 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/AbstractTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/AbstractTest.php @@ -24,7 +24,7 @@ protected function setUp() { parent::setUp(); - $this->_model = $this->getMockBuilder('Magento\ImportExport\Model\Import\Entity\AbstractEntity') + $this->_model = $this->getMockBuilder(\Magento\ImportExport\Model\Import\Entity\AbstractEntity::class) ->disableOriginalConstructor() ->setMethods(['_saveValidatedBunches', 'getErrorAggregator']) ->getMockForAbstractClass(); @@ -51,7 +51,7 @@ protected function _createSourceAdapterMock(array $columns) { /** @var $source \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject */ $source = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Import\AbstractSource', + \Magento\ImportExport\Model\Import\AbstractSource::class, [], '', false, diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/EavAbstractTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/EavAbstractTest.php index 73a8b2d3b6ff6..64fde415b9ce5 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/EavAbstractTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Entity/EavAbstractTest.php @@ -63,35 +63,35 @@ protected function setUp() parent::setUp(); $this->_string = new \Magento\Framework\Stdlib\StringUtils(); - $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_importFactory = $this->getMock( - 'Magento\ImportExport\Model\ImportFactory', + \Magento\ImportExport\Model\ImportFactory::class, [], [], '', false ); - $this->_resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->_resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->_resourceHelper = $this->getMock( - 'Magento\ImportExport\Model\ResourceModel\Helper', + \Magento\ImportExport\Model\ResourceModel\Helper::class, [], [], '', false ); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $this->_storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $this->_collectionFactory = $this->getMock( - 'Magento\ImportExport\Model\Export\Factory', + \Magento\ImportExport\Model\Export\Factory::class, [], [], '', false ); - $this->_eavConfig = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->_eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); $this->_model = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Import\Entity\AbstractEav', + \Magento\ImportExport\Model\Import\Entity\AbstractEav::class, [ $this->_string, $scopeConfig, diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/EntityAbstractTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/EntityAbstractTest.php index f57d7fb307041..293a871c62007 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/EntityAbstractTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/EntityAbstractTest.php @@ -37,7 +37,7 @@ protected function setUp() { parent::setUp(); - $this->_model = $this->getMockBuilder('Magento\ImportExport\Model\Import\AbstractEntity') + $this->_model = $this->getMockBuilder(\Magento\ImportExport\Model\Import\AbstractEntity::class) ->setConstructorArgs($this->_getModelDependencies()) ->setMethods(['_saveValidatedBunches']) ->getMockForAbstractClass(); @@ -56,10 +56,10 @@ protected function tearDown() protected function _getModelDependencies() { $string = new \Magento\Framework\Stdlib\StringUtils(); - $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $importFactory = $this->getMock('Magento\ImportExport\Model\ImportFactory', [], [], '', false); - $resourceHelper = $this->getMock('Magento\ImportExport\Model\ResourceModel\Helper', [], [], '', false); - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $importFactory = $this->getMock(\Magento\ImportExport\Model\ImportFactory::class, [], [], '', false); + $resourceHelper = $this->getMock(\Magento\ImportExport\Model\ResourceModel\Helper::class, [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $data = [ 'coreString' => $string, @@ -568,7 +568,7 @@ protected function _createSourceAdapterMock(array $columns) { /** @var $source \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject */ $source = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Import\AbstractSource', + \Magento\ImportExport\Model\Import\AbstractSource::class, [], '', false, diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorAggregatorTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorAggregatorTest.php index f8859da4f6f8a..cdf8fd2913ce2 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorAggregatorTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorAggregatorTest.php @@ -42,7 +42,7 @@ class ProcessingErrorAggregatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->processingErrorFactoryMock = $this->getMock( - '\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorFactory', + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorFactory::class, ['create'], [], '', @@ -50,7 +50,7 @@ protected function setUp() ); $this->processingErrorMock1 = $this->getMock( - '\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError', + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, null, [], '', @@ -58,7 +58,7 @@ protected function setUp() ); $this->processingErrorMock2 = $this->getMock( - '\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError', + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, null, [], '', @@ -66,7 +66,7 @@ protected function setUp() ); $this->processingErrorMock3 = $this->getMock( - '\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError', + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, null, [], '', @@ -82,7 +82,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - '\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator', + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class, [ 'errorFactory' => $this->processingErrorFactoryMock ] @@ -203,7 +203,7 @@ public function testInitValidationStrategyExceed() */ public function testInitValidationStrategyException() { - $this->setExpectedException('\Magento\Framework\Exception\LocalizedException'); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); $this->model->initValidationStrategy(null); } @@ -284,7 +284,7 @@ public function testGetAllErrors() //check if is array of objects $this->assertInternalType('array', $result); $this->assertCount(3, $result); - $this->assertInstanceOf('\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError', $result[0]); + $this->assertInstanceOf(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, $result[0]); } /** @@ -299,8 +299,8 @@ public function testGetErrorByRowNumber() $this->assertInternalType('array', $result); $this->assertCount(2, $result); - $this->assertInstanceOf('\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError', $result[0]); - $this->assertInstanceOf('\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError', $result[1]); + $this->assertInstanceOf(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, $result[0]); + $this->assertInstanceOf(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, $result[1]); $this->assertEquals('systemException1', $result[0]->getErrorCode()); $this->assertEquals('systemException2', $result[1]->getErrorCode()); } diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorTest.php index cd6ad66de9ff6..9719be6222cff 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ErrorProcessing/ProcessingErrorTest.php @@ -19,7 +19,9 @@ class ProcessingErrorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError'); + $this->model = $objectManager->getObject( + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class + ); } /** diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/CsvTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/CsvTest.php index c60973b5720a3..a865b4eea27a5 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/CsvTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/CsvTest.php @@ -22,9 +22,9 @@ class CsvTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->_filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->_directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, [], [], '', diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php index b0128dc03affd..37c380c2c3a9b 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php @@ -20,7 +20,7 @@ class ZipTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directory = $this->getMockBuilder('\Magento\Framework\Filesystem\Directory\Write') + $this->directory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Write::class) ->disableOriginalConstructor() ->setMethods(['getRelativePath']) ->getMock(); @@ -66,7 +66,7 @@ protected function _invokeConstructor($fileName) { try { $this->zip = $this->getMockBuilder( - '\Magento\ImportExport\Model\Import\Source\Zip' + \Magento\ImportExport\Model\Import\Source\Zip::class ) ->setConstructorArgs( [ @@ -78,7 +78,7 @@ protected function _invokeConstructor($fileName) ->getMock(); $reflectedClass = new \ReflectionClass( - '\Magento\ImportExport\Model\Import\Source\Zip' + \Magento\ImportExport\Model\Import\Source\Zip::class ); $constructor = $reflectedClass->getConstructor(); $constructor->invoke( diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/SourceAbstractTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/SourceAbstractTest.php index d12dd53a7fcb3..3367f5d2e0da5 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/SourceAbstractTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/SourceAbstractTest.php @@ -15,7 +15,7 @@ class SourceAbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Import\AbstractSource', + \Magento\ImportExport\Model\Import\AbstractSource::class, [['key1', 'key2', 'key3']] ); } @@ -27,7 +27,7 @@ protected function setUp() */ public function testConstructException($argument) { - $this->getMockForAbstractClass('Magento\ImportExport\Model\Import\AbstractSource', [$argument]); + $this->getMockForAbstractClass(\Magento\ImportExport\Model\Import\AbstractSource::class, [$argument]); } /** diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php index 48dbf7bd1e368..f39acf7add05d 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php @@ -112,26 +112,26 @@ protected function setUp() { parent::setUp(); - $logger = $this->getMockBuilder('\Psr\Log\LoggerInterface') + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->_filesystem = $this->getMockBuilder('\Magento\Framework\Filesystem') + $this->_filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->_importExportData = $this->getMockBuilder('\Magento\ImportExport\Helper\Data') + $this->_importExportData = $this->getMockBuilder(\Magento\ImportExport\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->_coreConfig = $this->getMockBuilder('\Magento\Framework\App\Config\ScopeConfigInterface') + $this->_coreConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->_importConfig = $this->getMockBuilder('\Magento\ImportExport\Model\Import\Config') + $this->_importConfig = $this->getMockBuilder(\Magento\ImportExport\Model\Import\Config::class) ->disableOriginalConstructor() ->setMethods(['getEntityTypeCode', 'getBehavior', 'getEntities']) ->getMockForAbstractClass(); - $this->_entityFactory = $this->getMockBuilder('\Magento\ImportExport\Model\Import\Entity\Factory') + $this->_entityFactory = $this->getMockBuilder(\Magento\ImportExport\Model\Import\Entity\Factory::class) ->disableOriginalConstructor() ->getMock(); - $this->_entityAdapter = $this->getMockBuilder('\Magento\ImportExport\Model\Import\Entity\AbstractEntity') + $this->_entityAdapter = $this->getMockBuilder(\Magento\ImportExport\Model\Import\Entity\AbstractEntity::class) ->disableOriginalConstructor() ->setMethods(['importData', '_saveValidatedBunches', 'getErrorAggregator']) ->getMockForAbstractClass(); @@ -140,36 +140,36 @@ protected function setUp() ); $this->_entityFactory->method('create')->willReturn($this->_entityAdapter); - $this->_importData = $this->getMockBuilder('\Magento\ImportExport\Model\ResourceModel\Import\Data') + $this->_importData = $this->getMockBuilder(\Magento\ImportExport\Model\ResourceModel\Import\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->_csvFactory = $this->getMockBuilder('\Magento\ImportExport\Model\Export\Adapter\CsvFactory') + $this->_csvFactory = $this->getMockBuilder(\Magento\ImportExport\Model\Export\Adapter\CsvFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->_httpFactory = $this->getMockBuilder('\Magento\Framework\HTTP\Adapter\FileTransferFactory') + $this->_httpFactory = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\FileTransferFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->_uploaderFactory = $this->getMockBuilder('\Magento\MediaStorage\Model\File\UploaderFactory') + $this->_uploaderFactory = $this->getMockBuilder(\Magento\MediaStorage\Model\File\UploaderFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->_behaviorFactory = $this->getMockBuilder('\Magento\ImportExport\Model\Source\Import\Behavior\Factory') + $this->_behaviorFactory = $this->getMockBuilder( + \Magento\ImportExport\Model\Source\Import\Behavior\Factory::class + )->disableOriginalConstructor()->getMock(); + $this->indexerRegistry = $this->getMockBuilder(\Magento\Framework\Indexer\IndexerRegistry::class) ->disableOriginalConstructor() ->getMock(); - $this->indexerRegistry = $this->getMockBuilder('\Magento\Framework\Indexer\IndexerRegistry') - ->disableOriginalConstructor() - ->getMock(); - $this->historyModel = $this->getMockBuilder('\Magento\ImportExport\Model\History') + $this->historyModel = $this->getMockBuilder(\Magento\ImportExport\Model\History::class) ->disableOriginalConstructor() ->setMethods(['updateReport', 'invalidateReport', 'addReport']) ->getMock(); $this->historyModel->expects($this->any())->method('updateReport')->willReturnSelf(); - $this->dateTime = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\DateTime') + $this->dateTime = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); - $this->_varDirectory = $this->getMockBuilder('\Magento\Framework\Filesystem\Directory\WriteInterface') + $this->_varDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->_driver = $this->getMockBuilder('\Magento\Framework\Filesystem\DriverInterface') + $this->_driver = $this->getMockBuilder(\Magento\Framework\Filesystem\DriverInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->_driver @@ -180,7 +180,7 @@ protected function setUp() ->expects($this->any()) ->method('getDriver') ->willReturn($this->_driver); - $this->import = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + $this->import = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->setConstructorArgs([ $logger, $this->_filesystem, @@ -233,7 +233,7 @@ public function testImportSource() ['entity', $entityTypeCode], ['behavior', $behaviour] ); - $phraseClass = '\Magento\Framework\Phrase'; + $phraseClass = \Magento\Framework\Phrase::class; $this->import->expects($this->any()) ->method('addLogComment') ->with($this->isInstanceOf($phraseClass)); @@ -288,7 +288,7 @@ public function testImportSourceException() ['entity', $entityTypeCode], ['behavior', $behaviour] ); - $phraseClass = '\Magento\Framework\Phrase'; + $phraseClass = \Magento\Framework\Phrase::class; $this->import->expects($this->any()) ->method('addLogComment') ->with($this->isInstanceOf($phraseClass)); @@ -323,7 +323,7 @@ public function testGetOperationResultMessages() public function testGetAttributeType() { /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute */ - $attribute = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['getFrontendInput', 'usesSource']) ->disableOriginalConstructor()->getMock(); $attribute->expects($this->any())->method('getFrontendInput')->willReturn('boolean'); @@ -450,7 +450,7 @@ public function testGetUniqueEntityBehaviors() */ public function testIsReportEntityType($entity, $getEntityResult, $expectedResult) { - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + $importMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->disableOriginalConstructor() ->setMethods([ 'getEntity', '_getEntityAdapter', 'getEntityTypeCode', 'isNeedToLogInHistory' @@ -488,7 +488,7 @@ public function testIsReportEntityType($entity, $getEntityResult, $expectedResul */ public function testIsReportEntityTypeException($entity, $getEntitiesResult, $getEntityResult, $expectedResult) { - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + $importMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->disableOriginalConstructor() ->setMethods([ 'getEntity', '_getEntityAdapter', 'getEntityTypeCode', 'isNeedToLogInHistory' @@ -699,7 +699,7 @@ public function testCreateHistoryReportThrowException() $this->_varDirectory ->expects($this->never()) ->method('getRelativePath'); - $phrase = $this->getMock('\Magento\Framework\Phrase', [], [], '', false); + $phrase = $this->getMock(\Magento\Framework\Phrase::class, [], [], '', false); $this->_driver ->expects($this->any()) ->method('fileGetContents') diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Report/CsvTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Report/CsvTest.php index da060b45b344a..7c61961ad29cc 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Report/CsvTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Report/CsvTest.php @@ -46,26 +46,26 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->reportHelperMock = $this->getMock('\Magento\ImportExport\Helper\Report', [], [], '', false); + $this->reportHelperMock = $this->getMock(\Magento\ImportExport\Helper\Report::class, [], [], '', false); $this->outputCsvFactoryMock = $this->getMock( - '\Magento\ImportExport\Model\Export\Adapter\CsvFactory', + \Magento\ImportExport\Model\Export\Adapter\CsvFactory::class, ['create'], [], '', false ); - $this->outputCsvMock = $this->getMock('\Magento\ImportExport\Model\Export\Adapter\Csv', [], [], '', false); + $this->outputCsvMock = $this->getMock(\Magento\ImportExport\Model\Export\Adapter\Csv::class, [], [], '', false); $this->outputCsvFactoryMock->expects($this->any())->method('create')->willReturn($this->outputCsvMock); $this->sourceCsvFactoryMock = $this->getMock( - '\Magento\ImportExport\Model\Import\Source\CsvFactory', + \Magento\ImportExport\Model\Import\Source\CsvFactory::class, ['create'], [], '', false ); - $this->sourceCsvMock = $this->getMock('\Magento\ImportExport\Model\Import\Source\Csv', [], [], '', false); + $this->sourceCsvMock = $this->getMock(\Magento\ImportExport\Model\Import\Source\Csv::class, [], [], '', false); $this->sourceCsvMock->expects($this->any())->method('valid')->willReturnOnConsecutiveCalls(true, true, false); $this->sourceCsvMock->expects($this->any())->method('current')->willReturnOnConsecutiveCalls( [23 => 'first error'], @@ -73,10 +73,10 @@ protected function setUp() ); $this->sourceCsvFactoryMock->expects($this->any())->method('create')->willReturn($this->sourceCsvMock); - $this->filesystemMock = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); + $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->csvModel = $objectManager->getObject( - '\Magento\ImportExport\Model\Report\Csv', + \Magento\ImportExport\Model\Report\Csv::class, [ 'reportHelper' => $this->reportHelperMock, 'sourceCsvFactory' => $this->sourceCsvFactoryMock, @@ -89,14 +89,14 @@ protected function setUp() public function testCreateReport() { $errorAggregatorMock = $this->getMock( - 'Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator', + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class, [], [], '', false ); $errorProcessingMock = $this->getMock( - 'Magento\ImportExport\Model\Import\ErrorProcessing', + \Magento\ImportExport\Model\Import\ErrorProcessing::class, ['getErrorMessage'], [], '', diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/CollectionByPagesIteratorTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/CollectionByPagesIteratorTest.php index 80da9a6d04b60..5b85f886283c4 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/CollectionByPagesIteratorTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/CollectionByPagesIteratorTest.php @@ -36,17 +36,19 @@ public function testIterate() $pageCount = 3; /** @var $callbackMock \PHPUnit_Framework_MockObject_MockObject */ - $callbackMock = $this->getMock('stdClass', ['callback']); + $callbackMock = $this->getMock(\stdClass::class, ['callback']); - $fetchStrategy = $this->getMockForAbstractClass('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $fetchStrategy = $this->getMockForAbstractClass( + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class + ); - $select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); - $entityFactory = $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); /** @var $collectionMock AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ - $collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->setConstructorArgs([$entityFactory, $logger, $fetchStrategy]) ->setMethods(['clear', 'setPageSize', 'setCurPage', 'count', 'getLastPageNumber', 'getSelect']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/HistoryTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/HistoryTest.php index 8fcff296935e3..9039f747e3d25 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/HistoryTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/ResourceModel/HistoryTest.php @@ -28,21 +28,21 @@ class HistoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->historyResourceModel = $this->getMock( - 'Magento\ImportExport\Model\ResourceModel\History', + \Magento\ImportExport\Model\ResourceModel\History::class, ['getConnection', 'getMainTable', 'getIdFieldName'], [], '', false ); $dbAdapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'fetchOne'], [], '', false ); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['from', 'order', 'where', 'limit'], [], '', diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Source/Import/BehaviorAbstractTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Source/Import/BehaviorAbstractTest.php index bc24cee604d14..c39749e72b250 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Source/Import/BehaviorAbstractTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Source/Import/BehaviorAbstractTest.php @@ -33,7 +33,7 @@ protected function setUp() parent::setUp(); $model = $this->getMockForAbstractClass( - 'Magento\ImportExport\Model\Source\Import\AbstractBehavior', + \Magento\ImportExport\Model\Source\Import\AbstractBehavior::class, [[]], '', false, diff --git a/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php b/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php index 528f22b74f358..5117a11142cca 100644 --- a/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php +++ b/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php @@ -45,7 +45,7 @@ public function __construct(ObjectManagerFactory $objectManagerFactory) */ protected function getAllIndexers() { - $collectionFactory = $this->getObjectManager()->create('Magento\Indexer\Model\Indexer\CollectionFactory'); + $collectionFactory = $this->getObjectManager()->create(\Magento\Indexer\Model\Indexer\CollectionFactory::class); return $collectionFactory->create()->getItems(); } @@ -60,9 +60,9 @@ protected function getObjectManager() $area = FrontNameResolver::AREA_CODE; $this->objectManager = $this->objectManagerFactory->create($_SERVER); /** @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($area); - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load($area)); } return $this->objectManager; diff --git a/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php b/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php index 357d9ec8c2f5c..9933a3990d1ab 100644 --- a/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php +++ b/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php @@ -38,7 +38,7 @@ protected function getIndexers(InputInterface $input) if (empty($requestedTypes)) { return $this->getAllIndexers(); } else { - $indexerFactory = $this->getObjectManager()->create('Magento\Indexer\Model\IndexerFactory'); + $indexerFactory = $this->getObjectManager()->create(\Magento\Indexer\Model\IndexerFactory::class); $indexers = []; $unsupportedTypes = []; foreach ($requestedTypes as $code) { diff --git a/app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php b/app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php index 6dc61d9110a5f..c5ee45e34831f 100644 --- a/app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php +++ b/app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php @@ -123,7 +123,7 @@ private function validateSharedIndex($sharedIndex) if (empty($indexerIds)) { return $this; } - $indexerFactory = $this->getObjectManager()->create('Magento\Indexer\Model\IndexerFactory'); + $indexerFactory = $this->getObjectManager()->create(\Magento\Indexer\Model\IndexerFactory::class); foreach ($indexerIds as $indexerId) { /** @var \Magento\Indexer\Model\Indexer $indexer */ $indexer = $indexerFactory->create(); diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php index 12c5be82420ce..f02937b9b913a 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php @@ -22,7 +22,9 @@ public function execute() try { foreach ($indexerIds as $indexerId) { /** @var \Magento\Framework\Indexer\IndexerInterface $model */ - $model = $this->_objectManager->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId); + $model = $this->_objectManager->get( + \Magento\Framework\Indexer\IndexerRegistry::class + )->get($indexerId); $model->setScheduled(true); } $this->messageManager->addSuccess( diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php index aba86fab9e65d..7b9f25b59f70e 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php @@ -22,7 +22,9 @@ public function execute() try { foreach ($indexerIds as $indexerId) { /** @var \Magento\Framework\Indexer\IndexerInterface $model */ - $model = $this->_objectManager->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId); + $model = $this->_objectManager->get( + \Magento\Framework\Indexer\IndexerRegistry::class + )->get($indexerId); $model->setScheduled(false); } $this->messageManager->addSuccess( diff --git a/app/code/Magento/Indexer/Model/Indexer/Collection.php b/app/code/Magento/Indexer/Model/Indexer/Collection.php index d8f5a49f244b5..9eb532b0b79c9 100644 --- a/app/code/Magento/Indexer/Model/Indexer/Collection.php +++ b/app/code/Magento/Indexer/Model/Indexer/Collection.php @@ -12,7 +12,7 @@ class Collection extends \Magento\Framework\Data\Collection * * @var string */ - protected $_itemObjectClass = 'Magento\Framework\Indexer\IndexerInterface'; + protected $_itemObjectClass = \Magento\Framework\Indexer\IndexerInterface::class; /** * @var \Magento\Framework\Indexer\ConfigInterface diff --git a/app/code/Magento/Indexer/Model/ResourceModel/Indexer/State/Collection.php b/app/code/Magento/Indexer/Model/ResourceModel/Indexer/State/Collection.php index d8a5c5ed64090..9d393c4d66478 100644 --- a/app/code/Magento/Indexer/Model/ResourceModel/Indexer/State/Collection.php +++ b/app/code/Magento/Indexer/Model/ResourceModel/Indexer/State/Collection.php @@ -14,6 +14,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Indexer\Model\Indexer\State', 'Magento\Indexer\Model\ResourceModel\Indexer\State'); + $this->_init( + \Magento\Indexer\Model\Indexer\State::class, + \Magento\Indexer\Model\ResourceModel\Indexer\State::class + ); } } diff --git a/app/code/Magento/Indexer/Model/ResourceModel/Mview/View/State/Collection.php b/app/code/Magento/Indexer/Model/ResourceModel/Mview/View/State/Collection.php index de5dc3acaff20..f61d88afef797 100644 --- a/app/code/Magento/Indexer/Model/ResourceModel/Mview/View/State/Collection.php +++ b/app/code/Magento/Indexer/Model/ResourceModel/Mview/View/State/Collection.php @@ -15,6 +15,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Indexer\Model\Mview\View\State', 'Magento\Indexer\Model\ResourceModel\Mview\View\State'); + $this->_init( + \Magento\Indexer\Model\Mview\View\State::class, + \Magento\Indexer\Model\ResourceModel\Mview\View\State::class + ); } } diff --git a/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php index 4f25768ac288e..8d19abfaa6932 100644 --- a/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php @@ -29,17 +29,22 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', ['getDirectoryWrite'], [], '', false); - $this->processor = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, ['getDirectoryWrite'], [], '', false); + $this->processor = $this->getMock(\Magento\Indexer\Model\Processor::class, [], [], '', false); $this->_response = $this->getMock( - 'Magento\Framework\App\Console\Response', + \Magento\Framework\App\Console\Response::class, ['setCode', 'getCode'], [], '', false ); - $this->entryPoint = new \Magento\Indexer\App\Indexer('reportDir', $this->filesystem, $this->processor, $this->_response); + $this->entryPoint = new \Magento\Indexer\App\Indexer( + 'reportDir', + $this->filesystem, + $this->processor, + $this->_response + ); } /** @@ -51,7 +56,7 @@ public function testExecute($isExist, $callCount) { $this->_response->expects($this->once())->method('setCode')->with(0); $this->_response->expects($this->once())->method('getCode')->will($this->returnValue(0)); - $dir = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $dir = $this->getMock(\Magento\Framework\Filesystem\Directory\Write::class, [], [], '', false); $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); $dir->expects($this->once())->method('isExist')->will($this->returnValue($isExist)); $dir->expects($this->exactly($callCount))->method('delete')->will($this->returnValue(true)); @@ -60,7 +65,8 @@ public function testExecute($isExist, $callCount) $this->assertEquals(0, $this->entryPoint->launch()->getCode()); } - public function executeProvider(){ + public function executeProvider() + { return [ 'set1' => ['isExist' => true, 'expectsValue' => 1], 'set1' => ['delete' => false, 'expectsValue' => 0] @@ -69,7 +75,7 @@ public function executeProvider(){ public function testCatchException() { - $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $bootstrap = $this->getMock(\Magento\Framework\App\Bootstrap::class, [], [], '', false); $this->assertFalse($this->entryPoint->catchException($bootstrap, new \Exception())); } } diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/ContainerTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/ContainerTest.php index 9640104ca8307..117e9a7700db0 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/ContainerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/ContainerTest.php @@ -10,11 +10,23 @@ class ContainerTest extends \PHPUnit_Framework_TestCase public function testPseudoConstruct() { $headerText = __('Indexer Management'); - $buttonList = $this->getMock('\Magento\Backend\Block\Widget\Button\ButtonList', ['remove', 'add'], [], '', false); + $buttonList = $this->getMock( + \Magento\Backend\Block\Widget\Button\ButtonList::class, + ['remove', 'add'], + [], + '', + false + ); $buttonList->expects($this->once())->method('add'); $buttonList->expects($this->once())->method('remove')->with('add'); - $urlBuilderMock = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false); - $contextMock = $this->getMock('\Magento\Backend\Block\Widget\Context', ['getUrlBuilder', 'getButtonList'], [], '', false); + $urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $contextMock = $this->getMock( + \Magento\Backend\Block\Widget\Context::class, + ['getUrlBuilder', 'getButtonList'], + [], + '', + false + ); $contextMock->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilderMock)); $contextMock->expects($this->once())->method('getButtonList')->will($this->returnValue($buttonList)); diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php index eaa1a35a65340..4c4da644adb3a 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php @@ -18,7 +18,7 @@ public function testRender($rowValue, $class, $text) $html = '' . $text . ''; $row = new \Magento\Framework\DataObject(); $column = new \Magento\Framework\DataObject(); - $context = $this->getMockBuilder('\Magento\Backend\Block\Context') + $context = $this->getMockBuilder(\Magento\Backend\Block\Context::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php index 1a5e54a91078a..4a73db6ae0408 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php @@ -14,7 +14,7 @@ class StatusTest extends \PHPUnit_Framework_TestCase */ public function testRender($indexValues, $expectedResult) { - $context = $this->getMockBuilder('\Magento\Backend\Block\Context') + $context = $this->getMockBuilder(\Magento\Backend\Block\Context::class) ->disableOriginalConstructor() ->getMock(); $model = new \Magento\Indexer\Block\Backend\Grid\Column\Renderer\Status($context); diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php index d487270033f20..9b28f7b7babcb 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php @@ -14,7 +14,7 @@ class UpdatedTest extends \PHPUnit_Framework_TestCase */ public function testRender($defaultValue, $assert) { - $context = $this->getMockBuilder('\Magento\Backend\Block\Context') + $context = $this->getMockBuilder(\Magento\Backend\Block\Context::class) ->disableOriginalConstructor() ->getMock(); $model = new \Magento\Indexer\Block\Backend\Grid\Column\Renderer\Updated($context); diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/ItemsUpdaterTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/ItemsUpdaterTest.php index ec20f7a809c7d..5740e464847d5 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/ItemsUpdaterTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/ItemsUpdaterTest.php @@ -15,14 +15,20 @@ public function testUpdate($argument) { $params = ['change_mode_onthefly' => 1, 'change_mode_changelog' => 2]; - $auth = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') + $auth = $this->getMockBuilder(\Magento\Framework\AuthorizationInterface::class) ->disableOriginalConstructor() ->getMock(); - $auth->expects($this->once())->method('isAllowed')->with('Magento_Indexer::changeMode')->will($this->returnValue($argument)); + $auth->expects($this->once()) + ->method('isAllowed') + ->with('Magento_Indexer::changeMode') + ->will($this->returnValue($argument)); $model = new \Magento\Indexer\Block\Backend\Grid\ItemsUpdater($auth); $params = $model->update($params); - $this->assertEquals($argument, (isset($params['change_mode_onthefly']) && isset($params['change_mode_changelog']))); + $this->assertEquals( + $argument, + (isset($params['change_mode_onthefly']) && isset($params['change_mode_changelog'])) + ); } /** diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/AbstractIndexerCommandCommonSetup.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/AbstractIndexerCommandCommonSetup.php index 90c0f5d0262a4..ceac09e516159 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/AbstractIndexerCommandCommonSetup.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/AbstractIndexerCommandCommonSetup.php @@ -42,22 +42,34 @@ class AbstractIndexerCommandCommonSetup extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerFactory = $this->getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false); - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerFactory = $this->getMock( + \Magento\Framework\App\ObjectManagerFactory::class, + [], + [], + '', + false + ); + $this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerFactory->expects($this->any())->method('create')->willReturn($this->objectManager); - $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->configLoaderMock = $this->getMock('Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false); + $this->stateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->configLoaderMock = $this->getMock( + \Magento\Framework\App\ObjectManager\ConfigLoader::class, + [], + [], + '', + false + ); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap($this->getObjectManagerReturnValueMap())); - $this->collectionFactory = $this->getMockBuilder('Magento\Indexer\Model\Indexer\CollectionFactory') + $this->collectionFactory = $this->getMockBuilder(\Magento\Indexer\Model\Indexer\CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->indexerFactory = $this->getMockBuilder('Magento\Indexer\Model\IndexerFactory') + $this->indexerFactory = $this->getMockBuilder(\Magento\Indexer\Model\IndexerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -66,8 +78,8 @@ protected function setUp() ->expects($this->any()) ->method('create') ->will($this->returnValueMap([ - ['Magento\Indexer\Model\Indexer\CollectionFactory', [], $this->collectionFactory], - ['Magento\Indexer\Model\IndexerFactory', [], $this->indexerFactory], + [\Magento\Indexer\Model\Indexer\CollectionFactory::class, [], $this->collectionFactory], + [\Magento\Indexer\Model\IndexerFactory::class, [], $this->indexerFactory], ])); } @@ -79,8 +91,8 @@ protected function setUp() protected function getObjectManagerReturnValueMap() { return [ - ['Magento\Framework\App\State', $this->stateMock], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $this->configLoaderMock] + [\Magento\Framework\App\State::class, $this->stateMock], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $this->configLoaderMock] ]; } diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerInfoCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerInfoCommandTest.php index 8bb5c5fe68077..9fb3cef353e6f 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerInfoCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerInfoCommandTest.php @@ -27,8 +27,8 @@ protected function setUp() public function testExecute() { $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getId')->willReturn('id_indexerOne'); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $collection->expects($this->once())->method('getItems')->willReturn([$indexerOne]); diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerReindexCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerReindexCommandTest.php index 40923b6418ce4..891f4897db49a 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerReindexCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerReindexCommandTest.php @@ -61,8 +61,8 @@ public function testExecuteAll() 'shared_index' => null ])); $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $collection->expects($this->once())->method('getItems')->willReturn([$indexerOne]); @@ -109,19 +109,19 @@ public function testExecuteWithIndex() )); $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('reindexAll'); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $indexerOne->expects($this->any())->method('getId')->willReturn('id_indexerOne'); $indexerOne->expects($this->any())->method('load')->with('id_indexerOne')->willReturn($indexerOne); - $indexerTwo = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerTwo = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerTwo->expects($this->once())->method('reindexAll'); $indexerTwo->expects($this->once())->method('getTitle')->willReturn('Title_indexerTwo'); $indexerTwo->expects($this->any())->method('getId')->willReturn('id_indexerTwo'); $indexerTwo->expects($this->any())->method('load')->with('id_indexerTwo')->willReturn($indexerTwo); - $indexer3 = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexer3 = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexer3->expects($this->never())->method('reindexAll'); $indexer3->expects($this->once())->method('getTitle')->willReturn('Title_indexer3'); $indexer3->expects($this->any())->method('getId')->willReturn('id_indexer3'); @@ -151,7 +151,7 @@ public function testExecuteWithIndex() public function testExecuteWithLocalizedException() { $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $localizedException = new LocalizedException(new Phrase('Some Exception Message')); $indexerOne->expects($this->once())->method('reindexAll')->will($this->throwException($localizedException)); $this->collectionFactory->expects($this->never())->method('create'); @@ -166,7 +166,7 @@ public function testExecuteWithLocalizedException() public function testExecuteWithException() { $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $exception = new \Exception(); $indexerOne->expects($this->once())->method('reindexAll')->will($this->throwException($exception)); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); @@ -186,8 +186,8 @@ public function testExecuteWithException() public function testExecuteWithExceptionInLoad() { $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getId')->willReturn('id_indexer1'); $collection->expects($this->once())->method('getItems')->willReturn([$indexerOne]); diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerResetStateCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerResetStateCommandTest.php index 5dac864ab277b..3854db16aad0c 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerResetStateCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerResetStateCommandTest.php @@ -27,8 +27,8 @@ protected function setUp() public function testExecute() { $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once()) ->method('getTitle') diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerSetModeCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerSetModeCommandTest.php index 46cfdd47cea87..b6517574f75db 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerSetModeCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerSetModeCommandTest.php @@ -58,8 +58,8 @@ public function testExecuteInvalidMode() public function testExecuteAll() { $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->at(0))->method('isScheduled')->willReturn(true); $indexerOne->expects($this->at(2))->method('isScheduled')->willReturn(false); @@ -92,7 +92,7 @@ public function testExecuteAll() public function testExecuteWithIndex($isScheduled, $previous, $current, $mode, $expectedValue) { $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $indexerOne->expects($this->once())->method('load')->with('id_indexerOne')->willReturn($indexerOne); $indexerOne->expects($this->once())->method('setScheduled')->with($isScheduled); @@ -153,7 +153,7 @@ public function executeWithIndexDataProvider() public function testExecuteWithLocalizedException() { $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $localizedException = new \Magento\Framework\Exception\LocalizedException(__('Some Exception Message')); $indexerOne->expects($this->once())->method('setScheduled')->will($this->throwException($localizedException)); $this->collectionFactory->expects($this->never())->method('create'); @@ -168,7 +168,7 @@ public function testExecuteWithLocalizedException() public function testExecuteWithException() { $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $exception = new \Exception(); $indexerOne->expects($this->once())->method('setScheduled')->will($this->throwException($exception)); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerShowModeCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerShowModeCommandTest.php index 1e06a3d753ede..5b1cac2ad2ba6 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerShowModeCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerShowModeCommandTest.php @@ -30,11 +30,11 @@ public function testGetOptions() public function testExecuteAll() { $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $indexerOne->expects($this->once())->method('isScheduled')->willReturn(true); - $indexerTwo = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerTwo = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerTwo->expects($this->once())->method('getTitle')->willReturn('Title_indexerTwo'); $indexerTwo->expects($this->once())->method('isScheduled')->willReturn(false); $collection->expects($this->once())->method('getItems')->willReturn([$indexerOne, $indexerTwo]); @@ -54,13 +54,13 @@ public function testExecuteAll() public function testExecuteWithIndex() { $this->configureAdminArea(); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $indexerOne->expects($this->once())->method('isScheduled')->willReturn(true); - $indexerTwo = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerTwo = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerTwo->expects($this->once())->method('getTitle')->willReturn('Title_indexerTwo'); $indexerTwo->expects($this->once())->method('isScheduled')->willReturn(false); - $indexerThree = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerThree = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerThree->expects($this->never())->method('getTitle')->willReturn('Title_indexer3'); $indexerThree->expects($this->never())->method('isScheduled')->willReturn(false); diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php index 13f627d43d4e6..6abbeae301a4c 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php @@ -20,26 +20,26 @@ class IndexerStatusCommandTest extends AbstractIndexerCommandCommonSetup public function testExecuteAll() { $this->configureAdminArea(); - $collection = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); - $indexerOne = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $collection = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); + $indexerOne = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerOne->expects($this->once())->method('getTitle')->willReturn('Title_indexerOne'); $indexerOne ->expects($this->once()) ->method('getStatus') ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_VALID); - $indexerTwo = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerTwo = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerTwo->expects($this->once())->method('getTitle')->willReturn('Title_indexerTwo'); $indexerTwo ->expects($this->once()) ->method('getStatus') ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); - $indexerThree = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerThree = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerThree->expects($this->once())->method('getTitle')->willReturn('Title_indexerThree'); $indexerThree ->expects($this->once()) ->method('getStatus') ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_WORKING); - $indexerFour = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerFour = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerFour->expects($this->once())->method('getTitle')->willReturn('Title_indexerFour'); $collection ->expects($this->once()) diff --git a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/ListActionTest.php b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/ListActionTest.php index 4a4eca5ced847..fd7cffb936a1e 100644 --- a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/ListActionTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/ListActionTest.php @@ -65,7 +65,7 @@ class ListActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getAuthorization', 'getSession', @@ -88,7 +88,7 @@ protected function setUp() ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', @@ -96,14 +96,14 @@ protected function setUp() ); $this->request = $this->getMockForAbstractClass( - '\Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, ['getParam', 'getRequest'], '', false ); $this->view = $this->getMock( - '\Magento\Framework\App\ViewInterface', + \Magento\Framework\App\ViewInterface::class, [ 'loadLayout', 'getPage', @@ -126,7 +126,7 @@ protected function setUp() ); $this->block = $this->getMock( - '\Magento\Framework\View\Element\AbstractBlock', + \Magento\Framework\View\Element\AbstractBlock::class, ['setActive', 'getMenuModel'], [], '', @@ -134,14 +134,14 @@ protected function setUp() ); $this->layout = $this->getMockForAbstractClass( - '\Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, ['getBlock'], '', false ); $this->menu = $this->getMock( - '\Magento\Backend\Model\Menu', + \Magento\Backend\Model\Menu::class, ['getParentItems'], [], '', @@ -149,7 +149,7 @@ protected function setUp() ); $this->items = $this->getMock( - '\Magento\Backend\Model\Menu\Item', + \Magento\Backend\Model\Menu\Item::class, ['getParentItems'], [], '', @@ -160,9 +160,9 @@ protected function setUp() $this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response); $this->contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->view)); - $this->page = $this->getMock('\Magento\Framework\View\Result\Page', ['getConfig'], [], '', false); - $this->config = $this->getMock('\Magento\Framework\View\Result\Page', ['getTitle'], [], '', false); - $this->title = $this->getMock('\Title', ['prepend'], [], '', false); + $this->page = $this->getMock(\Magento\Framework\View\Result\Page::class, ['getConfig'], [], '', false); + $this->config = $this->getMock(\Magento\Framework\View\Result\Page::class, ['getTitle'], [], '', false); + $this->title = $this->getMock('Title', ['prepend'], [], '', false); $this->block->expects($this->any())->method('setActive')->will($this->returnValue(1)); $this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout)); @@ -174,7 +174,6 @@ protected function setUp() } - public function testExecute() { $this->view->expects($this->any()) diff --git a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php index 35c16422f2b32..92791c0d9fffd 100644 --- a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php @@ -88,7 +88,7 @@ class MassChangelogTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getAuthorization', 'getSession', @@ -111,7 +111,7 @@ protected function setUp() ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', @@ -119,7 +119,7 @@ protected function setUp() ); $this->view = $this->getMock( - '\Magento\Framework\App\ViewInterface', + \Magento\Framework\App\ViewInterface::class, [ 'loadLayout', 'getPage', @@ -141,43 +141,43 @@ protected function setUp() false ); - $this->session = $this->getMock('\Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->session = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); $this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager); - $this->actionFlag = $this->getMock('\Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get'], [], '', false); $this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager); $this->objectManager = $this->getMock( - 'Magento\Framework\TestFramework\Unit\Helper\ObjectManager', + \Magento\Framework\TestFramework\Unit\Helper\ObjectManager::class, ['get'], [], '', false ); $this->request = $this->getMockForAbstractClass( - '\Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, ['getParam', 'getRequest'], '', false ); $this->response->expects($this->any())->method("setRedirect")->willReturn(1); - $this->page = $this->getMock('\Magento\Framework\View\Result\Page', [], [], '', false); - $this->config = $this->getMock('\Magento\Framework\View\Result\Page', [], [], '', false); - $this->title = $this->getMock('\Magento\Framework\View\Page\Title', [], [], '', false); + $this->page = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); + $this->title = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); $this->messageManager = $this->getMockForAbstractClass( - '\Magento\Framework\Message\ManagerInterface', + \Magento\Framework\Message\ManagerInterface::class, ['addError', 'addSuccess'], '', false ); $this->indexReg = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get', 'setScheduled'], [], '', false ); - $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->helper = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); $this->contextMock->expects($this->any())->method("getObjectManager")->willReturn($this->objectManager); $this->contextMock->expects($this->any())->method("getRequest")->willReturn($this->request); $this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response); @@ -207,10 +207,10 @@ public function testExecute($indexerIds, $exception, $expectsExceptionValues) } else { $this->objectManager->expects($this->any()) - ->method('get')->with('Magento\Framework\Indexer\IndexerRegistry') + ->method('get')->with(\Magento\Framework\Indexer\IndexerRegistry::class) ->will($this->returnValue($this->indexReg)); $indexerInterface = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, ['setScheduled'], '', false diff --git a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php index 6e18be95d5edf..2daa202b1bbe3 100644 --- a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php @@ -88,7 +88,7 @@ class MassOnTheFlyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getAuthorization', 'getSession', @@ -111,7 +111,7 @@ protected function setUp() ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', @@ -119,7 +119,7 @@ protected function setUp() ); $this->view = $this->getMock( - '\Magento\Framework\App\ViewInterface', + \Magento\Framework\App\ViewInterface::class, [ 'loadLayout', 'getPage', @@ -141,43 +141,43 @@ protected function setUp() false ); - $this->session = $this->getMock('\Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->session = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); $this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager); - $this->actionFlag = $this->getMock('\Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get'], [], '', false); $this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager); $this->objectManager = $this->getMock( - 'Magento\Framework\TestFramework\Unit\Helper\ObjectManager', + \Magento\Framework\TestFramework\Unit\Helper\ObjectManager::class, ['get'], [], '', false ); $this->request = $this->getMockForAbstractClass( - '\Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, ['getParam', 'getRequest'], '', false ); $this->response->expects($this->any())->method("setRedirect")->willReturn(1); - $this->page = $this->getMock('\Magento\Framework\View\Result\Page', [], [], '', false); - $this->config = $this->getMock('\Magento\Framework\View\Result\Page', [], [], '', false); - $this->title = $this->getMock('\Magento\Framework\View\Page\Title', [], [], '', false); + $this->page = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); + $this->title = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); $this->messageManager = $this->getMockForAbstractClass( - '\Magento\Framework\Message\ManagerInterface', + \Magento\Framework\Message\ManagerInterface::class, ['addError', 'addSuccess'], '', false ); $this->indexReg = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get', 'setScheduled'], [], '', false ); - $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->helper = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); $this->contextMock->expects($this->any())->method("getObjectManager")->willReturn($this->objectManager); $this->contextMock->expects($this->any())->method("getRequest")->willReturn($this->request); $this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response); @@ -207,10 +207,10 @@ public function testExecute($indexerIds, $exception, $expectsExceptionValues) } else { $this->objectManager->expects($this->any()) - ->method('get')->with('Magento\Framework\Indexer\IndexerRegistry') + ->method('get')->with(\Magento\Framework\Indexer\IndexerRegistry::class) ->will($this->returnValue($this->indexReg)); $indexerInterface = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, ['setScheduled'], '', false diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php index c8ec3420a25b3..5e0f7c314cf31 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php @@ -39,9 +39,9 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->reader = $this->getMock('Magento\Framework\Indexer\Config\Reader', ['read'], [], '', false); + $this->reader = $this->getMock(\Magento\Framework\Indexer\Config\Reader::class, ['read'], [], '', false); $this->cache = $this->getMockForAbstractClass( - 'Magento\Framework\Config\CacheInterface', + \Magento\Framework\Config\CacheInterface::class, [], '', false, @@ -50,7 +50,7 @@ protected function setUp() ['test', 'load', 'save'] ); $this->stateCollection = $this->getMock( - 'Magento\Indexer\Model\ResourceModel\Indexer\State\Collection', + \Magento\Indexer\Model\ResourceModel\Indexer\State\Collection::class, ['getItems'], [], '', @@ -89,7 +89,7 @@ public function testConstructorWithoutCache() $this->reader->expects($this->once())->method('read')->will($this->returnValue($this->indexers)); $stateExistent = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['getIndexerId', '__wakeup', 'delete'], [], '', @@ -99,7 +99,7 @@ public function testConstructorWithoutCache() $stateExistent->expects($this->never())->method('delete'); $stateNonexistent = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['getIndexerId', '__wakeup', 'delete'], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ConfigTest.php index a4586a792d883..cebfdb2bdba2a 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ConfigTest.php @@ -23,7 +23,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMock( - '\Magento\Indexer\Model\Config\Data', + \Magento\Indexer\Model\Config\Data::class, [], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php index 14e80d558aaed..feb2782d6bf00 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php @@ -22,7 +22,7 @@ class AbstractProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_indexerRegistryMock = $this->getMock( - '\Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['isScheduled', 'get', 'reindexRow', 'reindexList', 'reindexAll', 'invalidate'], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php index b037f3d83038b..031b2a2c93c52 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php @@ -13,25 +13,25 @@ public function testLoadData() $indexerIdSecond = 'second_indexer_id'; $entityFactory = $this->getMockBuilder( - 'Magento\Framework\Data\Collection\EntityFactoryInterface' + \Magento\Framework\Data\Collection\EntityFactoryInterface::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); - $config = $this->getMockBuilder('Magento\Framework\Indexer\ConfigInterface')->getMock(); + $config = $this->getMockBuilder(\Magento\Framework\Indexer\ConfigInterface::class)->getMock(); $statesFactory = $this->getMockBuilder( - 'Magento\Indexer\Model\ResourceModel\Indexer\State\CollectionFactory' + \Magento\Indexer\Model\ResourceModel\Indexer\State\CollectionFactory::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); $states = $this->getMockBuilder( - 'Magento\Indexer\Model\ResourceModel\Indexer\State\Collection' + \Magento\Indexer\Model\ResourceModel\Indexer\State\Collection::class )->disableOriginalConstructor()->getMock(); $state = $this->getMockBuilder( - 'Magento\Indexer\Model\Indexer\State' + \Magento\Indexer\Model\Indexer\State::class )->setMethods( ['getIndexerId', '__wakeup'] )->disableOriginalConstructor()->getMock(); @@ -39,7 +39,7 @@ public function testLoadData() $state->expects($this->any())->method('getIndexerId')->will($this->returnValue('second_indexer_id')); $indexer = $this->getMockBuilder( - 'Magento\Indexer\Model\Indexer\Collection' + \Magento\Indexer\Model\Indexer\Collection::class )->setMethods( ['load', 'setState'] )->disableOriginalConstructor()->getMock(); @@ -53,7 +53,7 @@ public function testLoadData() )->method( 'create' )->with( - 'Magento\Framework\Indexer\IndexerInterface' + \Magento\Framework\Indexer\IndexerInterface::class )->will( $this->returnValue($indexer) ); @@ -71,6 +71,6 @@ public function testLoadData() $states->expects($this->any())->method('getItems')->will($this->returnValue([$state])); $collection = new \Magento\Indexer\Model\Indexer\Collection($entityFactory, $config, $statesFactory); - $this->assertInstanceOf('Magento\Indexer\Model\Indexer\Collection', $collection->loadData()); + $this->assertInstanceOf(\Magento\Indexer\Model\Indexer\Collection::class, $collection->loadData()); } } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php index 269473f6df2e8..48cd6f064ffc2 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php @@ -34,13 +34,25 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_contextMock = $this->getMock('\Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); - $eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); + $this->_contextMock = $this->getMock( + \Magento\Framework\Model\Context::class, + ['getEventDispatcher'], + [], + '', + false + ); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $this->_contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); - $this->_registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); - $this->_resourceMock = $this->getMock('\Magento\Indexer\Model\ResourceModel\Indexer\State', [], [], '', false); + $this->_registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->_resourceMock = $this->getMock( + \Magento\Indexer\Model\ResourceModel\Indexer\State::class, + [], + [], + '', + false + ); $this->_resourceCollectionMock = $this->getMock( - '\Magento\Indexer\Model\ResourceModel\Indexer\State\Collection', + \Magento\Indexer\Model\ResourceModel\Indexer\State\Collection::class, [], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php index 483f795e9b743..839a7cfe917c5 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php @@ -43,7 +43,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\ConfigInterface', + \Magento\Framework\Indexer\ConfigInterface::class, [], '', false, @@ -52,14 +52,14 @@ protected function setUp() ['getIndexer'] ); $this->actionFactoryMock = $this->getMock( - 'Magento\Framework\Indexer\ActionFactory', + \Magento\Framework\Indexer\ActionFactory::class, ['create'], [], '', false ); $this->viewMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ViewInterface', + \Magento\Framework\Mview\ViewInterface::class, [], '', false, @@ -68,20 +68,20 @@ protected function setUp() ['load', 'isEnabled', 'getUpdated', 'getStatus', '__wakeup', 'getId', 'suspend', 'resume'] ); $this->stateFactoryMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\StateFactory', + \Magento\Indexer\Model\Indexer\StateFactory::class, ['create'], [], '', false ); $this->indexFactoryMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\CollectionFactory', + \Magento\Indexer\Model\Indexer\CollectionFactory::class, ['create'], [], '', false ); - $structureFactory = $this->getMockBuilder('Magento\Framework\Indexer\StructureFactory') + $structureFactory = $this->getMockBuilder(\Magento\Framework\Indexer\StructureFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -129,7 +129,7 @@ public function testGetState() { $indexId = 'indexer_internal_name'; $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['loadByIndexer', 'getId', '__wakeup'], [], '', @@ -140,7 +140,7 @@ public function testGetState() $this->loadIndexer($indexId); - $this->assertInstanceOf('\Magento\Indexer\Model\Indexer\State', $this->model->getState()); + $this->assertInstanceOf(\Magento\Indexer\Model\Indexer\State::class, $this->model->getState()); } /** @@ -159,7 +159,7 @@ public function testGetLatestUpdated($getViewIsEnabled, $getViewGetUpdated, $get $this->viewMock->expects($this->any())->method('getUpdated')->will($this->returnValue($getViewGetUpdated)); $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'getId', 'setIndexerId', '__wakeup', 'getUpdated'], [], '', @@ -208,7 +208,7 @@ public function testReindexAll() $this->loadIndexer($indexId); $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'], [], '', @@ -227,7 +227,7 @@ public function testReindexAll() $this->viewMock->expects($this->once())->method('resume'); $actionMock = $this->getMock( - 'Magento\Framework\Indexer\ActionInterface', + \Magento\Framework\Indexer\ActionInterface::class, ['executeFull', 'executeList', 'executeRow'], [], '', @@ -256,7 +256,7 @@ public function testReindexAllWithException() $this->loadIndexer($indexId); $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'], [], '', @@ -275,7 +275,7 @@ public function testReindexAllWithException() $this->viewMock->expects($this->once())->method('resume'); $actionMock = $this->getMock( - 'Magento\Framework\Indexer\ActionInterface', + \Magento\Framework\Indexer\ActionInterface::class, ['executeFull', 'executeList', 'executeRow'], [], '', @@ -346,7 +346,7 @@ public function testGetDescription() public function testSetState() { $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['loadByIndexer', 'getId', '__wakeup'], [], '', @@ -354,7 +354,7 @@ public function testSetState() ); $this->model->setState($stateMock); - $this->assertInstanceOf('\Magento\Indexer\Model\Indexer\State', $this->model->getState()); + $this->assertInstanceOf(\Magento\Indexer\Model\Indexer\State::class, $this->model->getState()); } public function testIsScheduled() @@ -373,7 +373,7 @@ public function testIsScheduled() public function testSetScheduled($scheduled, $method) { $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'save'], [], '', @@ -402,7 +402,7 @@ public function testGetStatus() { $status = StateInterface::STATUS_WORKING; $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'getStatus'], [], '', @@ -422,7 +422,7 @@ public function testGetStatus() public function testStatus($method, $status) { $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'getStatus'], [], '', @@ -449,7 +449,7 @@ public function statusDataProvider() public function testInvalidate() { $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'setStatus', 'save'], [], '', @@ -469,14 +469,14 @@ public function testReindexRow() $id = 1; $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'save'], [], '', false ); $actionMock = $this->getMock( - 'Magento\Framework\Indexer\ActionInterface', + \Magento\Framework\Indexer\ActionInterface::class, ['executeFull', 'executeList', 'executeRow'], [], '', @@ -502,14 +502,14 @@ public function testReindexList() $ids = [1]; $stateMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['load', 'save'], [], '', false ); $actionMock = $this->getMock( - 'Magento\Framework\Indexer\ActionInterface', + \Magento\Framework\Indexer\ActionInterface::class, ['executeFull', 'executeList', 'executeRow'], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php index 872f832fec11a..8206db3524e50 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php @@ -23,7 +23,7 @@ class InvalidTest extends \PHPUnit_Framework_TestCase protected function setUp() { $collectionMock = $this->getMock( - '\Magento\Indexer\Model\Indexer\Collection', + \Magento\Indexer\Model\Indexer\Collection::class, ['getItems'], [], '', @@ -31,7 +31,7 @@ protected function setUp() ); $this->indexerMock = $this->getMock( - '\Magento\Indexer\Model\Indexer', + \Magento\Indexer\Model\Indexer::class, ['getStatus'], [], '', @@ -39,7 +39,7 @@ protected function setUp() ); $urlBuilder = $this->getMock( - '\Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, [], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php index b05af0310e6a7..e0475e8802b86 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php @@ -34,14 +34,20 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_contextMock = $this->getMock('\Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); - $eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); + $this->_contextMock = $this->getMock( + \Magento\Framework\Model\Context::class, + ['getEventDispatcher'], + [], + '', + false + ); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $this->_contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); - $this->_registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $this->_registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->_resourceMock = - $this->getMock('\Magento\Indexer\Model\ResourceModel\Mview\View\State', [], [], '', false); + $this->getMock(\Magento\Indexer\Model\ResourceModel\Mview\View\State::class, [], [], '', false); $this->_resourceCollectionMock = $this->getMock( - '\Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection', + \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection::class, [], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Processor/CleanCacheTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Processor/CleanCacheTest.php index 511eb798e5528..4d15fce48b573 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Processor/CleanCacheTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Processor/CleanCacheTest.php @@ -40,9 +40,9 @@ class CleanCacheTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->subjectMock = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false); - $this->contextMock = $this->getMock('Magento\Framework\Indexer\CacheContext', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Indexer\Model\Processor::class, [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\Indexer\CacheContext::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); $this->plugin = new \Magento\Indexer\Model\Processor\CleanCache( $this->contextMock, $this->eventManagerMock diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php index d992f41ce720d..0ebb710e64b89 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php @@ -37,7 +37,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\ConfigInterface', + \Magento\Framework\Indexer\ConfigInterface::class, [], '', false, @@ -46,21 +46,21 @@ protected function setUp() ['getIndexers'] ); $this->indexerFactoryMock = $this->getMock( - 'Magento\Indexer\Model\IndexerFactory', + \Magento\Indexer\Model\IndexerFactory::class, ['create'], [], '', false ); $this->indexersFactoryMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\CollectionFactory', + \Magento\Indexer\Model\Indexer\CollectionFactory::class, ['create'], [], '', false ); $this->viewProcessorMock = $this->getMockForAbstractClass( - 'Magento\Framework\Mview\ProcessorInterface', + \Magento\Framework\Mview\ProcessorInterface::class, [], '', false @@ -80,7 +80,7 @@ public function testReindexAllInvalid() $this->configMock->expects($this->once())->method('getIndexers')->will($this->returnValue($indexers)); $state1Mock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['getStatus', '__wakeup'], [], '', @@ -94,7 +94,7 @@ public function testReindexAllInvalid() $this->returnValue(StateInterface::STATUS_INVALID) ); $indexer1Mock = $this->getMock( - 'Magento\Indexer\Model\Indexer', + \Magento\Indexer\Model\Indexer::class, ['load', 'getState', 'reindexAll'], [], '', @@ -104,7 +104,7 @@ public function testReindexAllInvalid() $indexer1Mock->expects($this->once())->method('reindexAll'); $state2Mock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['getStatus', '__wakeup'], [], '', @@ -118,7 +118,7 @@ public function testReindexAllInvalid() $this->returnValue(StateInterface::STATUS_VALID) ); $indexer2Mock = $this->getMock( - 'Magento\Indexer\Model\Indexer', + \Magento\Indexer\Model\Indexer::class, ['load', 'getState', 'reindexAll'], [], '', @@ -135,11 +135,11 @@ public function testReindexAllInvalid() public function testReindexAll() { - $indexerMock = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerMock = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerMock->expects($this->exactly(2))->method('reindexAll'); $indexers = [$indexerMock, $indexerMock]; - $indexersMock = $this->getMock('Magento\Indexer\Model\Indexer\Collection', [], [], '', false); + $indexersMock = $this->getMock(\Magento\Indexer\Model\Indexer\Collection::class, [], [], '', false); $this->indexersFactoryMock->expects($this->once())->method('create')->will($this->returnValue($indexersMock)); $indexersMock->expects($this->once())->method('getItems')->will($this->returnValue($indexers)); diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php index 46402a069c1af..d45e724cf5666 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php @@ -22,15 +22,15 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase */ protected $_tableStrategyInterface; - protected function setUp() { - $this->_resourceMock = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') - ->disableOriginalConstructor() + $this->_resourceMock = $this->getMockBuilder( + \Magento\Framework\App\ResourceConnection::class + )->disableOriginalConstructor() ->getMock(); $this->_tableStrategyInterface = $this->getMock( - 'Magento\Framework\Indexer\Table\StrategyInterface', + \Magento\Framework\Indexer\Table\StrategyInterface::class, [], [], '', @@ -38,14 +38,14 @@ protected function setUp() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = $objectManager->getConstructArguments( - '\Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub', + \Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub::class, [ 'resource' => $this->_resourceMock, 'tableStrategy' => $this->_tableStrategyInterface ] ); $this->model = $objectManager->getObject( - '\Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub', + \Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub::class, $arguments ); } @@ -65,7 +65,7 @@ public function testReindexAll() public function testClearTemporaryIndexTable() { - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $connectionMock->expects($this->once())->method('delete')->will($this->returnSelf()); $this->model->clearTemporaryIndexTable(); @@ -77,8 +77,8 @@ public function testSyncData() $resultColumns = [0 => 'column']; $describeTable = ['column' => 'column']; - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $connectionMock->expects($this->any())->method('describeTable')->will($this->returnValue($describeTable)); $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); @@ -93,7 +93,7 @@ public function testSyncData() $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); $this->assertInstanceOf( - 'Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub', + \Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub::class, $this->model->syncData() ); } @@ -104,7 +104,7 @@ public function testSyncData() public function testSyncDataException() { $describeTable = ['column' => 'column']; - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $connectionMock->expects($this->any())->method('describeTable')->will($this->returnValue($describeTable)); $connectionMock->expects($this->any())->method('select')->will($this->throwException(new \Exception())); $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); @@ -124,8 +124,8 @@ public function testInsertFromTable($readToIndex) $resultColumns = [0 => 'column']; $tableColumns = ['column' => 'column']; - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); - $connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -135,13 +135,13 @@ public function testInsertFromTable($readToIndex) if ($readToIndex) { $connectionCustomMock = $this->getMock( - 'Magento\Framework\DB\Adapter\CustomAdapterInterface', + \Magento\Framework\DB\Adapter\CustomAdapterInterface::class, ['describeTable', 'query', 'select', 'insertArray'], [], '', false ); - $pdoMock = $this->getMock('Zend_Db_Statement_Pdo', [], [], '', false); + $pdoMock = $this->getMock(\Zend_Db_Statement_Pdo::class, [], [], '', false); $connectionCustomMock->expects($this->any())->method('query')->will($this->returnValue($selectMock)); $connectionCustomMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); $connectionCustomMock->expects($this->any())->method('describeTable')->will( @@ -171,7 +171,7 @@ public function testInsertFromTable($readToIndex) ); } $this->assertInstanceOf( - 'Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub', + \Magento\Indexer\Test\Unit\Model\ResourceModel\AbstractResourceStub::class, $this->model->insertFromTable($sourceTable, $destTable, $readToIndex) ); } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/State/CollectionTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/State/CollectionTest.php index 611e2f13d383d..5f756c1404551 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/State/CollectionTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/State/CollectionTest.php @@ -14,16 +14,16 @@ class CollectionTest extends \PHPUnit_Framework_TestCase public function testConstruct() { - $entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactoryInterface'); - $loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $fetchStrategyMock = $this->getMock('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $managerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); - $selectRendererMock = $this->getMock('Magento\Framework\DB\Select\SelectRenderer', [], [], '', false); - $resourceMock = $this->getMock('Magento\Framework\Flag\FlagResource', [], [], '', false); + $entityFactoryMock = $this->getMock(\Magento\Framework\Data\Collection\EntityFactoryInterface::class); + $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $fetchStrategyMock = $this->getMock(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class); + $managerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $selectRendererMock = $this->getMock(\Magento\Framework\DB\Select\SelectRenderer::class, [], [], '', false); + $resourceMock = $this->getMock(\Magento\Framework\Flag\FlagResource::class, [], [], '', false); $resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['getPart', 'setPart', 'from', 'columns'], [$connectionMock, $selectRendererMock] ); @@ -39,15 +39,15 @@ public function testConstruct() ); $this->assertInstanceOf( - 'Magento\Indexer\Model\ResourceModel\Indexer\State\Collection', + \Magento\Indexer\Model\ResourceModel\Indexer\State\Collection::class, $this->model ); $this->assertEquals( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, $this->model->getModelName() ); $this->assertEquals( - 'Magento\Indexer\Model\ResourceModel\Indexer\State', + \Magento\Indexer\Model\ResourceModel\Indexer\State::class, $this->model->getResourceModelName() ); } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/StateTest.php index bfb8fbceb5739..b2d2d6f0c887c 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/StateTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Indexer/StateTest.php @@ -15,7 +15,7 @@ class StateTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $resourceMock = $this->getMock( - '\Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -23,11 +23,11 @@ public function testConstruct() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = $objectManager->getConstructArguments( - '\Magento\Indexer\Model\ResourceModel\Indexer\State', + \Magento\Indexer\Model\ResourceModel\Indexer\State::class, ['resource' => $resourceMock] ); $this->model = $objectManager->getObject( - '\Magento\Indexer\Model\ResourceModel\Indexer\State', + \Magento\Indexer\Model\ResourceModel\Indexer\State::class, $arguments ); $this->assertEquals( diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/State/CollectionTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/State/CollectionTest.php index 1b27e39748f40..b442ee6d9457d 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/State/CollectionTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/State/CollectionTest.php @@ -14,16 +14,16 @@ class CollectionTest extends \PHPUnit_Framework_TestCase public function testConstruct() { - $entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactoryInterface'); - $loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $fetchStrategyMock = $this->getMock('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $managerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); - $selectRendererMock = $this->getMock('Magento\Framework\DB\Select\SelectRenderer', [], [], '', false); - $resourceMock = $this->getMock('Magento\Framework\Flag\FlagResource', [], [], '', false); + $entityFactoryMock = $this->getMock(\Magento\Framework\Data\Collection\EntityFactoryInterface::class); + $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $fetchStrategyMock = $this->getMock(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class); + $managerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $selectRendererMock = $this->getMock(\Magento\Framework\DB\Select\SelectRenderer::class, [], [], '', false); + $resourceMock = $this->getMock(\Magento\Framework\Flag\FlagResource::class, [], [], '', false); $resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['getPart', 'setPart', 'from', 'columns'], [$connectionMock, $selectRendererMock] ); @@ -39,15 +39,15 @@ public function testConstruct() ); $this->assertInstanceOf( - 'Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection', + \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection::class, $this->model ); $this->assertEquals( - 'Magento\Indexer\Model\Mview\View\State', + \Magento\Indexer\Model\Mview\View\State::class, $this->model->getModelName() ); $this->assertEquals( - 'Magento\Indexer\Model\ResourceModel\Mview\View\State', + \Magento\Indexer\Model\ResourceModel\Mview\View\State::class, $this->model->getResourceModelName() ); } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/StateTest.php index 72cece87b2687..d967d68df6d21 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/StateTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/Mview/View/StateTest.php @@ -15,7 +15,7 @@ class StateTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $resourceMock = $this->getMock( - '\Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -23,11 +23,11 @@ public function testConstruct() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = $objectManager->getConstructArguments( - '\Magento\Indexer\Model\ResourceModel\Mview\View\State', + \Magento\Indexer\Model\ResourceModel\Mview\View\State::class, ['resource' => $resourceMock] ); $this->model = $objectManager->getObject( - '\Magento\Indexer\Model\ResourceModel\Mview\View\State', + \Magento\Indexer\Model\ResourceModel\Mview\View\State::class, $arguments ); $this->assertEquals( diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit.php index 5778feae2ee89..306b57995774d 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit.php @@ -69,7 +69,7 @@ protected function _construct() [ 'id' => 'save-split-button', 'label' => __('Save'), - 'class_name' => 'Magento\Backend\Block\Widget\Button\SplitButton', + 'class_name' => \Magento\Backend\Block\Widget\Button\SplitButton::class, 'button_class' => '', 'data_attribute' => [ 'mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']], diff --git a/app/code/Magento/Integration/Model/Config/Consolidated/Reader.php b/app/code/Magento/Integration/Model/Config/Consolidated/Reader.php index 3d504932c97fd..40a678a9fe1ea 100644 --- a/app/code/Magento/Integration/Model/Config/Consolidated/Reader.php +++ b/app/code/Magento/Integration/Model/Config/Consolidated/Reader.php @@ -38,7 +38,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'integration.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Integration/Model/Config/Integration/Reader.php b/app/code/Magento/Integration/Model/Config/Integration/Reader.php index e96d0f816d56c..0c28d210117b1 100644 --- a/app/code/Magento/Integration/Model/Config/Integration/Reader.php +++ b/app/code/Magento/Integration/Model/Config/Integration/Reader.php @@ -40,7 +40,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'integration/api.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Integration/Model/Config/Reader.php b/app/code/Magento/Integration/Model/Config/Reader.php index 5e9a30bcbb2b8..c646f4a8f6444 100644 --- a/app/code/Magento/Integration/Model/Config/Reader.php +++ b/app/code/Magento/Integration/Model/Config/Reader.php @@ -36,7 +36,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'integration/config.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Integration/Model/Integration.php b/app/code/Magento/Integration/Model/Integration.php index 20bf9e83283d6..bf511f8a4247c 100644 --- a/app/code/Magento/Integration/Model/Integration.php +++ b/app/code/Magento/Integration/Model/Integration.php @@ -95,7 +95,7 @@ public function __construct( protected function _construct() { parent::_construct(); - $this->_init('Magento\Integration\Model\ResourceModel\Integration'); + $this->_init(\Magento\Integration\Model\ResourceModel\Integration::class); } /** diff --git a/app/code/Magento/Integration/Model/Oauth/Consumer.php b/app/code/Magento/Integration/Model/Oauth/Consumer.php index c0bf015705100..b8e6b1416e190 100644 --- a/app/code/Magento/Integration/Model/Oauth/Consumer.php +++ b/app/code/Magento/Integration/Model/Oauth/Consumer.php @@ -82,7 +82,7 @@ public function __construct( protected function _construct() { parent::_construct(); - $this->_init('Magento\Integration\Model\ResourceModel\Oauth\Consumer'); + $this->_init(\Magento\Integration\Model\ResourceModel\Oauth\Consumer::class); } /** diff --git a/app/code/Magento/Integration/Model/Oauth/Nonce.php b/app/code/Magento/Integration/Model/Oauth/Nonce.php index 7723430de2cf0..97b88c05ec768 100644 --- a/app/code/Magento/Integration/Model/Oauth/Nonce.php +++ b/app/code/Magento/Integration/Model/Oauth/Nonce.php @@ -53,7 +53,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Integration\Model\ResourceModel\Oauth\Nonce'); + $this->_init(\Magento\Integration\Model\ResourceModel\Oauth\Nonce::class); } /** diff --git a/app/code/Magento/Integration/Model/Oauth/Token.php b/app/code/Magento/Integration/Model/Oauth/Token.php index 424d77c4dae20..3651a100f16e4 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Oauth/Token.php @@ -122,7 +122,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Integration\Model\ResourceModel\Oauth\Token'); + $this->_init(\Magento\Integration\Model\ResourceModel\Oauth\Token::class); } /** diff --git a/app/code/Magento/Integration/Model/ResourceModel/Integration/Collection.php b/app/code/Magento/Integration/Model/ResourceModel/Integration/Collection.php index 31e36c4d57493..5bc9259b54dc8 100644 --- a/app/code/Magento/Integration/Model/ResourceModel/Integration/Collection.php +++ b/app/code/Magento/Integration/Model/ResourceModel/Integration/Collection.php @@ -17,7 +17,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Integration\Model\Integration', 'Magento\Integration\Model\ResourceModel\Integration'); + $this->_init( + \Magento\Integration\Model\Integration::class, + \Magento\Integration\Model\ResourceModel\Integration::class + ); } /** diff --git a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Consumer/Collection.php b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Consumer/Collection.php index a054a5da937b1..d169b7834187b 100644 --- a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Consumer/Collection.php +++ b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Consumer/Collection.php @@ -18,8 +18,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab protected function _construct() { $this->_init( - 'Magento\Integration\Model\Oauth\Consumer', - 'Magento\Integration\Model\ResourceModel\Oauth\Consumer' + \Magento\Integration\Model\Oauth\Consumer::class, + \Magento\Integration\Model\ResourceModel\Oauth\Consumer::class ); } } diff --git a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Nonce/Collection.php b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Nonce/Collection.php index 53c202d9da5ef..63768a6e8ed16 100644 --- a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Nonce/Collection.php +++ b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Nonce/Collection.php @@ -17,6 +17,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Integration\Model\Oauth\Nonce', 'Magento\Integration\Model\ResourceModel\Oauth\Nonce'); + $this->_init( + \Magento\Integration\Model\Oauth\Nonce::class, + \Magento\Integration\Model\ResourceModel\Oauth\Nonce::class + ); } } diff --git a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/Collection.php b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/Collection.php index de9eed4eb2859..a3839ed15c56e 100644 --- a/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/Collection.php +++ b/app/code/Magento/Integration/Model/ResourceModel/Oauth/Token/Collection.php @@ -17,7 +17,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Integration\Model\Oauth\Token', 'Magento\Integration\Model\ResourceModel\Oauth\Token'); + $this->_init( + \Magento\Integration\Model\Oauth\Token::class, + \Magento\Integration\Model\ResourceModel\Oauth\Token::class + ); } /** diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php index e2e86e6118b74..002aced31bdd0 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php @@ -26,7 +26,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->infoBlock = $this->objectManager->getObject( - 'Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info' + \Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info::class ); } diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php index f82544abfc66d..0c6d9b7fc7aca 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php @@ -51,23 +51,23 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->rootResource = $this->getMockBuilder('Magento\Framework\Acl\RootResource') + $this->rootResource = $this->getMockBuilder(\Magento\Framework\Acl\RootResource::class) ->disableOriginalConstructor() ->getMock(); - $this->aclResourceProvider = $this->getMockBuilder('Magento\Framework\Acl\AclResource\ProviderInterface') + $this->aclResourceProvider = $this->getMockBuilder(\Magento\Framework\Acl\AclResource\ProviderInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->integrationHelper = $this->getMockBuilder('Magento\Integration\Helper\Data') + $this->integrationHelper = $this->getMockBuilder(\Magento\Integration\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->integrationService = $this->getMockBuilder('Magento\Integration\Model\IntegrationService') + $this->integrationService = $this->getMockBuilder(\Magento\Integration\Model\IntegrationService::class) ->disableOriginalConstructor() ->getMock(); } @@ -233,7 +233,7 @@ private function getWebapiBlock($integrationData = [], array $selectedResources ->willReturnOnConsecutiveCalls(false, $integrationData, $integrationData); return $this->objectManager->getObject( - 'Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Webapi', + \Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Webapi::class, [ 'registry' => $this->registry, 'rootResource' => $this->rootResource, diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php index 62bb7d7382db7..ac405834a93b3 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php @@ -30,14 +30,14 @@ class ButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); - $this->contextMock = $this->getMock('Magento\Backend\Block\Context', ['getEscaper'], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\Block\Context::class, ['getEscaper'], [], '', false); $this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock)); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->buttonRenderer = $this->objectManagerHelper->getObject( - 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Button', + \Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Button::class, ['context' => $this->contextMock] ); } @@ -48,7 +48,7 @@ protected function setUp() public function testRender() { $expectedResult = ''; - $column = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + $column = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class) ->disableOriginalConstructor() ->setMethods(['getType', 'getId', 'getIndex']) ->getMock(); diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php index 8ea35788ef9e3..268d34d0ba276 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php @@ -35,12 +35,12 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); - $this->urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); $this->urlBuilderMock->expects($this->once())->method('getUrl')->willReturn('http://magento.loc/linkurl'); $this->contextMock = $this->getMock( - 'Magento\Backend\Block\Context', + \Magento\Backend\Block\Context::class, ['getEscaper', 'getUrlBuilder'], [], '', @@ -53,7 +53,7 @@ protected function setUp() $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->linkRenderer = $this->objectManagerHelper->getObject( - 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Link', + \Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Link::class, ['context' => $this->contextMock] ); } @@ -64,7 +64,7 @@ protected function setUp() public function testRender() { $expectedResult = 'Link Caption'; - $column = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + $column = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class) ->disableOriginalConstructor() ->setMethods(['getCaption', 'getId']) ->getMock(); diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php index 3fb03dd3f65dc..198480c6e15d3 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php @@ -35,12 +35,12 @@ class NameTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); - $this->urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); $this->urlBuilderMock->expects($this->any())->method('getUrl')->willReturn('http://magento.loc/linkurl'); $this->contextMock = $this->getMock( - 'Magento\Backend\Block\Context', + \Magento\Backend\Block\Context::class, ['getEscaper', 'getUrlBuilder'], [], '', @@ -53,7 +53,7 @@ protected function setUp() $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->nameRenderer = $this->objectManagerHelper->getObject( - 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Name', + \Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Name::class, ['context' => $this->contextMock] ); } @@ -64,7 +64,7 @@ protected function setUp() */ public function testRender($endpoint, $name, $expectedResult) { - $column = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + $column = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class) ->disableOriginalConstructor() ->setMethods(['getIndex', 'getEditable', 'getGetter']) ->getMock(); @@ -79,7 +79,7 @@ public function testRender($endpoint, $name, $expectedResult) ->willReturn('getName'); $this->nameRenderer->setColumn($column); - $integrationMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationMock = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->setMethods(['getName', 'getEndpoint', 'getIdentityLinkUrl']) ->getMock(); diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/DeleteTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/DeleteTest.php index 8257dac52d4fb..5b9d96b70aff7 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/DeleteTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/DeleteTest.php @@ -25,7 +25,7 @@ protected function setUp() $this->integrationController = $this->_createIntegrationController('Delete'); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $resultRedirect->expects($this->any()) diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php index f3ebef5c5224b..22bb6e4ff2de2 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php @@ -126,71 +126,71 @@ protected function setUp() { /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManagerHelper */ $this->_objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); // Initialize mocks which are used in several test cases $this->_configMock = $this->getMockBuilder( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class )->disableOriginalConstructor()->getMock(); - $this->_eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->_eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); $this->_layoutFilterMock = $this->getMockBuilder( - 'Magento\Backend\Model\Layout\Filter\Acl' + \Magento\Backend\Model\Layout\Filter\Acl::class )->disableOriginalConstructor()->getMock(); - $this->_backendSessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->_backendSessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->setMethods(['__call', 'getIntegrationData']) ->disableOriginalConstructor() ->getMock(); - $this->_userMock = $this->getMockBuilder('Magento\User\Model\User') + $this->_userMock = $this->getMockBuilder(\Magento\User\Model\User::class) ->disableOriginalConstructor() ->setMethods(['getId', 'load', 'performIdentityCheck']) ->getMock(); $this->_translateModelMock = $this->getMockBuilder( - 'Magento\Framework\TranslateInterface' + \Magento\Framework\TranslateInterface::class )->disableOriginalConstructor()->getMock(); $this->_integrationSvcMock = $this->getMockBuilder( - 'Magento\Integration\Api\IntegrationServiceInterface' + \Magento\Integration\Api\IntegrationServiceInterface::class )->disableOriginalConstructor()->getMock(); $this->_oauthSvcMock = $this->getMockBuilder( - 'Magento\Integration\Api\OauthServiceInterface' + \Magento\Integration\Api\OauthServiceInterface::class )->disableOriginalConstructor()->getMock(); - $this->_authMock = $this->getMockBuilder('Magento\Backend\Model\Auth') + $this->_authMock = $this->getMockBuilder(\Magento\Backend\Model\Auth::class) ->disableOriginalConstructor() ->setMethods(['getUser', 'logout']) ->getMock(); $this->_requestMock = $this->getMockBuilder( - 'Magento\Framework\App\Request\Http' + \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->getMock(); $this->_responseMock = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' + \Magento\Framework\App\Response\Http::class )->disableOriginalConstructor()->getMock(); - $this->_registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->_registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); $this->_configScopeMock = $this->getMockBuilder( - 'Magento\Framework\Config\ScopeInterface' + \Magento\Framework\Config\ScopeInterface::class )->disableOriginalConstructor()->getMock(); $this->_integrationHelperMock = $this->getMockBuilder( - 'Magento\Integration\Helper\Data' + \Magento\Integration\Helper\Data::class )->disableOriginalConstructor()->getMock(); $this->_messageManager = $this->getMockBuilder( - 'Magento\Framework\Message\ManagerInterface' + \Magento\Framework\Message\ManagerInterface::class )->disableOriginalConstructor()->getMock(); $this->_escaper = $this->getMockBuilder( - 'Magento\Framework\Escaper' + \Magento\Framework\Escaper::class )->setMethods( ['escapeHtml'] )->disableOriginalConstructor()->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->viewConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->viewConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $this->securityCookieMock = $this->getMockBuilder(SecurityCookie::class) @@ -207,11 +207,11 @@ protected function setUp() protected function _createIntegrationController($actionName) { // Mock Layout passed into constructor - $this->_viewMock = $this->getMockBuilder('Magento\Framework\App\ViewInterface') + $this->_viewMock = $this->getMockBuilder(\Magento\Framework\App\ViewInterface::class) ->getMock(); - $this->_layoutMock = $this->getMock('Magento\Framework\View\LayoutInterface'); + $this->_layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class); $this->_layoutMergeMock = $this->getMockBuilder( - 'Magento\Framework\View\Model\Layout\Merge' + \Magento\Framework\View\Model\Layout\Merge::class )->disableOriginalConstructor()->getMock(); $this->_layoutMock->expects( $this->any() @@ -224,13 +224,13 @@ protected function _createIntegrationController($actionName) $this->_layoutMock->expects($this->any())->method('getNode')->will($this->returnValue($testElement)); // for _setActiveMenu $this->_viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->_layoutMock)); - $blockMock = $this->getMockBuilder('Magento\Backend\Block\Menu')->disableOriginalConstructor()->getMock(); + $blockMock = $this->getMockBuilder(\Magento\Backend\Block\Menu::class)->disableOriginalConstructor()->getMock(); $menuMock = $this->getMock( - 'Magento\Backend\Model\Menu', + \Magento\Backend\Model\Menu::class, [], - [$this->getMock('Psr\Log\LoggerInterface')] + [$this->getMock(\Psr\Log\LoggerInterface::class)] ); - $loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $loggerMock->expects($this->any())->method('critical')->will($this->returnSelf()); $menuMock->expects($this->any())->method('getParentItems')->will($this->returnValue([])); $blockMock->expects($this->any())->method('getMenuModel')->will($this->returnValue($menuMock)); @@ -247,12 +247,12 @@ protected function _createIntegrationController($actionName) ->willReturn($this->pageTitleMock); $this->_escaper->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0)); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -288,12 +288,12 @@ protected function _createIntegrationController($actionName) ]; $this->_backendActionCtxMock = $this->_objectManagerHelper->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, $contextParameters ); $integrationCollection = - $this->getMockBuilder('\Magento\Integration\Model\ResourceModel\Integration\Collection') + $this->getMockBuilder(\Magento\Integration\Model\ResourceModel\Integration\Collection::class) ->disableOriginalConstructor() ->setMethods(['addUnsecureUrlsFilter', 'getSize']) ->getMock(); @@ -336,11 +336,11 @@ protected function _createIntegrationController($actionName) protected function _verifyLoadAndRenderLayout() { $map = [ - ['Magento\Framework\App\Config\ScopeConfigInterface', $this->_configMock], - ['Magento\Backend\Model\Layout\Filter\Acl', $this->_layoutFilterMock], - ['Magento\Backend\Model\Session', $this->_backendSessionMock], - ['Magento\Framework\TranslateInterface', $this->_translateModelMock], - ['Magento\Framework\Config\ScopeInterface', $this->_configScopeMock], + [\Magento\Framework\App\Config\ScopeConfigInterface::class, $this->_configMock], + [\Magento\Backend\Model\Layout\Filter\Acl::class, $this->_layoutFilterMock], + [\Magento\Backend\Model\Session::class, $this->_backendSessionMock], + [\Magento\Framework\TranslateInterface::class, $this->_translateModelMock], + [\Magento\Framework\Config\ScopeInterface::class, $this->_configScopeMock], ]; $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap($map)); } @@ -372,7 +372,7 @@ protected function _getSampleIntegrationData() protected function _getIntegrationModelMock() { $integrationModelMock = $this->getMock( - 'Magento\Integration\Model\Integration', + \Magento\Integration\Model\Integration::class, ['save', '__wakeup'], [], '', diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php index 5c2757a05cc5f..08012a9d17830 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php @@ -6,6 +6,9 @@ namespace Magento\Integration\Test\Unit\Controller\Token; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AccessTest extends \PHPUnit_Framework_TestCase { /** @@ -56,7 +59,7 @@ class AccessTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [ 'getMethod', 'getModuleName', @@ -73,25 +76,22 @@ protected function setUp() '', false ); - $this->response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Console\Response::class, [], [], '', false); /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); /** @var \Magento\Framework\View\Layout\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $update = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + $update = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false); /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */ - $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $layout->expects($this->any())->method('getUpdate')->will($this->returnValue($update)); - /** @var \Magento\Framework\View\Page\Config */ - $pageConfig = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $pageConfig = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf()); - /** @var \Magento\Framework\View\Page|\PHPUnit_Framework_MockObject_MockObject */ $page = $this->getMock( - 'Magento\Framework\View\Page', + \Magento\Framework\View\Page::class, ['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout'], [], '', @@ -102,14 +102,14 @@ protected function setUp() $page->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ - $view = $this->getMock('Magento\Framework\App\ViewInterface', [], [], '', false); + $view = $this->getMock(\Magento\Framework\App\ViewInterface::class, [], [], '', false); $view->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); - /** @var Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */ - $resultFactory = $this->getMock('Magento\Framework\Controller\ResultFactory', [], [], '', false); + /** @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */ + $resultFactory = $this->getMock(\Magento\Framework\Controller\ResultFactory::class, [], [], '', false); $resultFactory->expects($this->any())->method('create')->will($this->returnValue($page)); - $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response)); $this->context->expects($this->any())->method('getObjectManager') @@ -119,22 +119,32 @@ protected function setUp() $this->context->expects($this->any())->method('getResultFactory') ->will($this->returnValue($resultFactory)); - $this->helperMock = $this->getMock('Magento\Framework\Oauth\Helper\Request', [], [], '', false); - $this->frameworkOauthSvcMock = $this->getMock('Magento\Framework\Oauth\OauthInterface', [], [], '', false); - $this->intOauthServiceMock = $this->getMock('Magento\Integration\Api\OauthServiceInterface', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Framework\Oauth\Helper\Request::class, [], [], '', false); + $this->frameworkOauthSvcMock = $this->getMock( + \Magento\Framework\Oauth\OauthInterface::class, + [], + [], + '', + false + ); + $this->intOauthServiceMock = $this->getMock( + \Magento\Integration\Api\OauthServiceInterface::class, + [], + [], + '', + false + ); $this->integrationServiceMock = $this->getMock( - 'Magento\Integration\Api\IntegrationServiceInterface', + \Magento\Integration\Api\IntegrationServiceInterface::class, [], [], '', false ); - /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManagerHelper */ $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->accessAction = $this->objectManagerHelper->getObject( - 'Magento\Integration\Controller\Token\Access', + \Magento\Integration\Controller\Token\Access::class, [ 'context' => $this->context, 'oauthService'=> $this->frameworkOauthSvcMock, @@ -161,14 +171,14 @@ public function testAccessAction() ->method('getAccessToken') ->willReturn(['response']); /** @var \Magento\Integration\Model\Oauth\Consumer|\PHPUnit_Framework_MockObject_MockObject */ - $consumerMock = $this->getMock('Magento\Integration\Model\Oauth\Consumer', [], [], '', false); + $consumerMock = $this->getMock(\Magento\Integration\Model\Oauth\Consumer::class, [], [], '', false); $consumerMock->expects($this->once()) ->method('getId'); $this->intOauthServiceMock->expects($this->once()) ->method('loadConsumerByKey') ->willReturn($consumerMock); /** @var \Magento\Integration\Model\Integration|\PHPUnit_Framework_MockObject_MockObject */ - $integrationMock = $this->getMock('Magento\Integration\Model\Integration', [], [], '', false); + $integrationMock = $this->getMock(\Magento\Integration\Model\Integration::class, [], [], '', false); $integrationMock->expects($this->once()) ->method('save') ->willReturnSelf(); diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php index fcdf0113b9f81..1071e156c1f62 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php @@ -6,6 +6,9 @@ namespace Magento\Integration\Test\Unit\Controller\Token; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RequestTest extends \PHPUnit_Framework_TestCase { /** @@ -46,7 +49,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->request = $this->getMock( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [ 'getMethod', 'getModuleName', @@ -63,25 +66,25 @@ protected function setUp() '', false ); - $this->response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Console\Response::class, [], [], '', false); /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); /** @var \Magento\Framework\View\Layout\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $update = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + $update = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class, [], [], '', false); /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */ - $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $layout->expects($this->any())->method('getUpdate')->will($this->returnValue($update)); /** @var \Magento\Framework\View\Page\Config */ - $pageConfig = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $pageConfig = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf()); /** @var \Magento\Framework\View\Page|\PHPUnit_Framework_MockObject_MockObject */ $page = $this->getMock( - 'Magento\Framework\View\Page', + \Magento\Framework\View\Page::class, ['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout'], [], '', @@ -92,14 +95,14 @@ protected function setUp() $page->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ - $view = $this->getMock('Magento\Framework\App\ViewInterface', [], [], '', false); + $view = $this->getMock(\Magento\Framework\App\ViewInterface::class, [], [], '', false); $view->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); /** @var Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */ - $resultFactory = $this->getMock('Magento\Framework\Controller\ResultFactory', [], [], '', false); + $resultFactory = $this->getMock(\Magento\Framework\Controller\ResultFactory::class, [], [], '', false); $resultFactory->expects($this->any())->method('create')->will($this->returnValue($page)); - $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response)); $this->context->expects($this->any())->method('getObjectManager') @@ -109,14 +112,20 @@ protected function setUp() $this->context->expects($this->any())->method('getResultFactory') ->will($this->returnValue($resultFactory)); - $this->helperMock = $this->getMock('Magento\Framework\Oauth\Helper\Request', [], [], '', false); - $this->frameworkOauthSvcMock = $this->getMock('Magento\Framework\Oauth\OauthInterface', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Framework\Oauth\Helper\Request::class, [], [], '', false); + $this->frameworkOauthSvcMock = $this->getMock( + \Magento\Framework\Oauth\OauthInterface::class, + [], + [], + '', + false + ); /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManagerHelper */ $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->requestAction = $this->objectManagerHelper->getObject( - 'Magento\Integration\Controller\Token\Request', + \Magento\Integration\Controller\Token\Request::class, [ 'context' => $this->context, 'oauthService'=> $this->frameworkOauthSvcMock, diff --git a/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php b/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php index 00bfc4b5c0d21..7032f04082cd5 100644 --- a/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php @@ -15,7 +15,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->dataHelper = $helper->getObject('Magento\Integration\Helper\Data'); + $this->dataHelper = $helper->getObject(\Magento\Integration\Helper\Data::class); } public function testMapResources() diff --git a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php index 89bb5d943b898..166ff95e3895c 100644 --- a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php @@ -44,12 +44,12 @@ class ConsumerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_consumerFactory = $this->getMockBuilder('Magento\Integration\Model\Oauth\ConsumerFactory') + $this->_consumerFactory = $this->getMockBuilder(\Magento\Integration\Model\Oauth\ConsumerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->_consumerMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Consumer' + \Magento\Integration\Model\Oauth\Consumer::class )->disableOriginalConstructor()->getMock(); $this->_consumerFactory->expects( $this->any() @@ -60,18 +60,18 @@ protected function setUp() ); $this->_tokenFactory = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\TokenFactory' + \Magento\Integration\Model\Oauth\TokenFactory::class )->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->_tokenMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Token' + \Magento\Integration\Model\Oauth\Token::class )->disableOriginalConstructor()->getMock(); $this->_tokenFactory->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); $this->_storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + \Magento\Store\Model\StoreManagerInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $this->_storeMock = $this->getMockBuilder( - 'Magento\Store\Model\Store' + \Magento\Store\Model\Store::class )->disableOriginalConstructor()->getMock(); $this->_storeManagerMock->expects( $this->any() @@ -82,22 +82,22 @@ protected function setUp() ); $this->_dataHelper = $this->getMockBuilder( - 'Magento\Integration\Helper\Oauth\Data' + \Magento\Integration\Helper\Oauth\Data::class )->disableOriginalConstructor()->getMock(); $oauthHelperMock = $this->getMockBuilder( - 'Magento\Framework\Oauth\Helper\Oauth' + \Magento\Framework\Oauth\Helper\Oauth::class )->disableOriginalConstructor()->getMock(); $tokenProviderMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Token\Provider' + \Magento\Integration\Model\Oauth\Token\Provider::class )->disableOriginalConstructor()->getMock(); $this->_httpClientMock = $this->getMockBuilder( - 'Magento\Framework\HTTP\ZendClient' + \Magento\Framework\HTTP\ZendClient::class )->disableOriginalConstructor()->getMock(); $this->_loggerMock = $this->getMockBuilder( - 'Psr\Log\LoggerInterface' + \Psr\Log\LoggerInterface::class )->getMock(); $this->_oauthService = new \Magento\Integration\Model\OauthService( @@ -158,12 +158,12 @@ public function testPostToConsumer() $this->returnSelf() ); - $dateHelperMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + $dateHelperMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); $dateHelperMock->expects($this->any())->method('gmtDate'); - $dateHelper = new \ReflectionProperty('Magento\Integration\Model\OauthService', '_dateHelper'); + $dateHelper = new \ReflectionProperty(\Magento\Integration\Model\OauthService::class, '_dateHelper'); $dateHelper->setAccessible(true); $dateHelper->setValue($this->_oauthService, $dateHelperMock); diff --git a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/DataTest.php b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/DataTest.php index 847297793fc77..c0f8283d6cfce 100644 --- a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/DataTest.php +++ b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/DataTest.php @@ -16,7 +16,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_scopeConfigMock = $this->getMockBuilder( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class )->disableOriginalConstructor()->getMock(); $this->_dataHelper = new \Magento\Integration\Helper\Oauth\Data($this->_scopeConfigMock); diff --git a/app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php index 834106129b2e9..7f838ae52abfc 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php @@ -38,28 +38,28 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_tokenFactoryMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\TokenFactory') + $this->_tokenFactoryMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\TokenFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->_tokenFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); - $this->_userModelMock = $this->getMockBuilder('Magento\User\Model\User') + $this->_userModelMock = $this->getMockBuilder(\Magento\User\Model\User::class) ->disableOriginalConstructor() ->getMock(); - $this->_tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $this->_tokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->disableOriginalConstructor() ->setMethods(['getToken', 'loadByAdminId', 'setRevoked', 'save', '__wakeup'])->getMock(); $this->_tokenModelCollectionMock = $this->getMockBuilder( - 'Magento\Integration\Model\ResourceModel\Oauth\Token\Collection' + \Magento\Integration\Model\ResourceModel\Oauth\Token\Collection::class )->disableOriginalConstructor()->setMethods( ['addFilterByAdminId', 'getSize', '__wakeup', '_beforeLoad', '_afterLoad', 'getIterator'] )->getMock(); $this->_tokenModelCollectionFactoryMock = $this->getMockBuilder( - 'Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory' + \Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory::class )->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->_tokenModelCollectionFactoryMock->expects($this->once()) @@ -67,7 +67,7 @@ protected function setUp() ->will($this->returnValue($this->_tokenModelCollectionMock)); $this->validatorHelperMock = $this->getMockBuilder( - 'Magento\Integration\Model\CredentialsValidator' + \Magento\Integration\Model\CredentialsValidator::class )->disableOriginalConstructor()->getMock(); $this->_tokenService = new \Magento\Integration\Model\AdminTokenService( diff --git a/app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php index 442df25b012b7..18d768d737ae8 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php @@ -11,6 +11,9 @@ use Magento\Framework\Acl\RootResource; use Magento\Integration\Model\AuthorizationService; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AuthorizationServiceTest extends \PHPUnit_Framework_TestCase { /** @@ -51,7 +54,7 @@ class AuthorizationServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->roleMock = $this->getMock( - 'Magento\Authorization\Model\Role', + \Magento\Authorization\Model\Role::class, ['load', 'delete', '__wakeup', 'getId', 'save'], [], '', @@ -63,7 +66,7 @@ protected function setUp() /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Authorization\Model\RoleFactory $roleFactoryMock */ $roleFactoryMock = $this->getMock( - 'Magento\Authorization\Model\RoleFactory', + \Magento\Authorization\Model\RoleFactory::class, ['create'], [], '', @@ -72,14 +75,14 @@ protected function setUp() $roleFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->roleMock)); $roleCollectionFactoryMock = $this->getMock( - 'Magento\Authorization\Model\ResourceModel\Role\CollectionFactory', + \Magento\Authorization\Model\ResourceModel\Role\CollectionFactory::class, ['create'], [], '', false ); $roleCollectionMock = $this->getMock( - 'Magento\Authorization\Model\ResourceModel\Role\Collection', + \Magento\Authorization\Model\ResourceModel\Role\Collection::class, ['setUserFilter', 'getFirstItem'], [], '', @@ -92,9 +95,9 @@ protected function setUp() ->method('create') ->will($this->returnValue($roleCollectionMock)); - $rulesFactoryMock = $this->getMock('Magento\Authorization\Model\RulesFactory', ['create'], [], '', false); + $rulesFactoryMock = $this->getMock(\Magento\Authorization\Model\RulesFactory::class, ['create'], [], '', false); $this->rulesMock = $this->getMock( - 'Magento\Authorization\Model\Rules', + \Magento\Authorization\Model\Rules::class, ['setRoleId', 'setResources', 'saveRel'], [], '', @@ -104,15 +107,27 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->rulesMock)); - $this->rootAclResourceMock = $this->getMock('Magento\Framework\Acl\RootResource', ['getId'], [], '', false); + $this->rootAclResourceMock = $this->getMock( + \Magento\Framework\Acl\RootResource::class, + ['getId'], + [], + '', + false + ); $this->integrationAuthorizationService = new AuthorizationService( - $this->getMock('Magento\Framework\Acl\Builder', [], [], '', false), + $this->getMock(\Magento\Framework\Acl\Builder::class, [], [], '', false), $roleFactoryMock, $roleCollectionFactoryMock, $rulesFactoryMock, - $this->getMock('Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory', [], [], '', false), - $this->getMock('Psr\Log\LoggerInterface'), + $this->getMock( + \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory::class, + [], + [], + '', + false + ), + $this->getMock(\Psr\Log\LoggerInterface::class), $this->rootAclResourceMock ); } diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/ConverterTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/ConverterTest.php index caec32cd99b4a..b9c6c5b3dc4c9 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/ConverterTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/ConverterTest.php @@ -22,13 +22,13 @@ class ConverterTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->resourceProviderMock = $this->getMockBuilder('Magento\Framework\Acl\AclResource\ProviderInterface') + $this->resourceProviderMock = $this->getMockBuilder(\Magento\Framework\Acl\AclResource\ProviderInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Integration\Model\Config\Consolidated\Converter', + \Magento\Integration\Model\Config\Consolidated\Converter::class, [ 'resourceProvider' => $this->resourceProviderMock ] diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/SchemaLocatorTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/SchemaLocatorTest.php index 3b2050ae8ed4f..64c901bfb13c6 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/SchemaLocatorTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/SchemaLocatorTest.php @@ -21,7 +21,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->moduleDir = 'moduleDirectory'; - $this->moduleReader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->moduleReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->moduleReader->expects($this->any()) ->method('getModuleDir') ->willReturn($this->moduleDir); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/XsdTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/XsdTest.php index a7c99134adf25..3df9ed5b92d14 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/XsdTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/Consolidated/XsdTest.php @@ -33,7 +33,13 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $messageFormat = '%message%'; diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/SchemaLocatorTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/SchemaLocatorTest.php index 29bd8ac4b36d7..ab3902508e711 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/SchemaLocatorTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/SchemaLocatorTest.php @@ -21,7 +21,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->moduleDir = 'moduleDirectory'; - $this->moduleReader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->moduleReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->moduleReader->expects($this->any()) ->method('getModuleDir') ->willReturn($this->moduleDir); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php index eab20b40edda3..f50c7ab65715f 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php @@ -33,7 +33,13 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $messageFormat = '%message%'; diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php index 04e39a39420fe..ff09308ea93c7 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php @@ -21,7 +21,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->moduleDir = 'moduleDirectory'; - $this->moduleReader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->moduleReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->moduleReader->expects($this->any()) ->method('getModuleDir') ->willReturn($this->moduleDir); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php index 81b04649d1c36..6966b72a9bdcc 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php @@ -33,7 +33,13 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $messageFormat = '%message%'; diff --git a/app/code/Magento/Integration/Test/Unit/Model/ConsolidatedConfigTest.php b/app/code/Magento/Integration/Test/Unit/Model/ConsolidatedConfigTest.php index 6f69f0200412f..0b75592782773 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ConsolidatedConfigTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ConsolidatedConfigTest.php @@ -32,15 +32,15 @@ class ConsolidatedConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configCacheTypeMock = $this->getMockBuilder('Magento\Integration\Model\Cache\TypeConsolidated') + $this->configCacheTypeMock = $this->getMockBuilder(\Magento\Integration\Model\Cache\TypeConsolidated::class) ->disableOriginalConstructor() ->getMock(); - $this->configReaderMock = $this->getMockBuilder('Magento\Integration\Model\Config\Consolidated\Reader') + $this->configReaderMock = $this->getMockBuilder(\Magento\Integration\Model\Config\Consolidated\Reader::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->configModel = $objectManagerHelper->getObject( - 'Magento\Integration\Model\ConsolidatedConfig', + \Magento\Integration\Model\ConsolidatedConfig::class, [ 'configCacheType' => $this->configCacheTypeMock, 'configReader' => $this->configReaderMock diff --git a/app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php index d43dfc10119ff..59d4c75a4924b 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php @@ -36,29 +36,29 @@ class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_tokenFactoryMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\TokenFactory') + $this->_tokenFactoryMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\TokenFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->_tokenFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); $this->_accountManagementMock = $this - ->getMockBuilder('Magento\Customer\Api\AccountManagementInterface') + ->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->_tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $this->_tokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->disableOriginalConstructor() ->setMethods(['getToken', 'loadByCustomerId', 'setRevoked', 'save', '__wakeup'])->getMock(); $this->_tokenModelCollectionMock = $this->getMockBuilder( - 'Magento\Integration\Model\ResourceModel\Oauth\Token\Collection' + \Magento\Integration\Model\ResourceModel\Oauth\Token\Collection::class )->disableOriginalConstructor()->setMethods( ['addFilterByCustomerId', 'getSize', '__wakeup', '_beforeLoad', '_afterLoad', 'getIterator'] )->getMock(); $this->_tokenModelCollectionFactoryMock = $this->getMockBuilder( - 'Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory' + \Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory::class )->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->_tokenModelCollectionFactoryMock->expects($this->once()) @@ -66,7 +66,7 @@ protected function setUp() ->will($this->returnValue($this->_tokenModelCollectionMock)); $this->validatorHelperMock = $this->getMockBuilder( - 'Magento\Integration\Model\CredentialsValidator' + \Magento\Integration\Model\CredentialsValidator::class )->disableOriginalConstructor()->getMock(); $this->_tokenService = new \Magento\Integration\Model\CustomerTokenService( diff --git a/app/code/Magento/Integration/Test/Unit/Model/IntegrationConfigTest.php b/app/code/Magento/Integration/Test/Unit/Model/IntegrationConfigTest.php index 6702e69ef46fe..aed4e02453dc4 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/IntegrationConfigTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/IntegrationConfigTest.php @@ -30,10 +30,10 @@ class IntegrationConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configCacheTypeMock = $this->getMockBuilder('Magento\Integration\Model\Cache\TypeIntegration') + $this->configCacheTypeMock = $this->getMockBuilder(\Magento\Integration\Model\Cache\TypeIntegration::class) ->disableOriginalConstructor() ->getMock(); - $this->configReaderMock = $this->getMockBuilder('Magento\Integration\Model\Config\Integration\Reader') + $this->configReaderMock = $this->getMockBuilder(\Magento\Integration\Model\Config\Integration\Reader::class) ->disableOriginalConstructor() ->getMock(); $this->integrationConfigModel = new IntegrationConfig( diff --git a/app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php index c8a58f5c03304..ad89a67350b6a 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php @@ -42,12 +42,12 @@ class IntegrationServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_integrationFactory = $this->getMockBuilder('Magento\Integration\Model\IntegrationFactory') + $this->_integrationFactory = $this->getMockBuilder(\Magento\Integration\Model\IntegrationFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->_integrationMock = $this->getMockBuilder( - 'Magento\Integration\Model\Integration' + \Magento\Integration\Model\Integration::class )->disableOriginalConstructor()->setMethods( [ 'getData', @@ -78,10 +78,10 @@ protected function setUp() ); $oauthConsumerHelper = $this->getMockBuilder( - 'Magento\Integration\Api\OauthServiceInterface' + \Magento\Integration\Api\OauthServiceInterface::class )->disableOriginalConstructor()->getMock(); $oauthConsumer = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Consumer' + \Magento\Integration\Model\Oauth\Consumer::class )->disableOriginalConstructor()->getMock(); $oauthConsumerHelper->expects( $this->any() @@ -97,7 +97,7 @@ protected function setUp() $oauthConsumerHelper ); $this->_emptyIntegrationMock = $this->getMockBuilder( - 'Magento\Integration\Model\Integration' + \Magento\Integration\Model\Integration::class )->disableOriginalConstructor()->setMethods( [ 'getData', @@ -479,7 +479,7 @@ private function _getAnotherIntegrationMock( $integrationId = self::VALUE_INTEGRATION_ID ) { $integrationMock = $this->getMockBuilder( - 'Magento\Integration\Model\Integration' + \Magento\Integration\Model\Integration::class )->disableOriginalConstructor()->setMethods( [ 'getData', diff --git a/app/code/Magento/Integration/Test/Unit/Model/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Model/IntegrationTest.php index 07d6591261ce6..d4c62c73086a2 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/IntegrationTest.php @@ -38,14 +38,14 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false ); $eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -57,14 +57,14 @@ protected function setUp() ->method('getEventDispatcher') ->will($this->returnValue($eventManagerMock)); $this->registryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, [], [], '', false ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\AbstractResource', + \Magento\Framework\Model\ResourceModel\AbstractResource::class, [], '', false, @@ -73,7 +73,7 @@ protected function setUp() ['getIdFieldName', 'load', 'selectActiveIntegrationByConsumerId'] ); $this->resourceCollectionMock = $this->getMock( - 'Magento\Framework\Data\Collection\AbstractDb', + \Magento\Framework\Data\Collection\AbstractDb::class, [], [], '', diff --git a/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php b/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php index e429f87a81539..a457baa282224 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php @@ -39,7 +39,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->integrationServiceMock = $this->getMockBuilder( - '\Magento\Integration\Api\IntegrationServiceInterface' + \Magento\Integration\Api\IntegrationServiceInterface::class )->disableOriginalConstructor()->setMethods( [ 'findByName', @@ -53,19 +53,19 @@ protected function setUp() ] )->getMock(); - $this->aclRetriever = $this->getMockBuilder('Magento\Authorization\Model\Acl\AclRetriever') + $this->aclRetriever = $this->getMockBuilder(\Magento\Authorization\Model\Acl\AclRetriever::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\Integration\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\Integration\Model\Config::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->integrationManager = $objectManagerHelper->getObject( - 'Magento\Integration\Model\ConfigBasedIntegrationManager', + \Magento\Integration\Model\ConfigBasedIntegrationManager::class, [ 'integrationService' => $this->integrationServiceMock, 'aclRetriever' => $this->aclRetriever, @@ -104,12 +104,12 @@ public function testProcessIntegrationConfigSuccess() ] ) ); - $intLookupData1 = $this->getMockBuilder('Magento\Integration\Model\Integration') + $intLookupData1 = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $intLookupData1->expects($this->any())->method('getId')->willReturn(1); - $intLookupData2 = $this->getMockBuilder('Magento\Integration\Model\Integration') + $intLookupData2 = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -180,7 +180,7 @@ public function testProcessConfigBasedIntegrationsRecreateUpdatedConfigAfterReso 'Magento_Customer::customer' ]; - $integrationObject = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationObject = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -221,7 +221,7 @@ public function testProcessConfigBasedIntegrationsCreateNewIntegrations() ] ]; - $integrationObject = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationObject = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Oauth/ConsumerTest.php b/app/code/Magento/Integration/Test/Unit/Model/Oauth/ConsumerTest.php index 3d7275882c40f..8e67bb389a47d 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Oauth/ConsumerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Oauth/ConsumerTest.php @@ -10,6 +10,7 @@ /** * Test for \Magento\Integration\Model\Oauth\Consumer + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ConsumerTest extends \PHPUnit_Framework_TestCase { @@ -66,14 +67,14 @@ class ConsumerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false ); $eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -86,7 +87,7 @@ protected function setUp() ->will($this->returnValue($eventManagerMock)); $this->registryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, [], [], '', @@ -98,7 +99,7 @@ protected function setUp() $this->urlValidator = new UrlValidator(); $this->oauthDataMock = $this->getMock( - 'Magento\Integration\Helper\Oauth\Data', + \Magento\Integration\Helper\Oauth\Data::class, ['getConsumerExpirationPeriod'], [], '', @@ -109,7 +110,7 @@ protected function setUp() ->will($this->returnValue(\Magento\Integration\Helper\Oauth\Data::CONSUMER_EXPIRATION_PERIOD_DEFAULT)); $this->resourceMock = $this->getMock( - 'Magento\Integration\Model\ResourceModel\Oauth\Consumer', + \Magento\Integration\Model\ResourceModel\Oauth\Consumer::class, ['getIdFieldName', 'selectByCompositeKey', 'deleteOldEntries'], [], '', @@ -118,7 +119,7 @@ protected function setUp() true ); $this->resourceCollectionMock = $this->getMock( - 'Magento\Framework\Data\Collection\AbstractDb', + \Magento\Framework\Data\Collection\AbstractDb::class, [], [], '', @@ -215,13 +216,13 @@ public function testValidateInvalidConsumerSecret() public function testGetConsumerExpirationPeriodValid() { - $dateHelperMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + $dateHelperMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); $dateHelperMock->expects($this->at(0))->method('gmtTimestamp')->willReturn(time()); $dateHelperMock->expects($this->at(1))->method('gmtTimestamp')->willReturn(time() - 100); - $dateHelper = new \ReflectionProperty('Magento\Integration\Model\Oauth\Consumer', '_dateHelper'); + $dateHelper = new \ReflectionProperty(\Magento\Integration\Model\Oauth\Consumer::class, '_dateHelper'); $dateHelper->setAccessible(true); $dateHelper->setValue($this->consumerModel, $dateHelperMock); @@ -231,13 +232,13 @@ public function testGetConsumerExpirationPeriodValid() public function testGetConsumerExpirationPeriodExpired() { - $dateHelperMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + $dateHelperMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); $dateHelperMock->expects($this->at(0))->method('gmtTimestamp')->willReturn(time()); $dateHelperMock->expects($this->at(1))->method('gmtTimestamp')->willReturn(time() - 1000); - $dateHelper = new \ReflectionProperty('Magento\Integration\Model\Oauth\Consumer', '_dateHelper'); + $dateHelper = new \ReflectionProperty(\Magento\Integration\Model\Oauth\Consumer::class, '_dateHelper'); $dateHelper->setAccessible(true); $dateHelper->setValue($this->consumerModel, $dateHelperMock); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Oauth/NonceTest.php b/app/code/Magento/Integration/Test/Unit/Model/Oauth/NonceTest.php index f348c2f008445..9dc5590bf2723 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Oauth/NonceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Oauth/NonceTest.php @@ -44,14 +44,14 @@ class NonceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false ); $eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -63,21 +63,21 @@ protected function setUp() ->method('getEventDispatcher') ->will($this->returnValue($eventManagerMock)); $this->registryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, [], [], '', false ); $this->oauthDataMock = $this->getMock( - 'Magento\Integration\Helper\Oauth\Data', + \Magento\Integration\Helper\Oauth\Data::class, [], [], '', false ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\AbstractResource', + \Magento\Framework\Model\ResourceModel\AbstractResource::class, [], '', false, @@ -86,7 +86,7 @@ protected function setUp() ['getIdFieldName', 'selectByCompositeKey', 'deleteOldEntries'] ); $this->resourceCollectionMock = $this->getMock( - 'Magento\Framework\Data\Collection\AbstractDb', + \Magento\Framework\Data\Collection\AbstractDb::class, [], [], '', diff --git a/app/code/Magento/Integration/Test/Unit/Model/Oauth/Token/ProviderTest.php b/app/code/Magento/Integration/Test/Unit/Model/Oauth/Token/ProviderTest.php index 89c7700e38003..d247e8b67fa8a 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Oauth/Token/ProviderTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Oauth/Token/ProviderTest.php @@ -40,21 +40,21 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->consumerFactoryMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\ConsumerFactory') + $this->consumerFactoryMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\ConsumerFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->tokenFactoryMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\TokenFactory') + $this->tokenFactoryMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\TokenFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->consumerMock = $this->getMockBuilder('Magento\Framework\Oauth\ConsumerInterface') + $this->consumerMock = $this->getMockBuilder(\Magento\Framework\Oauth\ConsumerInterface::class) ->setMethods( [ 'load', @@ -71,7 +71,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->requestTokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $this->requestTokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->setMethods( [ 'loadByConsumerIdAndUserType', @@ -89,7 +89,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->accessTokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $this->accessTokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->setMethods( [ 'getToken', @@ -105,7 +105,7 @@ protected function setUp() ->getMock(); $this->tokenProvider = $objectManagerHelper->getObject( - 'Magento\Integration\Model\Oauth\Token\Provider', + \Magento\Integration\Model\Oauth\Token\Provider::class, [ 'consumerFactory' => $this->consumerFactoryMock, 'tokenFactory' => $this->tokenFactoryMock, @@ -172,7 +172,7 @@ public function testCreateRequestToken() $tokenString = '12345678901234567890123456789012'; $secret = 'secret'; - $tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $tokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->setMethods( [ 'loadByConsumerIdAndUserType', @@ -217,7 +217,7 @@ public function testCreateRequestTokenIncorrectType() $consumerId = 1; $tokenId = 1; - $tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $tokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->setMethods( [ 'loadByConsumerIdAndUserType', diff --git a/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php b/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php index 796bf2e2d9318..e25fca9329d69 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php @@ -14,6 +14,7 @@ /** * Unit test for \Magento\Integration\Model\Oauth\Nonce + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class TokenTest extends \PHPUnit_Framework_TestCase { @@ -69,48 +70,48 @@ class TokenTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->setMethods(['getEventDispatcher']) ->disableOriginalConstructor() ->getMock(); - $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); $this->validatorKeyLengthMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength' + \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength::class ) ->setMethods(['isValid', 'setLength', 'setName', 'getMessages']) ->disableOriginalConstructor() ->getMock(); $this->keyLengthFactoryMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory' + \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory::class ) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->validatorMock = $this->getMockBuilder('Magento\Framework\Url\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Url\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->consumerFactoryMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\ConsumerFactory') + $this->consumerFactoryMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\ConsumerFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->oauthDataMock = $this->getMockBuilder('Magento\Integration\Helper\Oauth\Data') + $this->oauthDataMock = $this->getMockBuilder(\Magento\Integration\Helper\Oauth\Data::class) ->setMethods(['isCleanupProbability', 'getCleanupExpirationPeriod']) ->disableOriginalConstructor() ->getMock(); - $this->oauthHelperMock = $this->getMockBuilder('Magento\Framework\Oauth\Helper\Oauth') + $this->oauthHelperMock = $this->getMockBuilder(\Magento\Framework\Oauth\Helper\Oauth::class) ->disableOriginalConstructor() ->getMock(); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->setMethods( [ 'getIdFieldName', @@ -132,7 +133,7 @@ protected function setUp() ->method('getIdFieldName') ->willReturn('id'); - $eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->setMethods(['dispatch']) ->disableOriginalConstructor() ->getMock(); @@ -383,7 +384,7 @@ public function testValidateIfNotCallbackEstablishedAndNotValid() $this->validatorMock->expects($this->once())->method('isValid')->willReturn(false); $this->validatorMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->setExpectedException('\Magento\Framework\Oauth\Exception', $exceptionMessage); + $this->setExpectedException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); $this->tokenModel->validate(); } @@ -401,7 +402,7 @@ public function testValidateIfSecretNotValid() $this->validatorKeyLengthMock->expects($this->once())->method('isValid')->willReturn(false); $this->validatorKeyLengthMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->setExpectedException('\Magento\Framework\Oauth\Exception', $exceptionMessage); + $this->setExpectedException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); $this->tokenModel->validate(); } @@ -428,7 +429,7 @@ public function testValidateIfTokenNotValid() ] ); $this->validatorKeyLengthMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->setExpectedException('\Magento\Framework\Oauth\Exception', $exceptionMessage); + $this->setExpectedException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); $this->tokenModel->validate(); } @@ -458,7 +459,7 @@ public function testValidateIfVerifierNotValid() ] ); $this->validatorKeyLengthMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->setExpectedException('\Magento\Framework\Oauth\Exception', $exceptionMessage); + $this->setExpectedException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); $this->tokenModel->validate(); } diff --git a/app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php index a3b9fbebc4b16..5699b21e35db6 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php @@ -10,6 +10,9 @@ use Magento\Integration\Model\Integration; use Magento\Integration\Model\Oauth\Token; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class OauthServiceTest extends \PHPUnit_Framework_TestCase { const VALUE_CONSUMER_ID = 1; @@ -51,21 +54,21 @@ class OauthServiceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_consumerFactory = $this->getMockBuilder('Magento\Integration\Model\Oauth\ConsumerFactory') + $this->_consumerFactory = $this->getMockBuilder(\Magento\Integration\Model\Oauth\ConsumerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->_tokenProviderMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Token\Provider' + \Magento\Integration\Model\Oauth\Token\Provider::class )->disableOriginalConstructor()->getMock(); $this->_tokenMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Token' + \Magento\Integration\Model\Oauth\Token::class )->disableOriginalConstructor()->setMethods( ['createVerifierToken', 'getType', '__wakeup', 'delete'] )->getMock(); $this->_tokenFactoryMock = $this->getMock( - 'Magento\Integration\Model\Oauth\TokenFactory', + \Magento\Integration\Model\Oauth\TokenFactory::class, ['create'], [], '', @@ -73,7 +76,7 @@ protected function setUp() ); $this->_tokenFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); $this->_consumerMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Consumer' + \Magento\Integration\Model\Oauth\Consumer::class )->disableOriginalConstructor()->setMethods( ['getData', 'getId', 'load', 'save', 'delete', '__wakeup'] )->getMock(); @@ -95,17 +98,17 @@ protected function setUp() ); $this->_service = new \Magento\Integration\Model\OauthService( - $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false), + $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false), $this->_consumerFactory, $this->_tokenFactoryMock, - $this->getMock('Magento\Integration\Helper\Oauth\Data', [], [], '', false), - $this->getMock('Magento\Framework\HTTP\ZendClient', [], [], '', false), - $this->getMock('Psr\Log\LoggerInterface'), - $this->getMock('Magento\Framework\Oauth\Helper\Oauth', [], [], '', false), + $this->getMock(\Magento\Integration\Helper\Oauth\Data::class, [], [], '', false), + $this->getMock(\Magento\Framework\HTTP\ZendClient::class, [], [], '', false), + $this->getMock(\Psr\Log\LoggerInterface::class), + $this->getMock(\Magento\Framework\Oauth\Helper\Oauth::class, [], [], '', false), $this->_tokenProviderMock ); $this->_emptyConsumerMock = $this->getMockBuilder( - 'Magento\Integration\Model\Integration' + \Magento\Integration\Model\Integration::class )->disableOriginalConstructor()->setMethods( ['getData', 'load', 'getId', 'save', 'delete', '__wakeup'] )->getMock(); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php index e5bc5d3ca74d2..cf48094c16efc 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php @@ -46,26 +46,26 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->subjectMock = $this->getMock('Magento\Integration\Model\IntegrationService', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Integration\Model\IntegrationService::class, [], [], '', false); $this->integrationAuthServiceMock = $this->getMock( - 'Magento\Integration\Api\AuthorizationServiceInterface', + \Magento\Integration\Api\AuthorizationServiceInterface::class, ['removePermissions', 'grantAllPermissions', 'grantPermissions'], [], '', false ); $this->aclRetrieverMock = $this->getMock( - 'Magento\Authorization\Model\Acl\AclRetriever', + \Magento\Authorization\Model\Acl\AclRetriever::class, ['getAllowedResourcesByUser'], [], '', false ); - $this->integrationConfigMock = $this->getMockBuilder('Magento\Integration\Model\IntegrationConfig') + $this->integrationConfigMock = $this->getMockBuilder(\Magento\Integration\Model\IntegrationConfig::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->consolidatedConfigMock = $this->getMockBuilder('Magento\Integration\Model\ConsolidatedConfig') + $this->consolidatedConfigMock = $this->getMockBuilder(\Magento\Integration\Model\ConsolidatedConfig::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -73,7 +73,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->integrationPlugin = $objectManagerHelper->getObject( - 'Magento\Integration\Model\Plugin\Integration', + \Magento\Integration\Model\Plugin\Integration::class, [ 'integrationAuthorizationService' => $this->integrationAuthServiceMock, 'aclRetriever' => $this->aclRetrieverMock, @@ -103,7 +103,7 @@ public function testAfterDelete() public function testAfterCreateAllResources() { $integrationId = 1; - $integrationModelMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationModelMock = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->getMock(); $integrationModelMock->expects($this->exactly(2)) @@ -124,7 +124,7 @@ public function testAfterCreateAllResources() public function testAfterCreateSomeResources() { $integrationId = 1; - $integrationModelMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationModelMock = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->getMock(); $integrationModelMock->expects($this->exactly(2)) @@ -153,7 +153,7 @@ public function testAfterCreateSomeResources() public function testAfterCreateNoResource() { $integrationId = 1; - $integrationModelMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationModelMock = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->getMock(); $integrationModelMock->expects($this->exactly(2)) @@ -178,7 +178,7 @@ public function testAfterCreateNoResource() public function testAfterUpdateAllResources() { $integrationId = 1; - $integrationModelMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationModelMock = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->getMock(); $integrationModelMock->expects($this->exactly(2)) @@ -199,7 +199,7 @@ public function testAfterUpdateAllResources() public function testAfterGet() { $integrationId = 1; - $integrationModelMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + $integrationModelMock = $this->getMockBuilder(\Magento\Integration\Model\Integration::class) ->disableOriginalConstructor() ->getMock(); $integrationModelMock->expects($this->exactly(2)) diff --git a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Integration/CollectionTest.php b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Integration/CollectionTest.php index ae731fe821ec0..0a8c6957093fe 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Integration/CollectionTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Integration/CollectionTest.php @@ -22,18 +22,18 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); $connection->expects($this->any()) ->method('select') ->will($this->returnValue($this->select)); - $resource = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['__wakeup', 'getConnection']) ->getMockForAbstractClass(); @@ -43,12 +43,13 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = $objectManagerHelper->getConstructArguments( - 'Magento\Integration\Model\ResourceModel\Integration\Collection', + \Magento\Integration\Model\ResourceModel\Integration\Collection::class, ['resource' => $resource] ); - $this->collection = $this->getMockBuilder('Magento\Integration\Model\ResourceModel\Integration\Collection') - ->setConstructorArgs($arguments) + $this->collection = $this->getMockBuilder( + \Magento\Integration\Model\ResourceModel\Integration\Collection::class + )->setConstructorArgs($arguments) ->setMethods(['addFilter', '_translateCondition', 'getMainTable']) ->getMock(); } diff --git a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/IntegrationTest.php index 2192fd4a21c9d..e61b234cbc44d 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/IntegrationTest.php @@ -37,17 +37,23 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $this->selectMock->expects($this->any())->method('from')->will($this->returnValue($this->selectMock)); $this->selectMock->expects($this->any())->method('where')->will($this->returnValue($this->selectMock)); - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock); - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); - $this->contextMock = $this->getMock('Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $this->contextMock = $this->getMock( + \Magento\Framework\Model\ResourceModel\Db\Context::class, + [], + [], + '', + false + ); $this->contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $this->integrationResourceModel = new \Magento\Integration\Model\ResourceModel\Integration($this->contextMock); diff --git a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/ConsumerTest.php b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/ConsumerTest.php index f83ae4b122863..ee50510dee946 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/ConsumerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/ConsumerTest.php @@ -33,19 +33,19 @@ class ConsumerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->consumerMock = $this->getMock( - 'Magento\Integration\Model\Oauth\Consumer', + \Magento\Integration\Model\Oauth\Consumer::class, ['setUpdatedAt', 'getId'], [], '', false ); - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); - $contextMock = $this->getMock('Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $this->consumerResource = new \Magento\Integration\Model\ResourceModel\Oauth\Consumer( $contextMock, @@ -57,14 +57,14 @@ public function testAfterDelete() { $this->connectionMock->expects($this->exactly(2))->method('delete'); $this->assertInstanceOf( - 'Magento\Integration\Model\ResourceModel\Oauth\Consumer', + \Magento\Integration\Model\ResourceModel\Oauth\Consumer::class, $this->consumerResource->_afterDelete($this->consumerMock) ); } public function testGetTimeInSecondsSinceCreation() { - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->any())->method('from')->will($this->returnValue($selectMock)); $selectMock->expects($this->any())->method('reset')->will($this->returnValue($selectMock)); $selectMock->expects($this->any())->method('columns')->will($this->returnValue($selectMock)); diff --git a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/NonceTest.php b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/NonceTest.php index 53c0c806bb226..d6d8946e6de01 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/NonceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/NonceTest.php @@ -27,12 +27,12 @@ class NonceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $this->nonceResource = new \Magento\Integration\Model\ResourceModel\Oauth\Nonce($contextMock); @@ -47,7 +47,7 @@ public function testDeleteOldEntries() public function testSelectByCompositeKey() { - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->once())->method('from')->will($this->returnValue($selectMock)); $selectMock->expects($this->exactly(2))->method('where')->will($this->returnValue($selectMock)); $this->connectionMock->expects($this->once())->method('select')->willReturn($selectMock); diff --git a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/Token/CollectionTest.php b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/Token/CollectionTest.php index c45de375e1d71..8d2127b7ffed8 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/Token/CollectionTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/Token/CollectionTest.php @@ -22,18 +22,18 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); $connection->expects($this->any()) ->method('select') ->will($this->returnValue($this->select)); - $resource = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['__wakeup', 'getConnection']) ->getMockForAbstractClass(); @@ -43,12 +43,13 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = $objectManagerHelper->getConstructArguments( - 'Magento\Integration\Model\ResourceModel\Oauth\Token\Collection', + \Magento\Integration\Model\ResourceModel\Oauth\Token\Collection::class, ['resource' => $resource] ); - $this->collection = $this->getMockBuilder('Magento\Integration\Model\ResourceModel\Oauth\Token\Collection') - ->setConstructorArgs($arguments) + $this->collection = $this->getMockBuilder( + \Magento\Integration\Model\ResourceModel\Oauth\Token\Collection::class + )->setConstructorArgs($arguments) ->setMethods(['addFilter', 'getSelect', 'getTable', '_initSelect']) ->getMock(); } diff --git a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/TokenTest.php b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/TokenTest.php index b3f37d08e83bf..f4a9821ca69d2 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/TokenTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/TokenTest.php @@ -28,16 +28,16 @@ class TokenTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $this->tokenResource = $objectManager->getObject( - 'Magento\Integration\Model\ResourceModel\Oauth\Token', + \Magento\Integration\Model\ResourceModel\Oauth\Token::class, ['context' => $contextMock] ); } @@ -45,7 +45,7 @@ protected function setUp() public function testCleanOldAuthorizedTokensExcept() { $tokenMock = $this->getMock( - 'Magento\Integration\Model\Oauth\Token', + \Magento\Integration\Model\Oauth\Token::class, ['getId', 'getAuthorized', 'getConsumerId', 'getCustomerId', 'getAdminId'], [], '', @@ -68,7 +68,7 @@ public function testDeleteOldEntries() public function testSelectTokenByType() { - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->once())->method('from')->will($this->returnValue($selectMock)); $selectMock->expects($this->exactly(2))->method('where')->will($this->returnValue($selectMock)); $this->connectionMock->expects($this->once())->method('select')->willReturn($selectMock); @@ -78,7 +78,7 @@ public function testSelectTokenByType() public function testSelectTokenByConsumerIdAndUserType() { - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->once())->method('from')->will($this->returnValue($selectMock)); $selectMock->expects($this->exactly(2))->method('where')->will($this->returnValue($selectMock)); $this->connectionMock->expects($this->once())->method('select')->willReturn($selectMock); @@ -88,7 +88,7 @@ public function testSelectTokenByConsumerIdAndUserType() public function testSelectTokenByAdminId() { - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->once())->method('from')->will($this->returnValue($selectMock)); $selectMock->expects($this->exactly(2))->method('where')->will($this->returnValue($selectMock)); $this->connectionMock->expects($this->once())->method('select')->willReturn($selectMock); @@ -98,7 +98,7 @@ public function testSelectTokenByAdminId() public function testSelectTokenByCustomerId() { - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->once())->method('from')->will($this->returnValue($selectMock)); $selectMock->expects($this->exactly(2))->method('where')->will($this->returnValue($selectMock)); $this->connectionMock->expects($this->once())->method('select')->willReturn($selectMock); diff --git a/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php b/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php index 5f8b988f2ff62..eaa90e321e1dc 100644 --- a/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php +++ b/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php @@ -57,11 +57,11 @@ class OauthTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_consumerFactory = $this->getMockBuilder('Magento\Integration\Model\Oauth\ConsumerFactory') + $this->_consumerFactory = $this->getMockBuilder(\Magento\Integration\Model\Oauth\ConsumerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->_consumerMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Consumer') + $this->_consumerMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Consumer::class) ->disableOriginalConstructor()->setMethods( [ 'getCreatedAt', @@ -80,14 +80,14 @@ protected function setUp() $this->_consumerFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->_consumerMock)); - $this->_nonceFactory = $this->getMockBuilder('Magento\Integration\Model\Oauth\NonceFactory') + $this->_nonceFactory = $this->getMockBuilder(\Magento\Integration\Model\Oauth\NonceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->_tokenFactory = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\TokenFactory' + \Magento\Integration\Model\Oauth\TokenFactory::class )->disableOriginalConstructor()->setMethods(['create'])->getMock(); - $this->_tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + $this->_tokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class) ->disableOriginalConstructor() ->setMethods( [ @@ -109,16 +109,16 @@ protected function setUp() ) ->getMock(); $this->_tokenFactory->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); - $this->_oauthHelperMock = $this->getMockBuilder('Magento\Framework\Oauth\Helper\Oauth') + $this->_oauthHelperMock = $this->getMockBuilder(\Magento\Framework\Oauth\Helper\Oauth::class) ->setConstructorArgs([new \Magento\Framework\Math\Random()]) ->getMock(); - $this->_httpUtilityMock = $this->getMockBuilder('Zend_Oauth_Http_Utility') + $this->_httpUtilityMock = $this->getMockBuilder(\Zend_Oauth_Http_Utility::class) ->setMethods(['sign']) ->getMock(); - $this->_dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + $this->_dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); - $this->_loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->_loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -305,7 +305,7 @@ public function dataProviderForGetRequestTokenNonceTimestampRefusedTest() protected function _setupNonce($isUsed = false, $timestamp = 0) { $nonceMock = $this->getMockBuilder( - 'Magento\Integration\Model\Oauth\Nonce' + \Magento\Integration\Model\Oauth\Nonce::class )->disableOriginalConstructor()->setMethods( [ 'loadByCompositeKey', @@ -780,7 +780,7 @@ public function testBuildAuthorizationHeader() public function testMissingParamForBuildAuthorizationHeader($expectedMessage, $request) { $this->setExpectedException( - '\Magento\Framework\Oauth\OauthInputException', + \Magento\Framework\Oauth\OauthInputException::class, $expectedMessage, 0 ); From d7ff74d07e49b81f172044e81a7348008ea75b08 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:27:55 +0300 Subject: [PATCH 15/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- app/code/Magento/Msrp/Setup/InstallData.php | 17 ++-- .../Msrp/Test/Unit/Helper/DataTest.php | 12 +-- .../Attribute/Source/Type/PriceTest.php | 4 +- .../Quote/SetCanApplyMsrpObserverTest.php | 49 ++++++---- .../Test/Unit/Pricing/Price/MsrpPriceTest.php | 15 +-- .../Test/Unit/Block/Html/Head/ConfigTest.php | 23 +++-- .../Test/Unit/Model/FileManagerTest.php | 22 ++--- .../Review/Block/Adminhtml/Add/Form.php | 6 +- .../Review/Block/Adminhtml/Edit/Form.php | 8 +- .../Magento/Review/Block/Adminhtml/Grid.php | 4 +- .../Review/Block/Adminhtml/Product/Grid.php | 2 +- .../Block/Adminhtml/Rating/Edit/Tab/Form.php | 2 +- .../Block/Adminhtml/Rating/Edit/Tabs.php | 2 +- .../Review/Block/Customer/ListCustomer.php | 2 +- .../Magento/Review/Block/Product/View.php | 2 +- .../Controller/Adminhtml/Product/Edit.php | 2 +- .../Controller/Adminhtml/Product/Index.php | 2 +- .../Adminhtml/Product/NewAction.php | 6 +- .../Controller/Adminhtml/Product/Pending.php | 2 +- .../Controller/Adminhtml/Product/Post.php | 2 +- .../Adminhtml/Product/ProductGrid.php | 2 +- .../Adminhtml/Product/RatingItems.php | 2 +- .../Adminhtml/Product/ReviewGrid.php | 2 +- .../Controller/Adminhtml/Product/Save.php | 2 +- .../Review/Controller/Adminhtml/Rating.php | 2 +- .../Controller/Adminhtml/Rating/Delete.php | 2 +- .../Controller/Adminhtml/Rating/Edit.php | 7 +- .../Controller/Adminhtml/Rating/Save.php | 8 +- .../Magento/Review/Controller/Product.php | 4 +- app/code/Magento/Review/Model/Rating.php | 2 +- .../Magento/Review/Model/Rating/Entity.php | 2 +- .../Magento/Review/Model/Rating/Option.php | 2 +- .../Review/Model/Rating/Option/Vote.php | 2 +- .../Model/ResourceModel/Rating/Collection.php | 2 +- .../Rating/Option/Collection.php | 5 +- .../Rating/Option/Vote/Collection.php | 4 +- .../Model/ResourceModel/Review/Collection.php | 2 +- .../Review/Product/Collection.php | 2 +- .../Review/Status/Collection.php | 5 +- .../Review/Summary/Collection.php | 5 +- app/code/Magento/Review/Model/Review.php | 2 +- .../Magento/Review/Model/Review/Status.php | 2 +- .../Test/Unit/Block/Adminhtml/MainTest.php | 10 +- .../Adminhtml/Rating/Edit/Tab/FormTest.php | 36 ++++--- .../Block/Adminhtml/Rss/Grid/LinkTest.php | 4 +- .../Test/Unit/Block/Adminhtml/RssTest.php | 18 ++-- .../Test/Unit/Block/Customer/RecentTest.php | 12 +-- .../Review/Test/Unit/Block/FormTest.php | 16 +-- .../Test/Unit/Block/Product/ReviewTest.php | 19 ++-- .../Controller/Adminhtml/Product/PostTest.php | 26 ++--- .../Test/Unit/Controller/Product/PostTest.php | 43 ++++---- .../Test/Unit/Helper/Action/PagerTest.php | 4 +- .../ResourceModel/Review/CollectionTest.php | 14 +-- .../Review/Product/CollectionTest.php | 29 ++++-- .../Review/Summary/CollectionTest.php | 29 +++--- .../Review/Test/Unit/Model/ReviewTest.php | 47 ++++++--- .../Review/Test/Unit/Model/RssTest.php | 10 +- .../Block/Adminhtml/Order/Comments/View.php | 2 +- .../Sales/Block/Adminhtml/Order/Create.php | 6 +- .../Block/Adminhtml/Order/Create/Customer.php | 2 +- .../Block/Adminhtml/Order/Create/Form.php | 2 +- .../Order/Create/Form/AbstractForm.php | 20 ++-- .../Adminhtml/Order/Create/Form/Account.php | 3 +- .../Adminhtml/Order/Create/Form/Address.php | 2 +- .../Adminhtml/Order/Create/Giftmessage.php | 2 +- .../Block/Adminhtml/Order/Create/Items.php | 2 +- .../Adminhtml/Order/Create/Items/Grid.php | 4 +- .../Block/Adminhtml/Order/Create/Search.php | 2 +- .../Adminhtml/Order/Create/Search/Grid.php | 6 +- .../Block/Adminhtml/Order/Create/Sidebar.php | 2 +- .../Adminhtml/Order/Create/Sidebar/Cart.php | 2 +- .../Block/Adminhtml/Order/Create/Totals.php | 2 +- .../Order/Creditmemo/Create/Items.php | 8 +- .../Adminhtml/Order/Invoice/Create/Items.php | 4 +- .../Adminhtml/Order/Status/NewStatus/Form.php | 4 +- .../Adminhtml/Order/View/Giftmessage.php | 2 +- .../Block/Adminhtml/Order/View/History.php | 2 +- .../Block/Adminhtml/Report/Filter/Form.php | 2 +- .../Adminhtml/Report/Filter/Form/Coupon.php | 2 +- .../Config/Form/Fieldset/Order/Statuses.php | 2 +- .../Magento/Sales/Block/Order/History.php | 2 +- .../Magento/Sales/Block/Widget/Guest/Form.php | 2 +- .../AbstractController/PrintCreditmemo.php | 4 +- .../AbstractController/PrintInvoice.php | 8 +- .../AbstractController/PrintShipment.php | 6 +- .../Controller/AbstractController/Reorder.php | 4 +- .../Creditmemo/AbstractCreditmemo/Email.php | 2 +- .../AbstractCreditmemo/PrintAction.php | 8 +- .../Invoice/AbstractInvoice/Email.php | 6 +- .../Invoice/AbstractInvoice/PrintAction.php | 10 +- .../Invoice/AbstractInvoice/View.php | 2 +- .../Controller/Adminhtml/Order/AddComment.php | 2 +- .../Controller/Adminhtml/Order/Address.php | 2 +- .../Adminhtml/Order/AddressSave.php | 4 +- .../Controller/Adminhtml/Order/Cancel.php | 2 +- .../Adminhtml/Order/CommentsHistory.php | 2 +- .../Controller/Adminhtml/Order/Create.php | 10 +- .../Adminhtml/Order/Create/AddConfigured.php | 2 +- .../Order/Create/ConfigureProductToAdd.php | 4 +- .../Order/Create/ConfigureQuoteItems.php | 8 +- .../Adminhtml/Order/Create/LoadBlock.php | 2 +- .../Adminhtml/Order/Create/Reorder.php | 4 +- .../Order/Create/ShowUpdateResult.php | 2 +- .../Adminhtml/Order/Creditmemo/Cancel.php | 2 +- .../Adminhtml/Order/Creditmemo/NewAction.php | 2 +- .../Adminhtml/Order/Creditmemo/Save.php | 4 +- .../Adminhtml/Order/Creditmemo/Void.php | 2 +- .../Controller/Adminhtml/Order/Edit/Start.php | 2 +- .../Adminhtml/Order/Invoice/Cancel.php | 2 +- .../Adminhtml/Order/Invoice/Capture.php | 4 +- .../Adminhtml/Order/Invoice/NewAction.php | 4 +- .../Adminhtml/Order/Invoice/Save.php | 14 +-- .../Adminhtml/Order/Invoice/UpdateQty.php | 2 +- .../Adminhtml/Order/Invoice/Void.php | 4 +- .../Controller/Adminhtml/Order/Status.php | 2 +- .../Adminhtml/Order/Status/NewAction.php | 2 +- .../Adminhtml/Order/Status/Save.php | 4 +- .../Adminhtml/Order/View/Giftmessage.php | 2 +- .../Adminhtml/Order/VoidPayment.php | 2 +- .../Shipment/AbstractShipment/PrintAction.php | 10 +- .../Controller/Adminhtml/Transactions.php | 2 +- .../Adminhtml/Transactions/Fetch.php | 2 +- .../Download/DownloadCustomOption.php | 8 +- .../Magento/Sales/Controller/Guest/Form.php | 4 +- .../Sales/Controller/Guest/PrintInvoice.php | 4 +- .../Sales/Controller/Guest/PrintShipment.php | 2 +- .../Magento/Sales/Model/AdminOrder/Create.php | 50 +++++----- .../Magento/Sales/Model/Config/Reader.php | 2 +- .../Magento/Sales/Model/Convert/Order.php | 2 +- app/code/Magento/Sales/Model/Order.php | 4 +- .../Magento/Sales/Model/Order/Address.php | 2 +- .../Magento/Sales/Model/Order/Creditmemo.php | 2 +- .../Sales/Model/Order/Creditmemo/Comment.php | 3 +- .../Sales/Model/Order/Creditmemo/Item.php | 3 +- .../Model/Order/Creditmemo/Total/Shipping.php | 4 +- .../Sales/Model/Order/CustomerManagement.php | 4 +- .../Magento/Sales/Model/Order/Invoice.php | 3 +- .../Sales/Model/Order/Invoice/Comment.php | 3 +- .../Sales/Model/Order/Invoice/Item.php | 4 +- app/code/Magento/Sales/Model/Order/Item.php | 3 +- .../Magento/Sales/Model/Order/Payment.php | 2 +- .../Sales/Model/Order/Payment/Transaction.php | 2 +- .../Sales/Model/Order/Pdf/Total/Factory.php | 4 +- .../Magento/Sales/Model/Order/Shipment.php | 3 +- .../Sales/Model/Order/Shipment/Comment.php | 3 +- .../Sales/Model/Order/Shipment/Item.php | 2 +- .../Sales/Model/Order/Shipment/Track.php | 2 +- .../Sales/Model/Order/ShipmentFactory.php | 2 +- app/code/Magento/Sales/Model/Order/Status.php | 3 +- .../Sales/Model/Order/Status/History.php | 3 +- app/code/Magento/Sales/Model/Order/Tax.php | 2 +- .../Magento/Sales/Model/Order/Tax/Item.php | 2 +- .../Magento/Sales/Model/OrderRepository.php | 4 +- .../Model/ResourceModel/Grid/Collection.php | 3 +- .../Order/Address/Collection.php | 5 +- .../Model/ResourceModel/Order/Collection.php | 2 +- .../Order/Creditmemo/Collection.php | 5 +- .../Order/Creditmemo/Comment/Collection.php | 4 +- .../Order/Creditmemo/Grid/Collection.php | 2 +- .../Order/Creditmemo/Item/Collection.php | 4 +- .../Creditmemo/Order/Grid/Collection.php | 2 +- .../ResourceModel/Order/Grid/Collection.php | 2 +- .../Order/Invoice/Collection.php | 5 +- .../Order/Invoice/Comment/Collection.php | 4 +- .../Order/Invoice/Grid/Collection.php | 2 +- .../Order/Invoice/Item/Collection.php | 5 +- .../Order/Invoice/Orders/Grid/Collection.php | 2 +- .../ResourceModel/Order/Item/Collection.php | 2 +- .../Order/Payment/Collection.php | 5 +- .../Order/Payment/Transaction/Collection.php | 4 +- .../Order/Shipment/Collection.php | 5 +- .../Order/Shipment/Comment/Collection.php | 4 +- .../Order/Shipment/Grid/Collection.php | 2 +- .../Order/Shipment/Item/Collection.php | 4 +- .../Order/Shipment/Order/Grid/Collection.php | 2 +- .../Order/Shipment/Track/Collection.php | 4 +- .../ResourceModel/Order/Status/Collection.php | 2 +- .../Order/Status/History/Collection.php | 4 +- .../ResourceModel/Order/Tax/Collection.php | 2 +- .../Report/Collection/AbstractCollection.php | 2 +- .../Model/ResourceModel/Sale/Collection.php | 2 +- app/code/Magento/Sales/Model/Rss/NewOrder.php | 2 +- .../Sales/Model/Status/ListFactory.php | 2 +- app/code/Magento/Sales/Setup/SalesSetup.php | 16 +-- app/code/Magento/Sales/Setup/UpgradeData.php | 16 +-- .../Adminhtml/Items/AbstractItemsTest.php | 32 +++--- .../Block/Adminhtml/Items/AbstractTest.php | 16 +-- .../Items/Column/DefaultColumnTest.php | 4 +- .../Adminhtml/Order/Comments/ViewTest.php | 4 +- .../Adminhtml/Order/Create/CustomerTest.php | 12 ++- .../Adminhtml/Order/Create/Items/GridTest.php | 59 +++++------ .../Create/Search/Grid/Renderer/QtyTest.php | 8 +- .../Create/Sidebar/AbstractSidebarTest.php | 6 +- .../Adminhtml/Order/Create/TotalsTest.php | 12 +-- .../Order/Creditmemo/Create/ItemsTest.php | 33 ++++--- .../Adminhtml/Order/Invoice/ViewTest.php | 11 ++- .../Order/Status/Assign/FormTest.php | 20 ++-- .../Block/Adminhtml/Order/Totals/TaxTest.php | 12 +-- .../Adminhtml/Order/View/GiftmessageTest.php | 2 +- .../Adminhtml/Order/View/HistoryTest.php | 4 +- .../Block/Adminhtml/Order/View/InfoTest.php | 33 +++++-- .../Adminhtml/Order/View/Tab/HistoryTest.php | 6 +- .../Order/View/Tab/TransactionsTest.php | 22 ++--- .../Adminhtml/Rss/Order/Grid/LinkTest.php | 8 +- .../Sales/Test/Unit/Block/Guest/LinkTest.php | 6 +- .../Test/Unit/Block/Items/AbstractTest.php | 16 +-- .../Unit/Block/Order/Create/TotalsTest.php | 10 +- .../Order/Email/Items/DefaultItemsTest.php | 14 +-- .../Email/Items/Order/DefaultOrderTest.php | 14 +-- .../Test/Unit/Block/Order/HistoryTest.php | 21 ++-- .../Unit/Block/Order/Info/Buttons/RssTest.php | 14 +-- .../Item/Renderer/DefaultRendererTest.php | 14 +-- .../Test/Unit/Block/Order/RecentTest.php | 19 ++-- .../Test/Unit/Block/Reorder/SidebarTest.php | 37 +++---- .../AbstractCreditmemo/EmailTest.php | 36 ++++--- .../Invoice/AbstractInvoice/EmailTest.php | 48 ++++----- .../Controller/Adminhtml/Order/CancelTest.php | 20 ++-- .../Order/Create/ProcessDataTest.php | 38 ++++---- .../Order/Creditmemo/AddCommentTest.php | 46 ++++----- .../Adminhtml/Order/Creditmemo/CancelTest.php | 52 +++++----- .../Order/Creditmemo/NewActionTest.php | 39 +++++--- .../Order/Creditmemo/PrintActionTest.php | 44 +++++---- .../Adminhtml/Order/Creditmemo/SaveTest.php | 39 ++++---- .../Order/Creditmemo/UpdateQtyTest.php | 47 ++++----- .../Adminhtml/Order/Creditmemo/ViewTest.php | 49 +++++----- .../Adminhtml/Order/Creditmemo/VoidTest.php | 57 +++++------ .../Adminhtml/Order/CreditmemoLoaderTest.php | 48 +++++---- .../Controller/Adminhtml/Order/EmailTest.php | 32 +++--- .../Controller/Adminhtml/Order/HoldTest.php | 20 ++-- .../Order/Invoice/AddCommentTest.php | 46 ++++----- .../Adminhtml/Order/Invoice/CancelTest.php | 66 +++++++------ .../Adminhtml/Order/Invoice/CaptureTest.php | 69 ++++++------- .../Adminhtml/Order/Invoice/NewActionTest.php | 54 ++++++----- .../Order/Invoice/PrintActionTest.php | 31 +++--- .../Adminhtml/Order/Invoice/SaveTest.php | 16 +-- .../Adminhtml/Order/Invoice/UpdateQtyTest.php | 53 +++++----- .../Adminhtml/Order/Invoice/ViewTest.php | 50 +++++----- .../Adminhtml/Order/Invoice/VoidTest.php | 95 ++++++++---------- .../Adminhtml/Order/MassCancelTest.php | 48 +++++---- .../Adminhtml/Order/MassHoldTest.php | 48 +++++---- .../Adminhtml/Order/MassUnholdTest.php | 46 +++++---- .../Adminhtml/Order/ReviewPaymentTest.php | 23 +++-- .../Controller/Adminhtml/Order/UnholdTest.php | 20 ++-- .../Controller/Adminhtml/Order/ViewTest.php | 42 ++++---- .../Download/DownloadCustomOptionTest.php | 24 ++--- .../Test/Unit/Controller/Guest/ViewTest.php | 14 +-- .../Test/Unit/Cron/CleanExpiredQuotesTest.php | 8 +- .../Sales/Test/Unit/Helper/AdminTest.php | 33 ++++--- .../Sales/Test/Unit/Helper/DataTest.php | 15 +-- .../Sales/Test/Unit/Helper/GuestTest.php | 34 +++---- .../Sales/Test/Unit/Helper/ReorderTest.php | 12 +-- .../Test/Unit/Model/AbstractModelTest.php | 2 +- .../Test/Unit/Model/AdminOrder/CreateTest.php | 97 +++++++++---------- .../Unit/Model/AdminOrder/EmailSenderTest.php | 8 +- .../Product/Quote/InitializerTest.php | 22 ++--- .../Config/Backend/Email/AsyncSendingTest.php | 8 +- .../Config/Backend/Grid/AsyncIndexingTest.php | 8 +- .../Sales/Test/Unit/Model/Config/DataTest.php | 4 +- .../Test/Unit/Model/Config/ReaderTest.php | 10 +- .../Unit/Model/Config/SchemaLocatorTest.php | 2 +- .../Model/Config/Source/Order/StatusTest.php | 9 +- .../Sales/Test/Unit/Model/ConfigTest.php | 6 +- ...ggregateSalesReportBestsellersDataTest.php | 8 +- .../AggregateSalesReportInvoicedDataTest.php | 10 +- .../AggregateSalesReportOrderDataTest.php | 8 +- .../AggregateSalesReportRefundedDataTest.php | 10 +- .../Model/CronJob/CleanExpiredOrdersTest.php | 12 +-- .../Sales/Test/Unit/Model/DownloadTest.php | 23 ++--- .../Unit/Model/EmailSenderHandlerTest.php | 12 +-- .../Grid/Child/CollectionUpdaterTest.php | 8 +- .../Unit/Model/Grid/CollectionUpdaterTest.php | 12 +-- .../Test/Unit/Model/GridAsyncInsertTest.php | 6 +- .../Sales/Test/Unit/Model/IncrementTest.php | 9 +- .../Test/Unit/Model/InvoiceRepositoryTest.php | 36 +++---- .../Model/Order/Address/ValidatorTest.php | 6 +- .../Model/Order/AddressRepositoryTest.php | 40 ++++---- .../Test/Unit/Model/Order/AddressTest.php | 10 +- .../Test/Unit/Model/Order/Admin/ItemTest.php | 2 +- .../Test/Unit/Model/Order/ConfigTest.php | 8 +- .../Creditmemo/Comment/ValidatorTest.php | 2 +- .../Unit/Model/Order/Creditmemo/ItemTest.php | 40 ++++---- .../Model/Order/Creditmemo/Total/CostTest.php | 12 ++- .../Order/Creditmemo/Total/DiscountTest.php | 8 +- .../Order/Creditmemo/Total/ShippingTest.php | 12 +-- .../Order/Creditmemo/Total/SubtotalTest.php | 8 +- .../Model/Order/Creditmemo/Total/TaxTest.php | 22 ++--- .../Model/Order/CreditmemoNotifierTest.php | 12 +-- .../Model/Order/CreditmemoRepositoryTest.php | 39 ++++---- .../Test/Unit/Model/Order/CreditmemoTest.php | 40 ++++---- .../Model/Order/CustomerManagementTest.php | 26 ++--- .../CreditmemoCommentIdentityTest.php | 6 +- .../Container/CreditmemoIdentityTest.php | 6 +- .../Container/InvoiceCommentIdentityTest.php | 6 +- .../Email/Container/InvoiceIdentityTest.php | 6 +- .../Container/OrderCommentIdentityTest.php | 6 +- .../Email/Container/OrderIdentityTest.php | 6 +- .../Container/ShipmentCommentIdentityTest.php | 6 +- .../Email/Container/ShipmentIdentityTest.php | 6 +- .../Order/Email/Sender/AbstractSenderTest.php | 28 +++--- .../Sender/CreditmemoCommentSenderTest.php | 4 +- .../Email/Sender/CreditmemoSenderTest.php | 11 +-- .../Email/Sender/InvoiceCommentSenderTest.php | 8 +- .../Order/Email/Sender/InvoiceSenderTest.php | 11 +-- .../Email/Sender/OrderCommentSenderTest.php | 3 +- .../Order/Email/Sender/OrderSenderTest.php | 8 +- .../Sender/ShipmentCommentSenderTest.php | 4 +- .../Order/Email/Sender/ShipmentSenderTest.php | 10 +- .../Model/Order/Email/SenderBuilderTest.php | 12 +-- .../Grid/Massaction/ItemsUpdaterTest.php | 2 +- .../Model/Order/Grid/Row/UrlGeneratorTest.php | 4 +- .../Order/Invoice/Comment/ValidatorTest.php | 2 +- .../Invoice/Grid/Row/UrlGeneratorTest.php | 4 +- .../Unit/Model/Order/Invoice/ItemTest.php | 10 +- .../Order/Invoice/Total/ShippingTest.php | 37 +++---- .../Model/Order/Invoice/Total/TaxTest.php | 12 +-- .../Unit/Model/Order/InvoiceNotifierTest.php | 12 +-- .../Test/Unit/Model/Order/InvoiceTest.php | 32 +++--- .../Unit/Model/Order/ItemRepositoryTest.php | 45 +++++---- .../Sales/Test/Unit/Model/Order/ItemTest.php | 15 ++- .../Unit/Model/Order/Payment/InfoTest.php | 20 ++-- .../Operations/CaptureOperationTest.php | 18 ++-- .../Model/Order/Payment/RepositoryTest.php | 21 ++-- .../Order/Payment/Transaction/BuilderTest.php | 13 ++- .../Order/Payment/Transaction/ManagerTest.php | 12 +-- .../Payment/Transaction/RepositoryTest.php | 31 +++--- .../Model/Order/Payment/TransactionTest.php | 8 +- .../Test/Unit/Model/Order/PaymentTest.php | 66 +++++++------ .../Unit/Model/Order/Pdf/AbstractTest.php | 35 ++++--- .../Model/Order/Pdf/Config/ReaderTest.php | 8 +- .../Order/Pdf/Config/SchemaLocatorTest.php | 2 +- .../Unit/Model/Order/Pdf/Config/XsdTest.php | 8 +- .../Test/Unit/Model/Order/Pdf/ConfigTest.php | 2 +- .../Test/Unit/Model/Order/Pdf/InvoiceTest.php | 8 +- .../Model/Order/Pdf/Total/FactoryTest.php | 9 +- .../Order/Shipment/Comment/ValidatorTest.php | 2 +- .../Order/Shipment/Track/ValidatorTest.php | 2 +- .../Unit/Model/Order/Shipment/TrackTest.php | 6 +- .../Unit/Model/Order/ShipmentFactoryTest.php | 20 ++-- .../Model/Order/ShipmentRepositoryTest.php | 43 ++++---- .../Test/Unit/Model/Order/ShipmentTest.php | 2 +- .../Order/Status/History/ValidatorTest.php | 4 +- .../Unit/Model/Order/Status/HistoryTest.php | 10 +- .../Test/Unit/Model/Order/StatusTest.php | 24 +++-- .../Model/Order/Total/Config/BaseTest.php | 64 +++++++----- .../Test/Unit/Model/OrderNotifierTest.php | 12 +-- .../Test/Unit/Model/OrderRepositoryTest.php | 24 ++--- .../Sales/Test/Unit/Model/OrderTest.php | 65 +++++++------ .../Model/ResourceModel/AttributeTest.php | 8 +- .../Unit/Model/ResourceModel/GridPoolTest.php | 18 ++-- .../Unit/Model/ResourceModel/HelperTest.php | 8 +- .../Model/ResourceModel/Order/AddressTest.php | 14 +-- .../Order/Creditmemo/CommentTest.php | 17 ++-- .../Order/Creditmemo/Relation/RefundTest.php | 14 +-- .../Order/Creditmemo/RelationTest.php | 12 ++- .../Order/Handler/AddressTest.php | 8 +- .../ResourceModel/Order/Handler/StateTest.php | 6 +- .../Order/Invoice/CommentTest.php | 17 ++-- .../Order/Invoice/RelationTest.php | 14 +-- .../ResourceModel/Order/RelationTest.php | 84 +++++----------- .../Order/Shipment/CommentTest.php | 17 ++-- .../Order/Shipment/RelationTest.php | 16 +-- .../Order/Shipment/TrackTest.php | 17 ++-- .../Order/Status/History/CollectionTest.php | 37 +++++-- .../Order/Status/HistoryTest.php | 18 ++-- .../Model/ResourceModel/Order/StatusTest.php | 15 +-- .../ResourceModel/Order/Tax/ItemTest.php | 8 +- .../Unit/Model/ResourceModel/OrderTest.php | 28 +++--- .../Test/Unit/Model/Rss/NewOrderTest.php | 31 +++--- .../Test/Unit/Model/Rss/OrderStatusTest.php | 22 +++-- .../Model/Service/CreditmemoServiceTest.php | 18 ++-- .../Unit/Model/Service/InvoiceServiceTest.php | 22 ++--- .../Unit/Model/Service/OrderServiceTest.php | 26 ++--- .../Model/Service/ShipmentServiceTest.php | 20 ++-- .../Test/Unit/Model/Status/ListStatusTest.php | 4 +- .../Observer/Backend/CatalogPriceRuleTest.php | 4 +- .../CatalogProductSaveAfterObserverTest.php | 8 +- .../SubtractQtyFromQuotesObserverTest.php | 8 +- .../AddVatRequestParamsOrderCommentTest.php | 8 +- .../Frontend/RestoreCustomerGroupIdTest.php | 20 ++-- .../Observer/GridProcessAddressChangeTest.php | 4 +- .../Observer/GridSyncInsertObserverTest.php | 8 +- .../Observer/GridSyncRemoveObserverTest.php | 6 +- .../Component/Listing/Column/AddressTest.php | 8 +- .../Listing/Column/CustomerGroupTest.php | 10 +- .../Listing/Column/PaymentMethodTest.php | 10 +- .../Ui/Component/Listing/Column/PriceTest.php | 10 +- .../Listing/Column/PurchasedPriceTest.php | 10 +- .../Listing/Column/Status/OptionsTest.php | 6 +- .../Component/Listing/Column/StatusTest.php | 16 ++- .../Listing/Column/ViewActionTest.php | 8 +- 390 files changed, 2765 insertions(+), 2395 deletions(-) diff --git a/app/code/Magento/Msrp/Setup/InstallData.php b/app/code/Magento/Msrp/Setup/InstallData.php index 2b3789a67d1e5..fd05f4fff1b77 100644 --- a/app/code/Magento/Msrp/Setup/InstallData.php +++ b/app/code/Magento/Msrp/Setup/InstallData.php @@ -14,6 +14,7 @@ /** * @codeCoverageIgnore + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InstallData implements InstallDataInterface { @@ -55,7 +56,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'msrp', [ 'group' => 'Advanced Pricing', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Price', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Price::class, 'frontend' => '', 'label' => 'Manufacturer\'s Suggested Retail Price', 'type' => 'decimal', @@ -65,8 +66,8 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'required' => false, 'user_defined' => false, 'apply_to' => $productTypes, - 'input_renderer' => 'Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type', - 'frontend_input_renderer' => 'Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type', + 'input_renderer' => \Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type::class, + 'frontend_input_renderer' => \Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type::class, 'visible_on_front' => false, 'used_in_product_listing' => true, 'is_used_in_grid' => true, @@ -80,12 +81,12 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'msrp_display_actual_price_type', [ 'group' => 'Advanced Pricing', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Boolean', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Boolean::class, 'frontend' => '', 'label' => 'Display Actual Price', 'input' => 'select', - 'source' => 'Magento\Msrp\Model\Product\Attribute\Source\Type\Price', - 'source_model' => 'Magento\Msrp\Model\Product\Attribute\Source\Type\Price', + 'source' => \Magento\Msrp\Model\Product\Attribute\Source\Type\Price::class, + 'source_model' => \Magento\Msrp\Model\Product\Attribute\Source\Type\Price::class, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'required' => false, @@ -93,8 +94,8 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'default' => \Magento\Msrp\Model\Product\Attribute\Source\Type\Price::TYPE_USE_CONFIG, 'default_value' => \Magento\Msrp\Model\Product\Attribute\Source\Type\Price::TYPE_USE_CONFIG, 'apply_to' => $productTypes, - 'input_renderer' => 'Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type\Price', - 'frontend_input_renderer' => 'Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type\Price', + 'input_renderer' => \Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type\Price::class, + 'frontend_input_renderer' => \Magento\Msrp\Block\Adminhtml\Product\Helper\Form\Type\Price::class, 'visible_on_front' => false, 'used_in_product_listing' => true ] diff --git a/app/code/Magento/Msrp/Test/Unit/Helper/DataTest.php b/app/code/Magento/Msrp/Test/Unit/Helper/DataTest.php index bca0d884ff0c4..3d25f9203f90b 100644 --- a/app/code/Magento/Msrp/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Msrp/Test/Unit/Helper/DataTest.php @@ -31,16 +31,16 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); - $this->productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['getMsrp', 'getPriceInfo', '__wakeup']) ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->helper = $objectManager->getObject( - 'Magento\Msrp\Helper\Data', + $this->helper = $objectManager->getObject( + \Magento\Msrp\Helper\Data::class, [ 'priceCurrency' => $this->priceCurrencyMock, ] @@ -60,14 +60,14 @@ function ($arg) { ) ); - $finalPriceMock = $this->getMockBuilder('\Magento\Catalog\Pricing\Price\FinalPrice') + $finalPriceMock = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\FinalPrice::class) ->disableOriginalConstructor() ->getMock(); $finalPriceMock->expects($this->any()) ->method('getValue') ->will($this->returnValue($convertedFinalPrice)); - $priceInfoMock = $this->getMockBuilder('\Magento\Framework\Pricing\PriceInfo\Base') + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoMock->expects($this->once()) diff --git a/app/code/Magento/Msrp/Test/Unit/Model/Product/Attribute/Source/Type/PriceTest.php b/app/code/Magento/Msrp/Test/Unit/Model/Product/Attribute/Source/Type/PriceTest.php index 62966face3936..10ef13ed85ff9 100644 --- a/app/code/Magento/Msrp/Test/Unit/Model/Product/Attribute/Source/Type/PriceTest.php +++ b/app/code/Magento/Msrp/Test/Unit/Model/Product/Attribute/Source/Type/PriceTest.php @@ -17,13 +17,13 @@ class PriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Msrp\Model\Product\Attribute\Source\Type\Price'); + $this->_model = $objectManager->getObject(\Magento\Msrp\Model\Product\Attribute\Source\Type\Price::class); } public function testGetFlatColumns() { $abstractAttributeMock = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getAttributeCode', '__wakeup'], [], '', diff --git a/app/code/Magento/Msrp/Test/Unit/Observer/Frontend/Quote/SetCanApplyMsrpObserverTest.php b/app/code/Magento/Msrp/Test/Unit/Observer/Frontend/Quote/SetCanApplyMsrpObserverTest.php index d5c69c7dd374c..7508a9cd0483c 100644 --- a/app/code/Magento/Msrp/Test/Unit/Observer/Frontend/Quote/SetCanApplyMsrpObserverTest.php +++ b/app/code/Magento/Msrp/Test/Unit/Observer/Frontend/Quote/SetCanApplyMsrpObserverTest.php @@ -7,9 +7,6 @@ use Magento\Quote\Model\Quote\Address; -/** - * Tests Magento\Msrp\Model\Observer\Frontend\Quote\SetCanApplyMsrp - */ class SetCanApplyMsrpObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -30,9 +27,15 @@ class SetCanApplyMsrpObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('\Magento\Msrp\Model\Config', [], [], '', false); - $this->canApplyMsrpMock = $this->getMock('\Magento\Msrp\Model\Quote\Address\CanApplyMsrp', [], [], '', false); - $this->msrpMock = $this->getMock('\Magento\Msrp\Model\Quote\Msrp', [], [], '', false); + $this->configMock = $this->getMock(\Magento\Msrp\Model\Config::class, [], [], '', false); + $this->canApplyMsrpMock = $this->getMock( + \Magento\Msrp\Model\Quote\Address\CanApplyMsrp::class, + [], + [], + '', + false + ); + $this->msrpMock = $this->getMock(\Magento\Msrp\Model\Quote\Msrp::class, [], [], '', false); $this->observer = new \Magento\Msrp\Observer\Frontend\Quote\SetCanApplyMsrpObserver( $this->configMock, @@ -44,16 +47,22 @@ protected function setUp() public function testSetQuoteCanApplyMsrpIfMsrpCanApply() { $quoteId = 100; - $eventMock = $this->getMock('\Magento\Framework\Event', ['getQuote'], [], '', false); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', ['getAllAddresses', 'getId'], [], '', false); - $observerMock = $this->getMock('\Magento\Framework\Event\Observer', [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getQuote'], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getAllAddresses', 'getId'], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); $eventMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $this->configMock->expects($this->once())->method('isEnabled')->willReturn(true); $this->msrpMock->expects($this->once())->method('setCanApplyMsrp')->with($quoteId, true); - $addressMock = $this->getMock('\Magento\Customer\Model\Address\AbstractAddress', ['__wakeup'], [], '', false); + $addressMock = $this->getMock( + \Magento\Customer\Model\Address\AbstractAddress::class, + ['__wakeup'], + [], + '', + false + ); $this->canApplyMsrpMock->expects($this->once())->method('isCanApplyMsrp')->willReturn(true); $quoteMock->expects($this->once())->method('getAllAddresses')->willReturn([$addressMock]); @@ -64,16 +73,22 @@ public function testSetQuoteCanApplyMsrpIfMsrpCanApply() public function setQuoteCanApplyMsrpDataProvider() { $quoteId = 100; - $eventMock = $this->getMock('\Magento\Framework\Event', ['getQuote'], [], '', false); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', ['getAllAddresses', 'getId'], [], '', false); - $observerMock = $this->getMock('\Magento\Framework\Event\Observer', [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getQuote'], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getAllAddresses', 'getId'], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); $eventMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $this->configMock->expects($this->once())->method('isEnabled')->willReturn(true); $this->msrpMock->expects($this->once())->method('setCanApplyMsrp')->with($quoteId, false); - $addressMock = $this->getMock('\Magento\Customer\Model\Address\AbstractAddress', ['__wakeup'], [], '', false); + $addressMock = $this->getMock( + \Magento\Customer\Model\Address\AbstractAddress::class, + ['__wakeup'], + [], + '', + false + ); $this->canApplyMsrpMock->expects($this->once())->method('isCanApplyMsrp')->willReturn(false); $quoteMock->expects($this->once())->method('getAllAddresses')->willReturn([$addressMock]); @@ -84,9 +99,9 @@ public function setQuoteCanApplyMsrpDataProvider() public function testSetQuoteCanApplyMsrpIfMsrpDisabled() { $quoteId = 100; - $eventMock = $this->getMock('\Magento\Framework\Event', ['getQuote'], [], '', false); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', ['getAllAddresses', 'getId'], [], '', false); - $observerMock = $this->getMock('\Magento\Framework\Event\Observer', [], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getQuote'], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getAllAddresses', 'getId'], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); $eventMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); diff --git a/app/code/Magento/Msrp/Test/Unit/Pricing/Price/MsrpPriceTest.php b/app/code/Magento/Msrp/Test/Unit/Pricing/Price/MsrpPriceTest.php index 0dfbb679ffb38..f5197c4f9e2c5 100644 --- a/app/code/Magento/Msrp/Test/Unit/Pricing/Price/MsrpPriceTest.php +++ b/app/code/Magento/Msrp/Test/Unit/Pricing/Price/MsrpPriceTest.php @@ -32,6 +32,7 @@ class MsrpPriceTest extends \PHPUnit_Framework_TestCase * @var \Magento\Catalog\Pricing\Price\BasePrice|\PHPUnit_Framework_MockObject_MockObject */ protected $price; + /** * @var \Magento\Framework\Pricing\PriceInfo\Base|\PHPUnit_Framework_MockObject_MockObject */ @@ -55,15 +56,15 @@ class MsrpPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->saleableItem = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getPriceInfo', '__wakeup'], [], '', false ); - $this->priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); - $this->price = $this->getMock('Magento\Catalog\Pricing\Price\BasePrice', [], [], '', false); + $this->priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->price = $this->getMock(\Magento\Catalog\Pricing\Price\BasePrice::class, [], [], '', false); $this->priceInfo->expects($this->any()) ->method('getAdjustments') @@ -78,20 +79,20 @@ protected function setUp() ->with($this->equalTo('base_price')) ->will($this->returnValue($this->price)); - $this->calculator = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\Calculator') + $this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\Calculator::class) ->disableOriginalConstructor() ->getMock(); $this->helper = $this->getMock( - 'Magento\Msrp\Helper\Data', + \Magento\Msrp\Helper\Data::class, ['isShowPriceOnGesture', 'getMsrpPriceMessage', 'canApplyMsrp'], [], '', false ); - $this->config = $this->getMock('Magento\Msrp\Model\Config', ['isEnabled'], [], '', false); + $this->config = $this->getMock(\Magento\Msrp\Model\Config::class, ['isEnabled'], [], '', false); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->object = new \Magento\Msrp\Pricing\Price\MsrpPrice( $this->saleableItem, diff --git a/app/code/Magento/RequireJs/Test/Unit/Block/Html/Head/ConfigTest.php b/app/code/Magento/RequireJs/Test/Unit/Block/Html/Head/ConfigTest.php index 28df0a18a9379..2b763824dfe38 100644 --- a/app/code/Magento/RequireJs/Test/Unit/Block/Html/Head/ConfigTest.php +++ b/app/code/Magento/RequireJs/Test/Unit/Block/Html/Head/ConfigTest.php @@ -47,11 +47,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('\Magento\Framework\View\Element\Context', [], [], '', false); - $this->config = $this->getMock('\Magento\Framework\RequireJs\Config', [], [], '', false); - $this->fileManager = $this->getMock('\Magento\RequireJs\Model\FileManager', [], [], '', false); - $this->pageConfig = $this->getMock('\Magento\Framework\View\Page\Config', [], [], '', false); - $this->bundleConfig = $this->getMock('Magento\Framework\View\Asset\ConfigInterface', [], [], '', false); + $this->context = $this->getMock(\Magento\Framework\View\Element\Context::class, [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\RequireJs\Config::class, [], [], '', false); + $this->fileManager = $this->getMock(\Magento\RequireJs\Model\FileManager::class, [], [], '', false); + $this->pageConfig = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); + $this->bundleConfig = $this->getMock(\Magento\Framework\View\Asset\ConfigInterface::class, [], [], '', false); } public function testSetLayout() @@ -61,16 +61,16 @@ public function testSetLayout() ->method('isBundlingJsFiles') ->willReturn(true); $filePath = 'require_js_fie_path'; - $asset = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\LocalInterface'); + $asset = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\LocalInterface::class); $asset->expects($this->atLeastOnce()) ->method('getFilePath') ->willReturn($filePath); - $requireJsAsset = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\LocalInterface'); + $requireJsAsset = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\LocalInterface::class); $requireJsAsset ->expects($this->atLeastOnce()) ->method('getFilePath') ->willReturn('/path/to/require/require.js'); - $minResolverAsset = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\LocalInterface'); + $minResolverAsset = $this->getMockForAbstractClass(\Magento\Framework\View\Asset\LocalInterface::class); $minResolverAsset ->expects($this->atLeastOnce()) ->method('getFilePath') @@ -97,9 +97,9 @@ public function testSetLayout() ->method('createMinResolverAsset') ->will($this->returnValue($minResolverAsset)); - $layout = $this->getMock('Magento\Framework\View\LayoutInterface'); + $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); - $assetCollection = $this->getMockBuilder('Magento\Framework\View\Asset\GroupedCollection') + $assetCollection = $this->getMockBuilder(\Magento\Framework\View\Asset\GroupedCollection::class) ->disableOriginalConstructor() ->getMock(); $this->pageConfig->expects($this->atLeastOnce()) @@ -111,7 +111,7 @@ public function testSetLayout() ->method('insert') ->willReturn(true); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); $this->minificationMock @@ -120,7 +120,6 @@ public function testSetLayout() ->with('js') ->willReturn(true); - $object = new Config( $this->context, $this->config, diff --git a/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php b/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php index 9678ddf2977f8..4a8ea64994151 100644 --- a/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php +++ b/app/code/Magento/RequireJs/Test/Unit/Model/FileManagerTest.php @@ -48,13 +48,13 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('\Magento\Framework\RequireJs\Config', [], [], '', false); - $this->fileSystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); - $this->appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false); - $this->assetRepoMock = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\RequireJs\Config::class, [], [], '', false); + $this->fileSystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->assetRepoMock = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); $this->object = new FileManager($this->configMock, $this->fileSystem, $this->appState, $this->assetRepoMock); - $this->dir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); - $this->asset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $this->dir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); + $this->asset = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); } /** @@ -126,10 +126,10 @@ public function testCreateRequireJsAssetDevMode() public function testCreateBundleJsPool() { unset($this->configMock); - $dirRead = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], 'libDir', false); - $context = $this->getMock('Magento\Framework\View\Asset\File\FallbackContext', [], [], '', false); - $assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $config = $this->getMock('\Magento\Framework\RequireJs\Config', [], [], '', false); + $dirRead = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], 'libDir', false); + $context = $this->getMock(\Magento\Framework\View\Asset\File\FallbackContext::class, [], [], '', false); + $assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $config = $this->getMock(\Magento\Framework\RequireJs\Config::class, [], [], '', false); $config ->expects($this->never()) @@ -226,7 +226,7 @@ public function testCreateRequireJsMixinsAsset() public function testClearBundleJsPool() { - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); $this->fileSystem->expects($this->once()) diff --git a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php index 8fb7409c0a3e2..1a12ca9659b3e 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php @@ -69,7 +69,7 @@ protected function _prepareForm() 'label' => __('Product Rating'), 'required' => true, 'text' => '
' . $this->getLayout()->createBlock( - 'Magento\Review\Block\Adminhtml\Rating\Detailed' + \Magento\Review\Block\Adminhtml\Rating\Detailed::class )->toHtml() . '
' ] ); @@ -100,7 +100,7 @@ protected function _prepareForm() ] ); $renderer = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' + \Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element::class ); $field->setRenderer($renderer); } @@ -144,7 +144,7 @@ protected function _prepareForm() /*$gridFieldset = $form->addFieldset('add_review_grid', array('legend' => __('Please select a product'))); $gridFieldset->addField('products_grid', 'note', array( - 'text' => $this->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Product\Grid')->toHtml(), + 'text' => $this->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Product\Grid::class)->toHtml(), ));*/ $form->setMethod('post'); diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php index 27ba5c056a502..667ae22f47418 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php @@ -132,7 +132,9 @@ protected function _prepareForm() 'note', [ 'label' => __('Summary Rating'), - 'text' => $this->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Rating\Summary')->toHtml() + 'text' => $this->getLayout()->createBlock( + \Magento\Review\Block\Adminhtml\Rating\Summary::class + )->toHtml() ] ); @@ -143,7 +145,7 @@ protected function _prepareForm() 'label' => __('Detailed Rating'), 'required' => true, 'text' => '
' . $this->getLayout()->createBlock( - 'Magento\Review\Block\Adminhtml\Rating\Detailed' + \Magento\Review\Block\Adminhtml\Rating\Detailed::class )->toHtml() . '
' ] ); @@ -174,7 +176,7 @@ protected function _prepareForm() ] ); $renderer = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' + \Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element::class ); $field->setRenderer($renderer); $review->setSelectStores($review->getStores()); diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Grid.php index 5dc03420727db..9fa47b46eff3d 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Grid.php @@ -250,8 +250,8 @@ protected function _prepareColumns() 'header' => __('Type'), 'type' => 'select', 'index' => 'type', - 'filter' => 'Magento\Review\Block\Adminhtml\Grid\Filter\Type', - 'renderer' => 'Magento\Review\Block\Adminhtml\Grid\Renderer\Type' + 'filter' => \Magento\Review\Block\Adminhtml\Grid\Filter\Type::class, + 'renderer' => \Magento\Review\Block\Adminhtml\Grid\Renderer\Type::class ] ); diff --git a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php index 9432c0082cc01..b8506549ddd77 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php @@ -113,7 +113,7 @@ protected function _prepareColumns() 'header' => __('Status'), 'index' => 'status', 'type' => 'options', - 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Status', + 'source' => \Magento\Catalog\Model\Product\Attribute\Source\Status::class, 'options' => $this->_status->getOptionArray() ] ); diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php index 4d2b6d39020bb..f6957e5cb92dc 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php @@ -212,7 +212,7 @@ protected function addVisibilityFieldset() ] ); $renderer = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' + \Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element::class ); $field->setRenderer($renderer); if ($this->_coreRegistry->registry('rating_data')) { diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tabs.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tabs.php index b71f65348932d..422aa8a5f4233 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tabs.php +++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tabs.php @@ -34,7 +34,7 @@ protected function _beforeToHtml() 'label' => __('Rating Information'), 'title' => __('Rating Information'), 'content' => $this->getLayout() - ->createBlock('Magento\Review\Block\Adminhtml\Rating\Edit\Tab\Form') + ->createBlock(\Magento\Review\Block\Adminhtml\Rating\Edit\Tab\Form::class) ->toHtml() ] ); diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php index a45b96e77c04d..4ab75e2c99e0e 100644 --- a/app/code/Magento/Review/Block/Customer/ListCustomer.php +++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php @@ -83,7 +83,7 @@ protected function _prepareLayout() { if ($this->getReviews()) { $toolbar = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager', + \Magento\Theme\Block\Html\Pager::class, 'customer_review_list.toolbar' )->setCollection( $this->getReviews() diff --git a/app/code/Magento/Review/Block/Product/View.php b/app/code/Magento/Review/Block/Product/View.php index f6e1a267d36eb..d7b8502b33d1a 100644 --- a/app/code/Magento/Review/Block/Product/View.php +++ b/app/code/Magento/Review/Block/Product/View.php @@ -103,7 +103,7 @@ public function getReviewsSummaryHtml( $displayIfNoReviews = false ) { return $this->getLayout()->createBlock( - 'Magento\Review\Block\Rating\Entity\Detailed' + \Magento\Review\Block\Rating\Entity\Detailed::class )->setEntityId( $this->getProduct()->getId() )->toHtml() . $this->getLayout()->getBlock( diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php index 51c47475a5b70..e81e95613bf5c 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php @@ -20,7 +20,7 @@ public function execute() $resultPage->setActiveMenu('Magento_Review::catalog_reviews_ratings_reviews_all'); $resultPage->getConfig()->getTitle()->prepend(__('Customer Reviews')); $resultPage->getConfig()->getTitle()->prepend(__('Edit Review')); - $resultPage->addContent($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Edit')); + $resultPage->addContent($resultPage->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Edit::class)); return $resultPage; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php index 979f1cc79376c..0d7629a8bfd15 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php @@ -26,7 +26,7 @@ public function execute() $resultPage->setActiveMenu('Magento_Review::catalog_reviews_ratings_reviews_all'); $resultPage->getConfig()->getTitle()->prepend(__('Customer Reviews')); $resultPage->getConfig()->getTitle()->prepend(__('Reviews')); - $resultPage->addContent($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Main')); + $resultPage->addContent($resultPage->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Main::class)); return $resultPage; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php b/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php index c7aea8b75653c..e9c8426ba9dd9 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php @@ -20,8 +20,10 @@ public function execute() $resultPage->setActiveMenu('Magento_Review::catalog_reviews_ratings_reviews_all'); $resultPage->getConfig()->getTitle()->prepend(__('Customer Reviews')); $resultPage->getConfig()->getTitle()->prepend(__('New Review')); - $resultPage->addContent($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Add')); - $resultPage->addContent($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Product\Grid')); + $resultPage->addContent($resultPage->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Add::class)); + $resultPage->addContent($resultPage->getLayout()->createBlock( + \Magento\Review\Block\Adminhtml\Product\Grid::class + )); return $resultPage; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Pending.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Pending.php index 6c0116397616a..50167f2a57039 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Pending.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Pending.php @@ -27,7 +27,7 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Customer Reviews')); $resultPage->getConfig()->getTitle()->prepend(__('Pending Reviews')); $this->coreRegistry->register('usePendingFilter', true); - $resultPage->addContent($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Main')); + $resultPage->addContent($resultPage->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Main::class)); return $resultPage; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php index c0157df8adf2f..67480ca3038a0 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php @@ -22,7 +22,7 @@ public function execute() $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); if ($data = $this->getRequest()->getPostValue()) { /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); if ($storeManager->hasSingleStore()) { $data['stores'] = [ $storeManager->getStore(true)->getId(), diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php b/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php index 6d63b8171346c..2f15fc655a2df 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php @@ -46,7 +46,7 @@ public function execute() $layout = $this->layoutFactory->create(); /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultFactory->create(ResultFactory::TYPE_RAW); - $resultRaw->setContents($layout->createBlock('Magento\Review\Block\Adminhtml\Product\Grid')->toHtml()); + $resultRaw->setContents($layout->createBlock(\Magento\Review\Block\Adminhtml\Product\Grid::class)->toHtml()); return $resultRaw; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php b/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php index aa37e1995bc85..6fa5996949700 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php @@ -47,7 +47,7 @@ public function execute() /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultFactory->create(ResultFactory::TYPE_RAW); $resultRaw->setContents( - $layout->createBlock('Magento\Review\Block\Adminhtml\Rating\Detailed') + $layout->createBlock(\Magento\Review\Block\Adminhtml\Rating\Detailed::class) ->setIndependentMode() ->toHtml() ); diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/ReviewGrid.php b/app/code/Magento/Review/Controller/Adminhtml/Product/ReviewGrid.php index 0d58764ecf984..dfd3637c22235 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/ReviewGrid.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/ReviewGrid.php @@ -46,7 +46,7 @@ public function execute() $layout = $this->layoutFactory->create(); /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultFactory->create(ResultFactory::TYPE_RAW); - $resultRaw->setContents($layout->createBlock('Magento\Review\Block\Adminhtml\Grid')->toHtml()); + $resultRaw->setContents($layout->createBlock(\Magento\Review\Block\Adminhtml\Grid::class)->toHtml()); return $resultRaw; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php index 3328561ab93b5..b260a84ffe699 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php @@ -29,7 +29,7 @@ public function execute() $arrRatingId = $this->getRequest()->getParam('ratings', []); /** @var \Magento\Review\Model\Rating\Option\Vote $votes */ - $votes = $this->_objectManager->create('Magento\Review\Model\Rating\Option\Vote') + $votes = $this->_objectManager->create(\Magento\Review\Model\Rating\Option\Vote::class) ->getResourceCollection() ->setReviewFilter($reviewId) ->addOptionInfo() diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating.php b/app/code/Magento/Review/Controller/Adminhtml/Rating.php index c7ff600674f1a..e36ba72eeb684 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Rating.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Rating.php @@ -47,7 +47,7 @@ protected function initEnityId() { $this->coreRegistry->register( 'entityId', - $this->_objectManager->create('Magento\Review\Model\Rating\Entity')->getIdByCode('product') + $this->_objectManager->create(\Magento\Review\Model\Rating\Entity::class)->getIdByCode('product') ); } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php index ca164d310be80..efc9eac2dbbb7 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php @@ -20,7 +20,7 @@ public function execute() if ($this->getRequest()->getParam('id') > 0) { try { /** @var \Magento\Review\Model\Rating $model */ - $model = $this->_objectManager->create('Magento\Review\Model\Rating'); + $model = $this->_objectManager->create(\Magento\Review\Model\Rating::class); $model->load($this->getRequest()->getParam('id'))->delete(); $this->messageManager->addSuccess(__('You deleted the rating.')); } catch (\Exception $e) { diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php index 658f437e0fa99..04aaa0cf6462b 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php @@ -17,7 +17,7 @@ public function execute() { $this->initEnityId(); /** @var \Magento\Review\Model\Rating $ratingModel */ - $ratingModel = $this->_objectManager->create('Magento\Review\Model\Rating'); + $ratingModel = $this->_objectManager->create(\Magento\Review\Model\Rating::class); if ($this->getRequest()->getParam('id')) { $ratingModel->load($this->getRequest()->getParam('id')); } @@ -29,8 +29,9 @@ public function execute() $ratingModel->getId() ? $ratingModel->getRatingCode() : __('New Rating') ); $resultPage->addBreadcrumb(__('Manage Ratings'), __('Manage Ratings')); - $resultPage->addContent($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Rating\Edit')) - ->addLeft($resultPage->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Rating\Edit\Tabs')); + $resultPage->addContent($resultPage->getLayout()->createBlock( + \Magento\Review\Block\Adminhtml\Rating\Edit::class + ))->addLeft($resultPage->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Rating\Edit\Tabs::class)); return $resultPage; } } diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php index f508b7dc24f8a..ef08045634309 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php @@ -23,7 +23,7 @@ public function execute() if ($this->getRequest()->getPostValue()) { try { /** @var \Magento\Review\Model\Rating $ratingModel */ - $ratingModel = $this->_objectManager->create('Magento\Review\Model\Rating'); + $ratingModel = $this->_objectManager->create(\Magento\Review\Model\Rating::class); $stores = $this->getRequest()->getParam('stores'); $position = (int)$this->getRequest()->getParam('position'); $stores[] = 0; @@ -43,7 +43,7 @@ public function execute() if (is_array($options)) { $i = 1; foreach ($options as $key => $optionCode) { - $optionModel = $this->_objectManager->create('Magento\Review\Model\Rating\Option'); + $optionModel = $this->_objectManager->create(\Magento\Review\Model\Rating\Option::class); if (!preg_match("/^add_([0-9]*?)$/", $key)) { $optionModel->setId($key); } @@ -58,10 +58,10 @@ public function execute() } $this->messageManager->addSuccess(__('You saved the rating.')); - $this->_objectManager->get('Magento\Backend\Model\Session')->setRatingData(false); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setRatingData(false); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); - $this->_objectManager->get('Magento\Backend\Model\Session') + $this->_objectManager->get(\Magento\Backend\Model\Session::class) ->setRatingData($this->getRequest()->getPostValue()); $resultRedirect->setPath('review/rating/edit', ['id' => $this->getRequest()->getParam('id')]); return $resultRedirect; diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php index e76700befc87d..fbc3f1e6110b5 100644 --- a/app/code/Magento/Review/Controller/Product.php +++ b/app/code/Magento/Review/Controller/Product.php @@ -146,7 +146,7 @@ public function __construct( */ public function dispatch(RequestInterface $request) { - $allowGuest = $this->_objectManager->get('Magento\Review\Helper\Data')->getIsGuestAllowToWrite(); + $allowGuest = $this->_objectManager->get(\Magento\Review\Helper\Data::class)->getIsGuestAllowToWrite(); if (!$request->isDispatched()) { return parent::dispatch($request); } @@ -161,7 +161,7 @@ public function dispatch(RequestInterface $request) $this->_redirect->getRefererUrl() ); $this->getResponse()->setRedirect( - $this->_objectManager->get('Magento\Customer\Model\Url')->getLoginUrl() + $this->_objectManager->get(\Magento\Customer\Model\Url::class)->getLoginUrl() ); } } diff --git a/app/code/Magento/Review/Model/Rating.php b/app/code/Magento/Review/Model/Rating.php index 1f8735904ba06..a7b0f0129e745 100644 --- a/app/code/Magento/Review/Model/Rating.php +++ b/app/code/Magento/Review/Model/Rating.php @@ -71,7 +71,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Review\Model\ResourceModel\Rating'); + $this->_init(\Magento\Review\Model\ResourceModel\Rating::class); } /** diff --git a/app/code/Magento/Review/Model/Rating/Entity.php b/app/code/Magento/Review/Model/Rating/Entity.php index 62d640ce4f375..4332e6e18f5af 100644 --- a/app/code/Magento/Review/Model/Rating/Entity.php +++ b/app/code/Magento/Review/Model/Rating/Entity.php @@ -23,7 +23,7 @@ class Entity extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Review\Model\ResourceModel\Rating\Entity'); + $this->_init(\Magento\Review\Model\ResourceModel\Rating\Entity::class); } /** diff --git a/app/code/Magento/Review/Model/Rating/Option.php b/app/code/Magento/Review/Model/Rating/Option.php index fec1b40ab7c3a..2e75414491b79 100644 --- a/app/code/Magento/Review/Model/Rating/Option.php +++ b/app/code/Magento/Review/Model/Rating/Option.php @@ -29,7 +29,7 @@ class Option extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Review\Model\ResourceModel\Rating\Option'); + $this->_init(\Magento\Review\Model\ResourceModel\Rating\Option::class); } /** diff --git a/app/code/Magento/Review/Model/Rating/Option/Vote.php b/app/code/Magento/Review/Model/Rating/Option/Vote.php index 73d7e843a735f..2065ccbaeec80 100644 --- a/app/code/Magento/Review/Model/Rating/Option/Vote.php +++ b/app/code/Magento/Review/Model/Rating/Option/Vote.php @@ -18,6 +18,6 @@ class Vote extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Review\Model\ResourceModel\Rating\Option\Vote'); + $this->_init(\Magento\Review\Model\ResourceModel\Rating\Option\Vote::class); } } diff --git a/app/code/Magento/Review/Model/ResourceModel/Rating/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Rating/Collection.php index 6691bb11b9a52..3693b50806749 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Rating/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Rating/Collection.php @@ -65,7 +65,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Review\Model\Rating', 'Magento\Review\Model\ResourceModel\Rating'); + $this->_init(\Magento\Review\Model\Rating::class, \Magento\Review\Model\ResourceModel\Rating::class); } /** diff --git a/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Collection.php index 5daa82163ae31..522084bb1563d 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Collection.php @@ -26,7 +26,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Review\Model\Rating\Option', 'Magento\Review\Model\ResourceModel\Rating\Option'); + $this->_init( + \Magento\Review\Model\Rating\Option::class, + \Magento\Review\Model\ResourceModel\Rating\Option::class + ); $this->_ratingVoteTable = $this->getTable('rating_option_vote'); } diff --git a/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Vote/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Vote/Collection.php index a3c0d07c9efa2..c6fe678e92269 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Vote/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Vote/Collection.php @@ -57,8 +57,8 @@ public function __construct( protected function _construct() { $this->_init( - 'Magento\Review\Model\Rating\Option\Vote', - 'Magento\Review\Model\ResourceModel\Rating\Option\Vote' + \Magento\Review\Model\Rating\Option\Vote::class, + \Magento\Review\Model\ResourceModel\Rating\Option\Vote::class ); } diff --git a/app/code/Magento/Review/Model/ResourceModel/Review/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Review/Collection.php index fe84a2e5c4110..5f5737cb10d28 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Review/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Review/Collection.php @@ -110,7 +110,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Review\Model\Review', 'Magento\Review\Model\ResourceModel\Review'); + $this->_init(\Magento\Review\Model\Review::class, \Magento\Review\Model\ResourceModel\Review::class); } /** diff --git a/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php index f744f9ff88e2c..f4945508fe722 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php @@ -142,7 +142,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\Product', 'Magento\Catalog\Model\ResourceModel\Product'); + $this->_init(\Magento\Catalog\Model\Product::class, \Magento\Catalog\Model\ResourceModel\Product::class); $this->setRowIdFieldName('review_id'); $this->_reviewStoreTable = $this->_resource->getTableName('review_store'); $this->_initTables(); diff --git a/app/code/Magento/Review/Model/ResourceModel/Review/Status/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Review/Status/Collection.php index 7fe3aa79a7fa6..1d2c7fead3e6a 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Review/Status/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Review/Status/Collection.php @@ -27,7 +27,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Review\Model\Review\Status', 'Magento\Review\Model\ResourceModel\Review\Status'); + $this->_init( + \Magento\Review\Model\Review\Status::class, + \Magento\Review\Model\ResourceModel\Review\Status::class + ); } /** diff --git a/app/code/Magento/Review/Model/ResourceModel/Review/Summary/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Review/Summary/Collection.php index 85f36bae35097..478dda8a07e60 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Review/Summary/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Review/Summary/Collection.php @@ -17,7 +17,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Review\Model\Review\Summary', 'Magento\Review\Model\ResourceModel\Review\Summary'); + $this->_init( + \Magento\Review\Model\Review\Summary::class, + \Magento\Review\Model\ResourceModel\Review\Summary::class + ); } /** diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php index 5b9ab07dead65..cc9a35ac54094 100644 --- a/app/code/Magento/Review/Model/Review.php +++ b/app/code/Magento/Review/Model/Review.php @@ -161,7 +161,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Review\Model\ResourceModel\Review'); + $this->_init(\Magento\Review\Model\ResourceModel\Review::class); } /** diff --git a/app/code/Magento/Review/Model/Review/Status.php b/app/code/Magento/Review/Model/Review/Status.php index f6b5f1e13f17c..46d5e0a65cc06 100644 --- a/app/code/Magento/Review/Model/Review/Status.php +++ b/app/code/Magento/Review/Model/Review/Status.php @@ -29,6 +29,6 @@ public function __construct( array $data = [] ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_init('Magento\Review\Model\ResourceModel\Review\Status'); + $this->_init(\Magento\Review\Model\ResourceModel\Review\Status::class); } } diff --git a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/MainTest.php b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/MainTest.php index c7bee7710a4f1..e03218dd8b6d9 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/MainTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/MainTest.php @@ -33,9 +33,9 @@ class MainTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $this->customerRepository = $this - ->getMockForAbstractClass('Magento\Customer\Api\CustomerRepositoryInterface'); - $this->customerViewHelper = $this->getMock('Magento\Customer\Helper\View', [], [], '', false); - $dummyCustomer = $this->getMockForAbstractClass('Magento\Customer\Api\Data\CustomerInterface'); + ->getMockForAbstractClass(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->customerViewHelper = $this->getMock(\Magento\Customer\Helper\View::class, [], [], '', false); + $dummyCustomer = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerRepository->expects($this->once()) ->method('getById') @@ -45,7 +45,7 @@ public function testConstruct() ->method('getCustomerName') ->with($dummyCustomer) ->will($this->returnValue(new \Magento\Framework\DataObject())); - $this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface'); + $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); $this->request->expects($this->at(0)) ->method('getParam') ->with('customerId', false) @@ -57,7 +57,7 @@ public function testConstruct() $objectManagerHelper = new ObjectManagerHelper($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Review\Block\Adminhtml\Main', + \Magento\Review\Block\Adminhtml\Main::class, [ 'request' => $this->request, 'customerRepository' => $this->customerRepository, diff --git a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rating/Edit/Tab/FormTest.php b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rating/Edit/Tab/FormTest.php index 2552e1044b15c..257b8300d4a08 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rating/Edit/Tab/FormTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rating/Edit/Tab/FormTest.php @@ -96,37 +96,43 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->ratingOptionCollection = $this->getMock( - '\Magento\Review\Model\ResourceModel\Rating\Option\Collection', + \Magento\Review\Model\ResourceModel\Rating\Option\Collection::class, [], [], '', false ); $this->element = $this->getMock( - '\Magento\Framework\Data\Form\Element\Text', + \Magento\Framework\Data\Form\Element\Text::class, ['setValue', 'setIsChecked'], [], '', false ); $this->session = $this->getMock( - '\Magento\Framework\Session\Generic', + \Magento\Framework\Session\Generic::class, ['getRatingData', 'setRatingData'], [], '', false ); - $this->rating = $this->getMock('\Magento\Review\Model\Rating', ['getId', 'getRatingCodes'], [], '', false); - $this->optionRating = $this->getMock('\Magento\Review\Model\Rating\Option', [], [], '', false); - $this->store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->form = $this->getMock('\Magento\Framework\Data\Form', [], [], '', false); - $this->directoryReadInterface = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->registry = $this->getMock('\Magento\Framework\Registry'); - $this->formFactory = $this->getMock('\Magento\Framework\Data\FormFactory', [], [], '', false); - $this->optionFactory = $this->getMock('\Magento\Review\Model\Rating\OptionFactory', ['create'], [], '', false); - $this->systemStore = $this->getMock('\Magento\Store\Model\System\Store', [], [], '', false); - $this->viewFileSystem = $this->getMock('\Magento\Framework\View\FileSystem', [], [], '', false); - $this->fileSystem = $this->getMock('\Magento\Framework\Filesystem', ['getDirectoryRead'], [], '', false); + $this->rating = $this->getMock(\Magento\Review\Model\Rating::class, ['getId', 'getRatingCodes'], [], '', false); + $this->optionRating = $this->getMock(\Magento\Review\Model\Rating\Option::class, [], [], '', false); + $this->store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->form = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); + $this->directoryReadInterface = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->formFactory = $this->getMock(\Magento\Framework\Data\FormFactory::class, [], [], '', false); + $this->optionFactory = $this->getMock( + \Magento\Review\Model\Rating\OptionFactory::class, + ['create'], + [], + '', + false + ); + $this->systemStore = $this->getMock(\Magento\Store\Model\System\Store::class, [], [], '', false); + $this->viewFileSystem = $this->getMock(\Magento\Framework\View\FileSystem::class, [], [], '', false); + $this->fileSystem = $this->getMock(\Magento\Framework\Filesystem::class, ['getDirectoryRead'], [], '', false); $this->rating->expects($this->any())->method('getId')->will($this->returnValue('1')); $this->ratingOptionCollection->expects($this->any())->method('addRatingFilter')->will($this->returnSelf()); @@ -154,7 +160,7 @@ protected function setUp() $objectManagerHelper = new ObjectManagerHelper($this); $this->block = $objectManagerHelper->getObject( - 'Magento\Review\Block\Adminhtml\Rating\Edit\Tab\Form', + \Magento\Review\Block\Adminhtml\Rating\Edit\Tab\Form::class, [ 'registry' => $this->registry, 'formFactory' => $this->formFactory, diff --git a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php index 976453a03cad1..869d1506446c8 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php @@ -30,11 +30,11 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderInterface = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); + $this->urlBuilderInterface = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->link = $this->objectManagerHelper->getObject( - 'Magento\Review\Block\Adminhtml\Rss\Grid\Link', + \Magento\Review\Block\Adminhtml\Rss\Grid\Link::class, [ 'rssUrlBuilder' => $this->urlBuilderInterface ] diff --git a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php index ac68ecc99dd27..56b4181770408 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php @@ -37,12 +37,18 @@ class RssTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerInterface = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->rss = $this->getMock('Magento\Review\Model\Rss', ['__wakeUp', 'getProductCollection'], [], '', false); - $this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface'); + $this->storeManagerInterface = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->rss = $this->getMock( + \Magento\Review\Model\Rss::class, + ['__wakeUp', 'getProductCollection'], + [], + '', + false + ); + $this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->block = $this->objectManagerHelper->getObject( - 'Magento\Review\Block\Adminhtml\Rss', + \Magento\Review\Block\Adminhtml\Rss::class, [ 'storeManager' => $this->storeManagerInterface, 'rssModel' => $this->rss, @@ -73,7 +79,7 @@ public function testGetRssData() ]; $rssUrl = 'http://rss.magento.com'; $productModel = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product', + \Magento\Catalog\Model\ResourceModel\Product::class, [ 'getStoreId', 'getId', @@ -88,7 +94,7 @@ public function testGetRssData() '', false ); - $storeModel = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $storeModel = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerInterface->expects($this->once())->method('getStore')->will($this->returnValue($storeModel)); $storeModel->expects($this->once())->method('getName') ->will($this->returnValue($rssData['entries']['description']['store'])); diff --git a/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php b/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php index 482a022acfdd3..12806ab276481 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php @@ -32,8 +32,8 @@ class RecentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $this->context->expects( $this->any() )->method( @@ -42,14 +42,14 @@ protected function setUp() $this->returnValue($this->storeManager) ); $this->collection = $this->getMock( - 'Magento\Review\Model\ResourceModel\Review\Product\Collection', + \Magento\Review\Model\ResourceModel\Review\Product\Collection::class, [], [], '', false ); $this->collectionFactory = $this->getMock( - 'Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory', + \Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory::class, ['create'], [], '', @@ -63,7 +63,7 @@ protected function setUp() $this->returnValue($this->collection) ); $this->currentCustomer = $this->getMock( - 'Magento\Customer\Helper\Session\CurrentCustomer', + \Magento\Customer\Helper\Session\CurrentCustomer::class, [], [], '', @@ -72,7 +72,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->object = $this->objectManagerHelper->getObject( - 'Magento\Review\Block\Customer\Recent', + \Magento\Review\Block\Customer\Recent::class, [ 'context' => $this->context, 'collectionFactory' => $this->collectionFactory, diff --git a/app/code/Magento/Review/Test/Unit/Block/FormTest.php b/app/code/Magento/Review/Test/Unit/Block/FormTest.php index bc3d2da6d617d..3785401d5910f 100644 --- a/app/code/Magento/Review/Test/Unit/Block/FormTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/FormTest.php @@ -39,9 +39,9 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->requestMock = $this->getMock('\Magento\Framework\App\RequestInterface'); - $this->reviewDataMock = $this->getMockBuilder('\Magento\Review\Helper\Data') + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->reviewDataMock = $this->getMockBuilder(\Magento\Review\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); @@ -49,8 +49,8 @@ protected function setUp() ->method('getIsGuestAllowToWrite') ->willReturn(true); - $this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMockForAbstractClass(); - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $this->urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)->getMockForAbstractClass(); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $this->context->expects( $this->any() )->method( @@ -62,11 +62,11 @@ protected function setUp() ->method('getRequest') ->willReturn($this->requestMock); $this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder); - $this->productRepository = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface'); + $this->productRepository = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->object = $this->objectManagerHelper->getObject( - 'Magento\Review\Block\Form', + \Magento\Review\Block\Form::class, [ 'context' => $this->context, 'reviewData' => $this->reviewDataMock, @@ -93,7 +93,7 @@ public function testGetProductInfo() ->with('id', false) ->willReturn($productId); - $productMock = $this->getMock('Magento\Catalog\Api\Data\ProductInterface'); + $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); $this->productRepository->expects($this->once()) ->method('getById') ->with($productId, false, $storeId) diff --git a/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php b/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php index cc6744301082b..731145b44a316 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php @@ -74,11 +74,14 @@ protected function setUp() $this->initCollectionMocks(); $helper = new ObjectManager($this); - $this->block = $helper->getObject(ReviewBlock::class, [ - 'context' => $this->context, - 'registry' => $this->registry, - 'collectionFactory' => $this->collectionFactory, - ]); + $this->block = $helper->getObject( + ReviewBlock::class, + [ + 'context' => $this->context, + 'registry' => $this->registry, + 'collectionFactory' => $this->collectionFactory, + ] + ); } /** @@ -168,10 +171,10 @@ private function initContextMock() $this->storeManager->expects(static::any()) ->method('getStore') ->willReturn($this->store); - $this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMockForAbstractClass(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)->getMockForAbstractClass(); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMockForAbstractClass(); - $this->context = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock); diff --git a/app/code/Magento/Review/Test/Unit/Controller/Adminhtml/Product/PostTest.php b/app/code/Magento/Review/Test/Unit/Controller/Adminhtml/Product/PostTest.php index d103c4a7f43e3..e728f89265e76 100644 --- a/app/code/Magento/Review/Test/Unit/Controller/Adminhtml/Product/PostTest.php +++ b/app/code/Magento/Review/Test/Unit/Controller/Adminhtml/Product/PostTest.php @@ -79,7 +79,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $objectManagerHelper->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'request' => $this->requestMock, 'objectManager' => $this->objectManagerMock, @@ -87,7 +87,7 @@ protected function setUp() ] ); $this->postController = $objectManagerHelper->getObject( - 'Magento\Review\Controller\Adminhtml\Product\Post', + \Magento\Review\Controller\Adminhtml\Product\Post::class, [ 'reviewFactory' => $this->reviewFactoryMock, 'ratingFactory' => $this->ratingFactoryMock, @@ -102,50 +102,50 @@ protected function setUp() */ protected function _prepareMockObjects() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->storeManagerMock = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $this->storeModelMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['__wakeup', 'getId'], [], '', false ); $this->reviewMock = $this->getMock( - 'Magento\Review\Model\Review', + \Magento\Review\Model\Review::class, ['__wakeup', 'create', 'save', 'getId', 'getResource', 'aggregate'], [], '', false ); $this->reviewFactoryMock = $this->getMock( - 'Magento\Review\Model\ReviewFactory', + \Magento\Review\Model\ReviewFactory::class, ['create'], [], '', false ); $this->ratingMock = $this->getMock( - 'Magento\Review\Model\Rating', + \Magento\Review\Model\Rating::class, ['__wakeup', 'setRatingId', 'setReviewId', 'addOptionVote'], [], '', false ); $this->ratingFactoryMock = $this->getMock( - 'Magento\Review\Model\RatingFactory', + \Magento\Review\Model\RatingFactory::class, ['create'], [], '', false ); - $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $this->resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -173,7 +173,7 @@ public function testPostAction() ->willReturn(['status_id' => 1]); $this->objectManagerMock->expects($this->any()) ->method('get') - ->with('Magento\Store\Model\StoreManagerInterface') + ->with(\Magento\Store\Model\StoreManagerInterface::class) ->willReturn($this->storeManagerMock); $this->reviewFactoryMock->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php b/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php index 80f513dc81df6..211d0048a534c 100644 --- a/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php +++ b/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php @@ -10,6 +10,7 @@ /** * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PostTest extends \PHPUnit_Framework_TestCase { @@ -103,28 +104,28 @@ class PostTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->redirect = $this->getMock('\Magento\Framework\App\Response\RedirectInterface'); - $this->request = $this->getMock('\Magento\Framework\App\Request\Http', ['getParam'], [], '', false); - $this->response = $this->getMock('\Magento\Framework\App\Response\Http', ['setRedirect'], [], '', false); + $this->redirect = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, ['getParam'], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, ['setRedirect'], [], '', false); $this->formKeyValidator = $this->getMock( - 'Magento\Framework\Data\Form\FormKey\Validator', + \Magento\Framework\Data\Form\FormKey\Validator::class, ['validate'], [], '', false ); $this->reviewSession = $this->getMock( - '\Magento\Framework\Session\Generic', + \Magento\Framework\Session\Generic::class, ['getFormData', 'getRedirectUrl'], [], '', false ); - $this->eventManager = $this->getMock('\Magento\Framework\Event\ManagerInterface'); - $this->productRepository = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface'); - $this->coreRegistry = $this->getMock('\Magento\Framework\Registry'); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->productRepository = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->coreRegistry = $this->getMock(\Magento\Framework\Registry::class); $this->review = $this->getMock( - '\Magento\Review\Model\Review', + \Magento\Review\Model\Review::class, [ 'setData', 'validate', 'setEntityId', 'getEntityIdByCode', 'setEntityPkValue', 'setStatusId', 'setCustomerId', 'setStoreId', 'setStores', 'save', 'getId', 'aggregate', 'unsetData' @@ -135,7 +136,7 @@ protected function setUp() false ); $reviewFactory = $this->getMock( - '\Magento\Review\Model\ReviewFactory', + \Magento\Review\Model\ReviewFactory::class, ['create'], [], '', @@ -144,7 +145,7 @@ protected function setUp() ); $reviewFactory->expects($this->once())->method('create')->willReturn($this->review); $this->customerSession = $this->getMock( - '\Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, ['getCustomerId'], [], '', @@ -152,7 +153,7 @@ protected function setUp() false ); $this->rating = $this->getMock( - '\Magento\Review\Model\Rating', + \Magento\Review\Model\Rating::class, ['setRatingId', 'setReviewId', 'setCustomerId', 'addOptionVote'], [], '', @@ -160,7 +161,7 @@ protected function setUp() false ); $ratingFactory = $this->getMock( - '\Magento\Review\Model\RatingFactory', + \Magento\Review\Model\RatingFactory::class, ['create'], [], '', @@ -168,16 +169,16 @@ protected function setUp() false ); $ratingFactory->expects($this->once())->method('create')->willReturn($this->rating); - $this->messageManager = $this->getMock('\Magento\Framework\Message\ManagerInterface'); + $this->messageManager = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); - $this->store = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false); - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $this->store = $this->getMock(\Magento\Store\Model\Store::class, ['getId'], [], '', false); + $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects($this->any())->method('getStore')->willReturn($this->store); - $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $this->resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); @@ -188,7 +189,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $objectManagerHelper->getObject( - 'Magento\Framework\App\Action\Context', + \Magento\Framework\App\Action\Context::class, [ 'request' => $this->request, 'resultFactory' => $this->resultFactoryMock, @@ -196,7 +197,7 @@ protected function setUp() ] ); $this->model = $objectManagerHelper->getObject( - '\Magento\Review\Controller\Product\Post', + \Magento\Review\Controller\Product\Post::class, [ 'response' => $this->response, 'redirect' => $this->redirect, @@ -241,7 +242,7 @@ public function testExecute() ->with('id') ->willReturn(1); $product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['__wakeup', 'isVisibleInCatalog', 'isVisibleInSiteVisibility', 'getId'], [], '', diff --git a/app/code/Magento/Review/Test/Unit/Helper/Action/PagerTest.php b/app/code/Magento/Review/Test/Unit/Helper/Action/PagerTest.php index 48380cfc0211e..d4fd772b37ff8 100644 --- a/app/code/Magento/Review/Test/Unit/Helper/Action/PagerTest.php +++ b/app/code/Magento/Review/Test/Unit/Helper/Action/PagerTest.php @@ -16,7 +16,7 @@ class PagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $sessionMock = $this->getMockBuilder( - 'Magento\Backend\Model\Session' + \Magento\Backend\Model\Session::class )->disableOriginalConstructor()->setMethods( ['setData', 'getData'] )->getMock(); @@ -39,7 +39,7 @@ protected function setUp() ); $contextMock = $this->getMock( - 'Magento\Framework\App\Helper\Context', + \Magento\Framework\App\Helper\Context::class, ['getModuleManager', 'getRequest'], [], '', diff --git a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php index 21fedd54b9ed0..859c431ed9702 100644 --- a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php @@ -39,20 +39,20 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $store = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId'], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->objectManager = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['getConnection', 'getMainTable', 'getTable']) ->getMockForAbstractClass(); - $this->readerAdapterMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\Pdo\Mysql') + $this->readerAdapterMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->setMethods(['select', 'prepareSqlCondition', 'quoteInto']) ->getMockForAbstractClass(); - $this->selectMock = $this->getMockBuilder('\Magento\Framework\DB\Select') + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $this->readerAdapterMock->expects($this->any()) @@ -70,7 +70,7 @@ protected function setUp() return $table; }); $this->model = $this->objectManager->getObject( - '\Magento\Review\Model\ResourceModel\Review\Collection', + \Magento\Review\Model\ResourceModel\Review\Collection::class, [ 'storeManager' => $this->storeManagerMock, 'resource' => $this->resourceMock, @@ -89,7 +89,7 @@ public function testInitSelect() ['detail_id', 'title', 'detail', 'nickname', 'customer_id'] ); $this->objectManager->getObject( - '\Magento\Review\Model\ResourceModel\Review\Collection', + \Magento\Review\Model\ResourceModel\Review\Collection::class, [ 'storeManager' => $this->storeManagerMock, 'resource' => $this->resourceMock, diff --git a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Product/CollectionTest.php b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Product/CollectionTest.php index fea6fea7d8cb6..b1a1b9a69c7ff 100644 --- a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Product/CollectionTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Product/CollectionTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Review\Test\Unit\Model\ResourceModel\Review\Product; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CollectionTest extends \PHPUnit_Framework_TestCase { /** @@ -24,14 +27,14 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $attribute = $this->getMock('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', null, [], '', false); - $eavConfig = $this->getMock('\Magento\Eav\Model\Config', ['getAttribute'], [], '', false); + $attribute = $this->getMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, null, [], '', false); + $eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, ['getAttribute'], [], '', false); $eavConfig->expects($this->any())->method('getAttribute')->will($this->returnValue($attribute)); - $this->dbSelect = $this->getMock('Magento\Framework\DB\Select', ['where', 'from', 'join'], [], '', false); + $this->dbSelect = $this->getMock(\Magento\Framework\DB\Select::class, ['where', 'from', 'join'], [], '', false); $this->dbSelect->expects($this->any())->method('from')->will($this->returnSelf()); $this->dbSelect->expects($this->any())->method('join')->will($this->returnSelf()); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['prepareSqlCondition', 'select', 'quoteInto'], [], '', @@ -39,7 +42,7 @@ protected function setUp() ); $this->connectionMock->expects($this->once())->method('select')->will($this->returnValue($this->dbSelect)); $entity = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product', + \Magento\Catalog\Model\ResourceModel\Product::class, ['getConnection', 'getTable', 'getDefaultAttributes', 'getEntityTable', 'getEntityType', 'getType'], [], '', @@ -51,14 +54,20 @@ protected function setUp() $entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([1 => 1])); $entity->expects($this->any())->method('getType')->will($this->returnValue('type')); $entity->expects($this->any())->method('getEntityType')->will($this->returnValue('type')); - $universalFactory = $this->getMock('\Magento\Framework\Validator\UniversalFactory', ['create'], [], '', false); + $universalFactory = $this->getMock( + \Magento\Framework\Validator\UniversalFactory::class, + ['create'], + [], + '', + false + ); $universalFactory->expects($this->any())->method('create')->will($this->returnValue($entity)); - $store = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId'], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $fetchStrategy = $this->getMock( - '\Magento\Framework\Data\Collection\Db\FetchStrategy\Query', + \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, ['fetchAll'], [], '', @@ -67,7 +76,7 @@ protected function setUp() $fetchStrategy->expects($this->any())->method('fetchAll')->will($this->returnValue([])); $this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject( - '\Magento\Review\Model\ResourceModel\Review\Product\Collection', + \Magento\Review\Model\ResourceModel\Review\Product\Collection::class, [ 'universalFactory' => $universalFactory, 'storeManager' => $storeManager, diff --git a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Summary/CollectionTest.php b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Summary/CollectionTest.php index eae5f8c6744f0..d4c894a47348b 100644 --- a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Summary/CollectionTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/Summary/CollectionTest.php @@ -8,6 +8,9 @@ use \Magento\Review\Model\ResourceModel\Review\Summary\Collection; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CollectionTest extends \PHPUnit_Framework_TestCase { /** @@ -48,36 +51,36 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fetchStrategyMock = $this->getMock( - 'Magento\Framework\Data\Collection\Db\FetchStrategy\Query', + \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, ['fetchAll'], [], '', false ); $this->entityFactoryMock = $this->getMock( - 'Magento\Framework\Data\Collection\EntityFactory', + \Magento\Framework\Data\Collection\EntityFactory::class, ['create'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->setMethods(['getConnection', 'getMainTable', 'getTable']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->connectionMock = $this->getMock( - '\Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'query'], [], '', false ); - $selectRenderer = $this->getMockBuilder('Magento\Framework\DB\Select\SelectRenderer') + $selectRenderer = $this->getMockBuilder(\Magento\Framework\DB\Select\SelectRenderer::class) ->disableOriginalConstructor() ->getMock(); $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, ['from'], ['adapter' => $this->connectionMock, 'selectRenderer' => $selectRenderer] ); @@ -97,7 +100,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->collection = $objectManager->getObject( - 'Magento\Review\Model\ResourceModel\Review\Summary\Collection', + \Magento\Review\Model\ResourceModel\Review\Summary\Collection::class, [ 'entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, @@ -110,7 +113,7 @@ protected function setUp() public function testFetchItem() { $data = [1 => 'test']; - $statementMock = $this->getMock('Zend_Db_Statement_Pdo', ['fetch'], [], '', false); + $statementMock = $this->getMock(\Zend_Db_Statement_Pdo::class, ['fetch'], [], '', false); $statementMock->expects($this->once()) ->method('fetch') ->will($this->returnValue($data)); @@ -120,13 +123,13 @@ public function testFetchItem() ->with($this->selectMock, $this->anything()) ->will($this->returnValue($statementMock)); - $objectMock = $this->getMock('Magento\Framework\Model\AbstractModel', ['setData'], [], '', false); + $objectMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, ['setData'], [], '', false); $objectMock->expects($this->once()) ->method('setData') ->with($data); $this->entityFactoryMock->expects($this->once()) ->method('create') - ->with('Magento\Review\Model\Review\Summary') + ->with(\Magento\Review\Model\Review\Summary::class) ->will($this->returnValue($objectMock)); $item = $this->collection->fetchItem(); @@ -142,13 +145,13 @@ public function testLoad() ->with($this->selectMock, []) ->will($this->returnValue([$data])); - $objectMock = $this->getMock('Magento\Framework\DataObject', ['addData'], []); + $objectMock = $this->getMock(\Magento\Framework\DataObject::class, ['addData'], []); $objectMock->expects($this->once()) ->method('addData') ->with($data); $this->entityFactoryMock->expects($this->once()) ->method('create') - ->with('Magento\Review\Model\Review\Summary') + ->with(\Magento\Review\Model\Review\Summary::class) ->will($this->returnValue($objectMock)); $this->collection->load(); diff --git a/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php b/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php index 053510022aa35..cc92a675624c6 100644 --- a/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php @@ -11,6 +11,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ReviewTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Review\Model\Review */ @@ -54,44 +57,44 @@ class ReviewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registryMock = $this->getMock('Magento\Framework\Registry'); + $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class); $this->productFactoryMock = $this->getMock( - 'Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory', + \Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory::class, ['create'], [], '', false ); $this->statusFactoryMock = $this->getMock( - 'Magento\Review\Model\ResourceModel\Review\Status\CollectionFactory', + \Magento\Review\Model\ResourceModel\Review\Status\CollectionFactory::class, ['create'], [], '', false ); $this->reviewSummaryMock = $this->getMock( - 'Magento\Review\Model\ResourceModel\Review\Summary\CollectionFactory', + \Magento\Review\Model\ResourceModel\Review\Summary\CollectionFactory::class, [], [], '', false ); $this->summaryModMock = $this->getMock( - 'Magento\Review\Model\Review\SummaryFactory', + \Magento\Review\Model\Review\SummaryFactory::class, ['create'], [], '', false ); - $this->summaryMock = $this->getMock('Magento\Review\Model\Review\Summary', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->urlInterfaceMock = $this->getMock('Magento\Framework\UrlInterface'); - $this->resource = $this->getMock('Magento\Review\Model\ResourceModel\Review', [], [], '', false); + $this->summaryMock = $this->getMock(\Magento\Review\Model\Review\Summary::class, [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->urlInterfaceMock = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->resource = $this->getMock(\Magento\Review\Model\ResourceModel\Review::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->review = $this->objectManagerHelper->getObject( - 'Magento\Review\Model\Review', + \Magento\Review\Model\Review::class, [ 'context' => $this->contextMock, 'registry' => $this->registryMock, @@ -110,7 +113,13 @@ protected function setUp() public function testGetProductCollection() { - $collection = $this->getMock('Magento\Review\Model\ResourceModel\Review\Product\Collection', [], [], '', false); + $collection = $this->getMock( + \Magento\Review\Model\ResourceModel\Review\Product\Collection::class, + [], + [], + '', + false + ); $this->productFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($collection)); @@ -119,7 +128,13 @@ public function testGetProductCollection() public function testGetStatusCollection() { - $collection = $this->getMock('Magento\Review\Model\ResourceModel\Review\Status\Collection', [], [], '', false); + $collection = $this->getMock( + \Magento\Review\Model\ResourceModel\Review\Status\Collection::class, + [], + [], + '', + false + ); $this->statusFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($collection)); @@ -155,7 +170,7 @@ public function testGetEntitySummary() $summary->setData($testSummaryData); $product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId', 'setRatingSummary', '__wakeup'], [], '', @@ -165,7 +180,7 @@ public function testGetEntitySummary() $product->expects($this->once())->method('setRatingSummary')->with($summary)->will($this->returnSelf()); $summaryData = $this->getMock( - 'Magento\Review\Model\Review\Summary', + \Magento\Review\Model\Review\Summary::class, ['load', 'getData', 'setStoreId', '__wakeup'], [], '', @@ -239,7 +254,7 @@ public function testIsApproved() */ public function testIsAvailableOnStore($storeId, $result) { - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); if ($storeId) { $store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); $this->storeManagerMock->expects($this->once()) diff --git a/app/code/Magento/Review/Test/Unit/Model/RssTest.php b/app/code/Magento/Review/Test/Unit/Model/RssTest.php index 3005eae7bd88c..68305bc1ac9ec 100644 --- a/app/code/Magento/Review/Test/Unit/Model/RssTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/RssTest.php @@ -32,12 +32,12 @@ class RssTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->managerInterface = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->reviewFactory = $this->getMock('Magento\Review\Model\ReviewFactory', ['create'], [], '', false); + $this->managerInterface = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->reviewFactory = $this->getMock(\Magento\Review\Model\ReviewFactory::class, ['create'], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->rss = $this->objectManagerHelper->getObject( - 'Magento\Review\Model\Rss', + \Magento\Review\Model\Rss::class, [ 'eventManager' => $this->managerInterface, 'reviewFactory' => $this->reviewFactory @@ -48,7 +48,7 @@ protected function setUp() public function testGetProductCollection() { $reviewModel = $this->getMock( - 'Magento\Review\Model\Review', + \Magento\Review\Model\Review::class, [ '__wakeUp', 'getProductCollection' @@ -58,7 +58,7 @@ public function testGetProductCollection() false ); $productCollection = $this->getMock( - 'Magento\Review\Model\ResourceModel\Review\Product\Collection', + \Magento\Review\Model\ResourceModel\Review\Product\Collection::class, [ 'addStatusFilter', 'addAttributeToSelect', diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php index 160839cb13449..970fdfbaf90c7 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Comments/View.php @@ -67,7 +67,7 @@ protected function _prepareLayout() { $this->addChild( 'submit_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['id' => 'submit_comment_button', 'label' => __('Submit Comment'), 'class' => 'action-secondary save'] ); return parent::_prepareLayout(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create.php index f107247234b80..6fbf8751f0f71 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create.php @@ -90,7 +90,9 @@ protected function _construct() */ protected function _prepareLayout() { - $pageTitle = $this->getLayout()->createBlock('Magento\Sales\Block\Adminhtml\Order\Create\Header')->toHtml(); + $pageTitle = $this->getLayout()->createBlock( + \Magento\Sales\Block\Adminhtml\Order\Create\Header::class + )->toHtml(); if (is_object($this->getLayout()->getBlock('page.title'))) { $this->getLayout()->getBlock('page.title')->setPageTitle($pageTitle); } @@ -105,7 +107,7 @@ protected function _prepareLayout() public function getHeaderHtml() { $out = '
' . $this->getLayout()->createBlock( - 'Magento\Sales\Block\Adminhtml\Order\Create\Header' + \Magento\Sales\Block\Adminhtml\Order\Create\Header::class )->toHtml() . '
'; return $out; } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Customer.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Customer.php index 8bebfb5eca930..0fb776b3b0bc9 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Customer.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Customer.php @@ -46,7 +46,7 @@ public function getButtonsHtml() 'onclick' => 'order.setCustomerId(false)', 'class' => 'primary', ]; - return $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button') + return $this->getLayout()->createBlock(\Magento\Backend\Block\Widget\Button::class) ->setData($addButtonData) ->toHtml(); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php index 52dbfab429b83..465039fd2916b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php @@ -169,7 +169,7 @@ public function getOrderDataJson() foreach ($addresses as $address) { $addressForm = $this->_customerFormFactory->create( - 'customer_address', + \customer_address::class, 'adminhtml_customer_address', $this->addressMapper->toFlatArray($address) ); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php index 28f434c9cfb00..6287af52bb889 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php @@ -11,7 +11,7 @@ /** * Sales Order Create Form Abstract Block * - * @author Magento Core Team + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ abstract class AbstractForm extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate { @@ -69,19 +69,19 @@ protected function _prepareLayout() \Magento\Framework\Data\Form::setElementRenderer( $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Renderer\Element', + \Magento\Backend\Block\Widget\Form\Renderer\Element::class, $this->getNameInLayout() . '_element' ) ); \Magento\Framework\Data\Form::setFieldsetRenderer( $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Renderer\Fieldset', + \Magento\Backend\Block\Widget\Form\Renderer\Fieldset::class, $this->getNameInLayout() . '_fieldset' ) ); \Magento\Framework\Data\Form::setFieldsetElementRenderer( $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element', + \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element::class, $this->getNameInLayout() . '_fieldset_element' ) ); @@ -118,9 +118,9 @@ abstract protected function _prepareForm(); protected function _getAdditionalFormElementTypes() { return [ - 'file' => 'Magento\Customer\Block\Adminhtml\Form\Element\File', - 'image' => 'Magento\Customer\Block\Adminhtml\Form\Element\Image', - 'boolean' => 'Magento\Customer\Block\Adminhtml\Form\Element\Boolean' + 'file' => \Magento\Customer\Block\Adminhtml\Form\Element\File::class, + 'image' => \Magento\Customer\Block\Adminhtml\Form\Element\Image::class, + 'boolean' => \Magento\Customer\Block\Adminhtml\Form\Element\Boolean::class ]; } @@ -132,7 +132,9 @@ protected function _getAdditionalFormElementTypes() protected function _getAdditionalFormElementRenderers() { return [ - 'region' => $this->getLayout()->createBlock('Magento\Customer\Block\Adminhtml\Edit\Renderer\Region') + 'region' => $this->getLayout()->createBlock( + \Magento\Customer\Block\Adminhtml\Edit\Renderer\Region::class + ) ]; } @@ -195,7 +197,7 @@ protected function _addAttributesToForm($attributes, \Magento\Framework\Data\For $options[] = ConvertArray::toFlatArray( $this->dataObjectProcessor->buildOutputDataArray( $optionData, - '\Magento\Customer\Api\Data\OptionInterface' + \Magento\Customer\Api\Data\OptionInterface::class ) ); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php index 12161690c6722..59d4fb4708d29 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php @@ -16,6 +16,7 @@ * Create order account form * * @author Magento Core Team + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Account extends AbstractForm { @@ -165,7 +166,7 @@ public function getFormValues() } catch (\Exception $e) { /** If customer does not exist do nothing. */ } - $data = isset($customer) ? $this->_extensibleDataObjectConverter->toFlatArray($customer, [], '\Magento\Customer\Api\Data\CustomerInterface') : []; + $data = isset($customer) ? $this->_extensibleDataObjectConverter->toFlatArray($customer, [], \Magento\Customer\Api\Data\CustomerInterface::class) : []; foreach ($this->getQuote()->getData() as $key => $value) { if (strpos($key, 'customer_') === 0) { $data[substr($key, 9)] = $value; diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php index 4ccae8277f637..bcaca17ad3e1f 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php @@ -269,7 +269,7 @@ protected function _prepareForm() if ($vatIdElement && $this->getDisplayVatValidationButton() !== false) { $vatIdElement->setRenderer( $this->getLayout()->createBlock( - 'Magento\Customer\Block\Adminhtml\Sales\Order\Address\Form\Renderer\Vat' + \Magento\Customer\Block\Adminhtml\Sales\Order\Address\Form\Renderer\Vat::class )->setJsVariablePrefix( $this->getJsVariablePrefix() ) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php index f1ce5a90c6c68..96d7d599809d8 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Giftmessage.php @@ -61,7 +61,7 @@ public function __construct( public function getFormHtml(\Magento\Framework\DataObject $entity, $entityType = 'quote') { return $this->getLayout()->createBlock( - 'Magento\Sales\Block\Adminhtml\Order\Create\Giftmessage\Form' + \Magento\Sales\Block\Adminhtml\Order\Create\Giftmessage\Form::class )->setEntity( $entity )->setEntityType( diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items.php index cf8fff3dccd61..daf2232e5d0a1 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items.php @@ -75,7 +75,7 @@ public function getButtonsHtml() $this->_buttons = array_reverse($this->_buttons); foreach ($this->_buttons as $buttonData) { $html .= $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( $buttonData )->toHtml(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php index bb6351d533a6f..3af13c7b1ead2 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php @@ -544,7 +544,9 @@ public function getConfigureButtonHtml($item) $options['title'] = __('This product does not have any configurable options'); } - return $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button')->setData($options)->toHtml(); + return $this->getLayout()->createBlock( + \Magento\Backend\Block\Widget\Button::class + )->setData($options)->toHtml(); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search.php index 8bd77b081ac8b..0780e0a888a9c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search.php @@ -46,7 +46,7 @@ public function getButtonsHtml() 'class' => 'action-add action-secondary', ]; return $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( $addButtonData )->toHtml(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php index 114ebe3d580e1..551b1c221ecfc 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php @@ -179,7 +179,7 @@ protected function _prepareColumns() 'name', [ 'header' => __('Product'), - 'renderer' => 'Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Product', + 'renderer' => \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Product::class, 'index' => 'name' ] ); @@ -193,7 +193,7 @@ protected function _prepareColumns() 'currency_code' => $this->getStore()->getCurrentCurrencyCode(), 'rate' => $this->getStore()->getBaseCurrency()->getRate($this->getStore()->getCurrentCurrencyCode()), 'index' => 'price', - 'renderer' => 'Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Price' + 'renderer' => \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Price::class ] ); @@ -215,7 +215,7 @@ protected function _prepareColumns() 'filter' => false, 'sortable' => false, 'header' => __('Quantity'), - 'renderer' => 'Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty', + 'renderer' => \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty::class, 'name' => 'qty', 'inline_css' => 'qty', 'type' => 'input', diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar.php index 7d5a8b59fc8c4..8330f030c23d2 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar.php @@ -21,7 +21,7 @@ protected function _prepareLayout() { if ($this->getCustomerId()) { $button = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( [ 'label' => __('Update Changes'), diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php index f873f1de79712..6140cd0232c31 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php @@ -100,7 +100,7 @@ protected function _prepareLayout() $deleteAllConfirmString = __('Are you sure you want to delete all items from shopping cart?'); $this->addChild( 'empty_customer_cart_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Clear Shopping Cart'), 'onclick' => 'order.clearShoppingCart(\'' . $deleteAllConfirmString . '\')' diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php index 5e83b3d185a92..d5eee5492524b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php @@ -26,7 +26,7 @@ class Totals extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate * * @var string */ - protected $_defaultRenderer = 'Magento\Sales\Block\Adminhtml\Order\Create\Totals\DefaultTotals'; + protected $_defaultRenderer = \Magento\Sales\Block\Adminhtml\Order\Create\Totals\DefaultTotals::class; /** * Sales data diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php index 3cd0caf4da8a6..6bf91af519c08 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php @@ -52,7 +52,7 @@ protected function _prepareLayout() $onclick = "submitAndReloadArea($('creditmemo_item_container'),'" . $this->getUpdateUrl() . "')"; $this->addChild( 'update_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Update Qty\'s'), 'class' => 'update-button', 'onclick' => $onclick] ); @@ -60,7 +60,7 @@ protected function _prepareLayout() if ($this->getCreditmemo()->getInvoice() && $this->getCreditmemo()->getInvoice()->getTransactionId()) { $this->addChild( 'submit_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Refund'), 'class' => 'save submit-button refund primary', @@ -70,7 +70,7 @@ protected function _prepareLayout() } $this->addChild( 'submit_offline', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Refund Offline'), 'class' => 'save submit-button primary', @@ -80,7 +80,7 @@ protected function _prepareLayout() } else { $this->addChild( 'submit_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Refund Offline'), 'class' => 'save submit-button primary', diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/Items.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/Items.php index 4bb5c171c5c50..b07c84cb5ad4c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/Items.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/Items.php @@ -54,7 +54,7 @@ protected function _beforeToHtml() $onclick = "submitAndReloadArea($('invoice_item_container'),'" . $this->getUpdateUrl() . "')"; $this->addChild( 'update_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['class' => 'update-button', 'label' => __('Update Qty\'s'), 'onclick' => $onclick] ); $this->_disableSubmitButton = true; @@ -76,7 +76,7 @@ protected function _beforeToHtml() } $this->addChild( 'submit_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => $_submitLabel, 'class' => 'save submit-button primary' . $submitButtonClass, diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Status/NewStatus/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Status/NewStatus/Form.php index 7a963d3081e4f..6affaa2941bbe 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Status/NewStatus/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Status/NewStatus/Form.php @@ -84,7 +84,9 @@ protected function _addStoresFieldset($model, $form) 'store_labels_fieldset', ['legend' => __('Store View Specific Labels'), 'class' => 'store-scope'] ); - $renderer = $this->getLayout()->createBlock('Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset'); + $renderer = $this->getLayout()->createBlock( + \Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset::class + ); $fieldset->setRenderer($renderer); foreach ($this->_storeManager->getWebsites() as $website) { diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Giftmessage.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Giftmessage.php index 481bcd496e2fe..3f55e3b194a91 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Giftmessage.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Giftmessage.php @@ -99,7 +99,7 @@ protected function _prepareLayout() { $this->addChild( 'save_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Save Gift Message'), 'class' => 'save'] ); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/History.php index bae6e080826a4..a62dc6fa04923 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/History.php @@ -60,7 +60,7 @@ protected function _prepareLayout() { $onclick = "submitAndReloadArea($('order_history_block').parentNode, '" . $this->getSubmitUrl() . "')"; $button = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( ['label' => __('Submit Comment'), 'class' => 'action-save action-secondary', 'onclick' => $onclick] ); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form.php index 2ac78bf1ee539..8929ad64899d8 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form.php @@ -89,7 +89,7 @@ protected function _prepareForm() $this->setChild( 'form_after', $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Element\Dependence' + \Magento\Backend\Block\Widget\Form\Element\Dependence::class )->addFieldMap( "{$htmlIdPrefix}show_order_statuses", 'show_order_statuses' diff --git a/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php b/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php index 57eeba3b351e2..4228e2b6734fc 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Report/Filter/Form/Coupon.php @@ -115,7 +115,7 @@ protected function _afterToHtml($html) */ /** @var $formAfterBlock \Magento\Backend\Block\Widget\Form\Element\Dependence */ $formAfterBlock = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Element\Dependence', + \Magento\Backend\Block\Widget\Form\Element\Dependence::class, 'adminhtml.block.widget.form.element.dependence' ); $formAfterBlock->addFieldMap( diff --git a/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php b/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php index bb59c8a488156..f2e189f51e9d2 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php +++ b/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php @@ -91,7 +91,7 @@ protected function _getFieldRenderer() { if (empty($this->_fieldRenderer)) { $this->_fieldRenderer = $this->getLayout()->getBlockSingleton( - 'Magento\Config\Block\System\Config\Form\Field' + \Magento\Config\Block\System\Config\Form\Field::class ); } return $this->_fieldRenderer; diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index 683234666262a..3e24324cf859b 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -95,7 +95,7 @@ protected function _prepareLayout() parent::_prepareLayout(); if ($this->getOrders()) { $pager = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager', + \Magento\Theme\Block\Html\Pager::class, 'sales.order.history.pager' )->setCollection( $this->getOrders() diff --git a/app/code/Magento/Sales/Block/Widget/Guest/Form.php b/app/code/Magento/Sales/Block/Widget/Guest/Form.php index 358559ab27531..ce32e669eff5b 100644 --- a/app/code/Magento/Sales/Block/Widget/Guest/Form.php +++ b/app/code/Magento/Sales/Block/Widget/Guest/Form.php @@ -51,7 +51,7 @@ public function isEnable() public function getTypeSelectHtml() { $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' + \Magento\Framework\View\Element\Html\Select::class )->setData( ['id' => 'quick_search_type_id', 'class' => 'select guest-select'] )->setName( diff --git a/app/code/Magento/Sales/Controller/AbstractController/PrintCreditmemo.php b/app/code/Magento/Sales/Controller/AbstractController/PrintCreditmemo.php index 3b530b00ad5d7..4b09d3766527b 100644 --- a/app/code/Magento/Sales/Controller/AbstractController/PrintCreditmemo.php +++ b/app/code/Magento/Sales/Controller/AbstractController/PrintCreditmemo.php @@ -66,7 +66,7 @@ public function execute() $order = $creditmemo->getOrder(); } else { $orderId = (int)$this->getRequest()->getParam('order_id'); - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); } if ($this->orderAuthorization->canView($order)) { @@ -81,7 +81,7 @@ public function execute() } else { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); - if ($this->_objectManager->get('Magento\Customer\Model\Session')->isLoggedIn()) { + if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { $resultRedirect->setPath('*/*/history'); } else { $resultRedirect->setPath('sales/guest/form'); diff --git a/app/code/Magento/Sales/Controller/AbstractController/PrintInvoice.php b/app/code/Magento/Sales/Controller/AbstractController/PrintInvoice.php index 62e9bc32e124c..7b48f392df7fe 100644 --- a/app/code/Magento/Sales/Controller/AbstractController/PrintInvoice.php +++ b/app/code/Magento/Sales/Controller/AbstractController/PrintInvoice.php @@ -53,11 +53,13 @@ public function execute() { $invoiceId = (int)$this->getRequest()->getParam('invoice_id'); if ($invoiceId) { - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); + $invoice = $this->_objectManager->create( + \Magento\Sales\Api\InvoiceRepositoryInterface::class + )->get($invoiceId); $order = $invoice->getOrder(); } else { $orderId = (int)$this->getRequest()->getParam('order_id'); - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); } if ($this->orderAuthorization->canView($order)) { @@ -72,7 +74,7 @@ public function execute() } else { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); - if ($this->_objectManager->get('Magento\Customer\Model\Session')->isLoggedIn()) { + if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { $resultRedirect->setPath('*/*/history'); } else { $resultRedirect->setPath('sales/guest/form'); diff --git a/app/code/Magento/Sales/Controller/AbstractController/PrintShipment.php b/app/code/Magento/Sales/Controller/AbstractController/PrintShipment.php index 804026f5434df..13723815a0099 100644 --- a/app/code/Magento/Sales/Controller/AbstractController/PrintShipment.php +++ b/app/code/Magento/Sales/Controller/AbstractController/PrintShipment.php @@ -53,11 +53,11 @@ public function execute() { $shipmentId = (int)$this->getRequest()->getParam('shipment_id'); if ($shipmentId) { - $shipment = $this->_objectManager->create('Magento\Sales\Model\Order\Shipment')->load($shipmentId); + $shipment = $this->_objectManager->create(\Magento\Sales\Model\Order\Shipment::class)->load($shipmentId); $order = $shipment->getOrder(); } else { $orderId = (int)$this->getRequest()->getParam('order_id'); - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); } if ($this->orderAuthorization->canView($order)) { $this->_coreRegistry->register('current_order', $order); @@ -71,7 +71,7 @@ public function execute() } else { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); - if ($this->_objectManager->get('Magento\Customer\Model\Session')->isLoggedIn()) { + if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { $resultRedirect->setPath('*/*/history'); } else { $resultRedirect->setPath('sales/guest/form'); diff --git a/app/code/Magento/Sales/Controller/AbstractController/Reorder.php b/app/code/Magento/Sales/Controller/AbstractController/Reorder.php index d983c41d1d29e..d00dc5c7aee2e 100644 --- a/app/code/Magento/Sales/Controller/AbstractController/Reorder.php +++ b/app/code/Magento/Sales/Controller/AbstractController/Reorder.php @@ -52,13 +52,13 @@ public function execute() $resultRedirect = $this->resultRedirectFactory->create(); /* @var $cart \Magento\Checkout\Model\Cart */ - $cart = $this->_objectManager->get('Magento\Checkout\Model\Cart'); + $cart = $this->_objectManager->get(\Magento\Checkout\Model\Cart::class); $items = $order->getItemsCollection(); foreach ($items as $item) { try { $cart->addOrderItem($item); } catch (\Magento\Framework\Exception\LocalizedException $e) { - if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getUseNotice(true)) { + if ($this->_objectManager->get(\Magento\Checkout\Model\Session::class)->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); } else { $this->messageManager->addError($e->getMessage()); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php index c617c063a925a..c5530787b2d71 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php @@ -30,7 +30,7 @@ public function execute() if (!$creditmemoId) { return; } - $this->_objectManager->create('Magento\Sales\Api\CreditmemoManagementInterface') + $this->_objectManager->create(\Magento\Sales\Api\CreditmemoManagementInterface::class) ->notify($creditmemoId); $this->messageManager->addSuccess(__('You sent the message.')); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/PrintAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/PrintAction.php index 0d20b57cad262..390dca8e84091 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/PrintAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/PrintAction.php @@ -62,13 +62,15 @@ public function execute() $creditmemo = $this->creditmemoRepository->get($creditmemoId); if ($creditmemo) { $pdf = $this->_objectManager->create( - 'Magento\Sales\Model\Order\Pdf\Creditmemo' + \Magento\Sales\Model\Order\Pdf\Creditmemo::class )->getPdf( [$creditmemo] ); - $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get( + \Magento\Framework\Stdlib\DateTime\DateTime::class + )->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( - 'creditmemo' . $date . '.pdf', + \creditmemo::class . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf' diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php index b1c393512115d..f02962dcffcdc 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php @@ -48,12 +48,14 @@ public function execute() if (!$invoiceId) { return $this->resultForwardFactory->create()->forward('noroute'); } - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); + $invoice = $this->_objectManager->create(\Magento\Sales\Api\InvoiceRepositoryInterface::class)->get($invoiceId); if (!$invoice) { return $this->resultForwardFactory->create()->forward('noroute'); } - $this->_objectManager->create('Magento\Sales\Api\InvoiceManagementInterface')->notify($invoice->getEntityId()); + $this->_objectManager->create( + \Magento\Sales\Api\InvoiceManagementInterface::class + )->notify($invoice->getEntityId()); $this->messageManager->addSuccess(__('You sent the message.')); return $this->resultRedirectFactory->create()->setPath( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/PrintAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/PrintAction.php index 2c7b73cc1c4f9..40166cc232439 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/PrintAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/PrintAction.php @@ -50,10 +50,14 @@ public function execute() { $invoiceId = $this->getRequest()->getParam('invoice_id'); if ($invoiceId) { - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); + $invoice = $this->_objectManager->create( + \Magento\Sales\Api\InvoiceRepositoryInterface::class + )->get($invoiceId); if ($invoice) { - $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')->getPdf([$invoice]); - $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); + $pdf = $this->_objectManager->create(\Magento\Sales\Model\Order\Pdf\Invoice::class)->getPdf([$invoice]); + $date = $this->_objectManager->get( + \Magento\Framework\Stdlib\DateTime\DateTime::class + )->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'invoice' . $date . '.pdf', $pdf->render(), diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php index 25fb917184b32..3c887837ca289 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php @@ -71,7 +71,7 @@ protected function getInvoice() return false; } /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); + $invoice = $this->_objectManager->create(\Magento\Sales\Api\InvoiceRepositoryInterface::class)->get($invoiceId); if (!$invoice) { return false; } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php index 4c56548317cb9..c9acb6fe3c011 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php @@ -46,7 +46,7 @@ public function execute() $order->save(); /** @var OrderCommentSender $orderCommentSender */ $orderCommentSender = $this->_objectManager - ->create('Magento\Sales\Model\Order\Email\Sender\OrderCommentSender'); + ->create(\Magento\Sales\Model\Order\Email\Sender\OrderCommentSender::class); $orderCommentSender->send($order, $notify, $comment); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Address.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Address.php index 4b41c40afad68..ca4e0f66d6cdb 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Address.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Address.php @@ -23,7 +23,7 @@ class Address extends \Magento\Sales\Controller\Adminhtml\Order public function execute() { $addressId = $this->getRequest()->getParam('address_id'); - $address = $this->_objectManager->create('Magento\Sales\Model\Order\Address')->load($addressId); + $address = $this->_objectManager->create(\Magento\Sales\Model\Order\Address::class)->load($addressId); if ($address->getId()) { $this->_coreRegistry->register('order_address', $address); $resultPage = $this->resultPageFactory->create(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php index 7192863804178..9beb5fa8bc6c0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php @@ -24,7 +24,9 @@ public function execute() { $addressId = $this->getRequest()->getParam('address_id'); /** @var $address \Magento\Sales\Api\Data\OrderAddressInterface|\Magento\Sales\Model\Order\Address */ - $address = $this->_objectManager->create('Magento\Sales\Api\Data\OrderAddressInterface')->load($addressId); + $address = $this->_objectManager->create( + \Magento\Sales\Api\Data\OrderAddressInterface::class + )->load($addressId); $data = $this->getRequest()->getPostValue(); $resultRedirect = $this->resultRedirectFactory->create(); if ($data && $address->getId()) { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php index c752e9691b461..d3cd1b9ac756b 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php @@ -36,7 +36,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('You have not canceled the item.')); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } return $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php index 011a2daf0675a..7069a9da1b477 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php @@ -78,7 +78,7 @@ public function execute() { $this->_initOrder(); $layout = $this->layoutFactory->create(); - $html = $layout->createBlock('Magento\Sales\Block\Adminhtml\Order\View\Tab\History') + $html = $layout->createBlock(\Magento\Sales\Block\Adminhtml\Order\View\Tab\History::class) ->toHtml(); $this->_translateInline->processResponseBody($html); /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php index 1fb983e3228ba..a926545c76900 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php @@ -60,7 +60,7 @@ public function __construct( */ protected function _getSession() { - return $this->_objectManager->get('Magento\Backend\Model\Session\Quote'); + return $this->_objectManager->get(\Magento\Backend\Model\Session\Quote::class); } /** @@ -80,7 +80,7 @@ protected function _getQuote() */ protected function _getOrderCreateModel() { - return $this->_objectManager->get('Magento\Sales\Model\AdminOrder\Create'); + return $this->_objectManager->get(\Magento\Sales\Model\AdminOrder\Create::class); } /** @@ -90,7 +90,7 @@ protected function _getOrderCreateModel() */ protected function _getGiftmessageSaveModel() { - return $this->_objectManager->get('Magento\GiftMessage\Model\Save'); + return $this->_objectManager->get(\Magento\GiftMessage\Model\Save::class); } /** @@ -285,7 +285,7 @@ protected function _processActionData($action = null) */ if ($data = $this->getRequest()->getPost('add_products')) { $this->_getGiftmessageSaveModel()->importAllowQuoteItemsFromProducts( - $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonDecode($data) + $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonDecode($data) ); } @@ -344,7 +344,7 @@ protected function _processActionData($action = null) protected function _processFiles($items) { /* @var $productHelper \Magento\Catalog\Helper\Product */ - $productHelper = $this->_objectManager->get('Magento\Catalog\Helper\Product'); + $productHelper = $this->_objectManager->get(\Magento\Catalog\Helper\Product::class); foreach ($items as $id => $item) { $buyRequest = new \Magento\Framework\DataObject($item); $params = ['files_prefix' => 'item_' . $id . '_']; diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/AddConfigured.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/AddConfigured.php index bad9ff3e859fe..bd526a8e62638 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/AddConfigured.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/AddConfigured.php @@ -32,7 +32,7 @@ public function execute() } $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname')); - $this->_objectManager->get('Magento\Backend\Model\Session')->setCompositeProductResult($updateResult); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setCompositeProductResult($updateResult); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('catalog/product/showUpdateResult'); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureProductToAdd.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureProductToAdd.php index d778ef46860e5..607b34d8bea8b 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureProductToAdd.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureProductToAdd.php @@ -20,13 +20,13 @@ public function execute() $configureResult = new \Magento\Framework\DataObject(); $configureResult->setOk(true); $configureResult->setProductId($productId); - $sessionQuote = $this->_objectManager->get('Magento\Backend\Model\Session\Quote'); + $sessionQuote = $this->_objectManager->get(\Magento\Backend\Model\Session\Quote::class); $configureResult->setCurrentStoreId($sessionQuote->getStore()->getId()); $configureResult->setCurrentCustomerId($sessionQuote->getCustomerId()); // Render page /** @var \Magento\Catalog\Helper\Product\Composite $helper */ - $helper = $this->_objectManager->get('Magento\Catalog\Helper\Product\Composite'); + $helper = $this->_objectManager->get(\Magento\Catalog\Helper\Product\Composite::class); return $helper->renderConfigureResult($configureResult); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureQuoteItems.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureQuoteItems.php index cf035dd247b6f..b687d4ffc7e02 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureQuoteItems.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ConfigureQuoteItems.php @@ -22,13 +22,13 @@ public function execute() throw new \Magento\Framework\Exception\LocalizedException(__('Quote item id is not received.')); } - $quoteItem = $this->_objectManager->create('Magento\Quote\Model\Quote\Item')->load($quoteItemId); + $quoteItem = $this->_objectManager->create(\Magento\Quote\Model\Quote\Item::class)->load($quoteItemId); if (!$quoteItem->getId()) { throw new \Magento\Framework\Exception\LocalizedException(__('Quote item is not loaded.')); } $configureResult->setOk(true); - $optionCollection = $this->_objectManager->create('Magento\Quote\Model\Quote\Item\Option') + $optionCollection = $this->_objectManager->create(\Magento\Quote\Model\Quote\Item\Option::class) ->getCollection() ->addItemFilter([$quoteItemId]); $quoteItem->setOptions($optionCollection->getOptionsByItem($quoteItem)); @@ -36,7 +36,7 @@ public function execute() $configureResult->setBuyRequest($quoteItem->getBuyRequest()); $configureResult->setCurrentStoreId($quoteItem->getStoreId()); $configureResult->setProductId($quoteItem->getProductId()); - $sessionQuote = $this->_objectManager->get('Magento\Backend\Model\Session\Quote'); + $sessionQuote = $this->_objectManager->get(\Magento\Backend\Model\Session\Quote::class); $configureResult->setCurrentCustomerId($sessionQuote->getCustomerId()); } catch (\Exception $e) { $configureResult->setError(true); @@ -45,7 +45,7 @@ public function execute() // Render page /** @var \Magento\Catalog\Helper\Product\Composite $helper */ - $helper = $this->_objectManager->get('Magento\Catalog\Helper\Product\Composite'); + $helper = $this->_objectManager->get(\Magento\Catalog\Helper\Product\Composite::class); return $helper->renderConfigureResult($configureResult); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php index 0962dd48c7aa1..7a9cf105d24b4 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php @@ -85,7 +85,7 @@ public function execute() $result = $resultPage->getLayout()->renderElement('content'); if ($request->getParam('as_js_varname')) { - $this->_objectManager->get('Magento\Backend\Model\Session')->setUpdateResult($result); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setUpdateResult($result); return $this->resultRedirectFactory->create()->setPath('sales/*/showUpdateResult'); } return $this->resultRawFactory->create()->setContents($result); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php index 741072ba445ea..fca730c899fc5 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php @@ -14,8 +14,8 @@ public function execute() { $this->_getSession()->clearStorage(); $orderId = $this->getRequest()->getParam('order_id'); - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); - if (!$this->_objectManager->get('Magento\Sales\Helper\Reorder')->canReorder($order->getEntityId())) { + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); + if (!$this->_objectManager->get(\Magento\Sales\Helper\Reorder::class)->canReorder($order->getEntityId())) { return $this->resultForwardFactory->create()->forward('noroute'); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php index 5c06f2061dd91..9a8297e2145b5 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php @@ -53,7 +53,7 @@ public function execute() { /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultRawFactory->create(); - $session = $this->_objectManager->get('Magento\Backend\Model\Session'); + $session = $this->_objectManager->get(\Magento\Backend\Model\Session::class); if ($session->hasUpdateResult() && is_scalar($session->getUpdateResult())) { $resultRaw->setContents($session->getUpdateResult()); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php index 55db1f89dc4ee..9b37f408d19db 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php @@ -44,7 +44,7 @@ public function execute() if ($creditmemoId) { try { $creditmemoManagement = $this->_objectManager->create( - 'Magento\Sales\Api\CreditmemoManagementInterface' + \Magento\Sales\Api\CreditmemoManagementInterface::class ); $creditmemoManagement->cancel($creditmemoId); $this->messageManager->addSuccess(__('The credit memo has been canceled.')); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php index 2181cf7c0af0b..54258015cbcf9 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php @@ -62,7 +62,7 @@ public function execute() $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { - if ($comment = $this->_objectManager->get('Magento\Backend\Model\Session')->getCommentText(true)) { + if ($comment = $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getCommentText(true)) { $creditmemo->setCommentText($comment); } $resultPage = $this->resultPageFactory->create(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php index 0c5745b2e6d78..e55d1e6bfe869 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php @@ -100,7 +100,7 @@ public function execute() } } $creditmemoManagement = $this->_objectManager->create( - 'Magento\Sales\Api\CreditmemoManagementInterface' + \Magento\Sales\Api\CreditmemoManagementInterface::class ); $creditmemoManagement->refund($creditmemo, (bool)$data['do_offline'], !empty($data['send_email'])); @@ -121,7 +121,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); $this->_getSession()->setFormData($data); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addError(__('We can\'t save the credit memo right now.')); } $resultRedirect->setPath('sales/*/new', ['_current' => true]); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php index 98c0b386d30af..31b92f7a18258 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php @@ -56,7 +56,7 @@ public function execute() if ($creditmemo) { try { $creditmemo->void(); - $transactionSave = $this->_objectManager->create('Magento\Framework\DB\Transaction'); + $transactionSave = $this->_objectManager->create(\Magento\Framework\DB\Transaction::class); $transactionSave->addObject($creditmemo); $transactionSave->addObject($creditmemo->getOrder()); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit/Start.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit/Start.php index 578a25006881d..f730d3604f9e9 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit/Start.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Edit/Start.php @@ -23,7 +23,7 @@ public function execute() { $this->_getSession()->clearStorage(); $orderId = $this->getRequest()->getParam('order_id'); - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php index 493030d703034..85a06125e9952 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php @@ -25,7 +25,7 @@ public function execute() $invoice->cancel(); $invoice->getOrder()->setIsInProcess(true); $this->_objectManager->create( - 'Magento\Framework\DB\Transaction' + \Magento\Framework\DB\Transaction::class )->addObject( $invoice )->addObject( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php index 2cbb4a446e480..5ad2788da08be 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php @@ -23,11 +23,11 @@ public function execute() return $resultForward; } try { - $invoiceManagement = $this->_objectManager->get('Magento\Sales\Api\InvoiceManagementInterface'); + $invoiceManagement = $this->_objectManager->get(\Magento\Sales\Api\InvoiceManagementInterface::class); $invoiceManagement->setCapture($invoice->getEntityId()); $invoice->getOrder()->setIsInProcess(true); $this->_objectManager->create( - 'Magento\Framework\DB\Transaction' + \Magento\Framework\DB\Transaction::class )->addObject( $invoice )->addObject( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php index d152d0cf9200a..30d9a7a0448cb 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php @@ -80,7 +80,7 @@ public function execute() try { /** @var \Magento\Sales\Model\Order $order */ - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); if (!$order->getId()) { throw new \Magento\Framework\Exception\LocalizedException(__('The order no longer exists.')); } @@ -99,7 +99,7 @@ public function execute() } $this->registry->register('current_invoice', $invoice); - $comment = $this->_objectManager->get('Magento\Backend\Model\Session')->getCommentText(true); + $comment = $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getCommentText(true); if ($comment) { $invoice->setCommentText($comment); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php index 70dea5a7d1274..90c755cc99f4d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php @@ -125,14 +125,14 @@ public function execute() $orderId = $this->getRequest()->getParam('order_id'); if (!empty($data['comment_text'])) { - $this->_objectManager->get('Magento\Backend\Model\Session')->setCommentText($data['comment_text']); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setCommentText($data['comment_text']); } try { $invoiceData = $this->getRequest()->getParam('invoice', []); $invoiceItems = isset($invoiceData['items']) ? $invoiceData['items'] : []; /** @var \Magento\Sales\Model\Order $order */ - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); if (!$order->getId()) { throw new \Magento\Framework\Exception\LocalizedException(__('The order no longer exists.')); } @@ -176,7 +176,7 @@ public function execute() $invoice->getOrder()->setIsInProcess(true); $transactionSave = $this->_objectManager->create( - 'Magento\Framework\DB\Transaction' + \Magento\Framework\DB\Transaction::class )->addObject( $invoice )->addObject( @@ -210,7 +210,7 @@ public function execute() $this->invoiceSender->send($invoice); } } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addError(__('We can\'t send the invoice email right now.')); } if ($shipment) { @@ -219,17 +219,17 @@ public function execute() $this->shipmentSender->send($shipment); } } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addError(__('We can\'t send the shipment right now.')); } } - $this->_objectManager->get('Magento\Backend\Model\Session')->getCommentText(true); + $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getCommentText(true); return $resultRedirect->setPath('sales/order/view', ['order_id' => $orderId]); } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t save the invoice right now.')); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } return $resultRedirect->setPath('sales/*/new', ['order_id' => $orderId]); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php index 4017dbeeba929..f1bb78a07a453 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php @@ -78,7 +78,7 @@ public function execute() $invoiceData = $this->getRequest()->getParam('invoice', []); $invoiceItems = isset($invoiceData['items']) ? $invoiceData['items'] : []; /** @var \Magento\Sales\Model\Order $order */ - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); + $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); if (!$order->getId()) { throw new \Magento\Framework\Exception\LocalizedException(__('The order no longer exists.')); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php index b7ad522dc9e51..d65012c4eeee7 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php @@ -23,12 +23,12 @@ public function execute() } try { /** @var \Magento\Sales\Api\InvoiceManagementInterface $invoiceManagement */ - $invoiceManagement = $this->_objectManager->get('Magento\Sales\Api\InvoiceManagementInterface'); + $invoiceManagement = $this->_objectManager->get(\Magento\Sales\Api\InvoiceManagementInterface::class); $invoiceManagement->setVoid($invoice->getEntityId()); $invoice->getOrder()->setIsInProcess(true); $this->_objectManager->create( - 'Magento\Framework\DB\Transaction' + \Magento\Framework\DB\Transaction::class )->addObject( $invoice )->addObject( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php index fd9412b15ee8e..3b93f0533b9dc 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status.php @@ -45,7 +45,7 @@ protected function _initStatus() { $statusCode = $this->getRequest()->getParam('status'); if ($statusCode) { - $status = $this->_objectManager->create('Magento\Sales\Model\Order\Status')->load($statusCode); + $status = $this->_objectManager->create(\Magento\Sales\Model\Order\Status::class)->load($statusCode); } else { $status = false; } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/NewAction.php index 521054db8cca4..46b898fe93cea 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/NewAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/NewAction.php @@ -40,7 +40,7 @@ public function execute() { $data = $this->_getSession()->getFormData(true); if ($data) { - $status = $this->_objectManager->create('Magento\Sales\Model\Order\Status')->setData($data); + $status = $this->_objectManager->create(\Magento\Sales\Model\Order\Status::class)->setData($data); $this->_coreRegistry->register('current_status', $status); } /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php index 6e81434275856..d4d38e9a293be 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php @@ -24,7 +24,7 @@ public function execute() //filter tags in labels/status /** @var $filterManager \Magento\Framework\Filter\FilterManager */ - $filterManager = $this->_objectManager->get('Magento\Framework\Filter\FilterManager'); + $filterManager = $this->_objectManager->get(\Magento\Framework\Filter\FilterManager::class); if ($isNew) { $statusCode = $data['status'] = $filterManager->stripTags($data['status']); } @@ -33,7 +33,7 @@ public function execute() $label = $filterManager->stripTags($label); } - $status = $this->_objectManager->create('Magento\Sales\Model\Order\Status')->load($statusCode); + $status = $this->_objectManager->create(\Magento\Sales\Model\Order\Status::class)->load($statusCode); // check if status exist if ($isNew && $status->getStatus()) { $this->messageManager->addError(__('We found another order status with the same order status code.')); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php index 93c7c1986fc36..abbdbf004cd06 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/View/Giftmessage.php @@ -19,6 +19,6 @@ abstract class Giftmessage extends \Magento\Backend\App\Action */ protected function _getGiftmessageSaveModel() { - return $this->_objectManager->get('Magento\GiftMessage\Model\Save'); + return $this->_objectManager->get(\Magento\GiftMessage\Model\Save::class); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/VoidPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/VoidPayment.php index 86c82dd4288ba..6eb576c45c14f 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/VoidPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/VoidPayment.php @@ -26,7 +26,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t void the payment right now.')); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } $resultRedirect->setPath('sales/*/view', ['order_id' => $order->getId()]); return $resultRedirect; diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php index 12ffc047c3044..8d8f0aa580a53 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php @@ -53,16 +53,18 @@ public function execute() { $shipmentId = $this->getRequest()->getParam('shipment_id'); if ($shipmentId) { - $shipment = $this->_objectManager->create('Magento\Sales\Model\Order\Shipment')->load($shipmentId); + $shipment = $this->_objectManager->create(\Magento\Sales\Model\Order\Shipment::class)->load($shipmentId); if ($shipment) { $pdf = $this->_objectManager->create( - 'Magento\Sales\Model\Order\Pdf\Shipment' + \Magento\Sales\Model\Order\Pdf\Shipment::class )->getPdf( [$shipment] ); - $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get( + \Magento\Framework\Stdlib\DateTime\DateTime::class + )->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( - 'packingslip' . $date . '.pdf', + \packingslip::class . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf' diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php b/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php index 044ad4bd8726d..21587ed780eed 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Transactions.php @@ -76,7 +76,7 @@ public function __construct( protected function _initTransaction() { $txn = $this->_objectManager->create( - 'Magento\Sales\Model\Order\Payment\Transaction' + \Magento\Sales\Model\Order\Payment\Transaction::class )->load( $this->getRequest()->getParam('txn_id') ); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Fetch.php b/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Fetch.php index 56b1b73643207..0f41761d0a5b1 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Fetch.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Fetch.php @@ -40,7 +40,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t update the transaction details.')); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } return $resultRedirect->setPath('sales/transactions/view', ['_current' => true]); diff --git a/app/code/Magento/Sales/Controller/Download/DownloadCustomOption.php b/app/code/Magento/Sales/Controller/Download/DownloadCustomOption.php index 77ec234e00dd9..8ed0c705d5776 100644 --- a/app/code/Magento/Sales/Controller/Download/DownloadCustomOption.php +++ b/app/code/Magento/Sales/Controller/Download/DownloadCustomOption.php @@ -58,7 +58,9 @@ public function execute() { $quoteItemOptionId = $this->getRequest()->getParam('id'); /** @var $option \Magento\Quote\Model\Quote\Item\Option */ - $option = $this->_objectManager->create('Magento\Quote\Model\Quote\Item\Option')->load($quoteItemOptionId); + $option = $this->_objectManager->create( + \Magento\Quote\Model\Quote\Item\Option::class + )->load($quoteItemOptionId); /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); @@ -76,7 +78,9 @@ public function execute() $productOption = null; if ($optionId) { /** @var $productOption \Magento\Catalog\Model\Product\Option */ - $productOption = $this->_objectManager->create('Magento\Catalog\Model\Product\Option')->load($optionId); + $productOption = $this->_objectManager->create( + \Magento\Catalog\Model\Product\Option::class + )->load($optionId); } if (!$productOption || !$productOption->getId() || diff --git a/app/code/Magento/Sales/Controller/Guest/Form.php b/app/code/Magento/Sales/Controller/Guest/Form.php index 6cbc789707931..20e512c0aa131 100644 --- a/app/code/Magento/Sales/Controller/Guest/Form.php +++ b/app/code/Magento/Sales/Controller/Guest/Form.php @@ -32,12 +32,12 @@ public function __construct( */ public function execute() { - if ($this->_objectManager->get('Magento\Customer\Model\Session')->isLoggedIn()) { + if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { return $this->resultRedirectFactory->create()->setPath('customer/account/'); } $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->set(__('Orders and Returns')); - $this->_objectManager->get('Magento\Sales\Helper\Guest')->getBreadcrumbs($resultPage); + $this->_objectManager->get(\Magento\Sales\Helper\Guest::class)->getBreadcrumbs($resultPage); return $resultPage; } } diff --git a/app/code/Magento/Sales/Controller/Guest/PrintInvoice.php b/app/code/Magento/Sales/Controller/Guest/PrintInvoice.php index 9fa19adfb0e1f..21e84d5577ebf 100644 --- a/app/code/Magento/Sales/Controller/Guest/PrintInvoice.php +++ b/app/code/Magento/Sales/Controller/Guest/PrintInvoice.php @@ -51,7 +51,9 @@ public function execute() $invoiceId = (int)$this->getRequest()->getParam('invoice_id'); if ($invoiceId) { - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); + $invoice = $this->_objectManager->create( + \Magento\Sales\Api\InvoiceRepositoryInterface::class + )->get($invoiceId); $order = $invoice->getOrder(); } else { $order = $this->_coreRegistry->registry('current_order'); diff --git a/app/code/Magento/Sales/Controller/Guest/PrintShipment.php b/app/code/Magento/Sales/Controller/Guest/PrintShipment.php index 13ed5b0c8ca48..c87b6c11007c0 100644 --- a/app/code/Magento/Sales/Controller/Guest/PrintShipment.php +++ b/app/code/Magento/Sales/Controller/Guest/PrintShipment.php @@ -51,7 +51,7 @@ public function execute() $shipmentId = (int)$this->getRequest()->getParam('shipment_id'); if ($shipmentId) { - $shipment = $this->_objectManager->create('Magento\Sales\Model\Order\Shipment')->load($shipmentId); + $shipment = $this->_objectManager->create(\Magento\Sales\Model\Order\Shipment::class)->load($shipmentId); $order = $shipment->getOrder(); } else { $order = $this->_coreRegistry->registry('current_order'); diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 0bf781111fa10..52c5c5bf2c75a 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -567,7 +567,7 @@ protected function _initBillingAddressFromOrder(\Magento\Sales\Model\Order $orde { $this->getQuote()->getBillingAddress()->setCustomerAddressId(''); $this->_objectCopyService->copyFieldsetToTarget( - 'sales_copy_order_billing_address', + \sales_copy_order_billing_address::class, 'to_order', $order->getBillingAddress(), $this->getQuote()->getBillingAddress() @@ -589,7 +589,7 @@ protected function _initShippingAddressFromOrder(\Magento\Sales\Model\Order $ord $orderShippingAddress && $orderShippingAddress->getSameAsBilling() ); $this->_objectCopyService->copyFieldsetToTarget( - 'sales_copy_order_shipping_address', + \sales_copy_order_shipping_address::class, 'to_order', $orderShippingAddress, $quoteShippingAddress @@ -610,7 +610,7 @@ public function initFromOrderItem(\Magento\Sales\Model\Order\Item $orderItem, $q } $product = $this->_objectManager->create( - 'Magento\Catalog\Model\Product' + \Magento\Catalog\Model\Product::class )->setStoreId( $this->getSession()->getStoreId() )->load( @@ -664,7 +664,7 @@ public function getCustomerWishlist($cacheReload = false) $customerId = (int)$this->getSession()->getCustomerId(); if ($customerId) { - $this->_wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist'); + $this->_wishlist = $this->_objectManager->create(\Magento\Wishlist\Model\Wishlist::class); $this->_wishlist->loadByCustomerId($customerId, true); $this->_wishlist->setStore( $this->getSession()->getStore() @@ -718,7 +718,8 @@ public function getCustomerCompareList() } $customerId = (int)$this->getSession()->getCustomerId(); if ($customerId) { - $this->_compareList = $this->_objectManager->create('Magento\Catalog\Model\Product\Compare\ListCompare'); + $this->_compareList = $this->_objectManager->create( + \Magento\Catalog\Model\Product\Compare\ListCompare::class); } else { $this->_compareList = false; } @@ -764,7 +765,7 @@ public function moveQuoteItem($item, $moveTo, $qty) $info->setOptions($this->_prepareOptionsForRequest($item))->setQty($qty); $product = $this->_objectManager->create( - 'Magento\Catalog\Model\Product' + \Magento\Catalog\Model\Product::class )->setStoreId( $this->getQuote()->getStoreId() )->load( @@ -786,7 +787,7 @@ public function moveQuoteItem($item, $moveTo, $qty) if ($cart && is_null($item->getOptionByCode('additional_options'))) { //options and info buy request $product = $this->_objectManager->create( - 'Magento\Catalog\Model\Product' + \Magento\Catalog\Model\Product::class )->setStoreId( $this->getQuote()->getStoreId() )->load( @@ -821,13 +822,14 @@ public function moveQuoteItem($item, $moveTo, $qty) $wishlist = null; if (!isset($moveTo[1])) { $wishlist = $this->_objectManager->create( - 'Magento\Wishlist\Model\Wishlist' + \Magento\Wishlist\Model\Wishlist::class )->loadByCustomerId( $this->getSession()->getCustomerId(), true ); } else { - $wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist')->load($moveTo[1]); + $wishlist = $this->_objectManager->create( + \Magento\Wishlist\Model\Wishlist::class)->load($moveTo[1]); if (!$wishlist->getId() || $wishlist->getCustomerId() != $this->getSession()->getCustomerId() ) { $wishlist = null; @@ -887,7 +889,7 @@ public function applySidebarData($data) if (isset($data['add_order_item'])) { foreach ($data['add_order_item'] as $orderItemId => $value) { /* @var $orderItem \Magento\Sales\Model\Order\Item */ - $orderItem = $this->_objectManager->create('Magento\Sales\Model\Order\Item')->load($orderItemId); + $orderItem = $this->_objectManager->create(\Magento\Sales\Model\Order\Item::class)->load($orderItemId); $item = $this->initFromOrderItem($orderItem); if (is_string($item)) { throw new \Magento\Framework\Exception\LocalizedException(__($item)); @@ -906,7 +908,7 @@ public function applySidebarData($data) if (isset($data['add_wishlist_item'])) { foreach ($data['add_wishlist_item'] as $itemId => $qty) { $item = $this->_objectManager->create( - 'Magento\Wishlist\Model\Item' + \Magento\Wishlist\Model\Item::class )->loadWithOptions( $itemId, 'info_buyRequest' @@ -958,12 +960,13 @@ public function removeItem($itemId, $from) case 'wishlist': $wishlist = $this->getCustomerWishlist(); if ($wishlist) { - $item = $this->_objectManager->create('Magento\Wishlist\Model\Item')->load($itemId); + $item = $this->_objectManager->create(\Magento\Wishlist\Model\Item::class)->load($itemId); $item->delete(); } break; case 'compared': - $this->_objectManager->create('Magento\Catalog\Model\Product\Compare\Item')->load($itemId)->delete(); + $this->_objectManager->create( + \Magento\Catalog\Model\Product\Compare\Item::class)->load($itemId)->delete(); break; } @@ -1004,7 +1007,7 @@ public function addProduct($product, $config = 1) if (!$product instanceof \Magento\Catalog\Model\Product) { $productId = $product; $product = $this->_objectManager->create( - 'Magento\Catalog\Model\Product' + \Magento\Catalog\Model\Product::class )->setStore( $this->getSession()->getStore() )->setStoreId( @@ -1104,7 +1107,7 @@ public function updateQuoteItems($items) protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additionalOptions) { $productOptions = $this->_objectManager->get( - 'Magento\Catalog\Model\Product\Option\Type\DefaultType' + \Magento\Catalog\Model\Product\Option\Type\DefaultType::class )->setProduct( $item->getProduct() )->getProductOptions(); @@ -1133,7 +1136,7 @@ protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additio $option = $item->getProduct()->getOptionById($optionId); $group = $this->_objectManager->get( - 'Magento\Catalog\Model\Product\Option' + \Magento\Catalog\Model\Product\Option::class )->groupFactory( $option->getType() )->setOption( @@ -1232,7 +1235,7 @@ protected function _prepareOptionsForRequest($item) $optionValue = $item->getOptionByCode('option_' . $optionId)->getValue(); $group = $this->_objectManager->get( - 'Magento\Catalog\Model\Product\Option' + \Magento\Catalog\Model\Product\Option::class )->groupFactory( $option->getType() )->setOption( @@ -1256,7 +1259,7 @@ protected function _prepareOptionsForRequest($item) */ protected function _parseCustomPrice($price) { - $price = $this->_objectManager->get('Magento\Framework\Locale\FormatInterface')->getNumber($price); + $price = $this->_objectManager->get(\Magento\Framework\Locale\FormatInterface::class)->getNumber($price); $price = $price > 0 ? $price : 0; return $price; @@ -1310,6 +1313,7 @@ protected function _setQuoteAddress(\Magento\Quote\Model\Quote\Address $address, $data = isset($data['region']) && is_array($data['region']) ? array_merge($data, $data['region']) : $data; $addressForm = $this->_metadataFormFactory->create( + AddressMetadataInterface::ENTITY_TYPE_ADDRESS, 'adminhtml_customer_address', $data, @@ -1361,7 +1365,7 @@ public function setShippingAddress($address) { if (is_array($address)) { $shippingAddress = $this->_objectManager->create( - 'Magento\Quote\Model\Quote\Address' + \Magento\Quote\Model\Quote\Address::class )->setData( $address )->setAddressType( @@ -1429,7 +1433,7 @@ public function setBillingAddress($address) { if (is_array($address)) { $billingAddress = $this->_objectManager->create( - 'Magento\Quote\Model\Quote\Address' + \Magento\Quote\Model\Quote\Address::class )->setData( $address )->setAddressType( @@ -1570,8 +1574,7 @@ public function setAccountData($accountData) $customer = $this->customerFactory->create(); $this->dataObjectHelper->populateWithArray( $customer, - $data, - '\Magento\Customer\Api\Data\CustomerInterface' + $data, \Magento\Customer\Api\Data\CustomerInterface::class ); $this->getQuote()->updateCustomerData($customer); $data = []; @@ -1691,8 +1694,7 @@ protected function _validateCustomerData(\Magento\Customer\Api\Data\CustomerInte $this->dataObjectHelper->populateWithArray( $customer, - $data, - '\Magento\Customer\Api\Data\CustomerInterface' + $data, \Magento\Customer\Api\Data\CustomerInterface::class ); return $customer; } diff --git a/app/code/Magento/Sales/Model/Config/Reader.php b/app/code/Magento/Sales/Model/Config/Reader.php index b1cdb3bf6d2f9..8843efd5140ef 100644 --- a/app/code/Magento/Sales/Model/Config/Reader.php +++ b/app/code/Magento/Sales/Model/Config/Reader.php @@ -42,7 +42,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'sales.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Sales/Model/Convert/Order.php b/app/code/Magento/Sales/Model/Convert/Order.php index 359e73ad5e25e..ca1fd3382c063 100644 --- a/app/code/Magento/Sales/Model/Convert/Order.php +++ b/app/code/Magento/Sales/Model/Convert/Order.php @@ -123,7 +123,7 @@ public function itemToInvoiceItem(\Magento\Sales\Model\Order\Item $item) $invoiceItem->setOrderItem($item)->setProductId($item->getProductId()); $this->_objectCopyService->copyFieldsetToTarget( - 'sales_convert_order_item', + \sales_convert_order_item::class, 'to_invoice_item', $item, $invoiceItem diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 7ed85998bf520..84d9f4846e3ee 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -364,7 +364,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order::class); } /** @@ -1451,6 +1451,7 @@ public function setPayment(\Magento\Sales\Api\Data\OrderPaymentInterface $paymen } /*********************** STATUSES ***************************/ + /** * Return collection of order status history items. * @@ -2004,6 +2005,7 @@ public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderExtensionInt } //@codeCoverageIgnoreStart + /** * Returns adjustment_negative * diff --git a/app/code/Magento/Sales/Model/Order/Address.php b/app/code/Magento/Sales/Model/Order/Address.php index 850e26becb75a..45a14e1ee69dc 100644 --- a/app/code/Magento/Sales/Model/Order/Address.php +++ b/app/code/Magento/Sales/Model/Order/Address.php @@ -98,7 +98,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Address'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Address::class); } /** diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 34aedc3d5d705..0acffa9567ac8 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -176,7 +176,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Creditmemo'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Creditmemo::class); } /** diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php index f0363a062cb0d..31532d5881dfd 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php @@ -67,7 +67,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment::class); } /** @@ -110,6 +110,7 @@ public function getStore() } //@codeCoverageIgnoreStart + /** * Returns comment * diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php index f06803d16d427..f4aed7ef3f6bf 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php @@ -81,7 +81,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item::class); } /** @@ -582,6 +582,7 @@ public function getWeeeTaxRowDisposition() } //@codeCoverageIgnoreStart + /** * {@inheritdoc} */ diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php index d54307263d783..96527443d7067 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -137,7 +137,9 @@ private function isSuppliedShippingAmountInclTax($order) private function getTaxConfig() { if ($this->taxConfig === null) { - $this->taxConfig = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Tax\Model\Config'); + $this->taxConfig = \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Tax\Model\Config::class + ); } return $this->taxConfig; } diff --git a/app/code/Magento/Sales/Model/Order/CustomerManagement.php b/app/code/Magento/Sales/Model/Order/CustomerManagement.php index ad87d5ddb552e..bc9ef51d9f618 100644 --- a/app/code/Magento/Sales/Model/Order/CustomerManagement.php +++ b/app/code/Magento/Sales/Model/Order/CustomerManagement.php @@ -77,7 +77,7 @@ public function create($orderId) throw new AlreadyExistsException(__("This order already has associated customer account")); } $customerData = $this->objectCopyService->copyFieldsetToTarget( - 'order_address', + \order_address::class, 'to_customer', $order->getBillingAddress(), [] @@ -85,7 +85,7 @@ public function create($orderId) $addresses = $order->getAddresses(); foreach ($addresses as $address) { $addressData = $this->objectCopyService->copyFieldsetToTarget( - 'order_address', + \order_address::class, 'to_customer_address', $address, [] diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index 3df33c0780a27..1658407fccfd6 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -172,7 +172,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Invoice'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Invoice::class); } /** @@ -792,6 +792,7 @@ public function getComments() } //@codeCoverageIgnoreStart + /** * Returns increment id * diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php index 34dcf9fb8ec48..da4cc757600fd 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php @@ -67,7 +67,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Invoice\Comment'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Invoice\Comment::class); } /** @@ -164,6 +164,7 @@ public function getParentId() } //@codeCoverageIgnoreStart + /** * {@inheritdoc} */ diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Item.php b/app/code/Magento/Sales/Model/Order/Invoice/Item.php index 2e8b66e891e82..6927cad5ba07f 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Item.php @@ -31,6 +31,7 @@ * @method string getWeeeTaxApplied() * @method \Magento\Sales\Model\Order\Invoice\Item setWeeeTaxApplied(string $value) * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Item extends AbstractModel implements InvoiceItemInterface { @@ -93,7 +94,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Invoice\Item'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Invoice\Item::class); } /** @@ -266,6 +267,7 @@ public function isLast() } //@codeCoverageIgnoreStart + /** * Returns additional_data * diff --git a/app/code/Magento/Sales/Model/Order/Item.php b/app/code/Magento/Sales/Model/Order/Item.php index 911d279f3bca9..0d45ec4e07e1e 100644 --- a/app/code/Magento/Sales/Model/Order/Item.php +++ b/app/code/Magento/Sales/Model/Order/Item.php @@ -143,7 +143,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Item'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Item::class); } /** @@ -689,6 +689,7 @@ public function getStore() } //@codeCoverageIgnoreStart + /** * Returns additional_data * diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 76f612851359d..228275edeef51 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -169,7 +169,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Payment'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Payment::class); } /** diff --git a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php index 1ce47135a694e..4b6c071a7c2a4 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php @@ -179,7 +179,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Payment\Transaction'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Payment\Transaction::class); parent::_construct(); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php index 7c5b9fc0f1795..e1a44cedc86f6 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php @@ -17,7 +17,7 @@ class Factory * * @var string */ - protected $_defaultTotalModel = 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal'; + protected $_defaultTotalModel = \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal::class; /** * @param \Magento\Framework\ObjectManagerInterface $objectManager @@ -38,7 +38,7 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan public function create($class = null, $arguments = []) { $class = $class ?: $this->_defaultTotalModel; - if (!is_a($class, 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', true)) { + if (!is_a($class, \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal::class, true)) { throw new \Magento\Framework\Exception\LocalizedException( __( 'The PDF total model %1 must be or extend \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal.', diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index f3f5647f431d8..c0c66bb6e8c33 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -145,7 +145,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Shipment'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Shipment::class); } /** @@ -578,6 +578,7 @@ public function getTracks() } //@codeCoverageIgnoreStart + /** * Returns tracks * diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php index 97643dc424305..6f34b04448b0b 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php @@ -67,7 +67,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Shipment\Comment'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Shipment\Comment::class); } /** @@ -110,6 +110,7 @@ public function getStore() } //@codeCoverageIgnoreStart + /** * Returns comment * diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Item.php b/app/code/Magento/Sales/Model/Order/Shipment/Item.php index e3ebc1d00fc0f..c7fdca853b17e 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Item.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Item.php @@ -83,7 +83,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Shipment\Item'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Shipment\Item::class); } /** diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Order/Shipment/Track.php index 34c97f4d80245..e6bbdb39da148 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track.php @@ -92,7 +92,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Shipment\Track'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Shipment\Track::class); } /** diff --git a/app/code/Magento/Sales/Model/Order/ShipmentFactory.php b/app/code/Magento/Sales/Model/Order/ShipmentFactory.php index 148ba9af5f66d..2ac012760ee47 100644 --- a/app/code/Magento/Sales/Model/Order/ShipmentFactory.php +++ b/app/code/Magento/Sales/Model/Order/ShipmentFactory.php @@ -43,7 +43,7 @@ public function __construct( ) { $this->converter = $convertOrderFactory->create(); $this->trackFactory = $trackFactory; - $this->instanceName = '\Magento\Sales\Api\Data\ShipmentInterface'; + $this->instanceName = \Magento\Sales\Api\Data\ShipmentInterface::class; } /** diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index 10b0b7480ab67..2a11259270469 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -52,13 +52,12 @@ public function __construct( $this->_storeManager = $storeManager; } - /** * @return void */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Status'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Status::class); } /** diff --git a/app/code/Magento/Sales/Model/Order/Status/History.php b/app/code/Magento/Sales/Model/Order/Status/History.php index db6498c744914..e0d364ed172aa 100644 --- a/app/code/Magento/Sales/Model/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Order/Status/History.php @@ -82,7 +82,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Status\History'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Status\History::class); } /** @@ -178,6 +178,7 @@ public function beforeSave() } //@codeCoverageIgnoreStart + /** * Returns comment * diff --git a/app/code/Magento/Sales/Model/Order/Tax.php b/app/code/Magento/Sales/Model/Order/Tax.php index 04c38b55c21e1..77fe7aaf221de 100644 --- a/app/code/Magento/Sales/Model/Order/Tax.php +++ b/app/code/Magento/Sales/Model/Order/Tax.php @@ -39,6 +39,6 @@ class Tax extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Tax'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Tax::class); } } diff --git a/app/code/Magento/Sales/Model/Order/Tax/Item.php b/app/code/Magento/Sales/Model/Order/Tax/Item.php index 8c73612c481fd..cd16a38c4275d 100644 --- a/app/code/Magento/Sales/Model/Order/Tax/Item.php +++ b/app/code/Magento/Sales/Model/Order/Tax/Item.php @@ -25,7 +25,7 @@ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements */ protected function _construct() { - $this->_init('Magento\Sales\Model\ResourceModel\Order\Tax\Item'); + $this->_init(\Magento\Sales\Model\ResourceModel\Order\Tax\Item::class); } /** diff --git a/app/code/Magento/Sales/Model/OrderRepository.php b/app/code/Magento/Sales/Model/OrderRepository.php index 35f4f7b809c6b..d90944bb7d5bf 100644 --- a/app/code/Magento/Sales/Model/OrderRepository.php +++ b/app/code/Magento/Sales/Model/OrderRepository.php @@ -193,7 +193,7 @@ private function getOrderExtensionDependency() { if (!$this->orderExtension instanceof OrderExtension) { $this->orderExtension = \Magento\Framework\App\ObjectManager::getInstance()->get( - '\Magento\Sales\Api\Data\OrderExtension' + \Magento\Sales\Api\Data\OrderExtension::class ); } return $this->orderExtension; @@ -209,7 +209,7 @@ private function getShippingAssignmentBuilderDependency() { if (!$this->shippingAssignmentBuilder instanceof ShippingAssignmentBuilder) { $this->shippingAssignmentBuilder = \Magento\Framework\App\ObjectManager::getInstance()->get( - '\Magento\Sales\Model\Order\ShippingAssignmentBuilder' + \Magento\Sales\Model\Order\ShippingAssignmentBuilder::class ); } return $this->shippingAssignmentBuilder; diff --git a/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php index 469db17286980..42a01a63c75f3 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php @@ -45,7 +45,7 @@ public function __construct( $eventPrefix, $eventObject, $resourceModel, - $model = 'Magento\Sales\Model\ResourceModel\Grid\Document', + $model = \Magento\Sales\Model\ResourceModel\Grid\Document::class, $connection = null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { @@ -80,7 +80,6 @@ public function setAggregations($aggregations) $this->aggregations = $aggregations; } - /** * Retrieve all ids for collection * Backward compatibility with EAV collection diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Address/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Address/Collection.php index 12a91ff9c2694..de54cfaff9a65 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Address/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Address/Collection.php @@ -33,7 +33,10 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Order\Collection\Abs */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Address', 'Magento\Sales\Model\ResourceModel\Order\Address'); + $this->_init( + \Magento\Sales\Model\Order\Address::class, + \Magento\Sales\Model\ResourceModel\Order\Address::class + ); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Collection.php index 8ef7e419e42da..bae0054de28d5 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Collection.php @@ -78,7 +78,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order', 'Magento\Sales\Model\ResourceModel\Order'); + $this->_init(\Magento\Sales\Model\Order::class, \Magento\Sales\Model\ResourceModel\Order::class); $this->addFilterToMap( 'entity_id', 'main_table.entity_id' diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Collection.php index 071605c5df900..f8f15a67f8cf6 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Collection.php @@ -50,7 +50,10 @@ class Collection extends AbstractCollection implements CreditmemoSearchResultInt */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Creditmemo', 'Magento\Sales\Model\ResourceModel\Order\Creditmemo'); + $this->_init( + \Magento\Sales\Model\Order\Creditmemo::class, + \Magento\Sales\Model\ResourceModel\Order\Creditmemo::class + ); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Comment/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Comment/Collection.php index 4dd10abe33990..533117d0b0aa8 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Comment/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Comment/Collection.php @@ -38,8 +38,8 @@ protected function _construct() { parent::_construct(); $this->_init( - 'Magento\Sales\Model\Order\Creditmemo\Comment', - 'Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment' + \Magento\Sales\Model\Order\Creditmemo\Comment::class, + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Grid/Collection.php index d5c0689c14022..9c68b48319713 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Grid/Collection.php @@ -29,7 +29,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_creditmemo_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Creditmemo' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order\Creditmemo::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Item/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Item/Collection.php index 14884620630b3..d50b53d273fa3 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Item/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Item/Collection.php @@ -34,8 +34,8 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Collection\AbstractC protected function _construct() { $this->_init( - 'Magento\Sales\Model\Order\Creditmemo\Item', - 'Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item' + \Magento\Sales\Model\Order\Creditmemo\Item::class, + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Order/Grid/Collection.php index 4455879910ac8..96ee1a67c3dc7 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Order/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Order/Grid/Collection.php @@ -29,7 +29,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_creditmemo_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Creditmemo' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order\Creditmemo::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php index 162549fa6fbf4..bf7647e81f53b 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php @@ -31,7 +31,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_order_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Collection.php index d517176ae0a6c..5a70e32c2f17c 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Collection.php @@ -50,7 +50,10 @@ class Collection extends AbstractCollection implements InvoiceSearchResultInterf */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Invoice', 'Magento\Sales\Model\ResourceModel\Order\Invoice'); + $this->_init( + \Magento\Sales\Model\Order\Invoice::class, + \Magento\Sales\Model\ResourceModel\Order\Invoice::class + ); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Comment/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Comment/Collection.php index b90edecfb407e..1c278fc877142 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Comment/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Comment/Collection.php @@ -38,8 +38,8 @@ protected function _construct() { parent::_construct(); $this->_init( - 'Magento\Sales\Model\Order\Invoice\Comment', - 'Magento\Sales\Model\ResourceModel\Order\Invoice\Comment' + \Magento\Sales\Model\Order\Invoice\Comment::class, + \Magento\Sales\Model\ResourceModel\Order\Invoice\Comment::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php index e4c12a3a5f9ba..1c15716368db4 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php @@ -35,7 +35,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_invoice_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Invoice' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order\Invoice::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Item/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Item/Collection.php index d63ac307a3521..41c74c27c371d 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Item/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Item/Collection.php @@ -33,7 +33,10 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Collection\AbstractC */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Invoice\Item', 'Magento\Sales\Model\ResourceModel\Order\Invoice\Item'); + $this->_init( + \Magento\Sales\Model\Order\Invoice\Item::class, + \Magento\Sales\Model\ResourceModel\Order\Invoice\Item::class + ); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Orders/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Orders/Grid/Collection.php index ae4788c4daea3..f8c1197440fd1 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Orders/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Orders/Grid/Collection.php @@ -29,7 +29,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_invoice_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Invoice' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order\Invoice::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php index 88725250d4fb5..59b473505af52 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php @@ -40,7 +40,7 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Order\Collection\Abs */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Item', 'Magento\Sales\Model\ResourceModel\Order\Item'); + $this->_init(\Magento\Sales\Model\Order\Item::class, \Magento\Sales\Model\ResourceModel\Order\Item::class); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Collection.php index 81581059bbcfa..caa7f2e27b63a 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Collection.php @@ -63,7 +63,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Payment', 'Magento\Sales\Model\ResourceModel\Order\Payment'); + $this->_init( + \Magento\Sales\Model\Order\Payment::class, + \Magento\Sales\Model\ResourceModel\Order\Payment::class + ); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Transaction/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Transaction/Collection.php index c6179c777f7a5..f813ca23fc177 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Transaction/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Payment/Transaction/Collection.php @@ -79,8 +79,8 @@ class Collection extends AbstractCollection implements TransactionSearchResultIn protected function _construct() { $this->_init( - 'Magento\Sales\Model\Order\Payment\Transaction', - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction' + \Magento\Sales\Model\Order\Payment\Transaction::class, + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction::class ); $this->addFilterToMap('created_at', 'main_table.created_at'); parent::_construct(); diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Collection.php index 09ff04f8e24a2..2f15e20ee1762 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Collection.php @@ -48,7 +48,10 @@ class Collection extends AbstractCollection implements ShipmentSearchResultInter */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Shipment', 'Magento\Sales\Model\ResourceModel\Order\Shipment'); + $this->_init( + \Magento\Sales\Model\Order\Shipment::class, + \Magento\Sales\Model\ResourceModel\Order\Shipment::class + ); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Comment/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Comment/Collection.php index e11d2c9c91738..bee8d677b17d9 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Comment/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Comment/Collection.php @@ -37,8 +37,8 @@ class Collection extends AbstractCollection implements ShipmentCommentSearchResu protected function _construct() { $this->_init( - 'Magento\Sales\Model\Order\Shipment\Comment', - 'Magento\Sales\Model\ResourceModel\Order\Shipment\Comment' + \Magento\Sales\Model\Order\Shipment\Comment::class, + \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Grid/Collection.php index f3141f521623f..066f617f28bd5 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Grid/Collection.php @@ -29,7 +29,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_shipment_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Shipment' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order\Shipment::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Item/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Item/Collection.php index 97d47c5a2d986..a5624fe8cf026 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Item/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Item/Collection.php @@ -34,8 +34,8 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Collection\AbstractC protected function _construct() { $this->_init( - 'Magento\Sales\Model\Order\Shipment\Item', - 'Magento\Sales\Model\ResourceModel\Order\Shipment\Item' + \Magento\Sales\Model\Order\Shipment\Item::class, + \Magento\Sales\Model\ResourceModel\Order\Shipment\Item::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Order/Grid/Collection.php index 941b510a7f632..799173e1af170 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Order/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Order/Grid/Collection.php @@ -29,7 +29,7 @@ public function __construct( FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable = 'sales_shipment_grid', - $resourceModel = '\Magento\Sales\Model\ResourceModel\Order\Shipment' + $resourceModel = \Magento\Sales\Model\ResourceModel\Order\Shipment::class ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Track/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Track/Collection.php index 37714145050f4..ce6ee0a877799 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Track/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Track/Collection.php @@ -44,8 +44,8 @@ class Collection extends AbstractCollection implements ShipmentTrackSearchResult protected function _construct() { $this->_init( - 'Magento\Sales\Model\Order\Shipment\Track', - 'Magento\Sales\Model\ResourceModel\Order\Shipment\Track' + \Magento\Sales\Model\Order\Shipment\Track::class, + \Magento\Sales\Model\ResourceModel\Order\Shipment\Track::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Status/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Status/Collection.php index c3541e8385b3f..788dad899c6ee 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Status/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Status/Collection.php @@ -19,7 +19,7 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Collection\AbstractC */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Status', 'Magento\Sales\Model\ResourceModel\Order\Status'); + $this->_init(\Magento\Sales\Model\Order\Status::class, \Magento\Sales\Model\ResourceModel\Order\Status::class); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Status/History/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Status/History/Collection.php index 0310a758107e4..6ac9b8fa32d20 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Status/History/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Status/History/Collection.php @@ -39,8 +39,8 @@ class Collection extends AbstractCollection implements OrderStatusHistorySearchR protected function _construct() { $this->_init( - 'Magento\Sales\Model\Order\Status\History', - 'Magento\Sales\Model\ResourceModel\Order\Status\History' + \Magento\Sales\Model\Order\Status\History::class, + \Magento\Sales\Model\ResourceModel\Order\Status\History::class ); } diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Tax/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Tax/Collection.php index 0f34a4cf5f8e9..1dbf1f1e124c4 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Tax/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Tax/Collection.php @@ -19,7 +19,7 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Collection\AbstractC */ protected function _construct() { - $this->_init('Magento\Sales\Model\Order\Tax', 'Magento\Sales\Model\ResourceModel\Order\Tax'); + $this->_init(\Magento\Sales\Model\Order\Tax::class, \Magento\Sales\Model\ResourceModel\Order\Tax::class); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Report/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/ResourceModel/Report/Collection/AbstractCollection.php index 8d2be440715aa..1273ba5a8c378 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Report/Collection/AbstractCollection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Report/Collection/AbstractCollection.php @@ -36,7 +36,7 @@ public function __construct( \Magento\Framework\DB\Adapter\AdapterInterface $connection = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); - $this->setModel('Magento\Reports\Model\Item'); + $this->setModel(\Magento\Reports\Model\Item::class); } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Sale/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Sale/Collection.php index 1c257c44a9217..e5b12e2a04339 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Sale/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Sale/Collection.php @@ -86,7 +86,7 @@ public function __construct( protected function _construct() { parent::_construct(); - $this->_init('Magento\Sales\Model\Order', 'Magento\Sales\Model\ResourceModel\Order'); + $this->_init(\Magento\Sales\Model\Order::class, \Magento\Sales\Model\ResourceModel\Order::class); } /** diff --git a/app/code/Magento/Sales/Model/Rss/NewOrder.php b/app/code/Magento/Sales/Model/Rss/NewOrder.php index b5ea76f984a4a..284b3153ed545 100644 --- a/app/code/Magento/Sales/Model/Rss/NewOrder.php +++ b/app/code/Magento/Sales/Model/Rss/NewOrder.php @@ -113,7 +113,7 @@ public function getRssData() ->addAttributeToSort('created_at', 'desc'); $this->eventManager->dispatch('rss_order_new_collection_select', ['collection' => $collection]); - $detailBlock = $this->layout->getBlockSingleton('Magento\Sales\Block\Adminhtml\Order\Details'); + $detailBlock = $this->layout->getBlockSingleton(\Magento\Sales\Block\Adminhtml\Order\Details::class); foreach ($collection as $item) { $title = __('Order #%1 created at %2', $item->getIncrementId(), $this->localeDate->formatDate( $item->getCreatedAt() diff --git a/app/code/Magento/Sales/Model/Status/ListFactory.php b/app/code/Magento/Sales/Model/Status/ListFactory.php index 7b805943af8ca..de8ce4074961a 100644 --- a/app/code/Magento/Sales/Model/Status/ListFactory.php +++ b/app/code/Magento/Sales/Model/Status/ListFactory.php @@ -28,6 +28,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create(array $arguments = []) { - return $this->_objectManager->create('Magento\Sales\Model\Status\ListStatus', $arguments); + return $this->_objectManager->create(\Magento\Sales\Model\Status\ListStatus::class, $arguments); } } diff --git a/app/code/Magento/Sales/Setup/SalesSetup.php b/app/code/Magento/Sales/Setup/SalesSetup.php index d69147ba925f0..8a042c3c5e223 100644 --- a/app/code/Magento/Sales/Setup/SalesSetup.php +++ b/app/code/Magento/Sales/Setup/SalesSetup.php @@ -214,30 +214,30 @@ public function getDefaultEntities() { $entities = [ 'order' => [ - 'entity_model' => 'Magento\Sales\Model\ResourceModel\Order', + 'entity_model' => \Magento\Sales\Model\ResourceModel\Order::class, 'table' => 'sales_order', - 'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue', + 'increment_model' => \Magento\Eav\Model\Entity\Increment\NumericValue::class, 'increment_per_store' => true, 'attributes' => [], ], 'invoice' => [ - 'entity_model' => 'Magento\Sales\Model\ResourceModel\Order\Invoice', + 'entity_model' => \Magento\Sales\Model\ResourceModel\Order\Invoice::class, 'table' => 'sales_invoice', - 'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue', + 'increment_model' => \Magento\Eav\Model\Entity\Increment\NumericValue::class, 'increment_per_store' => true, 'attributes' => [], ], 'creditmemo' => [ - 'entity_model' => 'Magento\Sales\Model\ResourceModel\Order\Creditmemo', + 'entity_model' => \Magento\Sales\Model\ResourceModel\Order\Creditmemo::class, 'table' => 'sales_creditmemo', - 'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue', + 'increment_model' => \Magento\Eav\Model\Entity\Increment\NumericValue::class, 'increment_per_store' => true, 'attributes' => [], ], 'shipment' => [ - 'entity_model' => 'Magento\Sales\Model\ResourceModel\Order\Shipment', + 'entity_model' => \Magento\Sales\Model\ResourceModel\Order\Shipment::class, 'table' => 'sales_shipment', - 'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue', + 'increment_model' => \Magento\Eav\Model\Entity\Increment\NumericValue::class, 'increment_per_store' => true, 'attributes' => [], ], diff --git a/app/code/Magento/Sales/Setup/UpgradeData.php b/app/code/Magento/Sales/Setup/UpgradeData.php index dca53d0214aaf..9580dd8a667a0 100644 --- a/app/code/Magento/Sales/Setup/UpgradeData.php +++ b/app/code/Magento/Sales/Setup/UpgradeData.php @@ -51,42 +51,42 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $salesSetup->updateEntityType( \Magento\Sales\Model\Order::ENTITY, 'entity_model', - 'Magento\Sales\Model\ResourceModel\Order' + \Magento\Sales\Model\ResourceModel\Order::class ); $salesSetup->updateEntityType( \Magento\Sales\Model\Order::ENTITY, 'increment_model', - 'Magento\Eav\Model\Entity\Increment\NumericValue' + \Magento\Eav\Model\Entity\Increment\NumericValue::class ); $salesSetup->updateEntityType( 'invoice', 'entity_model', - 'Magento\Sales\Model\ResourceModel\Order' + \Magento\Sales\Model\ResourceModel\Order::class ); $salesSetup->updateEntityType( 'invoice', 'increment_model', - 'Magento\Eav\Model\Entity\Increment\NumericValue' + \Magento\Eav\Model\Entity\Increment\NumericValue::class ); $salesSetup->updateEntityType( 'creditmemo', 'entity_model', - 'Magento\Sales\Model\ResourceModel\Order\Creditmemo' + \Magento\Sales\Model\ResourceModel\Order\Creditmemo::class ); $salesSetup->updateEntityType( 'creditmemo', 'increment_model', - 'Magento\Eav\Model\Entity\Increment\NumericValue' + \Magento\Eav\Model\Entity\Increment\NumericValue::class ); $salesSetup->updateEntityType( 'shipment', 'entity_model', - 'Magento\Sales\Model\ResourceModel\Order\Shipment' + \Magento\Sales\Model\ResourceModel\Order\Shipment::class ); $salesSetup->updateEntityType( 'shipment', 'increment_model', - 'Magento\Eav\Model\Entity\Increment\NumericValue' + \Magento\Eav\Model\Entity\Increment\NumericValue::class ); } $this->eavConfig->clear(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php index 90dc9775574d3..24c1f8fd29f5e 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php @@ -11,6 +11,8 @@ * Class AbstractItemsTest * @package Magento\Sales\Block\Adminhtml\Items * TODO refactor me PLEASE + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AbstractItemsTest extends \PHPUnit_Framework_TestCase { @@ -28,13 +30,13 @@ class AbstractItemsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getManageStock', '__wakeup'], [], '', @@ -49,7 +51,7 @@ protected function setUp() public function testGetItemRenderer() { $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', 'getGroupChildNames'], [], '', @@ -66,7 +68,7 @@ public function testGetItemRenderer() /** @var \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer $renderer */ $renderer = $this->objectManagerHelper - ->getObject('Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer'); + ->getObject(\Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer::class); $renderer->setLayout($layout); $layout->expects($this->any()) @@ -75,7 +77,7 @@ public function testGetItemRenderer() ->will($this->returnValue($renderer)); /** @var \Magento\Sales\Block\Adminhtml\Items\AbstractItems $block */ - $block = $this->objectManagerHelper->getObject('Magento\Sales\Block\Adminhtml\Items\AbstractItems'); + $block = $this->objectManagerHelper->getObject(\Magento\Sales\Block\Adminhtml\Items\AbstractItems::class); $block->setLayout($layout); $this->assertSame($renderer, $block->getItemRenderer('some-type')); @@ -88,9 +90,9 @@ public function testGetItemRenderer() */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $renderer = $this->getMock('StdClass'); + $renderer = $this->getMock(\StdClass::class); $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', '__wakeup'], [], '', @@ -107,10 +109,10 @@ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() /** @var $block \Magento\Sales\Block\Adminhtml\Items\AbstractItems */ $block = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Adminhtml\Items\AbstractItems', + \Magento\Sales\Block\Adminhtml\Items\AbstractItems::class, [ 'context' => $this->objectManagerHelper->getObject( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $layout] ) ] @@ -130,7 +132,7 @@ public function testCanReturnItemToStock($canReturnToStock, $itemConfig, $result $productId = isset($itemConfig['product_id']) ? $itemConfig['product_id'] : null; $manageStock = isset($itemConfig['manage_stock']) ? $itemConfig['manage_stock'] : null; $item = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo\Item', + \Magento\Sales\Model\Order\Creditmemo\Item::class, ['hasCanReturnToStock', 'getOrderItem', 'setCanReturnToStock', 'getCanReturnToStock', '__wakeup'], [], '', @@ -146,7 +148,7 @@ public function testCanReturnItemToStock($canReturnToStock, $itemConfig, $result /** @var $block \Magento\Sales\Block\Adminhtml\Items\AbstractItems */ $block = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Adminhtml\Items\AbstractItems', + \Magento\Sales\Block\Adminhtml\Items\AbstractItems::class, $dependencies ); $this->assertSame($result, $block->canReturnItemToStock($item)); @@ -174,14 +176,14 @@ protected function prepareServiceMockDependency($item, $canReturnToStock, $produ ->will($this->returnValue($itemConfig['has_can_return_to_stock'])); if (!$itemConfig['has_can_return_to_stock']) { $orderItem = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, ['getProductId', '__wakeup', 'getStore'], [], '', false ); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->once()) ->method('getWebsiteId') ->will($this->returnValue(10)); @@ -214,7 +216,7 @@ protected function prepareServiceMockDependency($item, $canReturnToStock, $produ public function testCanReturnItemToStockEmpty() { - $stockConfiguration = $this->getMockBuilder('Magento\CatalogInventory\Model\Configuration') + $stockConfiguration = $this->getMockBuilder(\Magento\CatalogInventory\Model\Configuration::class) ->disableOriginalConstructor() ->setMethods(['canSubtractQty', '__wakeup']) ->getMock(); @@ -224,7 +226,7 @@ public function testCanReturnItemToStockEmpty() /** @var $block \Magento\Sales\Block\Adminhtml\Items\AbstractItems */ $block = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Adminhtml\Items\AbstractItems', + \Magento\Sales\Block\Adminhtml\Items\AbstractItems::class, [ 'stockConfiguration' => $stockConfiguration ] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php index 5ebd9631a8d17..c05b1d3c1983e 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php @@ -17,9 +17,9 @@ protected function setUp() public function testGetItemRenderer() { - $renderer = $this->getMock('Magento\Framework\View\Element\AbstractBlock', [], [], '', false); + $renderer = $this->getMock(\Magento\Framework\View\Element\AbstractBlock::class, [], [], '', false); $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', 'getGroupChildNames', '__wakeup'], [], '', @@ -47,10 +47,10 @@ public function testGetItemRenderer() /** @var $block \Magento\Sales\Block\Adminhtml\Items\AbstractItems */ $block = $this->_objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Items\AbstractItems', + \Magento\Sales\Block\Adminhtml\Items\AbstractItems::class, [ 'context' => $this->_objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $layout] ) ] @@ -65,9 +65,9 @@ public function testGetItemRenderer() */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $renderer = $this->getMock('StdClass'); + $renderer = $this->getMock(\StdClass::class); $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', '__wakeup'], [], '', @@ -95,10 +95,10 @@ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() /** @var $block \Magento\Sales\Block\Adminhtml\Items\AbstractItems */ $block = $this->_objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Items\AbstractItems', + \Magento\Sales\Block\Adminhtml\Items\AbstractItems::class, [ 'context' => $this->_objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $layout] ) ] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/Column/DefaultColumnTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/Column/DefaultColumnTest.php index c270b5ec8ac8d..69db3a9b9ea8f 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/Column/DefaultColumnTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/Column/DefaultColumnTest.php @@ -26,9 +26,9 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->defaultColumn = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn' + \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn::class ); - $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods(['getRowTotal', 'getDiscountAmount', 'getBaseRowTotal', 'getBaseDiscountAmount', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Comments/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Comments/ViewTest.php index 0ac9a912894b0..e2a8cdf024d03 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Comments/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Comments/ViewTest.php @@ -19,12 +19,12 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->adminHelperMock = $this->getMockBuilder('Magento\Sales\Helper\Admin') + $this->adminHelperMock = $this->getMockBuilder(\Magento\Sales\Helper\Admin::class) ->disableOriginalConstructor() ->getMock(); $this->commentsView = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Comments\View', + \Magento\Sales\Block\Adminhtml\Order\Comments\View::class, [ 'adminHelper' => $this->adminHelperMock ] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/CustomerTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/CustomerTest.php index 1e4bb178907f6..0274c83e15abd 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/CustomerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/CustomerTest.php @@ -9,14 +9,20 @@ class CustomerTest extends \PHPUnit_Framework_TestCase { public function testGetButtonsHtml() { - $contextMock = $this->getMock('Magento\Backend\Block\Template\Context', ['getAuthorization'], [], '', false); - $authorizationMock = $this->getMock('Magento\Framework\AuthorizationInterface', [], [], '', false); + $contextMock = $this->getMock( + \Magento\Backend\Block\Template\Context::class, + ['getAuthorization'], + [], + '', + false + ); + $authorizationMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class, [], [], '', false); $contextMock->expects($this->any())->method('getAuthorization')->will($this->returnValue($authorizationMock)); $arguments = ['context' => $contextMock]; $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Customer $block */ - $block = $helper->getObject('Magento\Sales\Block\Adminhtml\Order\Create\Customer', $arguments); + $block = $helper->getObject(\Magento\Sales\Block\Adminhtml\Order\Create\Customer::class, $arguments); $authorizationMock->expects($this->atLeastOnce()) ->method('isAllowed') diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php index 2235dff1d9ee0..00dcdf0ec5e58 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php @@ -8,6 +8,9 @@ namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Create\Items; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class GridTest extends \PHPUnit_Framework_TestCase { /** @@ -56,20 +59,22 @@ class GridTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $orderCreateMock = $this->getMock('Magento\Sales\Model\AdminOrder\Create', ['__wakeup'], [], '', false); - $taxData = $this->getMockBuilder('Magento\Tax\Helper\Data')->disableOriginalConstructor()->getMock(); - $this->priceCurrency = $this->getMockBuilder('\Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); - $sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + $orderCreateMock = $this->getMock(\Magento\Sales\Model\AdminOrder\Create::class, ['__wakeup'], [], '', false); + $taxData = $this->getMockBuilder(\Magento\Tax\Helper\Data::class)->disableOriginalConstructor()->getMock(); + $this->priceCurrency = $this->getMockBuilder( + \Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock( + ); + $sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session\Quote::class) ->disableOriginalConstructor() ->setMethods(['getQuote', '__wakeup']) ->getMock(); - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->setMethods(['getStore', '__wakeup']) ->getMock(); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); @@ -78,25 +83,25 @@ protected function setUp() ->will($this->returnArgument(0)); $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $sessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); - $wishlistFactoryMock = $this->getMockBuilder('Magento\Wishlist\Model\WishlistFactory') + $wishlistFactoryMock = $this->getMockBuilder(\Magento\Wishlist\Model\WishlistFactory::class) ->disableOriginalConstructor() ->setMethods(['methods', '__wakeup']) ->getMock(); - $giftMessageSave = $this->getMockBuilder('Magento\Giftmessage\Model\Save') + $giftMessageSave = $this->getMockBuilder(\Magento\Giftmessage\Model\Save::class) ->setMethods(['__wakeup']) ->disableOriginalConstructor() ->getMock(); - $taxConfig = $this->getMockBuilder('Magento\Tax\Model\Config')->disableOriginalConstructor()->getMock(); + $taxConfig = $this->getMockBuilder(\Magento\Tax\Model\Config::class)->disableOriginalConstructor()->getMock(); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getIsInStock', '__wakeup'], [], '', @@ -104,7 +109,7 @@ protected function setUp() ); $this->stockState = $this->getMock( - 'Magento\CatalogInventory\Model\StockState', + \Magento\CatalogInventory\Model\StockState::class, ['checkQuoteItemQty', '__wakeup'], [], '', @@ -117,7 +122,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $this->objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid', + \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid::class, [ 'wishlistFactory' => $wishlistFactoryMock, 'giftMessageSave' => $giftMessageSave, @@ -131,17 +136,17 @@ protected function setUp() ] ); - $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + $this->priceRenderBlock = $this->getMockBuilder(\Magento\Backend\Block\Template::class) ->disableOriginalConstructor() ->setMethods(['setItem', 'toHtml']) ->getMock(); - $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods(['getBlock']) ->getMock(); - $this->itemMock = $this->getMockBuilder('\Magento\Quote\Model\Quote\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); @@ -199,13 +204,13 @@ public function tierPriceDataProvider() */ protected function prepareItem($tierPrices, $productType) { - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['getTierPrice', '__wakeup']) ->getMock(); $product->expects($this->once())->method('getTierPrice')->will($this->returnValue($tierPrices)); $item = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [], ['getProduct', 'getProductType'], '', @@ -225,25 +230,25 @@ public function testGetItems() { $productId = 8; $itemQty = 23; - $layoutMock = $this->getMock('Magento\Framework\View\LayoutInterface'); - $blockMock = $this->getMock('Magento\Framework\View\Element\AbstractBlock', ['getItems'], [], '', false); + $layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $blockMock = $this->getMock(\Magento\Framework\View\Element\AbstractBlock::class, ['getItems'], [], '', false); $itemMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, ['getProduct', 'setHasError', 'setQty', 'getQty', '__sleep', '__wakeup'], [], '', false ); $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getStockItem', 'getID', '__sleep', '__wakeup'], [], '', false ); - $checkMock = $this->getMock('Magento\Framework\DataObject', ['getMessage', 'getHasError'], [], '', false); + $checkMock = $this->getMock(\Magento\Framework\DataObject::class, ['getMessage', 'getHasError'], [], '', false); $layoutMock->expects($this->once())->method('getParentName')->will($this->returnValue('parentBlock')); $layoutMock->expects($this->once())->method('getBlock')->with('parentBlock') @@ -284,10 +289,10 @@ protected function getGrid() { /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid $grid */ $grid = $this->objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid', + \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid::class, [ 'context' => $this->objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $this->layoutMock] ) ] @@ -371,14 +376,14 @@ public function testGetItemRowTotalWithDiscountHtml() public function testGetSubtotalWithDiscount($orderData, $displayTotalsIncludeTax, $expected) { $quoteAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getSubtotal', 'getTaxAmount','getDiscountTaxCompensationAmount','getDiscountAmount'], [], '', false ); $gridMock = $this->getMock( - 'Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid', + \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid::class, ['getQuoteAddress','displayTotalsIncludeTax'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php index 0ca1ae505f945..7a4dd5b35b5fe 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php @@ -26,10 +26,10 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->rowMock = $this->getMock('Magento\Framework\DataObject', ['getTypeId', 'getIndex'], [], '', false); - $this->typeConfigMock = $this->getMock('Magento\Catalog\Model\ProductTypes\ConfigInterface'); + $this->rowMock = $this->getMock(\Magento\Framework\DataObject::class, ['getTypeId', 'getIndex'], [], '', false); + $this->typeConfigMock = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); $this->renderer = $helper->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty', + \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty::class, ['typeConfig' => $this->typeConfigMock] ); } @@ -49,7 +49,7 @@ public function testRender() ); $this->rowMock->expects($this->once())->method('getTypeId')->will($this->returnValue('id')); $columnMock = $this->getMock( - 'Magento\Backend\Block\Widget\Grid\Column', + \Magento\Backend\Block\Widget\Grid\Column::class, ['getInlineCss', 'getId'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php index 9cad96d43dd35..8cd1076439634 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php @@ -20,9 +20,9 @@ class AbstractSidebarTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->itemMock = $this->getMock('Magento\Framework\DataObject', ['getQty'], [], '', false); + $this->itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getQty'], [], '', false); $this->abstractSidebar = $helper->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar', + \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar::class, [] ); } @@ -46,7 +46,7 @@ public function getItemQtyDataProvider() public function testIsConfigurationRequired() { - $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', [], [], '', false); + $productTypeMock = $this->getMock(\Magento\Catalog\Model\Product\Type::class, [], [], '', false); $this->assertEquals(false, $this->abstractSidebar->isConfigurationRequired($productTypeMock)); } } diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/TotalsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/TotalsTest.php index 3b11e6afcca61..56c8a4798f946 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/TotalsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/TotalsTest.php @@ -39,19 +39,19 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', ['getCustomerNoteNotify'], [], '', false + $this->quoteMock = $this->getMock( + \Magento\Quote\Model\Quote::class, ['getCustomerNoteNotify'], [], '', false ); - $this->sessionQuoteMock = $this->getMock( - '\Magento\Backend\Model\Session\Quote', [], [], '', false + $this->sessionQuoteMock = $this->getMock( + \Magento\Backend\Model\Session\Quote::class, [], [], '', false ); $this->sessionQuoteMock->expects($this->any()) ->method('getQuote') ->willReturn($this->quoteMock); - $this->totals = $this->objectManager->getObject( - '\Magento\Sales\Block\Adminhtml\Order\Create\Totals', + $this->totals = $this->objectManager->getObject( + \Magento\Sales\Block\Adminhtml\Order\Create\Totals::class, [ 'sessionQuote' => $this->sessionQuoteMock ] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Creditmemo/Create/ItemsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Creditmemo/Create/ItemsTest.php index c71dc81c9bcef..b673c2a888be9 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Creditmemo/Create/ItemsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Creditmemo/Create/ItemsTest.php @@ -7,6 +7,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ItemsTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Items */ @@ -37,14 +40,14 @@ class ItemsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock('Magento\Backend\Block\Template\Context', [], [], '', false); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->contextMock = $this->getMock(\Magento\Backend\Block\Template\Context::class, [], [], '', false); + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getManageStock', '__wakeup'], [], '', @@ -52,7 +55,7 @@ protected function setUp() ); $this->stockConfiguration = $this->getMock( - 'Magento\CatalogInventory\Model\Configuration', + \Magento\CatalogInventory\Model\Configuration::class, ['__wakeup', 'canSubtractQty'], [], '', @@ -63,15 +66,15 @@ protected function setUp() ->method('getStockItem') ->will($this->returnValue($this->stockItemMock)); - $this->registryMock = $this->getMock('Magento\Framework\Registry'); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->contextMock->expects($this->once()) ->method('getScopeConfig') ->will($this->returnValue($this->scopeConfig)); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->items = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Items', + \Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Items::class, [ 'context' => $this->contextMock, 'stockRegistry' => $this->stockRegistry, @@ -99,13 +102,13 @@ public function testCanReturnItemsToStock($canReturnToStock, $manageStock, $resu if ($canReturnToStock) { $orderItem = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, ['getProductId', '__wakeup', 'getStore'], [], '', false ); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->once()) ->method('getWebsiteId') ->will($this->returnValue(10)); @@ -117,14 +120,14 @@ public function testCanReturnItemsToStock($canReturnToStock, $manageStock, $resu ->will($this->returnValue($productId)); $creditMemoItem = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo\Item', + \Magento\Sales\Model\Order\Creditmemo\Item::class, ['setCanReturnToStock', 'getOrderItem', '__wakeup'], [], '', false ); - $creditMemo = $this->getMock('Magento\Sales\Model\Order\Creditmemo', [], [], '', false); + $creditMemo = $this->getMock(\Magento\Sales\Model\Order\Creditmemo::class, [], [], '', false); $creditMemo->expects($this->once()) ->method('getAllItems') ->will($this->returnValue([$creditMemoItem])); @@ -141,7 +144,13 @@ public function testCanReturnItemsToStock($canReturnToStock, $manageStock, $resu ->with($this->equalTo($manageStock)) ->will($this->returnSelf()); - $order = $this->getMock('Magento\Sales\Model\Order', ['setCanReturnToStock', '__wakeup'], [], '', false); + $order = $this->getMock( + \Magento\Sales\Model\Order::class, + ['setCanReturnToStock', '__wakeup'], + [], + '', + false + ); $order->expects($this->once()) ->method('setCanReturnToStock') ->with($this->equalTo($manageStock)) diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php index c176845c31d83..775c504c68724 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php @@ -20,7 +20,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase public function testIsPaymentReview($canReviewPayment, $canFetchUpdate, $expectedResult) { // Create order mock - $order = $this->getMockBuilder('Magento\Sales\Model\Order')->disableOriginalConstructor()->getMock(); + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->getMock(); $order->expects($this->any())->method('canReviewPayment')->will($this->returnValue($canReviewPayment)); $order->expects( $this->any() @@ -32,7 +32,7 @@ public function testIsPaymentReview($canReviewPayment, $canFetchUpdate, $expecte // Create invoice mock $invoice = $this->getMockBuilder( - 'Magento\Sales\Model\Order\Invoice' + \Magento\Sales\Model\Order\Invoice::class )->disableOriginalConstructor()->setMethods( ['getOrder', '__wakeup'] )->getMock(); @@ -40,12 +40,15 @@ public function testIsPaymentReview($canReviewPayment, $canFetchUpdate, $expecte // Prepare block to test protected method $block = $this->getMockBuilder( - 'Magento\Sales\Block\Adminhtml\Order\Invoice\View' + \Magento\Sales\Block\Adminhtml\Order\Invoice\View::class )->disableOriginalConstructor()->setMethods( ['getInvoice'] )->getMock(); $block->expects($this->once())->method('getInvoice')->will($this->returnValue($invoice)); - $testMethod = new \ReflectionMethod('Magento\Sales\Block\Adminhtml\Order\Invoice\View', '_isPaymentReview'); + $testMethod = new \ReflectionMethod( + \Magento\Sales\Block\Adminhtml\Order\Invoice\View::class, + '_isPaymentReview' + ); $testMethod->setAccessible(true); $this->assertEquals($expectedResult, $testMethod->invoke($block)); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Status/Assign/FormTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Status/Assign/FormTest.php index f74cd151886a5..faba0ec357776 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Status/Assign/FormTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Status/Assign/FormTest.php @@ -37,18 +37,18 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->formFactory = $this->getMock('Magento\Framework\Data\FormFactory', ['create'], [], '', false); + $this->formFactory = $this->getMock(\Magento\Framework\Data\FormFactory::class, ['create'], [], '', false); $this->collectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory::class, ['create'], [], '', false ); - $this->orderConfig = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); + $this->orderConfig = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); $this->block = $objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Status\Assign\Form', + \Magento\Sales\Block\Adminhtml\Order\Status\Assign\Form::class, [ 'formFactory' => $this->formFactory, 'collectionFactory' => $this->collectionFactory, @@ -67,9 +67,15 @@ public function testToHtml() array_unshift($statusesForField, ['value' => '', 'label' => '']); $statesForField = array_merge(['' => ''], $states); - $form = $this->getMock('Magento\Framework\Data\Form', [], [], '', false); - $fieldset = $this->getMock('Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false); - $collection = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Status\Collection', [], [], '', false); + $form = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); + $fieldset = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false); + $collection = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Status\Collection::class, + [], + [], + '', + false + ); $form->expects($this->once()) ->method('addFieldset') diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php index a6f0965577fc8..ca583856c2397 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php @@ -20,7 +20,7 @@ protected function setUp() 'tax' => 'tax', 'shipping_tax' => 'shipping_tax', ]; - $taxHelperMock = $this->getMockBuilder('Magento\Tax\Helper\Data') + $taxHelperMock = $this->getMockBuilder(\Magento\Tax\Helper\Data::class) ->setMethods(['getCalculatedTaxes']) ->disableOriginalConstructor() ->getMock(); @@ -28,7 +28,7 @@ protected function setUp() ->method('getCalculatedTaxes') ->will($this->returnValue($getCalculatedTax)); - $this->taxMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Totals\Tax') + $this->taxMock = $this->getMockBuilder(\Magento\Sales\Block\Adminhtml\Order\Totals\Tax::class) ->setConstructorArgs($this->_getConstructArguments($taxHelperMock)) ->setMethods(['getOrder', 'getSource']) ->getMock(); @@ -84,7 +84,7 @@ protected function _getConstructArguments($taxHelperMock) { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); return $objectManagerHelper->getConstructArguments( - 'Magento\Sales\Block\Adminhtml\Order\Totals\Tax', + \Magento\Sales\Block\Adminhtml\Order\Totals\Tax::class, ['taxHelper' => $taxHelperMock] ); } @@ -98,7 +98,7 @@ protected function _getConstructArguments($taxHelperMock) */ public function getFullTaxInfoDataProvider() { - $salesModelOrderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $salesModelOrderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); return [ @@ -122,11 +122,11 @@ public function getFullTaxInfoDataProvider() */ public function getCreditAndInvoiceFullTaxInfoDataProvider() { - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); - $creditMemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $creditMemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/GiftmessageTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/GiftmessageTest.php index 367cc3c2c553e..2a09e0ebea205 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/GiftmessageTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/GiftmessageTest.php @@ -14,7 +14,7 @@ public function testGetSaveButtonHtml() /** @var $block \Magento\Sales\Block\Adminhtml\Order\View\Giftmessage */ $block = $this->getMock( - 'Magento\Sales\Block\Adminhtml\Order\View\Giftmessage', + \Magento\Sales\Block\Adminhtml\Order\View\Giftmessage::class, ['getChildBlock', 'getChildHtml'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/HistoryTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/HistoryTest.php index d03ca7e8fdc82..aea134fee8257 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/HistoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/HistoryTest.php @@ -19,12 +19,12 @@ class HistoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->adminHelperMock = $this->getMockBuilder('Magento\Sales\Helper\Admin') + $this->adminHelperMock = $this->getMockBuilder(\Magento\Sales\Helper\Admin::class) ->disableOriginalConstructor() ->getMock(); $this->viewHistory = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Sales\Block\Adminhtml\Order\View\History', + \Magento\Sales\Block\Adminhtml\Order\View\History::class, [ 'adminHelper' => $this->adminHelperMock ] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/InfoTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/InfoTest.php index ea4ac59bb1d0a..25ec3ef8b2339 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/InfoTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/InfoTest.php @@ -50,15 +50,22 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock - = $this->getMock('Magento\Backend\Block\Template\Context', ['getAuthorization'], [], '', false); - $this->authorizationMock = $this->getMock('Magento\Framework\AuthorizationInterface', [], [], '', false); + = $this->getMock(\Magento\Backend\Block\Template\Context::class, ['getAuthorization'], [], '', false); + $this->authorizationMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class, [], [], '', false); $this->contextMock ->expects($this->any())->method('getAuthorization')->will($this->returnValue($this->authorizationMock)); - $this->groupRepositoryMock = $this->getMockForAbstractClass('Magento\Customer\Api\GroupRepositoryInterface'); - $this->coreRegistryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->groupRepositoryMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\GroupRepositoryInterface::class + ); + $this->coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $methods = ['getCustomerGroupId', '__wakeUp']; - $this->orderMock = $this->getMock('\Magento\Sales\Model\Order', $methods, [], '', false); - $this->groupMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\GroupInterface', [], '', false); + $this->orderMock = $this->getMock(\Magento\Sales\Model\Order::class, $methods, [], '', false); + $this->groupMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\GroupInterface::class, + [], + '', + false + ); $arguments = [ 'context' => $this->contextMock, 'groupRepository' => $this->groupRepositoryMock, @@ -67,19 +74,25 @@ protected function setUp() $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $block */ - $this->block = $helper->getObject('Magento\Sales\Block\Adminhtml\Order\View\Info', $arguments); + $this->block = $helper->getObject(\Magento\Sales\Block\Adminhtml\Order\View\Info::class, $arguments); } public function testGetAddressEditLink() { - $contextMock = $this->getMock('Magento\Backend\Block\Template\Context', ['getAuthorization'], [], '', false); - $authorizationMock = $this->getMock('Magento\Framework\AuthorizationInterface', [], [], '', false); + $contextMock = $this->getMock( + \Magento\Backend\Block\Template\Context::class, + ['getAuthorization'], + [], + '', + false + ); + $authorizationMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class, [], [], '', false); $contextMock->expects($this->any())->method('getAuthorization')->will($this->returnValue($authorizationMock)); $arguments = ['context' => $contextMock]; $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $block */ - $block = $helper->getObject('Magento\Sales\Block\Adminhtml\Order\View\Info', $arguments); + $block = $helper->getObject(\Magento\Sales\Block\Adminhtml\Order\View\Info::class, $arguments); $authorizationMock->expects($this->atLeastOnce()) ->method('isAllowed') diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/HistoryTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/HistoryTest.php index 79b349feabd88..6445fd36dd146 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/HistoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/HistoryTest.php @@ -34,11 +34,11 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->coreRegistryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->adminHelperMock = $this->getMock('\Magento\Sales\Helper\Admin', [], [], '', false); + $this->coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->adminHelperMock = $this->getMock(\Magento\Sales\Helper\Admin::class, [], [], '', false); $this->commentsHistory = $this->objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Order\View\Tab\History', + \Magento\Sales\Block\Adminhtml\Order\View\Tab\History::class, [ 'adminHelper' => $this->adminHelperMock, 'registry' => $this->coreRegistryMock diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/TransactionsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/TransactionsTest.php index 9f13bad0dc8d3..a2748bc2727ee 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/TransactionsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/TransactionsTest.php @@ -44,10 +44,10 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->authorizationMock = $this->getMock('\Magento\Framework\Authorization', [], [], '', false); - $this->coreRegistryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->orderMock = $this->getMock('\Magento\Sales\Model\Order', [], [], '', false); - $this->paymentMock = $this->getMock('\Magento\Sales\Model\Order\Payment', [], [], '', false); + $this->authorizationMock = $this->getMock(\Magento\Framework\Authorization::class, [], [], '', false); + $this->coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->orderMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); + $this->paymentMock = $this->getMock(\Magento\Sales\Model\Order\Payment::class, [], [], '', false); $this->coreRegistryMock->expects($this->any()) ->method('registry') @@ -59,7 +59,7 @@ protected function setUp() ->willReturn($this->paymentMock); $this->transactionsTab = $this->objectManager->getObject( - 'Magento\Sales\Block\Adminhtml\Order\View\Tab\Transactions', + \Magento\Sales\Block\Adminhtml\Order\View\Tab\Transactions::class, [ 'authorization' => $this->authorizationMock, 'registry' => $this->coreRegistryMock @@ -69,7 +69,7 @@ protected function setUp() public function testGetOrder() { - $this->assertInstanceOf('\Magento\Sales\Model\Order', $this->transactionsTab->getOrder()); + $this->assertInstanceOf(\Magento\Sales\Model\Order::class, $this->transactionsTab->getOrder()); } /** @@ -94,11 +94,11 @@ public function testCanShowTab($methodClass, $expectedResult) public function canShowTabDataProvider() { return [ - ['\Magento\Sales\Test\Unit\Block\Adminhtml\Order\View\Tab\Stub\OnlineMethod', true], - ['\Magento\OfflinePayments\Model\Cashondelivery', false], - ['\Magento\OfflinePayments\Model\Checkmo', false], - ['\Magento\OfflinePayments\Model\Banktransfer', false], - ['\Magento\OfflinePayments\Model\Purchaseorder', false] + [\Magento\Sales\Test\Unit\Block\Adminhtml\Order\View\Tab\Stub\OnlineMethod::class, true], + [\Magento\OfflinePayments\Model\Cashondelivery::class, false], + [\Magento\OfflinePayments\Model\Checkmo::class, false], + [\Magento\OfflinePayments\Model\Banktransfer::class, false], + [\Magento\OfflinePayments\Model\Purchaseorder::class, false] ]; } diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Rss/Order/Grid/LinkTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Rss/Order/Grid/LinkTest.php index 7f19faa79055f..1c856b20d4b1a 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Rss/Order/Grid/LinkTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Rss/Order/Grid/LinkTest.php @@ -40,13 +40,13 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->urlBuilderInterface = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); - $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->urlBuilderInterface = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); + $this->scopeConfigInterface = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->link = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Adminhtml\Rss\Order\Grid\Link', + \Magento\Sales\Block\Adminhtml\Rss\Order\Grid\Link::class, [ 'context' => $this->context, 'rssUrlBuilder' => $this->urlBuilderInterface, diff --git a/app/code/Magento/Sales/Test/Unit/Block/Guest/LinkTest.php b/app/code/Magento/Sales/Test/Unit/Block/Guest/LinkTest.php index 81316c27e27de..4b432f55c5745 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Guest/LinkTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Guest/LinkTest.php @@ -14,8 +14,8 @@ public function testToHtml() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $context = $objectManagerHelper->getObject('Magento\Framework\View\Element\Template\Context'); - $httpContext = $this->getMockBuilder('\Magento\Framework\App\Http\Context') + $context = $objectManagerHelper->getObject(\Magento\Framework\View\Element\Template\Context::class); + $httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -25,7 +25,7 @@ public function testToHtml() /** @var \Magento\Sales\Block\Guest\Link $link */ $link = $objectManagerHelper->getObject( - 'Magento\Sales\Block\Guest\Link', + \Magento\Sales\Block\Guest\Link::class, [ 'context' => $context, 'httpContext' => $httpContext, diff --git a/app/code/Magento/Sales/Test/Unit/Block/Items/AbstractTest.php b/app/code/Magento/Sales/Test/Unit/Block/Items/AbstractTest.php index 5f62404bab964..84c75cb316f2f 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Items/AbstractTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Items/AbstractTest.php @@ -21,14 +21,14 @@ public function testGetItemRenderer() { $rendererType = 'some-type'; $renderer = $this->getMock( - 'Magento\Framework\View\Element\AbstractBlock', + \Magento\Framework\View\Element\AbstractBlock::class, ['setRenderedBlock'], [], '', false ); - $rendererList = $this->getMock('Magento\Framework\View\Element\RendererList', [], [], '', false); + $rendererList = $this->getMock(\Magento\Framework\View\Element\RendererList::class, [], [], '', false); $rendererList->expects( $this->once() )->method( @@ -41,7 +41,7 @@ public function testGetItemRenderer() ); $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock'], [], '', @@ -62,10 +62,10 @@ public function testGetItemRenderer() /** @var $block \Magento\Sales\Block\Items\AbstractItems */ $block = $this->_objectManager->getObject( - 'Magento\Sales\Block\Items\AbstractItems', + \Magento\Sales\Block\Items\AbstractItems::class, [ 'context' => $this->_objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $layout] ) ] @@ -83,7 +83,7 @@ public function testGetItemRenderer() public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock'], [], '', @@ -93,10 +93,10 @@ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() /** @var $block \Magento\Sales\Block\Items\AbstractItems */ $block = $this->_objectManager->getObject( - 'Magento\Sales\Block\Items\AbstractItems', + \Magento\Sales\Block\Items\AbstractItems::class, [ 'context' => $this->_objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['layout' => $layout] ) ] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php index 58d593c67ccc8..6e14d80eb4383 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php @@ -47,10 +47,10 @@ class TotalsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->helperManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + $this->sessionQuoteMock = $this->getMockBuilder(\Magento\Backend\Model\Session\Quote::class) ->disableOriginalConstructor() ->getMock(); - $this->quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $this->quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->setMethods([ 'setTotalsCollectedFlag', @@ -61,10 +61,10 @@ protected function setUp() 'getShippingAddress' ]) ->getMock(); - $this->shippingAddressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address') + $this->shippingAddressMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class) ->disableOriginalConstructor() ->getMock(); - $this->billingAddressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address') + $this->billingAddressMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class) ->disableOriginalConstructor() ->getMock(); @@ -76,7 +76,7 @@ protected function setUp() ->willreturn($this->shippingAddressMock); $this->sessionQuoteMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock); $this->totals = $this->helperManager->getObject( - 'Magento\Sales\Block\Adminhtml\Order\Create\Totals', + \Magento\Sales\Block\Adminhtml\Order\Create\Totals::class, ['sessionQuote' => $this->sessionQuoteMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/DefaultItemsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/DefaultItemsTest.php index 0d0a64841ec76..5cc03a7f6552e 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/DefaultItemsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/DefaultItemsTest.php @@ -40,27 +40,27 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods(['getBlock']) ->getMock(); - $this->block = $this->objectManager->getObject( - 'Magento\Sales\Block\Order\Email\Items\DefaultItems', + $this->block = $this->objectManager->getObject( + \Magento\Sales\Block\Order\Email\Items\DefaultItems::class, [ - 'context' => $this->objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + 'context' => $this->objectManager->getObject( + \Magento\Backend\Block\Template\Context::class, ['layout' => $this->layoutMock] ) ] ); - $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + $this->priceRenderBlock = $this->getMockBuilder(\Magento\Backend\Block\Template::class) ->disableOriginalConstructor() ->setMethods(['setItem', 'toHtml']) ->getMock(); - $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/Order/DefaultOrderTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/Order/DefaultOrderTest.php index c721953625099..bc5b4e4a8df89 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/Order/DefaultOrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/Email/Items/Order/DefaultOrderTest.php @@ -40,27 +40,27 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods(['getBlock']) ->getMock(); - $this->block = $this->objectManager->getObject( - 'Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder', + $this->block = $this->objectManager->getObject( + \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder::class, [ - 'context' => $this->objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + 'context' => $this->objectManager->getObject( + \Magento\Backend\Block\Template\Context::class, ['layout' => $this->layoutMock] ) ] ); - $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + $this->priceRenderBlock = $this->getMockBuilder(\Magento\Backend\Block\Template::class) ->disableOriginalConstructor() ->setMethods(['setItem', 'toHtml']) ->getMock(); - $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/HistoryTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/HistoryTest.php index 9e8f325857b6b..06273ac609f40 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/HistoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/HistoryTest.php @@ -44,20 +44,27 @@ class HistoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false, false); + $this->context = $this->getMock( + \Magento\Framework\View\Element\Template\Context::class, + [], + [], + '', + false, + false + ); $this->orderCollectionFactory = - $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\CollectionFactory') + $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class) ->disableOriginalConstructor()->setMethods(['create'])->getMock(); - $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->setMethods(['getCustomerId'])->disableOriginalConstructor()->getMock(); - $this->orderConfig = $this->getMockBuilder('Magento\Sales\Model\Order\Config') + $this->orderConfig = $this->getMockBuilder(\Magento\Sales\Model\Order\Config::class) ->setMethods(['getVisibleOnFrontStatuses'])->disableOriginalConstructor()->getMock(); - $this->pageConfig = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfig = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor()->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); } @@ -77,7 +84,7 @@ public function testConstructMethod() ->will($this->returnValue($statuses)); $orderCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Collection', + \Magento\Sales\Model\ResourceModel\Order\Collection::class, ['addFieldToSelect', 'addFieldToFilter', 'setOrder'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/Info/Buttons/RssTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/Info/Buttons/RssTest.php index 17d2b287cbc41..f143d0346e812 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/Info/Buttons/RssTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/Info/Buttons/RssTest.php @@ -45,15 +45,15 @@ class RssTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); - $this->urlBuilderInterface = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); - $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $request = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->orderFactory = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); + $this->urlBuilderInterface = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); + $this->scopeConfigInterface = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $request = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->rss = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Order\Info\Buttons\Rss', + \Magento\Sales\Block\Order\Info\Buttons\Rss::class, [ 'request' => $request, 'orderFactory' => $this->orderFactory, @@ -65,7 +65,7 @@ protected function setUp() public function testGetLink() { - $order = $this->getMockBuilder('Magento\Sales\Model\Order') + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods(['getId', 'getCustomerId', 'getIncrementId', 'load', '__wakeup', '__sleep']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/Item/Renderer/DefaultRendererTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/Item/Renderer/DefaultRendererTest.php index 6696668ec7aa9..f80ba5e874118 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/Item/Renderer/DefaultRendererTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/Item/Renderer/DefaultRendererTest.php @@ -40,22 +40,22 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods(['getBlock']) ->getMock(); - $this->block = $this->objectManager->getObject( - 'Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer', + $this->block = $this->objectManager->getObject( + \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer::class, [ - 'context' => $this->objectManager->getObject( - 'Magento\Backend\Block\Template\Context', + 'context' => $this->objectManager->getObject( + \Magento\Backend\Block\Template\Context::class, ['layout' => $this->layoutMock] ) ] ); - $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + $this->priceRenderBlock = $this->getMockBuilder(\Magento\Backend\Block\Template::class) ->disableOriginalConstructor() ->setMethods(['setItem', 'toHtml']) ->getMock(); @@ -68,7 +68,7 @@ protected function setUp() 'getDiscountTaxCompensationAmount', 'getWeeeTaxAppliedRowAmount', ]; - $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods($itemMockMethods) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/RecentTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/RecentTest.php index df9dea520a283..817322c3f8307 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/RecentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/RecentTest.php @@ -34,9 +34,16 @@ class RecentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false, false); + $this->context = $this->getMock( + \Magento\Framework\View\Element\Template\Context::class, + [], + [], + '', + false, + false + ); $this->orderCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class, ['create'], [], '', @@ -44,7 +51,7 @@ protected function setUp() false ); $this->customerSession = $this->getMock( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, ['getCustomerId'], [], '', @@ -52,7 +59,7 @@ protected function setUp() false ); $this->orderConfig = $this->getMock( - 'Magento\Sales\Model\Order\Config', + \Magento\Sales\Model\Order\Config::class, ['getVisibleOnFrontStatuses'], [], '', @@ -66,7 +73,7 @@ public function testConstructMethod() $data = []; $attribute = ['customer_id', 'status']; $customerId = 25; - $layout = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false, false); + $layout = $this->getMock(\Magento\Framework\View\Layout::class, ['getBlock'], [], '', false, false); $this->context->expects($this->once()) ->method('getLayout') ->will($this->returnValue($layout)); @@ -80,7 +87,7 @@ public function testConstructMethod() ->will($this->returnValue($statuses)); $orderCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Collection', + \Magento\Sales\Model\ResourceModel\Order\Collection::class, [ 'addAttributeToSelect', 'addFieldToFilter', diff --git a/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php b/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php index 67dbb5783b196..cda74d76c0b66 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php @@ -11,6 +11,7 @@ * Class SidebarTest * * @package Magento\Sales\Block\Reorder + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SidebarTest extends \PHPUnit_Framework_TestCase { @@ -66,31 +67,31 @@ protected function setUp() { $this->markTestIncomplete('MAGETWO-36789'); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->httpContext = $this->getMock('Magento\Framework\App\Http\Context', ['getValue'], [], '', false); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class, ['getValue'], [], '', false); $this->orderCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class, ['create'], [], '', false ); $this->customerSession = $this->getMock( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, ['getCustomerId'], [], '', false ); $this->orderConfig = $this->getMock( - 'Magento\Sales\Model\Order\Config', + \Magento\Sales\Model\Order\Config::class, ['getVisibleOnFrontStatuses'], [], '', false ); $this->orderCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Collection', + \Magento\Sales\Model\ResourceModel\Order\Collection::class, [ 'addAttributeToFilter', 'addAttributeToSort', @@ -101,13 +102,13 @@ protected function setUp() '', false ); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getIsInStock', '__wakeup'], [], '', @@ -127,7 +128,7 @@ protected function tearDown() protected function createBlockObject() { $this->block = $this->objectManagerHelper->getObject( - 'Magento\Sales\Block\Reorder\Sidebar', + \Magento\Sales\Block\Reorder\Sidebar::class, [ 'context' => $this->context, 'orderCollectionFactory' => $this->orderCollectionFactory, @@ -146,12 +147,12 @@ public function testGetIdentities() $productTags = ['catalog_product_1']; $limit = 5; - $storeManager = $this->getMock('Magento\Store\Model\StoreManager', ['getStore'], [], '', false); + $storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, ['getStore'], [], '', false); $this->context->expects($this->once()) ->method('getStoreManager') ->will($this->returnValue($storeManager)); - $store = $this->getMock('Magento\Store\Model', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->once()) ->method('getWebsiteId') ->will($this->returnValue($websiteId)); @@ -161,7 +162,7 @@ public function testGetIdentities() ->will($this->returnValue($store)); $product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['__wakeUp', 'getIdentities', 'getWebsiteIds'], [], '', @@ -175,7 +176,7 @@ public function testGetIdentities() ->will($this->returnValue([$websiteId])); $item = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Item', + \Magento\Sales\Model\ResourceModel\Order\Item::class, ['__wakeup', 'getProduct'], [], '', @@ -186,7 +187,7 @@ public function testGetIdentities() ->will($this->returnValue($product)); $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['__wakeup', 'getParentItemsRandomCollection'], [], '', @@ -252,7 +253,7 @@ public function testIsItemAvailableForReorder() { $productId = 1; $result = true; - $product = $this->getMock('Magento\Catalog\Model\Product', ['getId', '__wakeup'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getId', '__wakeup'], [], '', false); $product->expects($this->once()) ->method('getId') ->will($this->returnValue($productId)); @@ -263,11 +264,11 @@ public function testIsItemAvailableForReorder() ->method('getStockItem') ->will($this->returnValue($this->stockItemMock)); - $orderItem = $this->getMock('Magento\Sales\Model\Order\Item', ['getStore', 'getProduct'], [], '', false); + $orderItem = $this->getMock(\Magento\Sales\Model\Order\Item::class, ['getStore', 'getProduct'], [], '', false); $orderItem->expects($this->any()) ->method('getProduct') ->will($this->returnValue($product)); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->any()) ->method('getWebsiteId') ->will($this->returnValue(10)); @@ -286,7 +287,7 @@ public function testItemNotAvailableForReorderWhenProductNotExist() ->method('getStockItem') ->will($this->returnValue($this->stockItemMock)); - $orderItem = $this->getMock('Magento\Sales\Model\Order\Item', [], [], '', false); + $orderItem = $this->getMock(\Magento\Sales\Model\Order\Item::class, [], [], '', false); $orderItem->expects($this->any()) ->method('getProduct') ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException()); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php index 4ee8de5c5646a..f8c1b8d35a7b5 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php @@ -15,6 +15,7 @@ * Class EmailTest * * @package Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class EmailTest extends \PHPUnit_Framework_TestCase { @@ -77,7 +78,7 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getRequest', 'getResponse', @@ -94,31 +95,38 @@ protected function setUp() false ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $this->messageManager = $this->getMock('Magento\Framework\Message\Manager', ['addSuccess'], [], '', false); - $this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); - $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); - $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->messageManager = $this->getMock( + \Magento\Framework\Message\Manager::class, + ['addSuccess'], + [], + '', + false + ); + $this->session = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get'], [], '', false); + $this->helper = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager); @@ -132,7 +140,7 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); $this->creditmemoEmail = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo\Email', + \Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo\Email::class, [ 'context' => $this->context ] @@ -142,7 +150,7 @@ protected function setUp() public function testEmail() { $cmId = 10000031; - $cmManagement = 'Magento\Sales\Api\CreditmemoManagementInterface'; + $cmManagement = \Magento\Sales\Api\CreditmemoManagementInterface::class; $cmManagementMock = $this->getMock($cmManagement, [], [], '', false); $this->prepareRedirect($cmId); @@ -162,7 +170,7 @@ public function testEmail() ->with('You sent the message.'); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->creditmemoEmail->execute() ); $this->assertEquals($this->response, $this->creditmemoEmail->getResponse()); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Invoice/AbstractInvoice/EmailTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Invoice/AbstractInvoice/EmailTest.php index 52d1cc6a17f60..4761fc79211fa 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Invoice/AbstractInvoice/EmailTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Invoice/AbstractInvoice/EmailTest.php @@ -92,18 +92,18 @@ class EmailTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); - $this->messageManager = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); - $this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); - $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); - $this->helper = $this->getMock('\Magento\Backend\Helper\Data', [], [], '', false); - $this->resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); + $this->messageManager = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->session = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); + $this->helper = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -133,19 +133,19 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactory); - $this->invoiceManagement = $this->getMockBuilder('Magento\Sales\Api\InvoiceManagementInterface') + $this->invoiceManagement = $this->getMockBuilder(\Magento\Sales\Api\InvoiceManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $this->resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->invoiceEmail = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Email', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\Email::class, [ 'context' => $this->context, 'resultForwardFactory' => $this->resultForwardFactory, @@ -157,13 +157,13 @@ public function testEmail() { $invoiceId = 10000031; $orderId = 100000030; - $invoiceClassName = 'Magento\Sales\Model\Order\Invoice'; - $cmNotifierClassName = 'Magento\Sales\Api\InvoiceManagementInterface'; + $invoiceClassName = \Magento\Sales\Model\Order\Invoice::class; + $cmNotifierClassName = \Magento\Sales\Api\InvoiceManagementInterface::class; $invoice = $this->getMock($invoiceClassName, [], [], '', false); $invoice->expects($this->once()) ->method('getEntityId') ->willReturn($invoiceId); - $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $order = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $order->expects($this->once()) ->method('getId') ->willReturn($orderId); @@ -172,7 +172,7 @@ public function testEmail() ->method('getParam') ->with('invoice_id') ->willReturn($invoiceId); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -180,7 +180,7 @@ public function testEmail() ->willReturn($invoice); $this->objectManager->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $invoice->expects($this->once()) @@ -206,7 +206,7 @@ public function testEmail() ->method('setPath') ->with('sales/invoice/view', ['order_id' => $orderId, 'invoice_id' => $invoiceId]) ->willReturnSelf(); - $this->assertInstanceOf('Magento\Backend\Model\View\Result\Redirect', $this->invoiceEmail->execute()); + $this->assertInstanceOf(\Magento\Backend\Model\View\Result\Redirect::class, $this->invoiceEmail->execute()); } public function testEmailNoInvoiceId() @@ -223,7 +223,7 @@ public function testEmailNoInvoiceId() ->with('noroute') ->willReturnSelf(); - $this->assertInstanceOf('Magento\Backend\Model\View\Result\Forward', $this->invoiceEmail->execute()); + $this->assertInstanceOf(\Magento\Backend\Model\View\Result\Forward::class, $this->invoiceEmail->execute()); } public function testEmailNoInvoice() @@ -234,7 +234,7 @@ public function testEmailNoInvoice() ->with('invoice_id') ->willReturn($invoiceId); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -242,7 +242,7 @@ public function testEmailNoInvoice() ->willReturn(null); $this->objectManager->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->resultForwardFactory->expects($this->any()) @@ -253,6 +253,6 @@ public function testEmailNoInvoice() ->with('noroute') ->willReturnSelf(); - $this->assertInstanceOf('Magento\Backend\Model\View\Result\Forward', $this->invoiceEmail->execute()); + $this->assertInstanceOf(\Magento\Backend\Model\View\Result\Forward::class, $this->invoiceEmail->execute()); } } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CancelTest.php index 10636f0b82809..3e6faf63608ec 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CancelTest.php @@ -11,6 +11,8 @@ /** * Class CancelTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CancelTest extends \PHPUnit_Framework_TestCase { @@ -63,44 +65,44 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [], [], '', false ); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->messageManager = $this->getMock( - 'Magento\Framework\Message\Manager', + \Magento\Framework\Message\Manager::class, ['addSuccess', 'addError'], [], '', false ); - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->validatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirect = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager); @@ -111,7 +113,7 @@ protected function setUp() $this->context->expects($this->once())->method('getFormKeyValidator')->willReturn($this->validatorMock); $this->controller = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Cancel', + \Magento\Sales\Controller\Adminhtml\Order\Cancel::class, [ 'context' => $this->context, 'request' => $this->request, diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php index b657e29a0dee9..46f92dc142b64 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php @@ -13,6 +13,8 @@ /** * Class ProcessDataTest * + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ProcessDataTest extends \PHPUnit_Framework_TestCase { @@ -64,10 +66,10 @@ class ProcessDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->request = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -89,7 +91,7 @@ protected function setUp() ] ); $response = $this->getMockForAbstractClass( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, [], '', false, @@ -100,23 +102,23 @@ protected function setUp() $context->expects($this->any())->method('getResponse')->willReturn($response); $context->expects($this->any())->method('getRequest')->willReturn($this->request); - $this->messageManager = $this->getMock('Magento\Framework\Message\ManagerInterface', [], [], '', false); + $this->messageManager = $this->getMock(\Magento\Framework\Message\ManagerInterface::class, [], [], '', false); $context->expects($this->any())->method('getMessageManager')->willReturn($this->messageManager); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $context->expects($this->any())->method('getEventManager')->willReturn($this->eventManager); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $context->expects($this->any())->method('getObjectManager')->willReturn($this->objectManager); - $this->session = $this->getMock('Magento\Backend\Model\Session\Quote', [], [], '', false); + $this->session = $this->getMock(\Magento\Backend\Model\Session\Quote::class, [], [], '', false); $context->expects($this->any())->method('getSession')->willReturn($this->session); - $this->escaper = $this->getMock('Magento\Framework\Escaper', ['escapeHtml'], [], '', false); + $this->escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); - $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $this->resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -126,7 +128,7 @@ protected function setUp() ->willReturn($this->resultForward); $this->processData = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Create\ProcessData', + \Magento\Sales\Controller\Adminhtml\Order\Create\ProcessData::class, [ 'context' => $context, 'escaper' => $this->escaper, @@ -145,13 +147,13 @@ protected function setUp() public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCouponCode) { $quote = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getCouponCode', 'isVirtual', 'getAllItems'], [], '', false ); - $create = $this->getMock('Magento\Sales\Model\AdminOrder\Create', [], [], '', false); + $create = $this->getMock(\Magento\Sales\Model\AdminOrder\Create::class, [], [], '', false); $paramReturnMap = [ ['customer_id', null, null], @@ -161,8 +163,8 @@ public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCoup $this->request->expects($this->atLeastOnce())->method('getParam')->willReturnMap($paramReturnMap); $objectManagerParamMap = [ - ['Magento\Sales\Model\AdminOrder\Create', $create], - ['Magento\Backend\Model\Session\Quote', $this->session] + [\Magento\Sales\Model\AdminOrder\Create::class, $create], + [\Magento\Backend\Model\Session\Quote::class, $this->session] ]; $this->objectManager->expects($this->atLeastOnce())->method('get')->willReturnMap($objectManagerParamMap); @@ -196,7 +198,7 @@ public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCoup $create->expects($this->once())->method('initRuleData')->willReturnSelf(); $create->expects($this->any())->method('getQuote')->willReturn($quote); - $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $address = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $create->expects($this->once())->method('getBillingAddress')->willReturn($address); $quote->expects($this->any())->method('isVirtual')->willReturn(true); @@ -207,7 +209,7 @@ public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCoup $this->session->expects($this->any())->method('getQuote')->willReturn($quote); $item = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Collection\AbstractCollection', + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], '', false, @@ -233,7 +235,7 @@ public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCoup ->method('forward') ->with('index') ->willReturnSelf(); - $this->assertInstanceOf('Magento\Backend\Model\View\Result\Forward', $this->processData->execute()); + $this->assertInstanceOf(\Magento\Backend\Model\View\Result\Forward::class, $this->processData->execute()); } public function isApplyDiscountDataProvider() diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php index 1d44e2dfad3c9..90645efa53848 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php @@ -7,6 +7,8 @@ /** * Class AddCommentTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddCommentTest extends \PHPUnit_Framework_TestCase { @@ -82,17 +84,17 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) @@ -107,37 +109,37 @@ protected function setUp() $this->contextMock->expects($this->any()) ->method('getTitle') ->will($this->returnValue($titleMock)); - $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + $this->loaderMock = $this->getMockBuilder(\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class) ->disableOriginalConstructor() ->getMock(); - $this->senderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender') + $this->senderMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Email\Sender\CreditmemoSender::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') + $this->resultRawFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $this->resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRawMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') + $this->resultRawMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\AddComment', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\AddComment::class, [ 'context' => $this->contextMock, 'creditmemoLoader' => $this->loaderMock, @@ -172,7 +174,7 @@ public function testExecuteModelException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Json', + \Magento\Framework\Controller\Result\Json::class, $this->controller->execute() ); } @@ -200,7 +202,7 @@ public function testExecuteException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Json', + \Magento\Framework\Controller\Result\Json::class, $this->controller->execute() ); } @@ -229,7 +231,7 @@ public function testExecuteNoComment() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Json', + \Magento\Framework\Controller\Result\Json::class, $this->controller->execute() ); } @@ -245,16 +247,16 @@ public function testExecute() $data = ['comment' => $comment]; $html = 'test output'; - $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); - $commentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo\Comment') + $commentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo\Comment::class) ->disableOriginalConstructor() ->getMock(); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->getMock(); - $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Comments') + $blockMock = $this->getMockBuilder(\Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Comments::class) ->disableOriginalConstructor() ->getMock(); @@ -293,7 +295,7 @@ public function testExecute() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Raw', + \Magento\Framework\Controller\Result\Raw::class, $this->controller->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php index 2be4529c52d6a..f0781784349e0 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php @@ -7,6 +7,8 @@ /** * Class CancelTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CancelTest extends \PHPUnit_Framework_TestCase { @@ -86,52 +88,54 @@ class CancelTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->creditmemoManagementMock = $this->getMock( - 'Magento\Sales\Api\CreditmemoManagementInterface', + \Magento\Sales\Api\CreditmemoManagementInterface::class, [], [], '', false ); - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) ->method('getHelper') ->will($this->returnValue($this->helperMock)); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) @@ -161,7 +165,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Cancel', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Cancel::class, [ 'context' => $this->contextMock, 'resultForwardFactory' => $this->resultForwardFactoryMock @@ -184,7 +188,7 @@ public function testExecuteModelException() ->willReturn($creditmemoId); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\CreditmemoManagementInterface') + ->with(\Magento\Sales\Api\CreditmemoManagementInterface::class) ->willReturn($this->creditmemoManagementMock); $this->creditmemoManagementMock->expects($this->once()) ->method('cancel') @@ -199,7 +203,7 @@ public function testExecuteModelException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute() ); } @@ -219,7 +223,7 @@ public function testExecuteException() ->willReturn($creditmemoId); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\CreditmemoManagementInterface') + ->with(\Magento\Sales\Api\CreditmemoManagementInterface::class) ->willReturn($this->creditmemoManagementMock); $this->creditmemoManagementMock->expects($this->once()) ->method('cancel') @@ -234,7 +238,7 @@ public function testExecuteException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute() ); } @@ -257,7 +261,7 @@ public function testExecuteNoCreditmemo() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Forward', + \Magento\Backend\Model\View\Result\Forward::class, $this->controller->execute() ); } @@ -275,7 +279,7 @@ public function testExecute() ->willReturn($creditmemoId); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\CreditmemoManagementInterface') + ->with(\Magento\Sales\Api\CreditmemoManagementInterface::class) ->willReturn($this->creditmemoManagementMock); $this->creditmemoManagementMock->expects($this->once()) ->method('cancel') @@ -292,7 +296,7 @@ public function testExecute() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php index b781d72a535f8..4b23d24334bfe 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php @@ -8,6 +8,7 @@ /** * Class NewActionTest * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class NewActionTest extends \PHPUnit_Framework_TestCase { @@ -83,31 +84,31 @@ class NewActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->creditmemoLoaderMock = $this->getMock( - 'Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader', + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class, ['setOrderId', 'setCreditmemoId', 'setCreditmemo', 'setInvoiceId', 'load'], [], '', false ); $this->creditmemoMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, ['getInvoice', '__wakeup', 'setCommentText'], [], '', false ); $this->invoiceMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, ['getIncrementId', '__wakeup'], [], '', false ); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->requestMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -116,7 +117,7 @@ protected function setUp() [] ); $this->responseMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, [], '', false, @@ -124,13 +125,19 @@ protected function setUp() true, [] ); - $this->titleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->backendSessionMock = $this->getMock('Magento\Backend\Model\Session', ['getCommentText'], [], '', false); + $this->backendSessionMock = $this->getMock( + \Magento\Backend\Model\Session::class, + ['getCommentText'], + [], + '', + false + ); $this->layoutMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, [], '', false, @@ -138,11 +145,11 @@ protected function setUp() true, [] ); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); @@ -158,7 +165,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\NewAction', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\NewAction::class, [ 'context' => $this->contextMock, 'creditmemoLoader' => $this->creditmemoLoaderMock, @@ -210,7 +217,7 @@ public function testExecute() ])); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with($this->equalTo('Magento\Backend\Model\Session')) + ->with($this->equalTo(\Magento\Backend\Model\Session::class)) ->will($this->returnValue($this->backendSessionMock)); $this->backendSessionMock->expects($this->once()) ->method('getCommentText') @@ -237,7 +244,7 @@ public function testExecute() ->willReturn($this->pageConfigMock); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Page', + \Magento\Backend\Model\View\Result\Page::class, $this->controller->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php index 55580d9688c74..ece03f0c7b59a 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php @@ -83,10 +83,11 @@ class PrintActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMock(); - $this->creditmemoLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') - ->disableOriginalConstructor() + $this->creditmemoLoaderMock = $this->getMockBuilder( + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class + )->disableOriginalConstructor() ->setMethods( [ 'setOrderId', @@ -97,50 +98,51 @@ protected function setUp() ] ) ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMock(); $this->creditmemoRepositoryMock = $this->getMock( - 'Magento\Sales\Api\CreditmemoRepositoryInterface', + \Magento\Sales\Api\CreditmemoRepositoryInterface::class, [], [], '', false ); - $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); - $this->creditmemoPdfMock = $this->getMockBuilder('Magento\Sales\Model\Order\Pdf\Creditmemo') + $this->creditmemoPdfMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Pdf\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); - $this->pdfMock = $this->getMockBuilder('Zend_Pdf') + $this->pdfMock = $this->getMockBuilder(\Zend_Pdf::class) ->disableOriginalConstructor() ->getMock(); - $this->dateTimeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + $this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); - $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + $this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $objectManager->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'request' => $this->requestMock, 'objectManager' => $this->objectManagerMock ] ); $this->printAction = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction::class, [ 'context' => $this->context, 'fileFactory' => $this->fileFactoryMock, @@ -166,8 +168,8 @@ public function testExecute() ->method('create') ->willReturnMap( [ - ['Magento\Sales\Model\Order\Creditmemo', [], $this->creditmemoMock], - ['Magento\Sales\Model\Order\Pdf\Creditmemo', [], $this->creditmemoPdfMock] + [\Magento\Sales\Model\Order\Creditmemo::class, [], $this->creditmemoMock], + [\Magento\Sales\Model\Order\Pdf\Creditmemo::class, [], $this->creditmemoPdfMock] ] ); $this->creditmemoRepositoryMock->expects($this->once()) @@ -180,7 +182,7 @@ public function testExecute() ->willReturn($this->pdfMock); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\Stdlib\DateTime\DateTime') + ->with(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->willReturn($this->dateTimeMock); $this->dateTimeMock->expects($this->once()) ->method('date') @@ -200,7 +202,7 @@ public function testExecute() ->willReturn($this->responseMock); $this->assertInstanceOf( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, $this->printAction->execute() ); } @@ -221,7 +223,7 @@ public function testExecuteNoCreditmemoId() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Forward', + \Magento\Backend\Model\View\Result\Forward::class, $this->printAction->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/SaveTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/SaveTest.php index d181c61f60340..b77804b1284a7 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/SaveTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/SaveTest.php @@ -74,46 +74,47 @@ class SaveTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->_responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $this->_responseMock->headersSentThrowsException = false; - $this->_requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $constructArguments = $objectManager->getConstructArguments( - 'Magento\Backend\Model\Session', + $constructArguments = $objectManager->getConstructArguments(\Magento\Backend\Model\Session::class, ['storage' => new \Magento\Framework\Session\Storage()] ); $this->_sessionMock = $this->getMock( - 'Magento\Backend\Model\Session', + \Magento\Backend\Model\Session::class, ['setFormData'], $constructArguments ); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false, false); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false, false); $this->_objectManager->expects( $this->any() )->method( 'get' )->with( - $this->equalTo('Magento\Framework\Registry') + $this->equalTo(\Magento\Framework\Registry::class) )->will( $this->returnValue($registryMock) ); $this->_messageManager = $this->getMock( - '\Magento\Framework\Message\ManagerInterface', + \Magento\Framework\Message\ManagerInterface::class, [], [], '', @@ -129,13 +130,13 @@ protected function setUp() 'resultRedirectFactory' => $this->resultRedirectFactoryMock ]; - $context = $helper->getObject('Magento\Backend\App\Action\Context', $arguments); + $context = $helper->getObject(\Magento\Backend\App\Action\Context::class, $arguments); $this->memoLoaderMock = $this->getMock( - '\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader', [], [], '', false + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class, [], [], '', false ); $this->_controller = $helper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Save', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Save::class, [ 'context' => $context, 'creditmemoLoader' => $this->memoLoaderMock, @@ -161,7 +162,7 @@ public function testSaveActionOnlineRefundToStoreCredit() $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValue(null)); $creditmemoMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, ['load', 'getGrandTotal', '__wakeup'], [], '', @@ -189,7 +190,7 @@ public function testSaveActionOnlineRefundToStoreCredit() ); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->_controller->execute() ); } @@ -212,7 +213,7 @@ public function testSaveActionWithNegativeCreditmemo() $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValue(null)); $creditmemoMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, ['load', 'getGrandTotal', 'getAllowZeroGrandTotal', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php index dc53c52e05011..a407fe46ac4c6 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php @@ -8,6 +8,7 @@ /** * Class UpdateQtyTest * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpdateQtyTest extends \PHPUnit_Framework_TestCase { @@ -103,36 +104,36 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeup']) ->getMock(); - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) ->method('getHelper') ->will($this->returnValue($this->helperMock)); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) @@ -156,34 +157,34 @@ protected function setUp() $this->contextMock->expects($this->any()) ->method('getMessageManager') ->will($this->returnValue($this->messageManagerMock)); - $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + $this->loaderMock = $this->getMockBuilder(\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') + $this->resultRawFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $this->resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRawMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') + $this->resultRawMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\UpdateQty', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\UpdateQty::class, [ 'context' => $this->contextMock, 'creditmemoLoader' => $this->loaderMock, @@ -220,7 +221,7 @@ public function testExecuteModelException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Json', + \Magento\Framework\Controller\Result\Json::class, $this->controller->execute() ); } @@ -251,7 +252,7 @@ public function testExecuteException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Json', + \Magento\Framework\Controller\Result\Json::class, $this->controller->execute() ); } @@ -270,10 +271,10 @@ public function testExecute() ->withAnyParameters() ->willReturnArgument(0); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->getMock(); - $blockMock = $this->getMockBuilder('Magento\Sales\Block\Order\Items') + $blockMock = $this->getMockBuilder(\Magento\Sales\Block\Order\Items::class) ->disableOriginalConstructor() ->getMock(); @@ -299,7 +300,7 @@ public function testExecute() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\Raw', + \Magento\Framework\Controller\Result\Raw::class, $this->controller->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php index e2ad9a10fa29f..4028fcf03c4d1 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php @@ -8,6 +8,7 @@ /** * Class ViewTest * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ViewTest extends \PHPUnit_Framework_TestCase { @@ -106,62 +107,64 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $this->invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); - $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeup']) ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) ->method('getHelper') ->will($this->returnValue($this->helperMock)); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); - $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + $this->loaderMock = $this->getMockBuilder(\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); @@ -195,7 +198,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\View', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\View::class, [ 'context' => $this->contextMock, 'creditmemoLoader' => $this->loaderMock, @@ -222,7 +225,7 @@ public function testExecuteNoCreditMemo() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Forward', + \Magento\Backend\Model\View\Result\Forward::class, $this->controller->execute() ); } @@ -232,10 +235,10 @@ public function testExecuteNoCreditMemo() */ public function testExecute($invoice) { - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->getMock(); - $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View') + $blockMock = $this->getMockBuilder(\Magento\Sales\Block\Adminhtml\Order\Creditmemo\View::class) ->disableOriginalConstructor() ->getMock(); @@ -268,7 +271,7 @@ public function testExecute($invoice) ->willReturn($this->pageConfigMock); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Page', + \Magento\Backend\Model\View\Result\Page::class, $this->controller->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php index b6bc453da5e2a..af21affe74a3b 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php @@ -8,6 +8,7 @@ /** * Class VoidTest * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class VoidTest extends \PHPUnit_Framework_TestCase { @@ -96,53 +97,55 @@ class VoidTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', 'void', '__wakeup']) ->getMock(); - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + $this->loaderMock = $this->getMockBuilder(\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader::class) ->disableOriginalConstructor() ->getMock(); - $this->senderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender') + $this->senderMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Email\Sender\CreditmemoSender::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); @@ -176,7 +179,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Void', + \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Void::class, [ 'context' => $this->contextMock, 'creditmemoLoader' => $this->loaderMock, @@ -206,7 +209,7 @@ public function testExecuteNoCreditmemo() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Forward', + \Magento\Backend\Model\View\Result\Forward::class, $this->controller->execute() ); } @@ -242,7 +245,7 @@ public function testExecuteModelException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute() ); } @@ -278,7 +281,7 @@ public function testExecuteException() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute() ); } @@ -290,13 +293,13 @@ public function testExecute() { $id = '111'; - $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + $transactionMock = $this->getMockBuilder(\Magento\Framework\DB\Transaction::class) ->disableOriginalConstructor() ->getMock(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); @@ -309,7 +312,7 @@ public function testExecute() ->willReturn($this->creditmemoMock); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Framework\DB\Transaction') + ->with(\Magento\Framework\DB\Transaction::class) ->willReturn($transactionMock); $this->creditmemoMock->expects($this->any()) ->method('getOrder') @@ -332,7 +335,7 @@ public function testExecute() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->controller->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CreditmemoLoaderTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CreditmemoLoaderTest.php index 6a600e177a00d..5ced1cf1cc772 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CreditmemoLoaderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/CreditmemoLoaderTest.php @@ -8,6 +8,8 @@ /** * Class CreditmemoLoaderTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CreditmemoLoaderTest extends \PHPUnit_Framework_TestCase { @@ -74,44 +76,50 @@ class CreditmemoLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $data = []; - $this->creditmemoRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\CreditmemoRepositoryInterface') + $this->creditmemoRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\CreditmemoRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->creditmemoFactoryMock = $this->getMock('Magento\Sales\Model\Order\CreditmemoFactory', [], [], '', false); - $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\OrderFactory') + $this->creditmemoFactoryMock = $this->getMock( + \Magento\Sales\Model\Order\CreditmemoFactory::class, + [], + [], + '', + false + ); + $this->orderFactoryMock = $this->getMockBuilder(\Magento\Sales\Model\OrderFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->invoiceRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $this->invoiceRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMockForAbstractClass(); - $this->serviceOrderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Service\OrderFactory') + $this->serviceOrderFactoryMock = $this->getMockBuilder(\Magento\Sales\Model\Service\OrderFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\CatalogInventory\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\CatalogInventory\Helper\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->stockConfiguration = $this->getMockBuilder('Magento\CatalogInventory\Model\Configuration') + $this->stockConfiguration = $this->getMockBuilder(\Magento\CatalogInventory\Model\Configuration::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -136,7 +144,7 @@ public function testLoadByCreditmemoId() $this->loader->setOrderId(1); $this->loader->setCreditmemo('test'); - $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -144,7 +152,7 @@ public function testLoadByCreditmemoId() ->method('get') ->willReturn($creditmemoMock); - $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo', $this->loader->load()); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Creditmemo::class, $this->loader->load()); } public function testLoadCannotCreditmemo() @@ -156,7 +164,7 @@ public function testLoadCannotCreditmemo() $this->loader->setCreditmemo('test'); $this->loader->setInvoiceId($invoiceId); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -172,7 +180,7 @@ public function testLoadCannotCreditmemo() $this->orderFactoryMock->expects($this->once()) ->method('create') ->willReturn($orderMock); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -201,7 +209,7 @@ public function testLoadByOrder() $this->loader->setCreditmemo($data); $this->loader->setInvoiceId($invoiceId); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -217,7 +225,7 @@ public function testLoadByOrder() $this->orderFactoryMock->expects($this->once()) ->method('create') ->willReturn($orderMock); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $invoiceMock->expects($this->any()) @@ -229,16 +237,16 @@ public function testLoadByOrder() $this->invoiceRepositoryMock->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $creditmemoItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo\Item') + $creditmemoItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo\Item::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php index 58aa92c09be4c..c316d8da9c5e3 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php @@ -92,7 +92,7 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getRequest', 'getResponse', @@ -108,42 +108,42 @@ protected function setUp() '', false ); - $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface') + $this->orderManagementMock = $this->getMockBuilder(\Magento\Sales\Api\OrderManagementInterface::class) ->getMockForAbstractClass(); - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->getMockForAbstractClass(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMockForAbstractClass(); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->messageManager = $this->getMock( - 'Magento\Framework\Message\Manager', + \Magento\Framework\Message\Manager::class, ['addSuccess', 'addError'], [], '', false ); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderInterface') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderInterface::class) ->getMockForAbstractClass(); - $this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); - $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false); - $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); - $this->resultRedirect = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->session = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get', 'set'], [], '', false); + $this->helper = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); + $this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager); @@ -156,7 +156,7 @@ protected function setUp() $this->context->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory); $this->orderEmail = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Email', + \Magento\Sales\Controller\Adminhtml\Order\Email::class, [ 'context' => $this->context, 'request' => $this->request, @@ -195,7 +195,7 @@ public function testEmail() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->orderEmail->execute() ); $this->assertEquals($this->response, $this->orderEmail->getResponse()); @@ -227,7 +227,7 @@ public function testEmailNoOrderId() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->orderEmail->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/HoldTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/HoldTest.php index 3d3c62c4ea6fd..45066feb18a99 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/HoldTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/HoldTest.php @@ -11,6 +11,8 @@ /** * Class HoldTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class HoldTest extends \PHPUnit_Framework_TestCase { @@ -63,44 +65,44 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [], [], '', false ); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->messageManager = $this->getMock( - 'Magento\Framework\Message\Manager', + \Magento\Framework\Message\Manager::class, ['addSuccess', 'addError'], [], '', false ); - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->validatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirect = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager); @@ -111,7 +113,7 @@ protected function setUp() $this->context->expects($this->once())->method('getFormKeyValidator')->willReturn($this->validatorMock); $this->controller = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Hold', + \Magento\Sales\Controller\Adminhtml\Order\Hold::class, [ 'context' => $this->context, 'request' => $this->request, diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php index 93d776a35d1f1..a878af7ac18c3 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php @@ -11,6 +11,7 @@ /** * Class AddCommentTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddCommentTest extends \PHPUnit_Framework_TestCase { @@ -88,36 +89,36 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\View') + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -146,32 +147,33 @@ protected function setUp() ->method('getTitle') ->willReturn($this->pageTitleMock); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $this->resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') + $this->resultRawFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->commentSenderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender') - ->disableOriginalConstructor() + $this->commentSenderMock = $this->getMockBuilder( + \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender::class + )->disableOriginalConstructor() ->setMethods([]) ->getMock(); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\AddComment', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\AddComment::class, [ 'context' => $contextMock, 'invoiceCommentSender' => $this->commentSenderMock, @@ -208,7 +210,7 @@ public function testExecute() ->with('invoice_id') ->willReturn($invoiceId); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -218,7 +220,7 @@ public function testExecute() $invoiceMock->expects($this->once()) ->method('save'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -226,10 +228,10 @@ public function testExecute() ->willReturn($invoiceMock); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $commentsBlockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Invoice\View\Comments') + $commentsBlockMock = $this->getMockBuilder(\Magento\Sales\Block\Adminhtml\Order\Invoice\View\Comments::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -237,7 +239,7 @@ public function testExecute() ->method('toHtml') ->will($this->returnValue($response)); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -258,7 +260,7 @@ public function testExecute() ->method('send') ->with($invoiceMock, false, $data['comment']); - $resultRaw = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') + $resultRaw = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php index 6331e60c69d1c..4e4f1c85d7c24 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php @@ -11,6 +11,8 @@ /** * Class CancelTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CancelTest extends \PHPUnit_Framework_TestCase { @@ -71,48 +73,50 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -142,7 +146,7 @@ protected function setUp() ->willReturn($this->resultRedirectFactoryMock); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Cancel', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\Cancel::class, [ 'context' => $contextMock, 'resultForwardFactory' => $this->resultForwardFactoryMock @@ -162,12 +166,12 @@ public function testExecute() ->with('invoice_id') ->willReturn($invoiceId); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['setIsInProcess', '__wakeup']) ->getMock(); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -177,7 +181,7 @@ public function testExecute() ->method('getOrder') ->will($this->returnValue($orderMock)); - $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + $transactionMock = $this->getMockBuilder(\Magento\Framework\DB\Transaction::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -196,7 +200,7 @@ public function testExecute() ->method('addSuccess') ->with('You canceled the invoice.'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -205,18 +209,18 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->objectManagerMock->expects($this->at(1)) ->method('create') - ->with('Magento\Framework\DB\Transaction') + ->with(\Magento\Framework\DB\Transaction::class) ->will($this->returnValue($transactionMock)); $invoiceMock->expects($this->once()) ->method('getId') ->will($this->returnValue($invoiceId)); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -241,7 +245,7 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -250,10 +254,10 @@ public function testExecuteNoInvoice() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -281,7 +285,7 @@ public function testExecuteModelException() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -297,7 +301,7 @@ public function testExecuteModelException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -306,10 +310,10 @@ public function testExecuteModelException() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -337,7 +341,7 @@ public function testExecuteException() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -353,7 +357,7 @@ public function testExecuteException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -362,10 +366,10 @@ public function testExecuteException() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php index e74264e8fb681..0cfd6ddd4e44b 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php @@ -11,6 +11,7 @@ /** * Class CaptureTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CaptureTest extends \PHPUnit_Framework_TestCase { @@ -76,48 +77,50 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -146,17 +149,17 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); - $this->invoiceManagement = $this->getMockBuilder('Magento\Sales\Api\InvoiceManagementInterface') + $this->invoiceManagement = $this->getMockBuilder(\Magento\Sales\Api\InvoiceManagementInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->any()) ->method('get') - ->with('Magento\Sales\Api\InvoiceManagementInterface') + ->with(\Magento\Sales\Api\InvoiceManagementInterface::class) ->willReturn($this->invoiceManagement); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Capture', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\Capture::class, [ 'context' => $contextMock, 'resultForwardFactory' => $this->resultForwardFactoryMock, @@ -176,7 +179,7 @@ public function testExecute() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['setIsInProcess', '__wakeup']) ->getMock(); @@ -185,7 +188,7 @@ public function testExecute() ->method('setCapture') ->with($invoiceId); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -196,7 +199,7 @@ public function testExecute() ->method('getOrder') ->will($this->returnValue($orderMock)); - $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + $transactionMock = $this->getMockBuilder(\Magento\Framework\DB\Transaction::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -219,7 +222,7 @@ public function testExecute() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -228,14 +231,14 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->objectManagerMock->expects($this->at(2)) ->method('create') - ->with('Magento\Framework\DB\Transaction') + ->with(\Magento\Framework\DB\Transaction::class) ->will($this->returnValue($transactionMock)); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $resultRedirect->expects($this->once())->method('setPath')->with('sales/*/view', ['invoice_id' => $invoiceId]); @@ -259,7 +262,7 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -268,10 +271,10 @@ public function testExecuteNoInvoice() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); $resultForward->expects($this->once())->method('forward')->with(('noroute'))->will($this->returnSelf()); @@ -303,7 +306,7 @@ public function testExecuteModelException() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); @@ -318,7 +321,7 @@ public function testExecuteModelException() ->method('getEntityId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -327,10 +330,10 @@ public function testExecuteModelException() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $resultRedirect->expects($this->once())->method('setPath')->with('sales/*/view', ['invoice_id' => $invoiceId]); @@ -362,7 +365,7 @@ public function testExecuteException() ->with($invoiceId) ->will($this->throwException($e)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); @@ -377,7 +380,7 @@ public function testExecuteException() ->method('getEntityId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -386,10 +389,10 @@ public function testExecuteException() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/NewActionTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/NewActionTest.php index 805b178d83742..233c91946b8c5 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/NewActionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/NewActionTest.php @@ -11,6 +11,7 @@ * Class NewActionTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class NewActionTest extends \PHPUnit_Framework_TestCase { @@ -93,62 +94,63 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\View') + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getCommentText', 'setIsUrlNotice']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -196,12 +198,12 @@ protected function setUp() ->method('getTitle') ->willReturn($this->pageTitleMock); - $this->invoiceServiceMock = $this->getMockBuilder('Magento\Sales\Model\Service\InvoiceService') + $this->invoiceServiceMock = $this->getMockBuilder(\Magento\Sales\Model\Service\InvoiceService::class) ->disableOriginalConstructor() ->getMock(); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\NewAction', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\NewAction::class, [ 'context' => $contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, @@ -225,7 +227,7 @@ public function testExecute() ->with('invoice', []) ->will($this->returnValue($invoiceData)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -233,7 +235,7 @@ public function testExecute() ->method('getTotalQty') ->willReturn(2); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'canInvoice']) ->getMock(); @@ -253,7 +255,7 @@ public function testExecute() ->with($orderMock, []) ->willReturn($invoiceMock); - $menuBlockMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + $menuBlockMock = $this->getMockBuilder(\Magento\Backend\Block\Menu::class) ->disableOriginalConstructor() ->setMethods(['getParentItems', 'getMenuModel']) ->getMock(); @@ -272,11 +274,11 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Model\Order') + ->with(\Magento\Sales\Model\Order::class) ->willReturn($orderMock); $this->objectManagerMock->expects($this->at(1)) ->method('get') - ->with('Magento\Backend\Model\Session') + ->with(\Magento\Backend\Model\Session::class) ->will($this->returnValue($this->sessionMock)); $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order'); @@ -301,7 +303,7 @@ public function testExecuteNoOrder() ->with('invoice', []) ->will($this->returnValue($invoiceData)); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'canInvoice']) ->getMock(); @@ -315,10 +317,10 @@ public function testExecuteNoOrder() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Model\Order') + ->with(\Magento\Sales\Model\Order::class) ->willReturn($orderMock); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/PrintActionTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/PrintActionTest.php index f276708c1e16f..8969460c5bfd8 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/PrintActionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/PrintActionTest.php @@ -11,6 +11,7 @@ /** * Class PrintActionTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PrintActionTest extends \PHPUnit_Framework_TestCase { @@ -53,28 +54,28 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -94,13 +95,13 @@ protected function setUp() ->method('getObjectManager') ->will($this->returnValue($this->objectManagerMock)); - $this->fileFactory = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + $this->fileFactory = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\PrintAction', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\PrintAction::class, [ 'context' => $contextMock, 'fileFactory' => $this->fileFactory @@ -117,17 +118,17 @@ public function testExecute() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceMock = $this->getMock('Magento\Sales\Model\Order\Invoice', [], [], '', false); + $invoiceMock = $this->getMock(\Magento\Sales\Model\Order\Invoice::class, [], [], '', false); - $pdfMock = $this->getMock('Magento\Sales\Model\Order\Pdf\Invoice', ['render', 'getPdf'], [], '', false); + $pdfMock = $this->getMock(\Magento\Sales\Model\Order\Pdf\Invoice::class, ['render', 'getPdf'], [], '', false); $pdfMock->expects($this->once()) ->method('getPdf') ->willReturnSelf(); $pdfMock->expects($this->once()) ->method('render'); - $dateTimeMock = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); + $dateTimeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, [], [], '', false); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -136,15 +137,15 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->objectManagerMock->expects($this->at(1)) ->method('create') - ->with('Magento\Sales\Model\Order\Pdf\Invoice') + ->with(\Magento\Sales\Model\Order\Pdf\Invoice::class) ->willReturn($pdfMock); $this->objectManagerMock->expects($this->at(2)) ->method('get') - ->with('Magento\Framework\Stdlib\DateTime\DateTime') + ->with(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->willReturn($dateTimeMock); $this->assertNull($this->controller->execute()); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/SaveTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/SaveTest.php index 64fce69d52e46..d3275d681bc52 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/SaveTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/SaveTest.php @@ -52,28 +52,28 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->formKeyValidatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->formKeyValidatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any()) @@ -93,7 +93,7 @@ protected function setUp() ->will($this->returnValue($this->messageManagerMock)); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Save', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\Save::class, [ 'context' => $contextMock, ] @@ -107,7 +107,7 @@ protected function setUp() */ public function testExecuteNotValidPost() { - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $this->resultPageFactoryMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php index 0e4ccf48cdd19..491f541a4fe4a 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php @@ -12,6 +12,7 @@ * Class UpdateQtyTest * * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpdateQtyTest extends \PHPUnit_Framework_TestCase { @@ -84,39 +85,39 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\ViewInterface') + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\ViewInterface::class) ->disableOriginalConstructor() ->getMock(); $this->viewMock->expects($this->any())->method('loadLayout')->will($this->returnSelf()); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->pageConfigMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock)); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any()) @@ -135,27 +136,27 @@ protected function setUp() ->method('getObjectManager') ->will($this->returnValue($this->objectManagerMock)); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') + $this->resultRawFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->invoiceServiceMock = $this->getMockBuilder('Magento\Sales\Model\Service\InvoiceService') + $this->invoiceServiceMock = $this->getMockBuilder(\Magento\Sales\Model\Service\InvoiceService::class) ->disableOriginalConstructor() ->getMock(); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\UpdateQty', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\UpdateQty::class, [ 'context' => $contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, @@ -186,7 +187,7 @@ public function testExecute() ->with('invoice', []) ->will($this->returnValue($invoiceData)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -194,7 +195,7 @@ public function testExecute() ->method('getTotalQty') ->willReturn(2); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'canInvoice']) ->getMock(); @@ -216,10 +217,10 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Model\Order') + ->with(\Magento\Sales\Model\Order::class) ->willReturn($orderMock); - $blockItemMock = $this->getMockBuilder('Magento\Sales\Block\Order\Items') + $blockItemMock = $this->getMockBuilder(\Magento\Sales\Block\Order\Items::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -227,7 +228,7 @@ public function testExecute() ->method('toHtml') ->will($this->returnValue($response)); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -249,7 +250,7 @@ public function testExecute() ->method('create') ->will($this->returnValue($this->resultPageMock)); - $resultRaw = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') + $resultRaw = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -270,7 +271,7 @@ public function testExecuteModelException() $message = 'The order no longer exists.'; $response = ['error' => true, 'message' => $message]; - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'canInvoice']) ->getMock(); @@ -282,7 +283,7 @@ public function testExecuteModelException() ->willReturn(null); $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Model\Order') + ->with(\Magento\Sales\Model\Order::class) ->willReturn($orderMock); $this->titleMock->expects($this->never()) @@ -290,7 +291,7 @@ public function testExecuteModelException() ->with('Invoices'); /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ - $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -313,7 +314,7 @@ public function testExecuteException() $message = 'The order no longer exists.'; $response = ['error' => true, 'message' => $message]; - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'canInvoice']) ->getMock(); @@ -325,7 +326,7 @@ public function testExecuteException() ->willReturn(null); $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Model\Order') + ->with(\Magento\Sales\Model\Order::class) ->willReturn($orderMock); $this->titleMock->expects($this->never()) @@ -333,7 +334,7 @@ public function testExecuteException() ->with('Invoices'); /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ - $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php index 8e4ade54c2911..231521502db6b 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php @@ -11,6 +11,7 @@ /** * Class ViewTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ViewTest extends \PHPUnit_Framework_TestCase { @@ -88,42 +89,42 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $this->titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\View') + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getCommentText', 'setIsUrlNotice']) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -158,18 +159,19 @@ protected function setUp() ->method('getTitle') ->willReturn($this->pageTitleMock); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\View', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\View::class, [ 'context' => $contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, @@ -191,7 +193,7 @@ public function testExecute() ->with('come_from') ->willReturn('anything'); - $menuBlockMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + $menuBlockMock = $this->getMockBuilder(\Magento\Backend\Block\Menu::class) ->disableOriginalConstructor() ->setMethods(['getParentItems', 'getMenuModel']) ->getMock(); @@ -203,12 +205,12 @@ public function testExecute() ->with('Magento_Sales::sales_order') ->will($this->returnValue([])); - $invoiceViewBlockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Invoice\View') + $invoiceViewBlockMock = $this->getMockBuilder(\Magento\Sales\Block\Adminhtml\Order\Invoice\View::class) ->disableOriginalConstructor() ->setMethods(['updateBackButtonUrl']) ->getMock(); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -221,12 +223,12 @@ public function testExecute() ->method('getLayout') ->will($this->returnValue($layoutMock)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -235,7 +237,7 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order'); @@ -256,7 +258,7 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -265,10 +267,10 @@ public function testExecuteNoInvoice() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php index 4cd66680b139d..92985f662c6e4 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php @@ -11,6 +11,7 @@ /** * Class VoidTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class VoidTest extends \PHPUnit_Framework_TestCase { @@ -81,94 +82,80 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + $this->titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') - ->disableOriginalConstructor() + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') - ->disableOriginalConstructor() + $this->resultForwardFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\ForwardFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->invoiceManagement = $this->getMockBuilder('Magento\Sales\Api\InvoiceManagementInterface') + $this->invoiceManagement = $this->getMockBuilder(\Magento\Sales\Api\InvoiceManagementInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->any()) ->method('get') - ->with('Magento\Sales\Api\InvoiceManagementInterface') + ->with(\Magento\Sales\Api\InvoiceManagementInterface::class) ->willReturn($this->invoiceManagement); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $contextMock->expects($this->any()) - ->method('getRequest') - ->willReturn($this->requestMock); - $contextMock->expects($this->any()) - ->method('getResponse') - ->willReturn($this->responseMock); - $contextMock->expects($this->any()) - ->method('getObjectManager') - ->willReturn($this->objectManagerMock); - $contextMock->expects($this->any()) - ->method('getMessageManager') - ->willReturn($this->messageManagerMock); - $contextMock->expects($this->any()) - ->method('getTitle') - ->willReturn($this->titleMock); - $contextMock->expects($this->any()) - ->method('getActionFlag') - ->willReturn($this->actionFlagMock); - $contextMock->expects($this->any()) - ->method('getSession') - ->willReturn($this->sessionMock); - $contextMock->expects($this->any()) - ->method('getHelper') - ->willReturn($this->helperMock); + $contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); + $contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock); + $contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); + $contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock); + $contextMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); + $contextMock->expects($this->any())->method('getActionFlag')->willReturn($this->actionFlagMock); + $contextMock->expects($this->any())->method('getSession')->willReturn($this->sessionMock); + $contextMock->expects($this->any())->method('getHelper')->willReturn($this->helperMock); $contextMock->expects($this->any()) ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); $this->controller = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Void', + \Magento\Sales\Controller\Adminhtml\Order\Invoice\Void::class, [ 'context' => $contextMock, 'resultForwardFactory' => $this->resultForwardFactoryMock @@ -188,7 +175,7 @@ public function testExecute() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['setIsInProcess', '__wakeup']) ->getMock(); @@ -198,7 +185,7 @@ public function testExecute() ->with($invoiceId) ->willReturn(true); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $invoiceMock->expects($this->any()) @@ -211,7 +198,7 @@ public function testExecute() ->method('getId') ->will($this->returnValue($invoiceId)); - $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + $transactionMock = $this->getMockBuilder(\Magento\Framework\DB\Transaction::class) ->disableOriginalConstructor() ->getMock(); $transactionMock->expects($this->at(0)) @@ -225,7 +212,7 @@ public function testExecute() $transactionMock->expects($this->at(2)) ->method('save'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -234,18 +221,18 @@ public function testExecute() $this->objectManagerMock->expects($this->at(0)) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->objectManagerMock->expects($this->at(2)) ->method('create') - ->with('Magento\Framework\DB\Transaction') + ->with(\Magento\Framework\DB\Transaction::class) ->will($this->returnValue($transactionMock)); $this->messageManagerMock->expects($this->once()) ->method('addSuccess') ->with('The invoice has been voided.'); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -270,7 +257,7 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -279,7 +266,7 @@ public function testExecuteNoInvoice() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->messageManagerMock->expects($this->never()) @@ -287,7 +274,7 @@ public function testExecuteNoInvoice() $this->messageManagerMock->expects($this->never()) ->method('addSuccess'); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -319,7 +306,7 @@ public function testExecuteModelException() ->with($invoiceId) ->will($this->throwException($e)); - $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $invoiceMock->expects($this->once()) @@ -329,7 +316,7 @@ public function testExecuteModelException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $invoiceRepository = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) @@ -338,13 +325,13 @@ public function testExecuteModelException() $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') + ->with(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->willReturn($invoiceRepository); $this->messageManagerMock->expects($this->once()) ->method('addError'); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php index 7bbd621f6e05d..2073580b5cc51 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php @@ -88,12 +88,12 @@ class MassCancelTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', @@ -101,34 +101,40 @@ protected function setUp() ); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Collection') + $this->orderCollectionMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Collection::class) ->disableOriginalConstructor() ->getMock(); - $resourceCollection = 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory'; + $resourceCollection = \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class; $this->orderCollectionFactoryMock = $this->getMockBuilder($resourceCollection) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); - $this->actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false); - $this->helperMock = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); - $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); + $this->actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get', 'set'], [], '', false); + $this->helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); + $this->resultRedirectMock = $this->getMock( + \Magento\Backend\Model\View\Result\Redirect::class, + [], + [], + '', + false + ); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) @@ -149,7 +155,7 @@ protected function setUp() $this->contextMock->expects($this->any()) ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->orderCollectionMock) @@ -158,7 +164,7 @@ protected function setUp() ->method('create') ->willReturn($this->orderCollectionMock); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\MassCancel', + \Magento\Sales\Controller\Adminhtml\Order\MassCancel::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, @@ -173,10 +179,10 @@ protected function setUp() */ public function testExecuteCanCancelOneOrder() { - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order2 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); $orders = [$order1, $order2]; @@ -224,10 +230,10 @@ public function testExecuteCanCancelOneOrder() */ public function testExcludedCannotCancelOrders() { - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order2 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); @@ -269,7 +275,7 @@ public function testException() { $exception = new \Exception('Can not cancel'); - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); $this->orderCollectionMock->expects($this->any()) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php index 6c98603585e03..4d2e309be1841 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php @@ -93,40 +93,40 @@ class MassHoldTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface') + $this->orderManagementMock = $this->getMockBuilder(\Magento\Sales\Api\OrderManagementInterface::class) ->getMockForAbstractClass(); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, ['create'], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); - $this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Collection') + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->orderCollectionMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Collection::class) ->disableOriginalConstructor() ->getMock(); - $orderCollection = 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory'; + $orderCollection = \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class; $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) @@ -134,10 +134,16 @@ protected function setUp() ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); - $this->actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false); - $this->helperMock = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); - $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); + $this->actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get', 'set'], [], '', false); + $this->helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); + $this->resultRedirectMock = $this->getMock( + \Magento\Backend\Model\View\Result\Redirect::class, + [], + [], + '', + false + ); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -155,7 +161,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->orderCollectionMock) @@ -165,7 +171,7 @@ protected function setUp() ->willReturn($this->orderCollectionMock); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\MassHold', + \Magento\Sales\Controller\Adminhtml\Order\MassHold::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, @@ -177,10 +183,10 @@ protected function setUp() public function testExecuteOneOrderPutOnHold() { - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order2 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); @@ -222,10 +228,10 @@ public function testExecuteOneOrderPutOnHold() public function testExecuteNoOrdersPutOnHold() { - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order2 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php index 7555d9dbb5b44..a8c122e93266c 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php @@ -88,45 +88,51 @@ class MassUnholdTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, [], [], '', false ); - $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false ); - $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); - $this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Collection') + $this->orderCollectionMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Collection::class) ->disableOriginalConstructor() ->getMock(); - $orderCollection = 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory'; + $orderCollection = \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class; $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); - $this->actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false); - $this->helperMock = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); - $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice'], [], '', false); + $this->actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, ['get', 'set'], [], '', false); + $this->helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, ['getUrl'], [], '', false); + $this->resultRedirectMock = $this->getMock( + \Magento\Backend\Model\View\Result\Redirect::class, + [], + [], + '', + false + ); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); - $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); $resultFactoryMock->expects($this->any()) @@ -149,7 +155,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->orderCollectionMock) @@ -159,7 +165,7 @@ protected function setUp() ->willReturn($this->orderCollectionMock); $this->massAction = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\MassUnhold', + \Magento\Sales\Controller\Adminhtml\Order\MassUnhold::class, [ 'context' => $this->contextMock, 'filter' => $this->filterMock, @@ -170,10 +176,10 @@ protected function setUp() public function testExecuteOneOrdersReleasedFromHold() { - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order2 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); @@ -217,10 +223,10 @@ public function testExecuteOneOrdersReleasedFromHold() public function testExecuteNoReleasedOrderFromHold() { - $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order1 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + $order2 = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php index 92b7f87e82819..e937143b9d08a 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php @@ -54,7 +54,7 @@ class ReviewPaymentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->contextMock = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getRequest', 'getResponse', @@ -70,17 +70,17 @@ protected function setUp() '', false ); - $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface') + $this->orderManagementMock = $this->getMockBuilder(\Magento\Sales\Api\OrderManagementInterface::class) ->getMockForAbstractClass(); - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->getMockForAbstractClass(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMockForAbstractClass(); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderInterface') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderInterface::class) ->setMethods(['getPayment']) ->getMockForAbstractClass(); $this->messageManagerMock = $this->getMock( - 'Magento\Framework\Message\Manager', + \Magento\Framework\Message\Manager::class, ['addSuccess', 'addError'], [], '', @@ -88,7 +88,7 @@ protected function setUp() ); $this->resultRedirectFactoryMock = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', @@ -96,7 +96,7 @@ protected function setUp() ); $this->paymentMock = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, ['update', 'getIsTransactionApproved'], [], '', @@ -104,14 +104,14 @@ protected function setUp() ); $this->resultRedirectMock = $this->getMock( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, ['setPath'], [], '', false ); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->setMethods(['getParam']) ->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); @@ -121,7 +121,7 @@ protected function setUp() ->willReturn($this->resultRedirectFactoryMock); $this->reviewPayment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\ReviewPayment', + \Magento\Sales\Controller\Adminhtml\Order\ReviewPayment::class, [ 'context' => $this->contextMock, 'orderManager' => $this->orderManagementMock, @@ -141,7 +141,6 @@ public function testExecuteUpdateAction() $this->resultRedirectFactoryMock->expects($this->once())->method('create') ->willReturn($this->resultRedirectMock); - $this->orderRepositoryMock->expects($this->once()) ->method('get') ->with($orderId) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/UnholdTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/UnholdTest.php index 4f8a3b779ef38..53e2041616db8 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/UnholdTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/UnholdTest.php @@ -11,6 +11,8 @@ /** * Class UnholdTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UnholdTest extends \PHPUnit_Framework_TestCase { @@ -63,44 +65,44 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [], [], '', false ); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->response = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', false ); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->messageManager = $this->getMock( - 'Magento\Framework\Message\Manager', + \Magento\Framework\Message\Manager::class, ['addSuccess', 'addError'], [], '', false ); - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->validatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirect = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager); @@ -111,7 +113,7 @@ protected function setUp() $this->context->expects($this->once())->method('getFormKeyValidator')->willReturn($this->validatorMock); $this->controller = $objectManagerHelper->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\Unhold', + \Magento\Sales\Controller\Adminhtml\Order\Unhold::class, [ 'context' => $this->context, 'request' => $this->request, diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php index 366f3ab5c16e6..ea0f08b31d267 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php @@ -99,51 +99,53 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface') + $this->orderManagementMock = $this->getMockBuilder(\Magento\Sales\Api\OrderManagementInterface::class) ->getMockForAbstractClass(); - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->getMockForAbstractClass(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMockForAbstractClass(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMock(); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMock(); - $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $this->actionFlagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); - $this->coreRegistryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->coreRegistryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfigMock = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactoryMock = $this->getMockBuilder( + \Magento\Backend\Model\View\Result\RedirectFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $objectManager->getObject( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'request' => $this->requestMock, 'objectManager' => $this->objectManagerMock, @@ -153,7 +155,7 @@ protected function setUp() ] ); $this->viewAction = $objectManager->getObject( - 'Magento\Sales\Controller\Adminhtml\Order\View', + \Magento\Sales\Controller\Adminhtml\Order\View::class, [ 'context' => $this->context, 'coreRegistry' => $this->coreRegistryMock, @@ -196,7 +198,7 @@ public function testExecute() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Page', + \Magento\Backend\Model\View\Result\Page::class, $this->viewAction->execute() ); } @@ -223,7 +225,7 @@ public function testExecuteNoOrder() $this->setPath('sales/*/'); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->viewAction->execute() ); } @@ -252,7 +254,7 @@ public function testGlobalException() $this->setPath('sales/order/index'); $this->assertInstanceOf( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, $this->viewAction->execute() ); } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php index 3ebbca491d602..387fc3b782b10 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php @@ -74,27 +74,27 @@ class DownloadCustomOptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $resultForwardFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\ForwardFactory') + $resultForwardFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardMock = $this->getMockBuilder('\Magento\Framework\Controller\Result\Forward') + $this->resultForwardMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Forward::class) ->disableOriginalConstructor() ->setMethods(['forward']) ->getMock(); $resultForwardFactoryMock->expects($this->any())->method('create')->willReturn($this->resultForwardMock); - $this->downloadMock = $this->getMockBuilder('Magento\Sales\Model\Download') + $this->downloadMock = $this->getMockBuilder(\Magento\Sales\Model\Download::class) ->disableOriginalConstructor() ->setMethods(['downloadFile']) ->getMock(); - $this->unserializeMock = $this->getMockBuilder('Magento\Framework\Unserialize\Unserialize') + $this->unserializeMock = $this->getMockBuilder(\Magento\Framework\Unserialize\Unserialize::class) ->disableOriginalConstructor() ->setMethods(['unserialize']) ->getMock(); - $requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->setMethods(['getParam']) ->getMock(); @@ -108,17 +108,17 @@ protected function setUp() ) ); - $this->itemOptionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $this->itemOptionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'getCode', 'getProductId', 'getValue']) ->getMock(); - $this->productOptionMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $this->productOptionMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(['load', 'getId', 'getProductId', 'getType']) ->getMock(); - $objectManagerMock = $this->getMockBuilder('Magento\Sales\Model\Download') + $objectManagerMock = $this->getMockBuilder(\Magento\Sales\Model\Download::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -126,13 +126,13 @@ protected function setUp() ->will( $this->returnValueMap( [ - ['Magento\Quote\Model\Quote\Item\Option', $this->itemOptionMock], - ['Magento\Catalog\Model\Product\Option', $this->productOptionMock], + [\Magento\Quote\Model\Quote\Item\Option::class, $this->itemOptionMock], + [\Magento\Catalog\Model\Product\Option::class, $this->productOptionMock], ] ) ); - $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->setMethods( [ @@ -144,7 +144,7 @@ protected function setUp() $contextMock->expects($this->once())->method('getObjectManager')->willReturn($objectManagerMock); $contextMock->expects($this->once())->method('getRequest')->willReturn($requestMock); - $this->objectMock = $this->getMockBuilder('Magento\Sales\Controller\Download\DownloadCustomOption') + $this->objectMock = $this->getMockBuilder(\Magento\Sales\Controller\Download\DownloadCustomOption::class) ->setMethods(['endExecute']) ->setConstructorArgs( [ diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Guest/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Guest/ViewTest.php index 492a031f27715..b119d25303348 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Guest/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Guest/ViewTest.php @@ -54,31 +54,31 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMock(); - $this->guestHelperMock = $this->getMockBuilder('Magento\Sales\Helper\Guest') + $this->guestHelperMock = $this->getMockBuilder(\Magento\Sales\Helper\Guest::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->resultRedirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->objectManagerHelper->getObject( - 'Magento\Framework\App\Action\Context', + \Magento\Framework\App\Action\Context::class, [ 'request' => $this->requestMock ] ); $this->viewController = $this->objectManagerHelper->getObject( - 'Magento\Sales\Controller\Guest\View', + \Magento\Sales\Controller\Guest\View::class, [ 'context' => $this->context, 'guestHelper' => $this->guestHelperMock, diff --git a/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php b/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php index a0b99f38e7a8a..90cebe5154026 100644 --- a/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php +++ b/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php @@ -29,9 +29,11 @@ class CleanExpiredQuotesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storesConfigMock = $this->getMock('Magento\Store\Model\StoresConfig', [], [], '', false); + $this->storesConfigMock = $this->getMock(\Magento\Store\Model\StoresConfig::class, [], [], '', false); - $this->quoteFactoryMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote\CollectionFactory') + $this->quoteFactoryMock = $this->getMockBuilder( + \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -51,7 +53,7 @@ public function testExecute($lifetimes, $additionalFilterFields) ->with($this->equalTo('checkout/cart/delete_quote_after')) ->will($this->returnValue($lifetimes)); - $quotesMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote\Collection') + $quotesMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->quoteFactoryMock->expects($this->exactly(count($lifetimes))) diff --git a/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php b/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php index 10d7509c0e3a8..ed4852b083c91 100644 --- a/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php +++ b/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php @@ -7,6 +7,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AdminTest extends \PHPUnit_Framework_TestCase { /** @@ -51,23 +54,25 @@ class AdminTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->salesConfigMock = $this->getMockBuilder('Magento\Sales\Model\Config') + $this->salesConfigMock = $this->getMockBuilder(\Magento\Sales\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->priceCurrency = $this->getMockBuilder('\Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $this->priceCurrency = $this->getMockBuilder( + \Magento\Framework\Pricing\PriceCurrencyInterface::class + )->getMock(); - $this->escaperMock = $this->getMockBuilder('Magento\Framework\Escaper') + $this->escaperMock = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->getMock(); $this->adminHelper = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Sales\Helper\Admin', + \Magento\Sales\Helper\Admin::class, [ 'context' => $this->contextMock, 'storeManager' => $this->storeManagerMock, @@ -77,12 +82,12 @@ protected function setUp() ] ); - $this->magentoObjectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $this->magentoObjectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getOrder', 'getData']) ->getMock(); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); $this->orderMock->expects($this->any()) @@ -116,7 +121,7 @@ public function testDisplayPrices( $this->orderMock->expects($this->any()) ->method('isCurrencyDifferent') ->will($this->returnValue($isCurrencyDifferent)); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $this->storeManagerMock->expects($this->any()) @@ -164,7 +169,7 @@ public function testDisplayPriceAttribute( $this->orderMock->expects($this->any()) ->method('isCurrencyDifferent') ->will($this->returnValue($isCurrencyDifferent)); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $this->storeManagerMock->expects($this->any()) @@ -265,20 +270,20 @@ public function displayPricesDataProvider() */ public function testApplySalableProductTypesFilter($itemKey, $type, $calledTimes) { - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); $productMock->expects($this->any()) ->method('getTypeId') ->will($this->returnValue($type)); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods(['__wakeup', 'getProductType']) ->getMock(); $orderMock->expects($this->any()) ->method('getProductType') ->will($this->returnValue($type)); - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->disableOriginalConstructor() ->getMock(); $quoteMock->expects($this->any()) @@ -290,7 +295,7 @@ public function testApplySalableProductTypesFilter($itemKey, $type, $calledTimes 'quote' => $quoteMock, 'other' => 'other', ]; - $collectionClassName = 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection'; + $collectionClassName = \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::class; $collectionMock = $this->getMockBuilder($collectionClassName) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Helper/DataTest.php b/app/code/Magento/Sales/Test/Unit/Helper/DataTest.php index 99d8527860291..7ce726a4b4719 100644 --- a/app/code/Magento/Sales/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Helper/DataTest.php @@ -6,6 +6,9 @@ namespace Magento\Sales\Test\Unit\Helper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DataTest extends \PHPUnit_Framework_TestCase { /** @@ -28,25 +31,25 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any()) ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $pricingCurrencyMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface') + $pricingCurrencyMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -57,7 +60,7 @@ protected function setUp() $pricingCurrencyMock ); - $this->storeMock = $this->getMockBuilder('Magento\Sales\Model\Store') + $this->storeMock = $this->getMockBuilder(\Magento\Sales\Model\Store::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/Sales/Test/Unit/Helper/GuestTest.php b/app/code/Magento/Sales/Test/Unit/Helper/GuestTest.php index 375d62c1e78ee..beedf30c88306 100644 --- a/app/code/Magento/Sales/Test/Unit/Helper/GuestTest.php +++ b/app/code/Magento/Sales/Test/Unit/Helper/GuestTest.php @@ -54,26 +54,26 @@ class GuestTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->appContextHelperMock = $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false); - $this->storeManagerInterfaceMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->registryMock = $this->getMock('Magento\Framework\Registry'); - $this->sessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); + $this->appContextHelperMock = $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false); + $this->storeManagerInterfaceMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class); + $this->sessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); $this->cookieMetadataFactoryMock = $this->getMock( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class, [], [], '', false ); - $this->managerInterfaceMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); - $this->orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); - $this->viewInterfaceMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $this->storeModelMock = $this->getMockBuilder('Magento\Store\Model\Store') + $this->managerInterfaceMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); + $this->orderFactoryMock = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); + $this->viewInterfaceMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->storeModelMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $this->salesOrderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'getProtectCode', 'loadByIncrementIdAndStoreId', 'loadByIncrementId', 'getId', 'getBillingAddress', '__wakeup' @@ -85,7 +85,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->guest = $this->objectManagerHelper->getObject( - 'Magento\Sales\Helper\Guest', + \Magento\Sales\Helper\Guest::class, [ 'context' => $this->appContextHelperMock, 'storeManager' => $this->storeManagerInterfaceMock, @@ -114,7 +114,7 @@ public function testLoadValidOrderNotEmptyPost() $incrementId = $post['oar_order_id']; $protectedCode = 'protectedCode'; $this->sessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false); - $requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $requestMock->expects($this->once())->method('getPostValue')->willReturn($post); $this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->willReturn($this->storeModelMock); $this->storeModelMock->expects($this->once())->method('getId')->willReturn($storeId); @@ -123,7 +123,7 @@ public function testLoadValidOrderNotEmptyPost() $this->salesOrderMock->expects($this->any())->method('getId')->willReturn($incrementId); $billingAddressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getLastname', 'getEmail', '__wakeup'], [], '', @@ -134,7 +134,7 @@ public function testLoadValidOrderNotEmptyPost() $this->salesOrderMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock); $this->salesOrderMock->expects($this->once())->method('getProtectCode')->willReturn($protectedCode); $metaDataMock = $this->getMock( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, [], [], '', @@ -175,7 +175,7 @@ public function testLoadValidOrderStoredCookie() $this->salesOrderMock->expects($this->exactly(1))->method('getId')->willReturn($incrementId); $this->salesOrderMock->expects($this->once())->method('getProtectCode')->willReturn($protectedCode); $metaDataMock = $this->getMock( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class, [], [], '', @@ -195,7 +195,7 @@ public function testLoadValidOrderStoredCookie() $this->cookieManagerMock->expects($this->once()) ->method('setPublicCookie') ->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock); - $requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->assertTrue($this->guest->loadValidOrder($requestMock)); } } diff --git a/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php b/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php index 0479b9048bdd6..2394be9acb0fa 100644 --- a/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php @@ -45,22 +45,22 @@ class ReorderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->setMethods(['getValue']) ->disableOriginalConstructor() ->getMock(); - $contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any()) ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); - $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->repositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->repositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->getMockForAbstractClass(); $this->helper = new \Magento\Sales\Helper\Reorder( $contextMock, @@ -68,11 +68,11 @@ protected function setUp() $this->repositoryMock ); - $this->storeParam = $this->getMockBuilder('Magento\Sales\Model\Store') + $this->storeParam = $this->getMockBuilder(\Magento\Sales\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/AbstractModelTest.php b/app/code/Magento/Sales/Test/Unit/Model/AbstractModelTest.php index dc8542d160055..a96524fb79b59 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/AbstractModelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/AbstractModelTest.php @@ -18,7 +18,7 @@ class AbstractModelTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Sales\Model\Order'); + $this->model = $objectManager->getObject(\Magento\Sales\Model\Order::class); } public function testGetEventPrefix() diff --git a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php index 1f684b00b075d..7d8e5c66b3e67 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php @@ -92,98 +92,98 @@ class CreateTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $registryMock = $this->getMock('Magento\Framework\Registry'); - $configMock = $this->getMock('Magento\Sales\Model\Config', [], [], '', false); - $this->sessionQuoteMock = $this->getMock('Magento\Backend\Model\Session\Quote', [], [], '', false); - $loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $copyMock = $this->getMock('Magento\Framework\DataObject\Copy', [], [], '', false); - $messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); - $this->formFactoryMock = $this->getMock( - 'Magento\Customer\Model\Metadata\FormFactory', + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $registryMock = $this->getMock(\Magento\Framework\Registry::class); + $configMock = $this->getMock(\Magento\Sales\Model\Config::class, [], [], '', false); + $this->sessionQuoteMock = $this->getMock(\Magento\Backend\Model\Session\Quote::class, [], [], '', false); + $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $copyMock = $this->getMock(\Magento\Framework\DataObject\Copy::class, [], [], '', false); + $messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); + $this->formFactoryMock = $this->getMock( + \Magento\Customer\Model\Metadata\FormFactory::class, ['create'], [], '', false ); - $this->customerFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + $this->customerFactoryMock = $this->getMock( + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create'], [], '', false ); - $this->itemUpdater = $this->getMock('Magento\Quote\Model\Quote\Item\Updater', [], [], '', false); + $this->itemUpdater = $this->getMock(\Magento\Quote\Model\Quote\Item\Updater::class, [], [], '', false); - $this->objectFactory = $this->getMockBuilder('\Magento\Framework\DataObject\Factory') + $this->objectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->customerMapper = $this->getMockBuilder( - 'Magento\Customer\Model\Customer\Mapper' + $this->customerMapper = $this->getMockBuilder( + \Magento\Customer\Model\Customer\Mapper::class )->setMethods(['toFlatArray'])->disableOriginalConstructor()->getMock(); - $this->quoteInitializerMock = $this->getMock( - 'Magento\Sales\Model\AdminOrder\Product\Quote\Initializer', + $this->quoteInitializerMock = $this->getMock( + \Magento\Sales\Model\AdminOrder\Product\Quote\Initializer::class, [], [], '', false ); - $this->customerRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + $this->customerRepositoryMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false ); - $this->addressRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AddressRepositoryInterface', + $this->addressRepositoryMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\AddressRepositoryInterface::class, [], '', false ); - $this->addressFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\AddressInterfaceFactory', + $this->addressFactoryMock = $this->getMock( + \Magento\Customer\Api\Data\AddressInterfaceFactory::class, [], [], '', false ); - $this->groupRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\GroupRepositoryInterface', + $this->groupRepositoryMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\GroupRepositoryInterface::class, [], '', false ); - $this->scopeConfigMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\Config\ScopeConfigInterface', + $this->scopeConfigMock = $this->getMockForAbstractClass( + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false ); - $this->emailSenderMock = $this->getMock( - 'Magento\Sales\Model\AdminOrder\EmailSender', + $this->emailSenderMock = $this->getMock( + \Magento\Sales\Model\AdminOrder\EmailSender::class, [], [], '', false ); - $this->accountManagementMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AccountManagementInterface', + $this->accountManagementMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\AccountManagementInterface::class, [], '', false ); - $this->dataObjectHelper = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelper = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); - $this->adminOrderCreate = $objectManagerHelper->getObject( - 'Magento\Sales\Model\AdminOrder\Create', + $this->adminOrderCreate = $objectManagerHelper->getObject( + \Magento\Sales\Model\AdminOrder\Create::class, [ 'objectManager' => $objectManagerMock, 'eventManager' => $eventManagerMock, @@ -219,8 +219,8 @@ public function testSetAccountData() $attributeMocks = []; foreach ($attributes as $attribute) { - $attributeMock = $this->getMock( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', + $attributeMock = $this->getMock( + \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], [], '', @@ -232,8 +232,8 @@ public function testSetAccountData() $attributeMocks[] = $attributeMock; } - $customerGroupMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\GroupInterface', + $customerGroupMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\GroupInterface::class, [], '', false, @@ -242,22 +242,22 @@ public function testSetAccountData() ['getTaxClassId'] ); $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId)); - $customerFormMock = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false); + $customerFormMock = $this->getMock(\Magento\Customer\Model\Metadata\Form::class, [], [], '', false); $customerFormMock->expects($this->any())->method('getAttributes')->will($this->returnValue($attributeMocks)); $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue([])); $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue([])); $customerFormMock->expects($this->any()) ->method('prepareRequest') - ->will($this->returnValue($this->getMock('Magento\Framework\App\RequestInterface'))); + ->will($this->returnValue($this->getMock(\Magento\Framework\App\RequestInterface::class))); - $customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->customerMapper->expects($this->atLeastOnce()) ->method('toFlatArray') ->willReturn(['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1]); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock)); $quoteMock->expects($this->once()) ->method('addData') @@ -272,8 +272,7 @@ public function testSetAccountData() ->method('populateWithArray') ->with( $customerMock, - ['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1], - '\Magento\Customer\Api\Data\CustomerInterface' + ['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1], \Magento\Customer\Api\Data\CustomerInterface::class ); $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock)); @@ -302,9 +301,9 @@ public function testUpdateQuoteItemsEmptyConfiguredOption() ] ]; - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->once()) ->method('getItemById') ->will($this->returnValue($itemMock)); @@ -330,12 +329,12 @@ public function testUpdateQuoteItemsWithConfiguredOption() ] ]; - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $itemMock->expects($this->once()) ->method('getQty') ->will($this->returnValue($qty)); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->once()) ->method('updateItem') ->will($this->returnValue($itemMock)); diff --git a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php index 949df9e4e0885..81cf63a466a01 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php @@ -37,28 +37,28 @@ class EmailSenderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->messageManagerMock = $this->getMock( - '\Magento\Framework\Message\Manager', + \Magento\Framework\Message\Manager::class, [], [], '', false ); $this->loggerMock = $this->getMock( - '\Psr\Log\LoggerInterface', + \Psr\Log\LoggerInterface::class, [], [], '', false ); $this->orderMock = $this->getMock( - '\Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', false ); $this->orderSenderMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Sender\OrderSender', + \Magento\Sales\Model\Order\Email\Sender\OrderSender::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/Product/Quote/InitializerTest.php b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/Product/Quote/InitializerTest.php index e88a225b3c6a0..d94288919f3e8 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/Product/Quote/InitializerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/Product/Quote/InitializerTest.php @@ -47,7 +47,7 @@ class InitializerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['addProduct', '__wakeup', 'getStore'], [], '', @@ -55,7 +55,7 @@ protected function setUp() ); $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId', 'setIsQtyDecimal', 'setCartQty', '__wakeup'], [], '', @@ -63,20 +63,20 @@ protected function setUp() ); $this->configMock = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getQty', 'setQty'], [], '', false ); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getIsQtyDecimal', '__wakeup'], [], '', @@ -87,7 +87,7 @@ protected function setUp() ->method('getStockItem') ->will($this->returnValue($this->stockItemMock)); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->once()) ->method('getWebsiteId') ->will($this->returnValue(10)); @@ -98,7 +98,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $this->objectManager ->getObject( - 'Magento\Sales\Model\AdminOrder\Product\Quote\Initializer', + \Magento\Sales\Model\AdminOrder\Product\Quote\Initializer::class, ['stockRegistry' => $this->stockRegistry] ); } @@ -106,7 +106,7 @@ protected function setUp() public function testInitWithDecimalQty() { $quoteItemMock = $this->getMock( - '\Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, ['getStockId', 'getIsQtyDecimal', '__wakeup'], [], '', @@ -141,7 +141,7 @@ public function testInitWithDecimalQty() ->will($this->returnValue($quoteItemMock)); $this->assertInstanceOf( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, $this->model->init( $this->quoteMock, $this->productMock, @@ -153,7 +153,7 @@ public function testInitWithDecimalQty() public function testInitWithNonDecimalQty() { $quoteItemMock = $this->getMock( - '\Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, ['getStockId', 'getIsQtyDecimal', '__wakeup'], [], '', @@ -184,7 +184,7 @@ public function testInitWithNonDecimalQty() ->will($this->returnValue($quoteItemMock)); $this->assertInstanceOf( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, $this->model->init( $this->quoteMock, $this->productMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php index aa4abc9c3b7ce..7ae2802281b5a 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php @@ -37,15 +37,15 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->config = $this->getMock('Magento\Framework\App\Config', [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); + $this->context = $this->getMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false); $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManager); $this->object = $objectManager->getObject( - '\Magento\Sales\Model\Config\Backend\Email\AsyncSending', + \Magento\Sales\Model\Config\Backend\Email\AsyncSending::class, [ 'config' => $this->config, 'context' => $this->context diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php index 7d8017d232720..d3e95ff6d04c6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php @@ -37,15 +37,15 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->config = $this->getMock('Magento\Framework\App\Config', [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); + $this->context = $this->getMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false); $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManager); $this->object = $objectManager->getObject( - '\Magento\Sales\Model\Config\Backend\Grid\AsyncIndexing', + \Magento\Sales\Model\Config\Backend\Grid\AsyncIndexing::class, [ 'config' => $this->config, 'context' => $this->context diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php index 1f2b46a31d4db..722fdb2b9495f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php @@ -20,10 +20,10 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_readerMock = $this->getMockBuilder( - 'Magento\Sales\Model\Config\Reader' + \Magento\Sales\Model\Config\Reader::class )->disableOriginalConstructor()->getMock(); $this->_cacheMock = $this->getMockBuilder( - 'Magento\Framework\App\Cache\Type\Config' + \Magento\Framework\App\Cache\Type\Config::class )->disableOriginalConstructor()->getMock(); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/ReaderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/ReaderTest.php index db6635a194b75..5a7bd82faa723 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/ReaderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/ReaderTest.php @@ -18,16 +18,16 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $fileResolver = $this->getMockBuilder( - 'Magento\Framework\App\Config\FileResolver' + \Magento\Framework\App\Config\FileResolver::class )->disableOriginalConstructor()->getMock(); $converter = $this->getMockBuilder( - 'Magento\Sales\Model\Config\Converter' + \Magento\Sales\Model\Config\Converter::class )->disableOriginalConstructor()->getMock(); $schema = $this->getMockBuilder( - 'Magento\Sales\Model\Config\SchemaLocator' + \Magento\Sales\Model\Config\SchemaLocator::class )->disableOriginalConstructor()->getMock(); $validator = $this->getMockBuilder( - '\Magento\Framework\Config\ValidationStateInterface' + \Magento\Framework\Config\ValidationStateInterface::class )->disableOriginalConstructor()->getMock(); $this->_reader = new \Magento\Sales\Model\Config\Reader($fileResolver, $converter, $schema, $validator); } @@ -37,6 +37,6 @@ protected function setUp() */ public function testInstanceof() { - $this->assertInstanceOf('Magento\Sales\Model\Config\Reader', $this->_reader); + $this->assertInstanceOf(\Magento\Sales\Model\Config\Reader::class, $this->_reader); } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/SchemaLocatorTest.php index 18a12287df9a9..7b2c1de92050c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/SchemaLocatorTest.php @@ -23,7 +23,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_moduleReaderMock = $this->getMockBuilder( - 'Magento\Framework\Module\Dir\Reader' + \Magento\Framework\Module\Dir\Reader::class )->disableOriginalConstructor()->getMock(); $this->_moduleReaderMock->expects( $this->once() diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Source/Order/StatusTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Source/Order/StatusTest.php index 2538e09e558bf..b9b27eb53262f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/Source/Order/StatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Source/Order/StatusTest.php @@ -20,12 +20,13 @@ class StatusTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); + $this->config = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); $this->objectManager = new ObjectManager($this); - $this->object = $this->objectManager->getObject('Magento\Sales\Model\Config\Source\Order\Status', [ - 'orderConfig' => $this->config - ]); + $this->object = $this->objectManager->getObject( + \Magento\Sales\Model\Config\Source\Order\Status::class, + ['orderConfig' => $this->config] + ); } public function testToOptionArray() diff --git a/app/code/Magento/Sales/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Sales/Test/Unit/Model/ConfigTest.php index 2403ac7881310..42419d62a8c15 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ConfigTest.php @@ -24,10 +24,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configDataMock = $this->getMockBuilder('Magento\Sales\Model\Config\Data') + $this->configDataMock = $this->getMockBuilder(\Magento\Sales\Model\Config\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->stateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->stateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); $this->model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock); @@ -36,7 +36,7 @@ protected function setUp() public function testInstanceOf() { $model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock); - $this->assertInstanceOf('Magento\Sales\Model\Config', $model); + $this->assertInstanceOf(\Magento\Sales\Model\Config::class, $model); } public function testGetTotalsRenderer() diff --git a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportBestsellersDataTest.php b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportBestsellersDataTest.php index c57db12fc5396..d14f41b2d9cbb 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportBestsellersDataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportBestsellersDataTest.php @@ -34,16 +34,16 @@ class AggregateSalesReportBestsellersDataTest extends \PHPUnit_Framework_TestCas protected function setUp() { - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); $this->bestsellersFactoryMock = - $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\BestsellersFactory') + $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\BestsellersFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -57,7 +57,7 @@ protected function setUp() public function testExecute() { $date = $this->setupAggregate(); - $bestsellersMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\Bestsellers') + $bestsellersMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\Bestsellers::class) ->disableOriginalConstructor() ->getMock(); $bestsellersMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportInvoicedDataTest.php b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportInvoicedDataTest.php index a4672277addaf..5cfc7955906b7 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportInvoicedDataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportInvoicedDataTest.php @@ -34,15 +34,17 @@ class AggregateSalesReportInvoicedDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->invoicedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\InvoicedFactory') + $this->invoicedFactoryMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Report\InvoicedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -56,7 +58,7 @@ protected function setUp() public function testExecute() { $date = $this->setupAggregate(); - $invoicedMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\Invoiced') + $invoicedMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\Invoiced::class) ->disableOriginalConstructor() ->getMock(); $invoicedMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportOrderDataTest.php b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportOrderDataTest.php index 41b1ff1c0a950..c0058dbcb23b6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportOrderDataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportOrderDataTest.php @@ -34,15 +34,15 @@ class AggregateSalesReportOrderDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\OrderFactory') + $this->orderFactoryMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\OrderFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -56,7 +56,7 @@ protected function setUp() public function testExecute() { $date = $this->setupAggregate(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\Order::class) ->disableOriginalConstructor() ->getMock(); $orderMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportRefundedDataTest.php b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportRefundedDataTest.php index b1565a5e7a724..a9bf5e49c500c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportRefundedDataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/CronJob/AggregateSalesReportRefundedDataTest.php @@ -34,15 +34,17 @@ class AggregateSalesReportRefundedDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->refundedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\RefundedFactory') + $this->refundedFactoryMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Report\RefundedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -56,7 +58,7 @@ protected function setUp() public function testExecute() { $date = $this->setupAggregate(); - $refundedMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\Refunded') + $refundedMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\Refunded::class) ->disableOriginalConstructor() ->getMock(); $refundedMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/CronJob/CleanExpiredOrdersTest.php b/app/code/Magento/Sales/Test/Unit/Model/CronJob/CleanExpiredOrdersTest.php index ba810d60d87bb..5f69de657c5b2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/CronJob/CleanExpiredOrdersTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/CronJob/CleanExpiredOrdersTest.php @@ -44,28 +44,28 @@ class CleanExpiredOrdersTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->storesConfigMock = $this->getMock( - '\Magento\Store\Model\StoresConfig', + \Magento\Store\Model\StoresConfig::class, [], [], '', false ); $this->collectionFactoryMock = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class, ['create'], [], '', false ); $this->orderCollectionMock = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order\Collection', + \Magento\Sales\Model\ResourceModel\Order\Collection::class, [], [], '', false ); - $this->loggerMock = $this->getMock('\Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->model = new CleanExpiredOrders( $this->storesConfigMock, @@ -90,7 +90,7 @@ public function testExecute() $this->orderCollectionMock->expects($this->exactly(4))->method('addFieldToFilter'); $this->orderCollectionMock->expects($this->exactly(4))->method('walk'); - $selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->exactly(2))->method('where')->willReturnSelf(); $this->orderCollectionMock->expects($this->exactly(2))->method('getSelect')->willReturn($selectMock); @@ -114,7 +114,7 @@ public function testExecuteWithException() ->willReturn($this->orderCollectionMock); $this->orderCollectionMock->expects($this->exactly(2))->method('addFieldToFilter'); - $selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->once())->method('where')->willReturnSelf(); $this->orderCollectionMock->expects($this->once())->method('getSelect')->willReturn($selectMock); diff --git a/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php b/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php index 75eafec543a34..f5ac9462a0d0f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php @@ -46,10 +46,10 @@ class DownloadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->writeDirectoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\Write') + $this->writeDirectoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Write::class) ->disableOriginalConstructor() ->getMock(); - $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); $this->filesystemMock->expects($this->any()) @@ -57,15 +57,16 @@ protected function setUp() ->with(DirectoryList::MEDIA) ->will($this->returnValue($this->writeDirectoryMock)); - $this->driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); - $this->storageMock = $this->getMockBuilder('Magento\MediaStorage\Helper\File\Storage\Database') + $this->driverMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); + $this->storageMock = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); - $this->storageFactoryMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\DatabaseFactory') - ->disableOriginalConstructor() + $this->storageFactoryMock = $this->getMockBuilder( + \Magento\MediaStorage\Model\File\Storage\DatabaseFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->httpFileFactoryMock = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + $this->httpFileFactoryMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -85,7 +86,7 @@ public function testInstanceOf() $this->storageFactoryMock, $this->httpFileFactoryMock ); - $this->assertInstanceOf('Magento\Sales\Model\Download', $model); + $this->assertInstanceOf(\Magento\Sales\Model\Download::class, $model); } /** @@ -161,7 +162,7 @@ public function testDownloadFileNoStorage() ->method('checkDbUsage') ->will($this->returnValue(true)); - $storageDatabaseMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $storageDatabaseMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $storageDatabaseMock->expects($this->at(0)) @@ -191,7 +192,7 @@ public function testDownloadFile() $isFile = true; $isReadable = false; - $writeMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\Write') + $writeMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\Write::class) ->disableOriginalConstructor() ->getMock(); $writeMock->expects($this->any()) @@ -229,7 +230,7 @@ public function testDownloadFile() ->method('checkDbUsage') ->will($this->returnValue(true)); - $storageDatabaseMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $storageDatabaseMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->setMethods(['loadByFilename', 'getId', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php index 6ae39f50cf989..3d78c60946ad2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php @@ -52,7 +52,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->emailSender = $this->getMock( - 'Magento\Sales\Model\Order\Email\Sender', + \Magento\Sales\Model\Order\Email\Sender::class, ['send'], [], '', @@ -60,7 +60,7 @@ protected function setUp() ); $this->entityResource = $this->getMockForAbstractClass( - 'Magento\Sales\Model\ResourceModel\EntityAbstract', + \Magento\Sales\Model\ResourceModel\EntityAbstract::class, [], '', false, @@ -70,7 +70,7 @@ protected function setUp() ); $this->entityCollection = $this->getMockForAbstractClass( - 'Magento\Sales\Model\ResourceModel\Collection\AbstractCollection', + \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection::class, [], '', false, @@ -80,7 +80,7 @@ protected function setUp() ); $this->globalConfig = $this->getMock( - 'Magento\Framework\App\Config', + \Magento\Framework\App\Config::class, [], [], '', @@ -88,7 +88,7 @@ protected function setUp() ); $this->object = $objectManager->getObject( - 'Magento\Sales\Model\EmailSenderHandler', + \Magento\Sales\Model\EmailSenderHandler::class, [ 'emailSender' => $this->emailSender, 'entityResource' => $this->entityResource, @@ -165,7 +165,7 @@ public function testExecute($configValue, $collectionItems, $emailSendingResult) public function executeDataProvider() { $entityModel = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', + \Magento\Sales\Model\AbstractModel::class, [], '', false, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Grid/Child/CollectionUpdaterTest.php b/app/code/Magento/Sales/Test/Unit/Model/Grid/Child/CollectionUpdaterTest.php index cd7e4211aeeca..d079c5b42b6a6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Grid/Child/CollectionUpdaterTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Grid/Child/CollectionUpdaterTest.php @@ -22,7 +22,7 @@ class CollectionUpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->collectionUpdater = new \Magento\Sales\Model\Grid\Child\CollectionUpdater( $this->registryMock @@ -31,10 +31,10 @@ protected function setUp() public function testUpdateIfOrderExists() { - $collectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection', [], [], '', false + $collectionMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection::class, [], [], '', false ); - $transactionMock = $this->getMock('Magento\Sales\Model\Order\Payment\Transaction', [], [], '', false); + $transactionMock = $this->getMock(\Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', false); $this->registryMock ->expects($this->once()) ->method('registry') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Grid/CollectionUpdaterTest.php b/app/code/Magento/Sales/Test/Unit/Model/Grid/CollectionUpdaterTest.php index d1472c4c32bb7..09a2fe0f8cb30 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Grid/CollectionUpdaterTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Grid/CollectionUpdaterTest.php @@ -22,7 +22,7 @@ class CollectionUpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->collectionUpdater = new \Magento\Sales\Model\Grid\CollectionUpdater( $this->registryMock @@ -31,8 +31,8 @@ protected function setUp() public function testUpdateIfOrderNotExists() { - $collectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection', [], [], '', false + $collectionMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection::class, [], [], '', false ); $this->registryMock ->expects($this->once()) @@ -50,10 +50,10 @@ public function testUpdateIfOrderNotExists() public function testUpdateIfOrderExists() { - $collectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection', [], [], '', false + $collectionMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection::class, [], [], '', false ); - $orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $orderMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $this->registryMock ->expects($this->once()) ->method('registry') diff --git a/app/code/Magento/Sales/Test/Unit/Model/GridAsyncInsertTest.php b/app/code/Magento/Sales/Test/Unit/Model/GridAsyncInsertTest.php index ed0e89d087705..f41d27da81c41 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/GridAsyncInsertTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/GridAsyncInsertTest.php @@ -33,9 +33,9 @@ class GridAsyncInsertTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->gridAggregatorMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\GridInterface') + $this->gridAggregatorMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\GridInterface::class) ->getMockForAbstractClass(); - $this->salesModelMock = $this->getMockBuilder('Magento\Sales\Model\AbstractModel') + $this->salesModelMock = $this->getMockBuilder(\Magento\Sales\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods( [ @@ -43,7 +43,7 @@ protected function setUp() ] ) ->getMockForAbstractClass(); - $this->scopeConfigurationMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigurationMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); $this->unit = new \Magento\Sales\Model\GridAsyncInsert( diff --git a/app/code/Magento/Sales/Test/Unit/Model/IncrementTest.php b/app/code/Magento/Sales/Test/Unit/Model/IncrementTest.php index 5288fabd72a99..4bff3b56f6937 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/IncrementTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/IncrementTest.php @@ -28,9 +28,12 @@ class IncrementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->eavConfig = $this->getMock('Magento\Eav\Model\Config', ['getEntityType'], [], '', false); - $this->model = $objectManager->getObject('Magento\Sales\Model\Increment', ['eavConfig' => $this->eavConfig]); - $this->type = $this->getMock('Magento\Eav\Model\Entity\Type', ['fetchNewIncrementId'], [], '', false); + $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, ['getEntityType'], [], '', false); + $this->model = $objectManager->getObject( + \Magento\Sales\Model\Increment::class, + ['eavConfig' => $this->eavConfig] + ); + $this->type = $this->getMock(\Magento\Eav\Model\Entity\Type::class, ['fetchNewIncrementId'], [], '', false); } public function testGetCurrentValue() diff --git a/app/code/Magento/Sales/Test/Unit/Model/InvoiceRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/InvoiceRepositoryTest.php index ffd49ca5b1e24..964974507d190 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/InvoiceRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/InvoiceRepositoryTest.php @@ -29,26 +29,28 @@ class InvoiceRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->invoiceMetadata = $this->getMock('Magento\Sales\Model\ResourceModel\Metadata', [], [], '', false); - $this->searchResultFactory = $this->getMockBuilder('Magento\Sales\Api\Data\InvoiceSearchResultInterfaceFactory') + $this->invoiceMetadata = $this->getMock(\Magento\Sales\Model\ResourceModel\Metadata::class, [], [], '', false); + $this->searchResultFactory = $this->getMockBuilder( + \Magento\Sales\Api\Data\InvoiceSearchResultInterfaceFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->invoice = $objectManager->getObject( - 'Magento\Sales\Model\Order\InvoiceRepository', + \Magento\Sales\Model\Order\InvoiceRepository::class, [ 'invoiceMetadata' => $this->invoiceMetadata, 'searchResultFactory' => $this->searchResultFactory ] ); - $this->type = $this->getMock('Magento\Eav\Model\Entity\Type', ['fetchNewIncrementId'], [], '', false); + $this->type = $this->getMock(\Magento\Eav\Model\Entity\Type::class, ['fetchNewIncrementId'], [], '', false); } public function testGet() { $id = 1; - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) @@ -83,7 +85,7 @@ public function testGetEntityNoId() { $id = 1; - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) @@ -103,7 +105,7 @@ public function testGetEntityNoId() public function testCreate() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $this->invoiceMetadata->expects($this->once()) @@ -114,14 +116,14 @@ public function testCreate() public function testGetList() { - $filterGroup = $this->getMockBuilder('Magento\Framework\Api\Search\FilterGroup') + $filterGroup = $this->getMockBuilder(\Magento\Framework\Api\Search\FilterGroup::class) ->disableOriginalConstructor() ->getMock(); $filterGroups = [$filterGroup]; $field = 'test_field'; $fieldValue = 'test_value'; - $filter = $this->getMockBuilder('Magento\Framework\Api\Filter') + $filter = $this->getMockBuilder(\Magento\Framework\Api\Filter::class) ->disableOriginalConstructor() ->getMock(); $filter->expects($this->any()) @@ -138,14 +140,14 @@ public function testGetList() ->method('getFilters') ->willReturn([$filter]); - $searchCriteria = $this->getMockBuilder('Magento\Framework\Api\SearchCriteria') + $searchCriteria = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteria::class) ->disableOriginalConstructor() ->getMock(); $searchCriteria->expects($this->once()) ->method('getFilterGroups') ->willReturn($filterGroups); - $collection = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice\Collection') + $collection = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class) ->disableOriginalConstructor() ->getMock(); $collection->expects($this->once()) @@ -161,14 +163,14 @@ public function testGetList() public function testDelete() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) ->method('getEntityId') ->willReturn(1); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) @@ -186,7 +188,7 @@ public function testDeleteById() { $id = 1; - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) @@ -201,7 +203,7 @@ public function testDeleteById() ->method('getNewInstance') ->willReturn($entity); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) @@ -217,14 +219,14 @@ public function testDeleteById() public function testSave() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->any()) ->method('getEntityId') ->willReturn(1); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Address/ValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Address/ValidatorTest.php index 7125074160e0f..d7e341a70d7db 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Address/ValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Address/ValidatorTest.php @@ -36,21 +36,21 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['hasData', 'getEmail', 'getAddressType', '__wakeup'], [], '', false ); $this->directoryHelperMock = $this->getMock( - 'Magento\Directory\Helper\Data', + \Magento\Directory\Helper\Data::class, [], [], '', false ); $this->countryFactoryMock = $this->getMock( - 'Magento\Directory\Model\CountryFactory', + \Magento\Directory\Model\CountryFactory::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressRepositoryTest.php index cb321c982f4a9..d99100f3c8048 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressRepositoryTest.php @@ -9,6 +9,8 @@ /** * Unit test for order address repository class. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +38,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->metadata = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Metadata', + \Magento\Sales\Model\ResourceModel\Metadata::class, ['getNewInstance', 'getMapper'], [], '', @@ -44,7 +46,7 @@ protected function setUp() ); $this->searchResultFactory = $this->getMock( - 'Magento\Sales\Api\Data\OrderAddressSearchResultInterfaceFactory', + \Magento\Sales\Api\Data\OrderAddressSearchResultInterfaceFactory::class, ['create'], [], '', @@ -52,7 +54,7 @@ protected function setUp() ); $this->subject = $objectManager->getObject( - 'Magento\Sales\Model\Order\AddressRepository', + \Magento\Sales\Model\Order\AddressRepository::class, [ 'metadata' => $this->metadata, 'searchResultFactory' => $this->searchResultFactory @@ -69,13 +71,13 @@ public function testGet($id, $entityId) { if (!$id) { $this->setExpectedException( - 'Magento\Framework\Exception\InputException' + \Magento\Framework\Exception\InputException::class ); $this->subject->get($id); } else { $address = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['load', 'getEntityId'], [], '', @@ -95,7 +97,7 @@ public function testGet($id, $entityId) if (!$entityId) { $this->setExpectedException( - 'Magento\Framework\Exception\NoSuchEntityException' + \Magento\Framework\Exception\NoSuchEntityException::class ); $this->subject->get($id); @@ -135,7 +137,7 @@ public function getDataProvider() public function testGetList() { $filter = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, ['getConditionType', 'getField', 'getValue'], [], '', @@ -152,7 +154,7 @@ public function testGetList() ->willReturn('test_value'); $filterGroup = $this->getMock( - 'Magento\Framework\Api\Search\FilterGroup', + \Magento\Framework\Api\Search\FilterGroup::class, ['getFilters'], [], '', @@ -163,7 +165,7 @@ public function testGetList() ->willReturn([$filter]); $searchCriteria = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, ['getFilterGroups'], [], '', @@ -174,7 +176,7 @@ public function testGetList() ->willReturn([$filterGroup]); $collection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Address\Collection', + \Magento\Sales\Model\ResourceModel\Order\Address\Collection::class, ['addFieldToFilter'], [], '', @@ -194,7 +196,7 @@ public function testGetList() public function testDelete() { $address = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getEntityId'], [], '', @@ -205,7 +207,7 @@ public function testDelete() ->willReturn(1); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -231,7 +233,7 @@ public function testDelete() public function testDeleteWithException() { $address = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getEntityId'], [], '', @@ -241,7 +243,7 @@ public function testDeleteWithException() ->method('getEntityId'); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -263,7 +265,7 @@ public function testDeleteWithException() public function testSave() { $address = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getEntityId'], [], '', @@ -274,7 +276,7 @@ public function testSave() ->willReturn(1); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -300,7 +302,7 @@ public function testSave() public function testSaveWithException() { $address = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getEntityId'], [], '', @@ -310,7 +312,7 @@ public function testSaveWithException() ->method('getEntityId'); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -332,7 +334,7 @@ public function testSaveWithException() public function testCreate() { $address = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getEntityId'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php index 97404f4154aa8..394588a20be5d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php @@ -38,28 +38,28 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', false ); $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', false ); $this->regionFactoryMock = $this->getMock( - 'Magento\Directory\Model\RegionFactory', + \Magento\Directory\Model\RegionFactory::class, [], [], '', false ); $this->regionMock = $this->getMock( - 'Magento\Directory\Model\Region', + \Magento\Directory\Model\Region::class, ['load', 'getCountryId', 'getCode'], [], '', @@ -67,7 +67,7 @@ protected function setUp() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->address = $objectManager->getObject( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [ 'regionFactory' => $this->regionFactoryMock ] diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Admin/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Admin/ItemTest.php index d71b18e136ded..c2169b359ae4c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Admin/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Admin/ItemTest.php @@ -20,7 +20,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $this->orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $this->item = new \Magento\Sales\Model\Order\Admin\Item(); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php index 934096c1c77b2..1f29235efaef2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php @@ -24,9 +24,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $orderStatusFactory = $this->getMock('Magento\Sales\Model\Order\StatusFactory', [], [], '', false, false); + $orderStatusFactory = $this->getMock(\Magento\Sales\Model\Order\StatusFactory::class, [], [], '', false, false); $this->orderStatusCollectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory::class, ['create'], [], '', @@ -35,7 +35,7 @@ protected function setUp() ); $this->salesConfig = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject( - 'Magento\Sales\Model\Order\Config', + \Magento\Sales\Model\Order\Config::class, [ 'orderStatusFactory' => $orderStatusFactory, 'orderStatusCollectionFactory' => $this->orderStatusCollectionFactoryMock @@ -78,7 +78,7 @@ public function testGetInvisibleOnFrontStatuses() $expectedResult = ['complete', 'pending_payment']; $collectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\Collection', + \Magento\Sales\Model\ResourceModel\Order\Status\Collection::class, ['create', 'joinStates'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Comment/ValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Comment/ValidatorTest.php index edb8ac0bab516..e9b02d5c5dee2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Comment/ValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Comment/ValidatorTest.php @@ -26,7 +26,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->commentModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo\Comment', + \Magento\Sales\Model\Order\Creditmemo\Comment::class, ['hasData', 'getData', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php index bcf68ea6734c8..3fd646111050b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php @@ -20,12 +20,12 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->orderItemFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\ItemFactory') + $this->orderItemFactoryMock = $this->getMockBuilder(\Magento\Sales\Model\Order\ItemFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->item = $objectManager->getObject( - 'Magento\Sales\Model\Order\Creditmemo\Item', + \Magento\Sales\Model\Order\Creditmemo\Item::class, [ 'orderItemFactory' => $this->orderItemFactoryMock ] @@ -34,23 +34,23 @@ protected function setUp() public function testGetOrderItemExist() { - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $this->item->setOrderItem($orderItemMock); $result = $this->item->getOrderItem(); - $this->assertInstanceOf('Magento\Sales\Model\Order\Item', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Item::class, $result); } public function testGetOrderItemFromCreditmemo() { $orderItemId = 1; - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); $orderMock->expects($this->once()) @@ -58,7 +58,7 @@ public function testGetOrderItemFromCreditmemo() ->with($orderItemId) ->willReturn($orderItemMock); - $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $creditmemoMock->expects($this->once()) @@ -68,14 +68,14 @@ public function testGetOrderItemFromCreditmemo() $this->item->setData(CreditmemoItemInterface::ORDER_ITEM_ID, $orderItemId); $this->item->setCreditmemo($creditmemoMock); $result = $this->item->getOrderItem(); - $this->assertInstanceOf('Magento\Sales\Model\Order\Item', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Item::class, $result); } public function testGetOrderItemFromFactory() { $orderItemId = 1; - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -89,7 +89,7 @@ public function testGetOrderItemFromFactory() $this->item->setData(CreditmemoItemInterface::ORDER_ITEM_ID, $orderItemId); $result = $this->item->getOrderItem(); - $this->assertInstanceOf('Magento\Sales\Model\Order\Item', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Item::class, $result); } /** @@ -102,7 +102,7 @@ public function testSetQtyDecimalException() $orderItemQty = 10; $name = 'test_item_name'; - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -127,7 +127,7 @@ public function testSetQtyNumericException() $orderItemQty = 10; $name = 'test_item_name2'; - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -147,7 +147,7 @@ public function testSetQty() $qty = 10; $orderItemQty = 100; - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -164,7 +164,7 @@ public function testSetQty() public function testRegister() { - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -208,12 +208,12 @@ public function testRegister() $this->item->setOrderItem($orderItemMock); $this->item->setData($data); $result = $this->item->register(); - $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo\Item', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Creditmemo\Item::class, $result); } public function testCancel() { - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods( [ @@ -261,7 +261,7 @@ public function testCancel() $this->item->setData('qty', 1); $this->item->setOrderItem($orderItemMock); $result = $this->item->cancel(); - $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo\Item', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Creditmemo\Item::class, $result); } /** @@ -269,7 +269,7 @@ public function testCancel() */ public function testCalcRowTotal($qty) { - $creditmemoMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Creditmemo') + $creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $creditmemoMock->expects($this->exactly(4)) @@ -290,7 +290,7 @@ function ($arg) { $expectedRowTotal = ($rowInvoiced - $amountRefunded) / $qtyAvailable * $qty; $expectedRowTotal = round($expectedRowTotal, 2); - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -332,7 +332,7 @@ function ($arg) { $this->item->setOrderItem($orderItemMock); $result = $this->item->calcRowTotal(); - $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo\Item', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Order\Creditmemo\Item::class, $result); $this->assertEquals($expectedRowTotal, $this->item->getData('row_total')); $this->assertEquals($expectedRowTotal, $this->item->getData('base_row_total')); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/CostTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/CostTest.php index 9fd77b4270630..83a3764dbf726 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/CostTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/CostTest.php @@ -28,11 +28,15 @@ class CostTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->creditmemoMock = $this->getMock('\Magento\Sales\Model\Order\Creditmemo', [ - 'setBaseCost', 'getAllItems' - ], [], '', false); + $this->creditmemoMock = $this->getMock( + \Magento\Sales\Model\Order\Creditmemo::class, + ['setBaseCost', 'getAllItems'], + [], + '', + false + ); $this->creditmemoItemMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo\Item', + \Magento\Sales\Model\Order\Creditmemo\Item::class, ['getHasChildren', 'getBaseCost', 'getQty'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php index 6b03924b2f80c..70177dd65af07 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php @@ -39,14 +39,14 @@ class DiscountTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['getBaseShippingDiscountAmount', 'getBaseShippingAmount', 'getShippingAmount'], [], '', false ); $this->orderItemMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'isDummy', 'getDiscountInvoiced', 'getBaseDiscountInvoiced', 'getQtyInvoiced', 'getQty', 'getDiscountRefunded', 'getQtyRefunded' @@ -56,7 +56,7 @@ protected function setUp() false ); $this->creditmemoMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, [ 'setBaseCost', 'getAllItems', 'getOrder', 'getBaseShippingAmount', 'roundPrice', 'setDiscountAmount', 'setBaseDiscountAmount' @@ -66,7 +66,7 @@ protected function setUp() false ); $this->creditmemoItemMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo\Item', + \Magento\Sales\Model\Order\Creditmemo\Item::class, [ 'getHasChildren', 'getBaseCost', 'getQty', 'getOrderItem', 'setDiscountAmount', 'setBaseDiscountAmount', 'isLast' diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php index 935b1c0f6ccfc..44464facf194b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php @@ -29,7 +29,7 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods( [ @@ -47,7 +47,7 @@ protected function setUp() ] )->getMock(); - $priceCurrencyMock = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); + $priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $priceCurrencyMock->expects($this->any()) ->method('round') ->willReturnCallback( @@ -56,10 +56,10 @@ function ($amount) { } ); - $this->taxConfig = $this->getMock('Magento\Tax\Model\Config', [], [], '', false); + $this->taxConfig = $this->getMock(\Magento\Tax\Model\Config::class, [], [], '', false); - $this->shippingCollector = $objectManager->getObject( - 'Magento\Sales\Model\Order\Creditmemo\Total\Shipping', + $this->shippingCollector = $objectManager->getObject( + \Magento\Sales\Model\Order\Creditmemo\Total\Shipping::class, [ 'priceCurrency' => $priceCurrencyMock, ] @@ -87,7 +87,7 @@ public function testCollectException() $this->taxConfig->expects($this->any())->method('displaySalesShippingInclTax')->willReturn(false); - $currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + $currencyMock = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) ->disableOriginalConstructor() ->getMock(); $currencyMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/SubtotalTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/SubtotalTest.php index 93ee01a36f4f2..961204616c710 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/SubtotalTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/SubtotalTest.php @@ -34,14 +34,14 @@ class SubtotalTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['getBaseShippingDiscountAmount', 'getBaseShippingAmount', 'getShippingAmount'], [], '', false ); $this->orderItemMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'isDummy', 'getDiscountInvoiced', 'getBaseDiscountInvoiced', 'getQtyInvoiced', 'getQty', 'getDiscountRefunded', 'getQtyRefunded' @@ -51,7 +51,7 @@ protected function setUp() false ); $this->creditmemoMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, [ 'setBaseCost', 'getAllItems', 'getOrder', 'getBaseShippingAmount', 'roundPrice', 'setDiscountAmount', 'setBaseDiscountAmount', 'setSubtotal', 'setBaseSubtotal', @@ -63,7 +63,7 @@ protected function setUp() false ); $this->creditmemoItemMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo\Item', + \Magento\Sales\Model\Order\Creditmemo\Item::class, [ 'getHasChildren', 'getBaseCost', 'getQty', 'getOrderItem', 'setDiscountAmount', 'setBaseDiscountAmount', 'isLast', 'getRowTotalInclTax', 'getBaseRowTotalInclTax', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php index 5210080744436..37244480a1b22 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php @@ -41,10 +41,10 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Sales\Model\Order\Creditmemo\Total\Tax $model */ - $this->model = $this->objectManager->getObject('Magento\Sales\Model\Order\Creditmemo\Total\Tax'); + $this->model = $this->objectManager->getObject(\Magento\Sales\Model\Order\Creditmemo\Total\Tax::class); - $this->order = $this->getMock( - '\Magento\Sales\Model\Order', + $this->order = $this->getMock( + \Magento\Sales\Model\Order::class, [ '__wakeup' ], @@ -53,8 +53,8 @@ protected function setUp() false ); - $this->invoice = $this->getMock( - '\Magento\Sales\Model\Order\Invoice', + $this->invoice = $this->getMock( + \Magento\Sales\Model\Order\Invoice::class, [ '__wakeup', ], @@ -63,8 +63,8 @@ protected function setUp() false ); - $this->creditmemo = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo', + $this->creditmemo = $this->getMock( + \Magento\Sales\Model\Order\Creditmemo::class, [ 'getAllItems', 'getOrder', @@ -631,8 +631,8 @@ public function collectDataProvider() protected function getCreditmemoItem($creditmemoItemData) { /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject $orderItem */ - $orderItem = $this->getMock( - '\Magento\Sales\Model\Order\Item', + $orderItem = $this->getMock( + \Magento\Sales\Model\Order\Item::class, [ 'isDummy', '__wakeup' @@ -646,8 +646,8 @@ protected function getCreditmemoItem($creditmemoItemData) } /** @var \Magento\Sales\Model\Order\Creditmemo\Item|\PHPUnit_Framework_MockObject_MockObject $creditmemoItem */ - $creditmemoItem = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo\Item', + $creditmemoItem = $this->getMock( + \Magento\Sales\Model\Order\Creditmemo\Item::class, [ 'getOrderItem', 'isLast', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoNotifierTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoNotifierTest.php index 2388c0581b3c9..360c47fa95635 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoNotifierTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoNotifierTest.php @@ -44,27 +44,27 @@ class CreditmemoNotifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->historyCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory::class, ['create'], [], '', false ); $this->creditmemo = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, ['__wakeUp', 'getEmailSent'], [], '', false ); $this->creditmemoSenderMock = $this->getMock( - 'Magento\Sales\Model\Order\Email\Sender\CreditmemoSender', + \Magento\Sales\Model\Order\Email\Sender\CreditmemoSender::class, ['send'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->notifier = new CreditmemoNotifier( $this->historyCollectionFactory, $this->loggerMock, @@ -78,14 +78,14 @@ protected function setUp() public function testNotifySuccess() { $historyCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\Collection', + \Magento\Sales\Model\ResourceModel\Order\Status\History\Collection::class, ['getUnnotifiedForInstance', 'save', 'setIsCustomerNotified'], [], '', false ); $historyItem = $this->getMock( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, ['setIsCustomerNotified', 'save', '__wakeUp'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoRepositoryTest.php index a46465e13a0b1..3bbf663bd2d26 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoRepositoryTest.php @@ -10,6 +10,7 @@ /** * Class CreditmemoRepositoryTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CreditmemoRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -31,28 +32,28 @@ class CreditmemoRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->metadataMock = $this->getMock('Magento\Sales\Model\ResourceModel\Metadata', [], [], '', false); + $this->metadataMock = $this->getMock(\Magento\Sales\Model\ResourceModel\Metadata::class, [], [], '', false); $this->searchResultFactoryMock = $this->getMock( - 'Magento\Sales\Api\Data\CreditmemoSearchResultInterfaceFactory', + \Magento\Sales\Api\Data\CreditmemoSearchResultInterfaceFactory::class, ['create'], [], '', false ); $this->creditmemo = $objectManager->getObject( - 'Magento\Sales\Model\Order\CreditmemoRepository', + \Magento\Sales\Model\Order\CreditmemoRepository::class, [ 'metadata' => $this->metadataMock, 'searchResultFactory' => $this->searchResultFactoryMock ] ); - $this->type = $this->getMock('Magento\Eav\Model\Entity\Type', ['fetchNewIncrementId'], [], '', false); + $this->type = $this->getMock(\Magento\Eav\Model\Entity\Type::class, ['fetchNewIncrementId'], [], '', false); } public function testGet() { $id = 1; - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) @@ -88,7 +89,7 @@ public function testGetNoId() public function testGetEntityNoId() { $id = 1; - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) @@ -108,7 +109,7 @@ public function testGetEntityNoId() public function testCreate() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $this->metadataMock->expects($this->once()) @@ -119,14 +120,14 @@ public function testCreate() public function testGetList() { - $filterGroup = $this->getMockBuilder('Magento\Framework\Api\Search\FilterGroup') + $filterGroup = $this->getMockBuilder(\Magento\Framework\Api\Search\FilterGroup::class) ->disableOriginalConstructor() ->getMock(); $filterGroups = [$filterGroup]; $field = 'test_field'; $fieldValue = 'test_value'; - $filter = $this->getMockBuilder('Magento\Framework\Api\Filter') + $filter = $this->getMockBuilder(\Magento\Framework\Api\Filter::class) ->disableOriginalConstructor() ->getMock(); $filter->expects($this->any()) @@ -143,14 +144,14 @@ public function testGetList() ->method('getFilters') ->willReturn([$filter]); - $searchCriteria = $this->getMockBuilder('Magento\Framework\Api\SearchCriteria') + $searchCriteria = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteria::class) ->disableOriginalConstructor() ->getMock(); $searchCriteria->expects($this->once()) ->method('getFilterGroups') ->willReturn($filterGroups); - $collection = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection') + $collection = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection::class) ->disableOriginalConstructor() ->getMock(); $collection->expects($this->once()) @@ -166,14 +167,14 @@ public function testGetList() public function testDelete() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->once()) ->method('getEntityId') ->willReturn(1); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) @@ -193,13 +194,13 @@ public function testDelete() */ public function testDeleteWithException() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->never()) ->method('getEntityId'); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) @@ -215,14 +216,14 @@ public function testDeleteWithException() public function testSave() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->any()) ->method('getEntityId') ->willReturn(1); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) @@ -242,13 +243,13 @@ public function testSave() */ public function testSaveWithException() { - $entity = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $entity = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $entity->expects($this->never()) ->method('getEntityId'); - $mapper = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo') + $mapper = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $mapper->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoTest.php index 0c24c856ba2df..4dfb4224d948e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoTest.php @@ -15,6 +15,8 @@ /** * Class CreditmemoTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CreditmemoTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +38,7 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderFactory = $this->getMock( - '\Magento\Sales\Model\OrderFactory', + \Magento\Sales\Model\OrderFactory::class, ['create'], [], '', @@ -45,30 +47,32 @@ protected function setUp() $objectManagerHelper = new ObjectManagerHelper($this); $this->cmItemCollectionFactoryMock = $this->getMockBuilder( - '\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\CollectionFactory' + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\CollectionFactory::class )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $arguments = [ - 'context' => $this->getMock('Magento\Framework\Model\Context', [], [], '', false), - 'registry' => $this->getMock('Magento\Framework\Registry', [], [], '', false), - 'localeDate' => $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', [], [], '', false), - 'dateTime' => $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false), - 'creditmemoConfig' => $this->getMock('Magento\Sales\Model\Order\Creditmemo\Config', [], [], '', false), + 'context' => $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false), + 'registry' => $this->getMock(\Magento\Framework\Registry::class, [], [], '', false), + 'localeDate' => $this->getMock( + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, [], [], '', false), + 'dateTime' => $this->getMock(\Magento\Framework\Stdlib\DateTime::class, [], [], '', false), + 'creditmemoConfig' => $this->getMock( + \Magento\Sales\Model\Order\Creditmemo\Config::class, [], [], '', false), 'orderFactory' => $this->orderFactory, 'cmItemCollectionFactory' => $this->cmItemCollectionFactoryMock, - 'calculatorFactory' => $this->getMock('Magento\Framework\Math\CalculatorFactory', [], [], '', false), - 'storeManager' => $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false), + 'calculatorFactory' => $this->getMock(\Magento\Framework\Math\CalculatorFactory::class, [], [], '', false), + 'storeManager' => $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false), 'commentFactory' => $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo\CommentFactory', + \Magento\Sales\Model\Order\Creditmemo\CommentFactory::class, [], [], '', false ), 'commentCollectionFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment\CollectionFactory::class, [], [], '', @@ -76,7 +80,7 @@ protected function setUp() ), ]; $this->creditmemo = $objectManagerHelper->getObject( - 'Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, $arguments ); } @@ -87,7 +91,7 @@ public function testGetOrder() $this->creditmemo->setOrderId($orderId); $entityName = 'creditmemo'; $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['load', 'setHistoryEntityName', '__wakeUp'], [], '', @@ -146,7 +150,7 @@ public function testGetItemsCollectionWithId() $this->creditmemo->setId($id); $items = []; - $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Creditmemo\Item') + $itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo\Item::class) ->disableOriginalConstructor() ->getMock(); $itemMock->expects($this->once()) @@ -155,7 +159,8 @@ public function testGetItemsCollectionWithId() $items[] = $itemMock; /** @var ItemCollection|\PHPUnit_Framework_MockObject_MockObject $itemCollectionMock */ - $itemCollectionMock = $this->getMockBuilder('\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\Collection') + $itemCollectionMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\Collection::class) ->disableOriginalConstructor() ->getMock(); $itemCollectionMock->expects($this->once()) @@ -174,7 +179,7 @@ public function testGetItemsCollectionWithId() public function testGetItemsCollectionWithoutId() { $items = []; - $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Creditmemo\Item') + $itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo\Item::class) ->disableOriginalConstructor() ->getMock(); $itemMock->expects($this->never()) @@ -182,7 +187,8 @@ public function testGetItemsCollectionWithoutId() $items[] = $itemMock; /** @var ItemCollection|\PHPUnit_Framework_MockObject_MockObject $itemCollectionMock */ - $itemCollectionMock = $this->getMockBuilder('\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\Collection') + $itemCollectionMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\Collection::class) ->disableOriginalConstructor() ->getMock(); $itemCollectionMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php index 4aca25741d11c..d11db6da48591 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php @@ -9,6 +9,8 @@ /** * Class BuilderTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CustomerManagementTest extends \PHPUnit_Framework_TestCase { @@ -49,30 +51,30 @@ class CustomerManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectCopyService = $this->getMock('\Magento\Framework\DataObject\Copy', [], [], '', false); - $this->accountManagement = $this->getMock('\Magento\Customer\Api\AccountManagementInterface'); + $this->objectCopyService = $this->getMock(\Magento\Framework\DataObject\Copy::class, [], [], '', false); + $this->accountManagement = $this->getMock(\Magento\Customer\Api\AccountManagementInterface::class); $this->customerFactory = $this->getMock( - '\Magento\Customer\Api\Data\CustomerInterfaceFactory', + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create'], [], '', false ); $this->addressFactory = $this->getMock( - '\Magento\Customer\Api\Data\AddressInterfaceFactory', + \Magento\Customer\Api\Data\AddressInterfaceFactory::class, ['create'], [], '', false ); $this->regionFactory = $this->getMock( - 'Magento\Customer\Api\Data\RegionInterfaceFactory', + \Magento\Customer\Api\Data\RegionInterfaceFactory::class, ['create'], [], '', false ); - $this->orderRepository = $this->getMock('\Magento\Sales\Api\OrderRepositoryInterface'); + $this->orderRepository = $this->getMock(\Magento\Sales\Api\OrderRepositoryInterface::class); $this->service = new \Magento\Sales\Model\Order\CustomerManagement( $this->objectCopyService, @@ -89,7 +91,7 @@ protected function setUp() */ public function testCreateThrowsExceptionIfCustomerAlreadyExists() { - $orderMock = $this->getMock('\Magento\Sales\Api\Data\OrderInterface'); + $orderMock = $this->getMock(\Magento\Sales\Api\Data\OrderInterface::class); $orderMock->expects($this->once())->method('getCustomerId')->will($this->returnValue('customer_id')); $this->orderRepository->expects($this->once())->method('get')->with(1)->will($this->returnValue($orderMock)); $this->service->create(1); @@ -97,16 +99,16 @@ public function testCreateThrowsExceptionIfCustomerAlreadyExists() public function testCreateCreatesCustomerBasedonGuestOrder() { - $orderMock = $this->getMock('\Magento\Sales\Model\Order', [], [], '', false); + $orderMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $orderMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(null)); $orderMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue('billing_address')); - $orderBillingAddress = $this->getMock('\Magento\Sales\Api\Data\OrderAddressInterface'); + $orderBillingAddress = $this->getMock(\Magento\Sales\Api\Data\OrderAddressInterface::class); $orderBillingAddress->expects($this->once()) ->method('getAddressType') ->willReturn(Address::ADDRESS_TYPE_BILLING); - $orderShippingAddress = $this->getMock('\Magento\Sales\Api\Data\OrderAddressInterface'); + $orderShippingAddress = $this->getMock(\Magento\Sales\Api\Data\OrderAddressInterface::class); $orderShippingAddress->expects($this->once()) ->method('getAddressType') ->willReturn(Address::ADDRESS_TYPE_SHIPPING); @@ -124,7 +126,7 @@ public function testCreateCreatesCustomerBasedonGuestOrder() ] )); - $addressMock = $this->getMock('\Magento\Customer\Api\Data\AddressInterface'); + $addressMock = $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class); $addressMock->expects($this->any()) ->method('setIsDefaultBilling') ->with(true) @@ -137,7 +139,7 @@ public function testCreateCreatesCustomerBasedonGuestOrder() $this->addressFactory->expects($this->any())->method('create')->with(['data' => 'address_data'])->will( $this->returnValue($addressMock) ); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerMock->expects($this->any())->method('getId')->will($this->returnValue('customer_id')); $this->customerFactory->expects($this->once())->method('create')->with( ['data' => ['customer_data' => [], 'addresses' => [$addressMock, $addressMock]]] diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php index b02af0bfb9c74..d73981211e17c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php @@ -34,12 +34,12 @@ class CreditmemoCommentIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php index 4f215aa457dd0..2e3d3e502e7b6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php @@ -34,12 +34,12 @@ class CreditmemoIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php index 1ec7bf233d1ca..3bd0b3d632bef 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php @@ -34,12 +34,12 @@ class InvoiceCommentIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php index 5aef9349aa4b2..9d44cb9c340ee 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php @@ -34,12 +34,12 @@ class InvoiceIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php index 1b5b4a8391e73..57bfe7ffa4520 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php @@ -34,12 +34,12 @@ class OrderCommentIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php index be8fd1f64d733..8761bc7d799e1 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php @@ -34,12 +34,12 @@ class OrderIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMock( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php index c5bcd76208b63..1322b5cc30288 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php @@ -34,12 +34,12 @@ class ShipmentCommentIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMock( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php index 56ed8de57115a..ae3080f10bb81 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php @@ -34,12 +34,12 @@ class ShipmentIdentityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->scopeConfigInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php index 7a37cf50c8214..fe8f04e68d21e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php @@ -7,6 +7,8 @@ /** * Class AbstractSenderTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ abstract class AbstractSenderTest extends \PHPUnit_Framework_TestCase { @@ -75,7 +77,7 @@ abstract class AbstractSenderTest extends \PHPUnit_Framework_TestCase public function stepMockSetup() { $this->senderMock = $this->getMock( - 'Magento\Sales\Model\Order\Email\Sender', + \Magento\Sales\Model\Order\Email\Sender::class, ['send', 'sendCopyTo'], [], '', @@ -83,14 +85,14 @@ public function stepMockSetup() ); $this->senderBuilderFactoryMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + \Magento\Sales\Model\Order\Email\SenderBuilderFactory::class, ['create'], [], '', false ); $this->templateContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\Template', + \Magento\Sales\Model\Order\Email\Container\Template::class, ['setTemplateVars'], [], '', @@ -98,7 +100,7 @@ public function stepMockSetup() ); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', @@ -106,7 +108,7 @@ public function stepMockSetup() ); $this->orderMock = $this->getMock( - '\Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'getStore', 'getBillingAddress', 'getPayment', '__wakeup', 'getCustomerIsGuest', 'getCustomerName', @@ -121,7 +123,7 @@ public function stepMockSetup() ->method('getStore') ->will($this->returnValue($this->storeMock)); $paymentInfoMock = $this->getMock( - '\Magento\Payment\Model\Info', + \Magento\Payment\Model\Info::class, [], [], '', @@ -131,17 +133,17 @@ public function stepMockSetup() ->method('getPayment') ->will($this->returnValue($paymentInfoMock)); - $this->addressRenderer = $this->getMock('Magento\Sales\Model\Order\Address\Renderer', [], [], '', false); - $this->addressMock = $this->getMock('Magento\Sales\Model\Order\Address', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->addressRenderer = $this->getMock(\Magento\Sales\Model\Order\Address\Renderer::class, [], [], '', false); + $this->addressMock = $this->getMock(\Magento\Sales\Model\Order\Address::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false); + $this->paymentHelper = $this->getMock(\Magento\Payment\Helper\Data::class, ['getInfoBlockHtml'], [], '', false); $this->paymentHelper->expects($this->any()) ->method('getInfoBlockHtml') ->will($this->returnValue('payment')); $this->globalConfig = $this->getMock( - 'Magento\Framework\App\Config', + \Magento\Framework\App\Config::class, ['getValue'], [], '', @@ -149,7 +151,7 @@ public function stepMockSetup() ); $this->loggerMock = $this->getMock( - '\Psr\Log\LoggerInterface', + \Psr\Log\LoggerInterface::class, [], [], '', @@ -202,7 +204,7 @@ protected function stepSend( \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendCopyToExpects ) { $senderMock = $this->getMock( - 'Magento\Sales\Model\Order\Email\Sender', + \Magento\Sales\Model\Order\Email\Sender::class, ['send', 'sendCopyTo'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php index 846146bfb929d..ca40d0f868353 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php @@ -25,10 +25,10 @@ class CreditmemoCommentSenderTest extends AbstractSenderTest protected function setUp() { $this->stepMockSetup(); - $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity'); + $this->stepIdentityContainerInit(\Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity::class); $this->addressRenderer->expects($this->any())->method('format')->willReturn(1); $this->creditmemoMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, ['getStore', '__wakeup', 'getOrder'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php index cedb59dc52dc1..87dda4f2120e0 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php @@ -29,7 +29,7 @@ protected function setUp() $this->stepMockSetup(); $this->creditmemoResourceMock = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order\Creditmemo', + \Magento\Sales\Model\ResourceModel\Order\Creditmemo::class, ['saveAttribute'], [], '', @@ -37,7 +37,7 @@ protected function setUp() ); $this->creditmemoMock = $this->getMock( - '\Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, [ 'getStore', '__wakeup', 'getOrder', 'setSendEmail', 'setEmailSent', 'getCustomerNoteNotify', @@ -55,7 +55,7 @@ protected function setUp() ->will($this->returnValue($this->orderMock)); $this->identityContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity', + \Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity::class, ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], [], '', @@ -104,7 +104,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema if (!$configValue || $forceSyncMode) { $addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [], [], '', @@ -116,7 +116,6 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema ->with($addressMock, 'html') ->willReturn($address); - $this->stepAddressFormat($addressMock); $this->creditmemoMock->expects($this->once()) @@ -223,7 +222,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte ->with('sales_email/general/async_sending') ->willReturn(false); - $addressMock = $this->getMock('Magento\Sales\Model\Order\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Sales\Model\Order\Address::class, [], [], '', false); $this->addressRenderer->expects($this->exactly($formatCallCount)) ->method('format') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php index 9b2bab3d68e7c..07f2f6eb10b80 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php @@ -23,7 +23,7 @@ protected function setUp() { $this->stepMockSetup(); $this->paymentHelper = $this->getMock( - '\Magento\Payment\Helper\Data', + \Magento\Payment\Helper\Data::class, ['getInfoBlockHtml'], [], '', @@ -31,19 +31,19 @@ protected function setUp() ); $this->invoiceResource = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order\Invoice', + \Magento\Sales\Model\ResourceModel\Order\Invoice::class, [], [], '', false ); - $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity'); + $this->stepIdentityContainerInit(\Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity::class); $this->addressRenderer->expects($this->any())->method('format')->willReturn(1); $this->invoiceMock = $this->getMock( - '\Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, ['getStore', '__wakeup', 'getOrder'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php index 9ed5a3357f21e..5290b2483bb99 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php @@ -29,7 +29,7 @@ protected function setUp() $this->stepMockSetup(); $this->invoiceResourceMock = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order\Invoice', + \Magento\Sales\Model\ResourceModel\Order\Invoice::class, ['saveAttribute'], [], '', @@ -37,7 +37,7 @@ protected function setUp() ); $this->invoiceMock = $this->getMock( - '\Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, [ 'getStore', '__wakeup', 'getOrder', 'setSendEmail', 'setEmailSent', 'getCustomerNoteNotify', @@ -55,7 +55,7 @@ protected function setUp() ->will($this->returnValue($this->orderMock)); $this->identityContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\InvoiceIdentity', + \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::class, ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], [], '', @@ -104,7 +104,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema if (!$configValue || $forceSyncMode) { $addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [], [], '', @@ -227,7 +227,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte ->with('sales_email/general/async_sending') ->willReturn(false); - $addressMock = $this->getMock('Magento\Sales\Model\Order\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Sales\Model\Order\Address::class, [], [], '', false); $this->addressRenderer->expects($this->exactly($formatCallCount)) ->method('format') @@ -259,7 +259,6 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte ->method('isEnabled') ->willReturn(false); - $this->invoiceResourceMock->expects($this->once()) ->method('saveAttribute') ->with($this->invoiceMock, 'send_email'); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php index 24a097fc195f3..52f82ed7b574f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php @@ -17,7 +17,7 @@ class OrderCommentSenderTest extends AbstractSenderTest protected function setUp() { $this->stepMockSetup(); - $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity'); + $this->stepIdentityContainerInit(\Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity::class); $this->addressRenderer->expects($this->any())->method('format')->willReturn(1); $this->sender = new OrderCommentSender( $this->templateContainerMock, @@ -45,7 +45,6 @@ public function testSendTrue() ->method('getCustomerIsGuest') ->will($this->returnValue(false)); - $this->identityContainerMock->expects($this->once()) ->method('isEnabled') ->will($this->returnValue(true)); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php index da4cb3309ef12..2b1e0bcd42fad 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php @@ -24,7 +24,7 @@ protected function setUp() $this->stepMockSetup(); $this->orderResourceMock = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order', + \Magento\Sales\Model\ResourceModel\Order::class, ['saveAttribute'], [], '', @@ -32,7 +32,7 @@ protected function setUp() ); $this->identityContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\OrderIdentity', + \Magento\Sales\Model\Order\Email\Container\OrderIdentity::class, ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], [], '', @@ -83,7 +83,7 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult) if ($emailSendingResult) { $addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [], [], '', @@ -195,7 +195,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte ->method('isEnabled') ->willReturn(true); - $addressMock = $this->getMock('Magento\Sales\Model\Order\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Sales\Model\Order\Address::class, [], [], '', false); $this->addressRenderer->expects($this->exactly($formatCallCount)) ->method('format') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php index b89bff84d928a..137e90410651c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php @@ -22,10 +22,10 @@ class ShipmentCommentSenderTest extends AbstractSenderTest protected function setUp() { $this->stepMockSetup(); - $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity'); + $this->stepIdentityContainerInit(\Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity::class); $this->addressRenderer->expects($this->any())->method('format')->willReturn(1); $this->shipmentMock = $this->getMock( - '\Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getStore', '__wakeup', 'getOrder'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php index 62a803f492b90..ee7f99de86423 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php @@ -29,7 +29,7 @@ protected function setUp() $this->stepMockSetup(); $this->shipmentResourceMock = $this->getMock( - '\Magento\Sales\Model\ResourceModel\Order\Shipment', + \Magento\Sales\Model\ResourceModel\Order\Shipment::class, ['saveAttribute'], [], '', @@ -37,7 +37,7 @@ protected function setUp() ); $this->shipmentMock = $this->getMock( - '\Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, [ 'getStore', '__wakeup', 'getOrder', 'setSendEmail', 'setEmailSent', 'getCustomerNoteNotify', @@ -55,7 +55,7 @@ protected function setUp() ->will($this->returnValue($this->orderMock)); $this->identityContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\ShipmentIdentity', + \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity::class, ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], [], '', @@ -104,7 +104,7 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema if (!$configValue || $forceSyncMode) { $addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [], [], '', @@ -227,7 +227,7 @@ public function testSendVirtualOrder($isVirtualOrder, $formatCallCount, $expecte ->with('sales_email/general/async_sending') ->willReturn(false); - $addressMock = $this->getMock('Magento\Sales\Model\Order\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Sales\Model\Order\Address::class, [], [], '', false); $this->addressRenderer->expects($this->exactly($formatCallCount)) ->method('format') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php index 1c0e42b28695f..bb44b4c877ba8 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php @@ -38,7 +38,7 @@ protected function setUp() $emailCopyTo = ['example@mail.com']; $this->templateContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\Template', + \Magento\Sales\Model\Order\Email\Container\Template::class, ['getTemplateVars', 'getTemplateOptions', 'getTemplateId'], [], '', @@ -46,7 +46,7 @@ protected function setUp() ); $this->storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getStoreId', '__wakeup'], [], '', @@ -54,7 +54,7 @@ protected function setUp() ); $this->identityContainerMock = $this->getMock( - '\Magento\Sales\Model\Order\Email\Container\ShipmentIdentity', + \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity::class, [ 'getEmailIdentity', 'getCustomerEmail', 'getCustomerName', 'getTemplateOptions', 'getEmailCopyTo', @@ -66,7 +66,7 @@ protected function setUp() ); $this->transportBuilder = $this->getMock( - '\Magento\Framework\Mail\Template\TransportBuilder', + \Magento\Framework\Mail\Template\TransportBuilder::class, [ 'addTo', 'addBcc', 'getTransport', 'setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', @@ -119,7 +119,7 @@ public function testSend() $customerName = 'test_name'; $customerEmail = 'test_email'; $transportMock = $this->getMock( - '\Magento\Sales\Test\Unit\Model\Order\Email\Stub\TransportInterfaceMock', + \Magento\Sales\Test\Unit\Model\Order\Email\Stub\TransportInterfaceMock::class, [], [], '', @@ -152,7 +152,7 @@ public function testSend() public function testSendCopyTo() { $transportMock = $this->getMock( - '\Magento\Sales\Test\Unit\Model\Order\Email\Stub\TransportInterfaceMock', + \Magento\Sales\Test\Unit\Model\Order\Email\Stub\TransportInterfaceMock::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Massaction/ItemsUpdaterTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Massaction/ItemsUpdaterTest.php index 6f830397952d2..9cebd7a14615d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Massaction/ItemsUpdaterTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Massaction/ItemsUpdaterTest.php @@ -20,7 +20,7 @@ class ItemsUpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->authorizationMock = $this->getMock('Magento\Framework\Authorization', [], [], '', false); + $this->authorizationMock = $this->getMock(\Magento\Framework\Authorization::class, [], [], '', false); $this->itemUpdater = new \Magento\Sales\Model\Order\Grid\Massaction\ItemsUpdater( $this->authorizationMock ); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Row/UrlGeneratorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Row/UrlGeneratorTest.php index 64ac33e0bb5cb..3bdf0bca7cd8f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Row/UrlGeneratorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Grid/Row/UrlGeneratorTest.php @@ -26,7 +26,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urlMock = $this->getMockForAbstractClass( - 'Magento\Backend\Model\UrlInterface', + \Magento\Backend\Model\UrlInterface::class, [], '', false, @@ -35,7 +35,7 @@ protected function setUp() [] ); $this->authorizationMock = $this->getMockForAbstractClass( - 'Magento\Framework\AuthorizationInterface', + \Magento\Framework\AuthorizationInterface::class, [], '', false, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Comment/ValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Comment/ValidatorTest.php index 9fc2a4d632ad8..801d0bf0d5656 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Comment/ValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Comment/ValidatorTest.php @@ -26,7 +26,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->commentModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice\Comment', + \Magento\Sales\Model\Order\Invoice\Comment::class, ['hasData', 'getData', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Grid/Row/UrlGeneratorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Grid/Row/UrlGeneratorTest.php index 19e6356f90afa..90a997fc873f9 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Grid/Row/UrlGeneratorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Grid/Row/UrlGeneratorTest.php @@ -26,7 +26,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->urlMock = $this->getMockForAbstractClass( - 'Magento\Backend\Model\UrlInterface', + \Magento\Backend\Model\UrlInterface::class, [], '', false, @@ -35,7 +35,7 @@ protected function setUp() [] ); $this->authorizationMock = $this->getMockForAbstractClass( - 'Magento\Framework\AuthorizationInterface', + \Magento\Framework\AuthorizationInterface::class, [], '', false, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php index 09dd455564a9f..fcfd688a16c29 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php @@ -42,28 +42,28 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->orderItemFactoryMock = $this->getMock( - 'Magento\Sales\Model\Order\ItemFactory', + \Magento\Sales\Model\Order\ItemFactory::class, ['create'], [], '', false ); $this->invoiceMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, [], [], '', false ); $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', false ); $this->orderItemMock = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, [ 'load', 'isDummy', 'getIsQtyDecimal', 'getQtyToInvoice', 'getQtyInvoiced', 'getTaxInvoiced', 'getBaseTaxInvoiced', 'getDiscountTaxCompensationInvoiced', @@ -79,7 +79,7 @@ protected function setUp() false ); $this->item = $this->objectManager->getObject( - 'Magento\Sales\Model\Order\Invoice\Item', + \Magento\Sales\Model\Order\Invoice\Item::class, [ 'orderItemFactory' => $this->orderItemFactoryMock ] diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/ShippingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/ShippingTest.php index 6c1ec7b769b71..243d9d9467c0b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/ShippingTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/ShippingTest.php @@ -8,6 +8,9 @@ namespace Magento\Sales\Test\Unit\Model\Order\Invoice\Total; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ShippingTest extends \PHPUnit_Framework_TestCase { /** @@ -18,43 +21,43 @@ class ShippingTest extends \PHPUnit_Framework_TestCase */ protected function _getInvoiceCollection(array $invoicesData) { - $className = 'Magento\Sales\Model\Order\Invoice'; + $className = \Magento\Sales\Model\Order\Invoice::class; $result = new \Magento\Framework\Data\Collection( - $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false) + $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = [ - 'orderFactory' => $this->getMock('Magento\Sales\Model\OrderFactory', [], [], '', false), + 'orderFactory' => $this->getMock(\Magento\Sales\Model\OrderFactory::class, [], [], '', false), 'orderResourceFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\OrderFactory', + \Magento\Sales\Model\ResourceModel\OrderFactory::class, [], [], '', false ), 'calculatorFactory' => $this->getMock( - 'Magento\Framework\Math\CalculatorFactory', + \Magento\Framework\Math\CalculatorFactory::class, [], [], '', false ), 'invoiceItemCollectionFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Invoice\Item\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Invoice\Item\CollectionFactory::class, [], [], '', false ), 'invoiceCommentFactory' => $this->getMock( - 'Magento\Sales\Model\Order\Invoice\CommentFactory', + \Magento\Sales\Model\Order\Invoice\CommentFactory::class, [], [], '', false ), 'commentCollectionFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Invoice\Comment\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Invoice\Comment\CollectionFactory::class, [], [], '', @@ -82,47 +85,47 @@ public function testCollect(array $prevInvoicesData, $orderShipping, $invoiceShi { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = [ - 'productFactory' => $this->getMock('Magento\Catalog\Model\ProductFactory', [], [], '', false), + 'productFactory' => $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false), 'orderItemCollectionFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory::class, [], [], '', false ), 'serviceOrderFactory' => $this->getMock( - 'Magento\Sales\Model\Service\OrderFactory', + \Magento\Sales\Model\Service\OrderFactory::class, [], [], '', false ), 'currencyFactory' => $this->getMock( - 'Magento\Directory\Model\CurrencyFactory', + \Magento\Directory\Model\CurrencyFactory::class, [], [], '', false ), 'orderHistoryFactory' => $this->getMock( - 'Magento\Sales\Model\Order\Status\HistoryFactory', + \Magento\Sales\Model\Order\Status\HistoryFactory::class, [], [], '', false ), 'orderTaxCollectionFactory' => $this->getMock( - 'Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory', + \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory::class, [], [], '', false ), ]; - $orderConstructorArgs = $objectManager->getConstructArguments('Magento\Sales\Model\Order', $arguments); + $orderConstructorArgs = $objectManager->getConstructArguments(\Magento\Sales\Model\Order::class, $arguments); /** @var $order \Magento\Sales\Model\Order|PHPUnit_Framework_MockObject_MockObject */ $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['_init', 'getInvoiceCollection', '__wakeup'], $orderConstructorArgs, '', @@ -137,7 +140,7 @@ public function testCollect(array $prevInvoicesData, $orderShipping, $invoiceShi $this->returnValue($this->_getInvoiceCollection($prevInvoicesData)) ); /** @var $invoice \Magento\Sales\Model\Order\Invoice|PHPUnit_Framework_MockObject_MockObject */ - $invoice = $this->getMock('Magento\Sales\Model\Order\Invoice', ['_init', '__wakeup'], [], '', false); + $invoice = $this->getMock(\Magento\Sales\Model\Order\Invoice::class, ['_init', '__wakeup'], [], '', false); $invoice->setData('shipping_amount', $invoiceShipping); $invoice->setOrder($order); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/TaxTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/TaxTest.php index 691ff8bfc64eb..8f468a8eee4c6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/TaxTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/TaxTest.php @@ -32,10 +32,10 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Sales\Model\Order\Invoice\Total\Tax $model */ - $this->model = $this->objectManager->getObject('Magento\Sales\Model\Order\Invoice\Total\Tax'); + $this->model = $this->objectManager->getObject(\Magento\Sales\Model\Order\Invoice\Total\Tax::class); $this->order = $this->getMock( - '\Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'getInvoiceCollection', '__wakeup' @@ -46,7 +46,7 @@ protected function setUp() ); $this->invoice = $this->getMock( - '\Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, [ 'getAllItems', 'getOrder', @@ -78,7 +78,7 @@ public function testCollect($orderData, $invoiceData, $expectedResults) /** @var \Magento\Sales\Model\Order\Invoice[] $previousInvoices */ $previousInvoices = []; foreach ($orderData['previous_invoices'] as $previousInvoiceData) { - $previousInvoice = $this->getMockBuilder('\Magento\Sales\Model\Order\Invoice') + $previousInvoice = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods(['isCanceled', '__wakeup']) ->getMock(); @@ -368,7 +368,7 @@ protected function getInvoiceItem($invoiceItemData) { /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject $orderItem */ $orderItem = $this->getMock( - '\Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, [ 'isDummy', '__wakeup' @@ -383,7 +383,7 @@ protected function getInvoiceItem($invoiceItemData) /** @var \Magento\Sales\Model\Order\Invoice\Item|\PHPUnit_Framework_MockObject_MockObject $invoiceItem */ $invoiceItem = $this->getMock( - '\Magento\Sales\Model\Order\Invoice\Item', + \Magento\Sales\Model\Order\Invoice\Item::class, [ 'getOrderItem', 'isLast', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceNotifierTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceNotifierTest.php index 13d45fbcaf9ca..a3149ef4da9b7 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceNotifierTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceNotifierTest.php @@ -44,27 +44,27 @@ class InvoiceNotifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->historyCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory::class, ['create'], [], '', false ); $this->invoice = $this->getMock( - 'Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, ['__wakeUp', 'getEmailSent'], [], '', false ); $this->invoiceSenderMock = $this->getMock( - 'Magento\Sales\Model\Order\Email\Sender\InvoiceSender', + \Magento\Sales\Model\Order\Email\Sender\InvoiceSender::class, ['send'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->notifier = new InvoiceNotifier( $this->historyCollectionFactory, $this->loggerMock, @@ -78,14 +78,14 @@ protected function setUp() public function testNotifySuccess() { $historyCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\Collection', + \Magento\Sales\Model\ResourceModel\Order\Status\History\Collection::class, ['getUnnotifiedForInstance', 'save', 'setIsCustomerNotified'], [], '', false ); $historyItem = $this->getMock( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, ['setIsCustomerNotified', 'save', '__wakeUp'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php index 6c4199288ac7f..a9870833654b3 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php @@ -15,6 +15,7 @@ * Class InvoiceTest * * @package Magento\Sales\Model\Order + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InvoiceTest extends \PHPUnit_Framework_TestCase { @@ -63,7 +64,7 @@ protected function setUp() { $this->helperManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->orderMock = $this->getMockBuilder( - 'Magento\Sales\Model\Order' + \Magento\Sales\Model\Order::class )->disableOriginalConstructor()->setMethods( [ 'getPayment', '__wakeup', 'load', 'setHistoryEntityName', 'getStore', 'getBillingAddress', @@ -76,15 +77,15 @@ protected function setUp() ->will($this->returnSelf()); $this->paymentMock = $this->getMockBuilder( - 'Magento\Sales\Model\Order\Payment' + \Magento\Sales\Model\Order\Payment::class )->disableOriginalConstructor()->setMethods( ['canVoid', '__wakeup', 'canCapture', 'capture', 'pay'] )->getMock(); - $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); + $this->orderFactory = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); - $this->eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface', [], [], '', false); - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); $contextMock->expects($this->any()) ->method('getEventDispatcher') ->willReturn($this->eventManagerMock); @@ -93,44 +94,47 @@ protected function setUp() 'context' => $contextMock, 'orderFactory' => $this->orderFactory, 'orderResourceFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\OrderFactory', + \Magento\Sales\Model\ResourceModel\OrderFactory::class, [], [], '', false ), 'calculatorFactory' => $this->getMock( - 'Magento\Framework\Math\CalculatorFactory', + \Magento\Framework\Math\CalculatorFactory::class, [], [], '', false ), 'invoiceItemCollectionFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Invoice\Item\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Invoice\Item\CollectionFactory::class, [], [], '', false ), 'invoiceCommentFactory' => $this->getMock( - 'Magento\Sales\Model\Order\Invoice\CommentFactory', + \Magento\Sales\Model\Order\Invoice\CommentFactory::class, [], [], '', false ), 'commentCollectionFactory' => $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Invoice\Comment\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Invoice\Comment\CollectionFactory::class, [], [], '', false ), ]; - $this->model = $this->helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments); + $this->model = $this->helperManager->getObject(\Magento\Sales\Model\Order\Invoice::class, $arguments); $this->model->setOrder($this->orderMock); - $this->modelWithoutOrder = $this->helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments); + $this->modelWithoutOrder = $this->helperManager->getObject( + \Magento\Sales\Model\Order\Invoice::class, + $arguments + ); } /** @@ -222,7 +226,7 @@ public function testSetOrder() public function testGetStore() { - $store = $this->helperManager->getObject('\Magento\Store\Model\Store', []); + $store = $this->helperManager->getObject(\Magento\Store\Model\Store::class, []); $this->orderMock->expects($this->once())->method('getStore')->willReturn($store); $this->assertEquals($store, $this->model->getStore()); @@ -230,7 +234,7 @@ public function testGetStore() public function testGetShippingAddress() { - $address = $this->helperManager->getObject('\Magento\Sales\Model\Order\Address', []); + $address = $this->helperManager->getObject(\Magento\Sales\Model\Order\Address::class, []); $this->orderMock->expects($this->once())->method('getShippingAddress')->willReturn($address); $this->assertEquals($address, $this->model->getShippingAddress()); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemRepositoryTest.php index 69e72fede242e..76509010d70d3 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemRepositoryTest.php @@ -7,6 +7,9 @@ use Magento\Sales\Model\Order\ItemRepository; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ItemRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -46,30 +49,30 @@ class ItemRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectFactory = $this->getMockBuilder('Magento\Framework\DataObject\Factory') + $this->objectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->metadata = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Metadata') + $this->metadata = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Metadata::class) ->disableOriginalConstructor() ->getMock(); $this->searchResultFactory = $this->getMockBuilder( - 'Magento\Sales\Api\Data\OrderItemSearchResultInterfaceFactory' + \Magento\Sales\Api\Data\OrderItemSearchResultInterfaceFactory::class ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->productOptionFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductOptionFactory') + $this->productOptionFactory = $this->getMockBuilder(\Magento\Catalog\Model\ProductOptionFactory::class) ->setMethods([ 'create', ]) ->disableOriginalConstructor() ->getMock(); - $this->extensionFactory = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductOptionExtensionFactory') + $this->extensionFactory = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductOptionExtensionFactory::class) ->setMethods([ 'create', ]) @@ -102,7 +105,7 @@ public function testGetEmptyEntity() { $orderItemId = 1; - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -166,7 +169,7 @@ public function testGetList() $this->productOptionData = ['option1' => 'value1']; - $filterMock = $this->getMockBuilder('Magento\Framework\Api\Filter') + $filterMock = $this->getMockBuilder(\Magento\Framework\Api\Filter::class) ->disableOriginalConstructor() ->getMock(); $filterMock->expects($this->once()) @@ -179,14 +182,14 @@ public function testGetList() ->method('getValue') ->willReturn($value); - $filterGroupMock = $this->getMockBuilder('Magento\Framework\Api\Search\FilterGroup') + $filterGroupMock = $this->getMockBuilder(\Magento\Framework\Api\Search\FilterGroup::class) ->disableOriginalConstructor() ->getMock(); $filterGroupMock->expects($this->once()) ->method('getFilters') ->willReturn([$filterMock]); - $searchCriteriaMock = $this->getMockBuilder('Magento\Framework\Api\SearchCriteria') + $searchCriteriaMock = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteria::class) ->disableOriginalConstructor() ->getMock(); $searchCriteriaMock->expects($this->once()) @@ -197,7 +200,7 @@ public function testGetList() $productOption = $this->getProductOptionMock(); $orderItemMock = $this->getOrderMock($productType, $productOption); - $searchResultMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderItemSearchResultInterface') + $searchResultMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderItemSearchResultInterface::class) ->setMethods([ 'addFieldToFilter', 'getItems', @@ -224,11 +227,11 @@ public function testDeleteById() $orderItemId = 1; $productType = 'configurable'; - $requestMock = $this->getMockBuilder('Magento\Framework\DataObject') + $requestMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -245,7 +248,7 @@ public function testDeleteById() ->method('getBuyRequest') ->willReturn($requestMock); - $orderItemResourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $orderItemResourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->getMock(); $orderItemResourceMock->expects($this->once()) @@ -275,11 +278,11 @@ protected function getModel( $productType, array $data = [] ) { - $requestMock = $this->getMockBuilder('Magento\Framework\DataObject') + $requestMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); - $requestUpdateMock = $this->getMockBuilder('Magento\Framework\DataObject') + $requestUpdateMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); $requestUpdateMock->expects($this->any()) @@ -287,7 +290,7 @@ protected function getModel( ->willReturn($data); $this->productOptionProcessorMock = $this->getMockBuilder( - 'Magento\Catalog\Model\ProductOptionProcessorInterface' + \Magento\Catalog\Model\ProductOptionProcessorInterface::class ) ->getMockForAbstractClass(); $this->productOptionProcessorMock->expects($this->any()) @@ -320,11 +323,11 @@ protected function getModel( */ protected function getOrderMock($productType, $productOption) { - $requestMock = $this->getMockBuilder('Magento\Framework\DataObject') + $requestMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); - $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->getMock(); $orderItemMock->expects($this->once()) @@ -349,7 +352,7 @@ protected function getOrderMock($productType, $productOption) */ protected function getProductOptionMock() { - $productOption = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductOptionInterface') + $productOption = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductOptionInterface::class) ->getMockForAbstractClass(); $productOption->expects($this->any()) ->method('getExtensionAttributes') @@ -364,7 +367,9 @@ protected function getProductOptionMock() protected function getProductOptionExtensionMock() { - $productOptionExtension = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductOptionExtensionInterface') + $productOptionExtension = $this->getMockBuilder( + \Magento\Catalog\Api\Data\ProductOptionExtensionInterface::class + ) ->setMethods([ 'setData', ]) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php index 8e7790e60c153..3d6ba772618c7 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php @@ -20,6 +20,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Item */ protected $model; + /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ @@ -34,25 +35,23 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); + $this->orderFactory = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); $arguments = [ 'orderFactory' => $this->orderFactory, ]; - $this->model = $this->objectManager->getObject('Magento\Sales\Model\Order\Item', $arguments); + $this->model = $this->objectManager->getObject(\Magento\Sales\Model\Order\Item::class, $arguments); } - public function testSetParentItemNull() { $this->assertEquals($this->model, $this->model->setParentItem(null)); $this->assertNull($this->model->getParentItem()); } - public function testSetParentItem() { - $item = $this->objectManager->getObject('Magento\Sales\Model\Order\Item', []); + $item = $this->objectManager->getObject(\Magento\Sales\Model\Order\Item::class, []); $this->assertEquals($this->model, $this->model->setParentItem($item)); $this->assertEquals($item, $this->model->getParentItem()); $this->assertTrue($item->getHasChildren()); @@ -61,7 +60,7 @@ public function testSetParentItem() public function testGetPatentItem() { - $item = $this->objectManager->getObject('Magento\Sales\Model\Order\Item', []); + $item = $this->objectManager->getObject(\Magento\Sales\Model\Order\Item::class, []); $this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::PARENT_ITEM, $item); $this->assertEquals($item, $this->model->getParentItem()); } @@ -69,7 +68,7 @@ public function testGetPatentItem() public function testSetOrder() { $orderId = 123; - $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $order = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $order->expects($this->once()) ->method('getId') ->willReturn($orderId); @@ -84,7 +83,7 @@ public function testGetOrder() //set order_id and get order by id $orderId = 123; - $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $order = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $order->expects($this->once()) ->method('load') ->with($orderId) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php index 3516aef705982..9bb5e47db947c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php @@ -34,22 +34,28 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registryMock = $this->getMock('Magento\Framework\Registry'); - $this->paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', ['getMethodInstance'], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class); + $this->paymentHelperMock = $this->getMock( + \Magento\Payment\Helper\Data::class, + ['getMethodInstance'], + [], + '', + false + ); $this->encryptorInterfaceMock = $this->getMock( - 'Magento\Framework\Encryption\EncryptorInterface', + \Magento\Framework\Encryption\EncryptorInterface::class, [], [], '', false ); - $this->methodInstanceMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $this->methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->info = $this->objectManagerHelper->getObject( - 'Magento\Sales\Model\Order\Payment\Info', + \Magento\Sales\Model\Order\Payment\Info::class, [ 'context' => $this->contextMock, 'registry' => $this->registryMock, @@ -89,7 +95,7 @@ public function ccKeysDataProvider() ['cc_cid', 'cc_cid_enc'] ]; } - + public function testGetMethodInstanceWithRealMethod() { $method = 'real_method'; diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Operations/CaptureOperationTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Operations/CaptureOperationTest.php index b19cce3d3a175..6a2c3912f242e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Operations/CaptureOperationTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Operations/CaptureOperationTest.php @@ -39,23 +39,23 @@ class CaptureOperationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $transactionClass = 'Magento\Sales\Model\Order\Payment\Transaction\ManagerInterface'; - $transactionBuilderClass = 'Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface'; + $transactionClass = \Magento\Sales\Model\Order\Payment\Transaction\ManagerInterface::class; + $transactionBuilderClass = \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface::class; $this->transactionManager = $this->getMockBuilder($transactionClass) ->disableOriginalConstructor() ->getMock(); - $this->eventManager = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->transactionBuilder = $this->getMockBuilder($transactionBuilderClass) ->disableOriginalConstructor() ->getMock(); - $this->stateCommand = $this->getMockBuilder('Magento\Sales\Model\Order\Payment\State\CommandInterface') + $this->stateCommand = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment\State\CommandInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Sales\Model\Order\Payment\Operations\CaptureOperation', + \Magento\Sales\Model\Order\Payment\Operations\CaptureOperation::class, [ 'transactionManager' => $this->transactionManager, 'eventManager' => $this->eventManager, @@ -69,15 +69,15 @@ public function testCapture() { $baseGrandTotal = 10; - $order = $this->getMockBuilder('Magento\Sales\Model\Order') + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $paymentMethod = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $paymentMethod = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->disableOriginalConstructor() ->getMock(); - $orderPayment = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $orderPayment = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->getMock(); $orderPayment->expects($this->any()) @@ -106,7 +106,7 @@ public function testCapture() ->with($orderPayment) ->willReturnSelf(); - $invoice = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $invoice = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->getMock(); $invoice->expects($this->any()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php index 99b16bde038a9..ab2f42acfd51e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php @@ -7,6 +7,9 @@ namespace Magento\Sales\Test\Unit\Model\Order\Payment; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -53,56 +56,56 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->metaData = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Metadata', + \Magento\Sales\Model\ResourceModel\Metadata::class, [], [], '', false ); $this->searchResultFactory = $this->getMock( - 'Magento\Sales\Api\Data\OrderPaymentSearchResultInterfaceFactory', + \Magento\Sales\Api\Data\OrderPaymentSearchResultInterfaceFactory::class, ['create'], [], '', false ); $this->searchCriteria = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, [], [], '', false ); $this->collection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Collection', + \Magento\Sales\Model\ResourceModel\Order\Payment\Collection::class, [], [], '', false ); $this->paymentResource = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment', + \Magento\Sales\Model\ResourceModel\Order\Payment::class, [], [], '', false ); $this->filterGroup = $this->getMock( - 'Magento\Framework\Api\Search\FilterGroup', + \Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false ); $this->filter = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, [], [], '', false ); $this->repository = $objectManager->getObject( - 'Magento\Sales\Model\Order\Payment\Repository', + \Magento\Sales\Model\Order\Payment\Repository::class, [ 'searchResultFactory' => $this->searchResultFactory, 'metaData' => $this->metaData, @@ -179,7 +182,7 @@ public function testGetList() protected function mockPayment($id = false) { $payment = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php index 1195643111c69..34af81e0cf5bb 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php @@ -34,14 +34,14 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->repositoryMock = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction\Repository', + \Magento\Sales\Model\Order\Payment\Transaction\Repository::class, [], [], '', false ); $this->paymentMock = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, [ 'hasIsTransactionClosed', 'getIsTransactionClosed', @@ -54,14 +54,14 @@ protected function setUp() false ); $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', false ); $this->builder = $objectManager->getObject( - 'Magento\Sales\Model\Order\Payment\Transaction\Builder', + \Magento\Sales\Model\Order\Payment\Transaction\Builder::class, ['transactionRepository' => $this->repositoryMock] ); } @@ -194,7 +194,6 @@ protected function expectsLinkWithParentTransaction( } } - /** * @param int $orderId * @param int $paymentId @@ -203,7 +202,7 @@ protected function expectsLinkWithParentTransaction( protected function expectTransaction($orderId, $paymentId) { $newTransaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [ 'getId', 'setOrderId', @@ -239,7 +238,7 @@ protected function expectTransaction($orderId, $paymentId) protected function expectDocument($transactionId) { $document = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'setTransactionId' ], diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php index 548bf800aacd4..ebc9bab78d331 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php @@ -31,14 +31,14 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->repositoryMock = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction\Repository', + \Magento\Sales\Model\Order\Payment\Transaction\Repository::class, [], [], '', false ); $this->manager = $objectManager->getObject( - 'Magento\Sales\Model\Order\Payment\Transaction\Manager', + \Magento\Sales\Model\Order\Payment\Transaction\Manager::class, ['transactionRepository' => $this->repositoryMock] ); } @@ -52,7 +52,7 @@ protected function setUp() public function testGetAuthorizationTransaction($parentTransactionId, $paymentId, $orderId) { $transaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', @@ -90,7 +90,7 @@ public function testIsTransactionExists($transactionId, $isRepositoryReturnTrans if ($transactionId && $isRepositoryReturnTransaction) { $transaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', @@ -123,7 +123,7 @@ public function testGenerateTransactionId( $transactionBasedOn = false; $payment = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, ["setParentTransactionId", "getParentTransactionId", "getTransactionId"], [], '', @@ -133,7 +133,7 @@ public function testGenerateTransactionId( if (!$parentTransactionId && !$transactionId && $transactionBasedTxnId) { $transactionBasedOn = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/RepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/RepositoryTest.php index 6bde91a057e27..6526b4e729b5f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/RepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/RepositoryTest.php @@ -9,6 +9,9 @@ use Magento\Sales\Model\Order\Payment\Transaction; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -79,84 +82,84 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->searchResultFactory = $this->getMock( - 'Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory', + \Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory::class, ['create'], [], '', false ); $this->filterBuilder = $this->getMock( - 'Magento\Framework\Api\FilterBuilder', + \Magento\Framework\Api\FilterBuilder::class, [], [], '', false ); $this->searchCriteriaBuilder = $this->getMock( - 'Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false ); $this->sortOrderBuilder = $this->getMock( - 'Magento\Framework\Api\SortOrderBuilder', + \Magento\Framework\Api\SortOrderBuilder::class, [], [], '', false ); $this->metaData = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Metadata', + \Magento\Sales\Model\ResourceModel\Metadata::class, [], [], '', false ); $entityStorageFactory = $this->getMock( - 'Magento\Sales\Model\EntityStorageFactory', + \Magento\Sales\Model\EntityStorageFactory::class, ['create'], [], '', false ); $this->entityStorage = $this->getMock( - 'Magento\Sales\Model\EntityStorage', + \Magento\Sales\Model\EntityStorage::class, [], [], '', false ); $this->transactionResource = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction', + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction::class, [], [], '', false ); $this->searchCriteria = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, [], [], '', false ); $this->filterGroup = $this->getMock( - 'Magento\Framework\Api\Search\FilterGroup', + \Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false ); $this->filter = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, [], [], '', false ); $this->collection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection', + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection::class, [], [], '', @@ -164,7 +167,7 @@ protected function setUp() ); $entityStorageFactory->expects($this->once())->method('create')->willReturn($this->entityStorage); $this->repository = $objectManager->getObject( - 'Magento\Sales\Model\Order\Payment\Transaction\Repository', + \Magento\Sales\Model\Order\Payment\Transaction\Repository::class, [ 'searchResultFactory' => $this->searchResultFactory, 'filterBuilder' => $this->filterBuilder, @@ -423,7 +426,7 @@ public function testGetByTransactionTypeFromCache() protected function mockTransaction($transactionId, $withoutTransactionIdMatcher = false) { $transaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionTest.php index d5cdada073506..296b627956a29 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionTest.php @@ -24,11 +24,11 @@ class TransactionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('\Magento\Framework\Model\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->setMethods(['getEventDispatcher']) ->disableOriginalConstructor() ->getMock(); - $this->eventManagerMock = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->setMethods(['dispatch']) ->getMockForAbstractClass(); @@ -38,7 +38,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->transaction = $this->objectManagerHelper->getObject( - '\Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [ 'context' => $this->contextMock ] @@ -52,7 +52,6 @@ public function testGetHtmlTxnId() $this->transaction->setData('html_txn_id', 'test'); - $this->assertEquals('test', $this->transaction->getHtmlTxnId()); } @@ -63,7 +62,6 @@ public function testGetHtmlTxnIdIsNull() $this->transaction->setData('txn_id', 'test'); - $this->assertEquals('test', $this->transaction->getHtmlTxnId()); $this->assertEquals(null, $this->transaction->getData('html_txn_id')); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index f640e9dfdbb0e..09128777109ea 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -20,6 +20,7 @@ class PaymentTest extends \PHPUnit_Framework_TestCase const TRANSACTION_ID = 'ewr34fM49V0'; private $mockContext; + /** * @var Payment */ @@ -108,11 +109,11 @@ class PaymentTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->mockContext = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->mockContext = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->getMock(); @@ -120,26 +121,32 @@ protected function setUp() ->method('getEventDispatcher') ->will($this->returnValue($this->eventManagerMock)); - $this->helperMock = $this->getMockBuilder('Magento\Payment\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Payment\Helper\Data::class) ->disableOriginalConstructor() ->setMethods(['getMethodInstance']) ->getMock(); - $this->priceCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\PriceCurrency') + $this->priceCurrencyMock = $this->getMockBuilder(\Magento\Directory\Model\PriceCurrency::class) ->disableOriginalConstructor() ->setMethods(['format']) ->getMock(); - $this->currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + $this->currencyMock = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) ->disableOriginalConstructor() ->setMethods(['formatTxt']) ->getMock(); - $transaction = 'Magento\Sales\Model\Order\Payment\Transaction\Repository'; + $transaction = \Magento\Sales\Model\Order\Payment\Transaction\Repository::class; $this->transactionRepositoryMock = $this->getMockBuilder($transaction) ->disableOriginalConstructor() ->setMethods(['get', 'getByTransactionType', 'getByTransactionId']) ->getMock(); - $this->paymentProcessor = $this->getMock('Magento\Sales\Model\Order\Payment\Processor', [], [], '', false); - $this->orderRepository = $this->getMock('Magento\Sales\Model\OrderRepository', ['get'], [], '', false); + $this->paymentProcessor = $this->getMock( + \Magento\Sales\Model\Order\Payment\Processor::class, + [], + [], + '', + false + ); + $this->orderRepository = $this->getMock(\Magento\Sales\Model\OrderRepository::class, ['get'], [], '', false); $this->priceCurrencyMock->expects($this->any()) ->method('format') @@ -149,7 +156,7 @@ function ($value) { } ); - $this->paymentMethodMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + $this->paymentMethodMock = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->disableOriginalConstructor() ->setMethods( [ @@ -173,7 +180,7 @@ function ($value) { ) ->getMock(); - $this->invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $this->invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods( [ @@ -197,7 +204,7 @@ function ($value) { $this->helperMock->method('getMethodInstance') ->will($this->returnValue($this->paymentMethodMock)); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods( [ @@ -224,35 +231,35 @@ function ($value) { ->getMock(); $this->transactionCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory::class, ['create'], [], '', false ); $this->creditmemoFactoryMock = $this->getMock( - 'Magento\Sales\Model\Order\CreditmemoFactory', + \Magento\Sales\Model\Order\CreditmemoFactory::class, [], [], '', false ); $this->transactionManagerMock = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction\Manager', + \Magento\Sales\Model\Order\Payment\Transaction\Manager::class, [], [], '', false ); $this->transactionBuilderMock = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction\Builder', + \Magento\Sales\Model\Order\Payment\Transaction\Builder::class, [], [], '', false ); $this->creditMemoMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo', + \Magento\Sales\Model\Order\Creditmemo::class, [ 'setPaymentRefundDisallowed', 'getItemsCollection', @@ -354,7 +361,7 @@ public function testPlaceActionOrder() ->willReturnSelf(); $this->mockPlaceEvents(); $statusHistory = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderStatusHistoryInterface' + \Magento\Sales\Api\Data\OrderStatusHistoryInterface::class ); $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote); $this->orderMock->expects($this->any()) @@ -414,7 +421,7 @@ public function testPlaceActionAuthorizeInitializeNeeded() ->willReturnSelf(); $this->mockPlaceEvents(); $statusHistory = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderStatusHistoryInterface' + \Magento\Sales\Api\Data\OrderStatusHistoryInterface::class ); $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote); $this->orderMock->expects($this->any()) @@ -450,7 +457,7 @@ public function testPlaceActionAuthorizeFraud() ->with('order_status', null) ->willReturn($newOrderStatus); $statusHistory = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderStatusHistoryInterface' + \Magento\Sales\Api\Data\OrderStatusHistoryInterface::class ); $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote); $this->orderMock->expects($this->any()) @@ -496,7 +503,7 @@ public function testPlaceActionAuthorizeCapture() ->with('order_status', null) ->willReturn($newOrderStatus); $statusHistory = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderStatusHistoryInterface' + \Magento\Sales\Api\Data\OrderStatusHistoryInterface::class ); $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote); $this->orderMock->expects($this->any()) @@ -858,7 +865,6 @@ public function testUpdateOnlineTransactionApproved() $this->mockInvoice($this->transactionId); $this->mockResultTrueMethods($this->transactionId, $baseGrandTotal, $message); - $this->orderMock->expects($this->once()) ->method('getStoreId') ->willReturn($storeId); @@ -1155,7 +1161,7 @@ public function testCanCaptureCreateTransaction() $this->payment->setId($paymentId); $this->payment->setParentTransactionId($parentTransactionId); - $transaction = $this->getMock('Magento\Sales\Model\Order\Payment\Transaction', [], [], '', false); + $transaction = $this->getMock(\Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', false); $transaction->expects($this->once()) ->method('getIsClosed') ->willReturn(false); @@ -1176,7 +1182,7 @@ public function testCanCaptureAuthorizationTransaction() $this->paymentMethodMock->expects($this->once()) ->method('canCapture') ->willReturn(true); - $transaction = $this->getMock('Magento\Sales\Model\Order\Payment\Transaction', [], [], '', false); + $transaction = $this->getMock(\Magento\Sales\Model\Order\Payment\Transaction::class, [], [], '', false); $this->transactionManagerMock->expects($this->once()) ->method('getAuthorizationTransaction') ->with($parentTransactionId, $paymentId) @@ -1290,7 +1296,7 @@ public function testRegisterRefundNotificationTransactionExists() $this->payment->setId($paymentId); $this->orderMock->setId($orderId); $transaction = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\Transaction', + \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction::class, [], [], '', @@ -1345,7 +1351,7 @@ public function testRegisterRefundNotification() $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock); $parentTransaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, ['setOrderId', 'setPaymentId', 'loadByTxnId', 'getId', 'getTxnId', 'setTxnId', 'getTxnType'], [], '', @@ -1400,7 +1406,7 @@ public function testRegisterRefundNotificationWrongAmount() $this->mockInvoice($this->transactionId, 1); $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock); $parentTransaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, ['setOrderId', 'setPaymentId', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], [], '', @@ -1544,7 +1550,7 @@ public function testGetShouldCloseParentTransaction() protected function initPayment() { return (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, [ 'context' => $this->mockContext, 'creditmemoFactory' => $this->creditmemoFactoryMock, @@ -1575,7 +1581,7 @@ protected function assertOrderUpdated( ->willReturnSelf(); $statusHistory = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderStatusHistoryInterface' + \Magento\Sales\Api\Data\OrderStatusHistoryInterface::class ); $this->orderMock->expects($this->any()) ->method('addStatusHistoryComment') @@ -1590,7 +1596,7 @@ protected function assertOrderUpdated( protected function mockGetDefaultStatus($state, $status, $allStatuses = []) { /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfigMock */ - $orderConfigMock = $this->getMockBuilder('Magento\Sales\Model\Order\Config') + $orderConfigMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Config::class) ->disableOriginalConstructor() ->setMethods(['getStateStatuses', 'getStateDefaultStatus']) ->getMock(); @@ -1615,7 +1621,7 @@ protected function mockGetDefaultStatus($state, $status, $allStatuses = []) protected function getTransactionMock($transactionId) { $transaction = $this->getMock( - 'Magento\Sales\Model\Order\Payment\Transaction', + \Magento\Sales\Model\Order\Payment\Transaction::class, [ 'getId', 'setOrderId', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php index 4015a963a89fb..4041fd922f364 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Sales\Test\Unit\Model\Order\Pdf; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractTest extends \PHPUnit_Framework_TestCase { /** @@ -14,22 +17,22 @@ class AbstractTest extends \PHPUnit_Framework_TestCase public function testInsertTotals() { // Setup parameters, that will be passed to the tested model method - $page = $this->getMock('Zend_Pdf_Page', [], [], '', false); + $page = $this->getMock(\Zend_Pdf_Page::class, [], [], '', false); $order = new \StdClass(); - $source = $this->getMock('Magento\Sales\Model\Order\Invoice', [], [], '', false); + $source = $this->getMock(\Magento\Sales\Model\Order\Invoice::class, [], [], '', false); $source->expects($this->any())->method('getOrder')->will($this->returnValue($order)); // Setup most constructor dependencies - $paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); - $addressRenderer = $this->getMock('Magento\Sales\Model\Order\Address\Renderer', [], [], '', false); - $string = $this->getMock('Magento\Framework\Stdlib\StringUtils', [], [], '', false); - $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $translate = $this->getMock('Magento\Framework\Translate\Inline\StateInterface', [], [], '', false); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $pdfItemsFactory = $this->getMock('Magento\Sales\Model\Order\Pdf\ItemsFactory', [], [], '', false); + $paymentData = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); + $addressRenderer = $this->getMock(\Magento\Sales\Model\Order\Address\Renderer::class, [], [], '', false); + $string = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class, [], [], '', false); + $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $translate = $this->getMock(\Magento\Framework\Translate\Inline\StateInterface::class, [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $pdfItemsFactory = $this->getMock(\Magento\Sales\Model\Order\Pdf\ItemsFactory::class, [], [], '', false); $localeMock = $this->getMock( - 'Magento\Framework\Stdlib\DateTime\TimezoneInterface', + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, [], [], '', @@ -39,12 +42,12 @@ public function testInsertTotals() // Setup config file totals $configTotals = ['item1' => [''], 'item2' => ['model' => 'custom_class']]; - $pdfConfig = $this->getMock('Magento\Sales\Model\Order\Pdf\Config', [], [], '', false); + $pdfConfig = $this->getMock(\Magento\Sales\Model\Order\Pdf\Config::class, [], [], '', false); $pdfConfig->expects($this->once())->method('getTotals')->will($this->returnValue($configTotals)); // Setup total factory $total1 = $this->getMock( - 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', + \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal::class, ['setSource', 'setOrder', 'canDisplay', 'getTotalsForDisplay'], [], '', @@ -58,7 +61,7 @@ public function testInsertTotals() ->will($this->returnValue([['label' => 'label1', 'font_size' => 1, 'amount' => '$1']])); $total2 = $this->getMock( - 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', + \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal::class, ['setSource', 'setOrder', 'canDisplay', 'getTotalsForDisplay'], [], '', @@ -72,13 +75,13 @@ public function testInsertTotals() ->will($this->returnValue([['label' => 'label2', 'font_size' => 2, 'amount' => '$2']])); $valueMap = [[null, [], $total1], ['custom_class', [], $total2]]; - $pdfTotalFactory = $this->getMock('Magento\Sales\Model\Order\Pdf\Total\Factory', [], [], '', false); + $pdfTotalFactory = $this->getMock(\Magento\Sales\Model\Order\Pdf\Total\Factory::class, [], [], '', false); $pdfTotalFactory->expects($this->exactly(2))->method('create')->will($this->returnValueMap($valueMap)); // Test model /** @var \Magento\Sales\Model\Order\Pdf\AbstractPdf $model */ $model = $this->getMockForAbstractClass( - 'Magento\Sales\Model\Order\Pdf\AbstractPdf', + \Magento\Sales\Model\Order\Pdf\AbstractPdf::class, [ $paymentData, $string, @@ -99,7 +102,7 @@ public function testInsertTotals() ); $model->expects($this->once())->method('drawLineBlocks')->will($this->returnValue($page)); - $reflectionMethod = new \ReflectionMethod('Magento\Sales\Model\Order\Pdf\AbstractPdf', 'insertTotals'); + $reflectionMethod = new \ReflectionMethod(\Magento\Sales\Model\Order\Pdf\AbstractPdf::class, 'insertTotals'); $reflectionMethod->setAccessible(true); $actual = $reflectionMethod->invoke($model, $page, $source); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php index fb0b267d8d9d0..6774d4ee0d902 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php @@ -34,7 +34,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); + $this->_fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); $this->_fileResolverMock->expects( $this->once() )->method( @@ -51,10 +51,10 @@ protected function setUp() ) ); - $this->_converter = $this->getMock('Magento\Sales\Model\Order\Pdf\Config\Converter', ['convert']); + $this->_converter = $this->getMock(\Magento\Sales\Model\Order\Pdf\Config\Converter::class, ['convert']); $moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['getModuleDir'], [], '', @@ -73,7 +73,7 @@ protected function setUp() ); $this->_schemaLocator = new \Magento\Sales\Model\Order\Pdf\Config\SchemaLocator($moduleReader); - $this->_validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->_validationState = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->_validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(false); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/SchemaLocatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/SchemaLocatorTest.php index d9393e86e14fe..5e852f35aeb1f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/SchemaLocatorTest.php @@ -25,7 +25,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['getModuleDir'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php index 95a9f15ab6f3d..6a091f2e45e7d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php @@ -62,7 +62,13 @@ public function testFileSchemaByExemplar($fixtureXml, array $expectedErrors) */ protected function _testSchema($schema, $fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/ConfigTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/ConfigTest.php index d6f749415d93b..44148e20d5fcc 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/ConfigTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/ConfigTest.php @@ -19,7 +19,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_dataStorage = $this->getMock('Magento\Framework\Config\Data', [], [], '', false); + $this->_dataStorage = $this->getMock(\Magento\Framework\Config\Data::class, [], [], '', false); $this->_model = new \Magento\Sales\Model\Order\Pdf\Config($this->_dataStorage); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/InvoiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/InvoiceTest.php index a6c1dd84bb2d4..c50e832989c23 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/InvoiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/InvoiceTest.php @@ -19,11 +19,11 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_pdfConfigMock = $this->getMockBuilder('Magento\Sales\Model\Order\Pdf\Config') + $this->_pdfConfigMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Pdf\Config::class) ->disableOriginalConstructor() ->getMock(); $directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, [], [], '', @@ -37,13 +37,13 @@ function ($argument) { } ) ); - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false, false); + $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false, false); $filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($directoryMock)); $filesystemMock->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($directoryMock)); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $helper->getObject( - 'Magento\Sales\Model\Order\Pdf\Invoice', + \Magento\Sales\Model\Order\Pdf\Invoice::class, [ 'filesystem' => $filesystemMock, 'pdfConfig' => $this->_pdfConfigMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php index 7dfbefb2d92cc..cfcffcc3b5df7 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php @@ -19,7 +19,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_factory = new \Magento\Sales\Model\Order\Pdf\Total\Factory($this->_objectManager); } @@ -32,7 +32,7 @@ protected function setUp() public function testCreate($class, $arguments, $expectedClassName) { $createdModel = $this->getMock( - 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', + \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal::class, [], [], (string)$class, @@ -61,8 +61,7 @@ public static function createDataProvider() return [ 'default model' => [ null, - ['param1', 'param2'], - 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', + ['param1', 'param2'], \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal::class, ], 'custom model' => ['custom_class', ['param1', 'param2'], 'custom_class'] ]; @@ -75,6 +74,6 @@ public static function createDataProvider() */ public function testCreateException() { - $this->_factory->create('TEST'); + $this->_factory->create(\TEST::class); } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Comment/ValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Comment/ValidatorTest.php index 1b366fad23f1e..e6826eeb6c608 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Comment/ValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Comment/ValidatorTest.php @@ -26,7 +26,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->commentModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Comment', + \Magento\Sales\Model\Order\Shipment\Comment::class, ['hasData', 'getData', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Track/ValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Track/ValidatorTest.php index 48cf835bcc058..530d40945b479 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Track/ValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/Track/ValidatorTest.php @@ -26,7 +26,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->trackModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Track', + \Magento\Sales\Model\Order\Shipment\Track::class, ['hasData', 'getData', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/TrackTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/TrackTest.php index 6e4780bccc244..a9f5b1cd828ed 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/TrackTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Shipment/TrackTest.php @@ -17,7 +17,7 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = [ 'shipmentRepository' => $this->getMock( - 'Magento\Sales\Model\Order\ShipmentRepository', + \Magento\Sales\Model\Order\ShipmentRepository::class, [], [], '', @@ -25,7 +25,7 @@ protected function setUp() ), ]; - $this->_model = $objectManagerHelper->getObject('Magento\Sales\Model\Order\Shipment\Track', $arguments); + $this->_model = $objectManagerHelper->getObject(\Magento\Sales\Model\Order\Shipment\Track::class, $arguments); } public function testAddData() @@ -44,7 +44,7 @@ public function testGetStoreId() $storeObject = new \Magento\Framework\DataObject(['id' => $storeId]); $shipmentMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getStore', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentFactoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentFactoryTest.php index a2c7058a0949b..3760934457a85 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentFactoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentFactoryTest.php @@ -42,7 +42,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->converter = $this->getMock( - 'Magento\Sales\Model\Convert\Order', + \Magento\Sales\Model\Convert\Order::class, ['toShipment', 'itemToShipmentItem'], [], '', @@ -50,7 +50,7 @@ protected function setUp() ); $convertOrderFactory = $this->getMock( - 'Magento\Sales\Model\Convert\OrderFactory', + \Magento\Sales\Model\Convert\OrderFactory::class, ['create'], [], '', @@ -61,7 +61,7 @@ protected function setUp() ->willReturn($this->converter); $this->trackFactory = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\TrackFactory', + \Magento\Sales\Model\Order\Shipment\TrackFactory::class, ['create'], [], '', @@ -69,7 +69,7 @@ protected function setUp() ); $this->subject = $objectManager->getObject( - 'Magento\Sales\Model\Order\ShipmentFactory', + \Magento\Sales\Model\Order\ShipmentFactory::class, [ 'convertOrderFactory' => $convertOrderFactory, 'trackFactory' => $this->trackFactory @@ -85,7 +85,7 @@ protected function setUp() public function testCreate($tracks) { $orderItem = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, ['getId', 'getQtyOrdered'], [], '', @@ -99,7 +99,7 @@ public function testCreate($tracks) ->willReturn(5); $shipmentItem = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Item', + \Magento\Sales\Model\Order\Shipment\Item::class, ['setQty'], [], '', @@ -110,7 +110,7 @@ public function testCreate($tracks) ->with(5); $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['getAllItems'], [], '', @@ -121,7 +121,7 @@ public function testCreate($tracks) ->willReturn([$orderItem]); $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['addItem', 'setTotalQty', 'addTrack'], [], '', @@ -146,7 +146,7 @@ public function testCreate($tracks) if ($tracks) { $shipmentTrack = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Track', + \Magento\Sales\Model\Order\Shipment\Track::class, ['addData'], [], '', @@ -164,7 +164,7 @@ public function testCreate($tracks) ->method('addTrack'); $this->setExpectedException( - 'Magento\Framework\Exception\LocalizedException' + \Magento\Framework\Exception\LocalizedException::class ); } else { $shipmentTrack->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentRepositoryTest.php index 35a7ccb996087..3f213e899a6c9 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentRepositoryTest.php @@ -9,6 +9,7 @@ /** * Unit test for shipment repository class. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ShipmentRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +37,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->metadata = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Metadata', + \Magento\Sales\Model\ResourceModel\Metadata::class, ['getNewInstance', 'getMapper'], [], '', @@ -44,7 +45,7 @@ protected function setUp() ); $this->searchResultFactory = $this->getMock( - 'Magento\Sales\Api\Data\ShipmentSearchResultInterfaceFactory', + \Magento\Sales\Api\Data\ShipmentSearchResultInterfaceFactory::class, ['create'], [], '', @@ -52,7 +53,7 @@ protected function setUp() ); $this->subject = $objectManager->getObject( - 'Magento\Sales\Model\Order\ShipmentRepository', + \Magento\Sales\Model\Order\ShipmentRepository::class, [ 'metadata' => $this->metadata, 'searchResultFactory' => $this->searchResultFactory @@ -68,14 +69,12 @@ protected function setUp() public function testGet($id, $entityId) { if (!$id) { - $this->setExpectedException( - 'Magento\Framework\Exception\InputException' - ); + $this->setExpectedException(\Magento\Framework\Exception\InputException::class); $this->subject->get($id); } else { $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['load', 'getEntityId'], [], '', @@ -94,9 +93,7 @@ public function testGet($id, $entityId) ->willReturn($shipment); if (!$entityId) { - $this->setExpectedException( - 'Magento\Framework\Exception\NoSuchEntityException' - ); + $this->setExpectedException(\Magento\Framework\Exception\NoSuchEntityException::class); $this->subject->get($id); } else { @@ -135,7 +132,7 @@ public function getDataProvider() public function testGetList() { $filter = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, ['getConditionType', 'getField', 'getValue'], [], '', @@ -152,7 +149,7 @@ public function testGetList() ->willReturn('test_value'); $filterGroup = $this->getMock( - 'Magento\Framework\Api\Search\FilterGroup', + \Magento\Framework\Api\Search\FilterGroup::class, ['getFilters'], [], '', @@ -163,7 +160,7 @@ public function testGetList() ->willReturn([$filter]); $searchCriteria = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, ['getFilterGroups'], [], '', @@ -174,7 +171,7 @@ public function testGetList() ->willReturn([$filterGroup]); $collection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Shipment\Collection', + \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class, ['addFieldToFilter'], [], '', @@ -194,7 +191,7 @@ public function testGetList() public function testDelete() { $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getEntityId'], [], '', @@ -205,7 +202,7 @@ public function testDelete() ->willReturn(1); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -231,7 +228,7 @@ public function testDelete() public function testDeleteWithException() { $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getEntityId'], [], '', @@ -241,7 +238,7 @@ public function testDeleteWithException() ->method('getEntityId'); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -263,7 +260,7 @@ public function testDeleteWithException() public function testSave() { $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getEntityId'], [], '', @@ -274,7 +271,7 @@ public function testSave() ->willReturn(1); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -300,7 +297,7 @@ public function testSave() public function testSaveWithException() { $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getEntityId'], [], '', @@ -310,7 +307,7 @@ public function testSaveWithException() ->method('getEntityId'); $mapper = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -332,7 +329,7 @@ public function testSaveWithException() public function testCreate() { $shipment = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentTest.php index 40c216436fa23..d8165a6eaeef5 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentTest.php @@ -16,7 +16,7 @@ protected function setUp() { $helperManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = []; - $this->shipmentModel = $helperManager->getObject('Magento\Sales\Model\Order\Shipment', $arguments); + $this->shipmentModel = $helperManager->getObject(\Magento\Sales\Model\Order\Shipment::class, $arguments); } public function testGetIncrementId() diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Status/History/ValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Status/History/ValidatorTest.php index cdff70d912831..d9eca493b26cd 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Status/History/ValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Status/History/ValidatorTest.php @@ -11,7 +11,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase { public function testValidate() { - $history = $this->getMock('Magento\Sales\Model\Order\Status\History', ['hasData'], [], '', false); + $history = $this->getMock(\Magento\Sales\Model\Order\Status\History::class, ['hasData'], [], '', false); $history->expects($this->any()) ->method('hasData') ->will($this->returnValue(true)); @@ -21,7 +21,7 @@ public function testValidate() public function testValidateNegative() { - $history = $this->getMock('Magento\Sales\Model\Order\Status\History', ['hasData'], [], '', false); + $history = $this->getMock(\Magento\Sales\Model\Order\Status\History::class, ['hasData'], [], '', false); $history->expects($this->any()) ->method('hasData') ->with('parent_id') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php index 6867d82a2c2f2..49b66eee2d9ff 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php @@ -37,18 +37,16 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $this->order = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $this->storeManager = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false ); - - $this->model = $this->objectManager->getObject( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, ['storeManager' => $this->storeManager] ); } @@ -78,7 +76,7 @@ public function testGetStatusLabel() $status = 'pending'; $this->assertNull($this->model->getStatusLabel()); $this->model->setStatus($status); - $config = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); + $config = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); $config->expects($this->once())->method('getStatusLabel')->with($status)->willReturn($status); $this->order->expects($this->once())->method('getConfig')->willReturn($config); $this->model->setOrder($this->order); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/StatusTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/StatusTest.php index 6e427344b1341..9ab886dab3ebe 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/StatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/StatusTest.php @@ -39,21 +39,21 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->resourceMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status', + \Magento\Sales\Model\ResourceModel\Order\Status::class, [], [], '', false ); $this->eventManagerMock = $this->getMock( - 'Magento\Framework\Event\Manager', + \Magento\Framework\Event\Manager::class, [], [], '', false ); $this->contextMock = $this->getMock( - 'Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, [], [], '', @@ -64,7 +64,7 @@ protected function setUp() ->will($this->returnValue($this->eventManagerMock)); $this->model = $objectManager->getObject( - 'Magento\Sales\Model\Order\Status', + \Magento\Sales\Model\Order\Status::class, [ 'context' => $this->contextMock, 'resource' => $this->resourceMock, @@ -152,14 +152,14 @@ public function testUnassignStateStatusUsed() protected function _getPreparedModel($resource = null, $eventDispatcher = null) { if (!$resource) { - $resource = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Status', [], [], '', false); + $resource = $this->getMock(\Magento\Sales\Model\ResourceModel\Order\Status::class, [], [], '', false); } if (!$eventDispatcher) { - $eventDispatcher = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventDispatcher = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); } $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $model = $helper->getObject( - 'Magento\Sales\Model\Order\Status', + \Magento\Sales\Model\Order\Status::class, ['resource' => $resource, 'eventDispatcher' => $eventDispatcher] ); return $model; @@ -174,7 +174,7 @@ public function testAssignState() $status = 'test_status'; $visibleOnFront = true; - $resource = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Status', [], [], '', false); + $resource = $this->getMock(\Magento\Sales\Model\ResourceModel\Order\Status::class, [], [], '', false); $resource->expects($this->once()) ->method('beginTransaction'); $resource->expects($this->once()) @@ -185,10 +185,14 @@ public function testAssignState() ); $resource->expects($this->once())->method('commit'); - $eventDispatcher = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventDispatcher = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $model = $this->_getPreparedModel($resource, $eventDispatcher); $model->setStatus($status); - $this->assertInstanceOf('Magento\Sales\Model\Order\Status', $model->assignState($state), $visibleOnFront); + $this->assertInstanceOf( + \Magento\Sales\Model\Order\Status::class, + $model->assignState($state), + $visibleOnFront + ); } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php index 0e0baec500765..ed44331f577d0 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php @@ -26,32 +26,37 @@ class BaseTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configCacheType = $this->getMock('Magento\Framework\App\Cache\Type\Config', [], [], '', false); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->salesConfig = $this->getMock('Magento\Sales\Model\Config', [], [], '', false); - $this->orderTotalFactory = $this->getMock('Magento\Sales\Model\Order\TotalFactory', [], [], '', false); + $this->configCacheType = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->salesConfig = $this->getMock(\Magento\Sales\Model\Config::class, [], [], '', false); + $this->orderTotalFactory = $this->getMock(\Magento\Sales\Model\Order\TotalFactory::class, [], [], '', false); $objectManager = new ObjectManager($this); - $this->object = $objectManager->getObject('Magento\Sales\Model\Order\Total\Config\Base', [ - 'configCacheType' => $this->configCacheType, - 'logger' => $this->logger, - 'salesConfig' => $this->salesConfig, - 'orderTotalFactory' => $this->orderTotalFactory, - ]); + $this->object = $objectManager->getObject( + \Magento\Sales\Model\Order\Total\Config\Base::class, + [ + 'configCacheType' => $this->configCacheType, + 'logger' => $this->logger, + 'salesConfig' => $this->salesConfig, + 'orderTotalFactory' => $this->orderTotalFactory, + ] + ); } public function testGetTotalModels() { - $total = $this->getMockForAbstractClass('Magento\Sales\Model\Order\Total\AbstractTotal'); + $total = $this->getMockForAbstractClass(\Magento\Sales\Model\Order\Total\AbstractTotal::class); $this->salesConfig->expects($this->once())->method('getGroupTotals')->will( $this->returnValue([ - 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], - 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1723], + 'some_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1903], + 'other_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1723], ]) ); $this->orderTotalFactory->expects($this->any())->method('create') - ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->with(\Magento\Sales\Model\Order\Total\AbstractTotal::class) ->will($this->returnValue($total)); $this->configCacheType->expects($this->once())->method('save') @@ -71,13 +76,15 @@ public function testGetTotalModelsInvalidTotalModel() { $this->salesConfig->expects($this->once())->method('getGroupTotals')->will( $this->returnValue([ - 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], - 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1723], + 'some_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1903], + 'other_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1723], ]) ); $this->orderTotalFactory->expects($this->any())->method('create') - ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->with(\Magento\Sales\Model\Order\Total\AbstractTotal::class) ->will($this->returnValue($this)); $this->object->getTotalModels(); @@ -85,16 +92,18 @@ public function testGetTotalModelsInvalidTotalModel() public function testGetTotalUnserializeCachedCollectorCodes() { - $total = $this->getMockForAbstractClass('Magento\Sales\Model\Order\Total\AbstractTotal'); + $total = $this->getMockForAbstractClass(\Magento\Sales\Model\Order\Total\AbstractTotal::class); $this->salesConfig->expects($this->any())->method('getGroupTotals')->will( $this->returnValue([ - 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], - 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1723], + 'some_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1903], + 'other_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1723], ]) ); $this->orderTotalFactory->expects($this->any())->method('create') - ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->with(\Magento\Sales\Model\Order\Total\AbstractTotal::class) ->will($this->returnValue($total)); $this->configCacheType->expects($this->once())->method('load')->with('sorted_collectors') @@ -109,17 +118,20 @@ public function testGetTotalUnserializeCachedCollectorCodes() public function testGetTotalModelsSortingSubroutine() { - $total = $this->getMockForAbstractClass('Magento\Sales\Model\Order\Total\AbstractTotal'); + $total = $this->getMockForAbstractClass(\Magento\Sales\Model\Order\Total\AbstractTotal::class); $this->salesConfig->expects($this->once())->method('getGroupTotals')->will( $this->returnValue([ - 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], - 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], - 'big_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 3000], + 'some_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1903], + 'other_code' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 1112], + 'big_order' => + ['instance' => \Magento\Sales\Model\Order\Total\AbstractTotal::class, 'sort_order' => 3000], ]) ); $this->orderTotalFactory->expects($this->any())->method('create') - ->with('Magento\Sales\Model\Order\Total\AbstractTotal') + ->with(\Magento\Sales\Model\Order\Total\AbstractTotal::class) ->will($this->returnValue($total)); $this->assertSame( diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderNotifierTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderNotifierTest.php index b9e1aba80ce3c..2a211043361db 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderNotifierTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderNotifierTest.php @@ -44,27 +44,27 @@ class OrderNotifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->historyCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory::class, ['create'], [], '', false ); $this->order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['__wakeUp', 'getEmailSent'], [], '', false ); $this->orderSenderMock = $this->getMock( - 'Magento\Sales\Model\Order\Email\Sender\OrderSender', + \Magento\Sales\Model\Order\Email\Sender\OrderSender::class, ['send'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->notifier = new OrderNotifier( $this->historyCollectionFactory, $this->loggerMock, @@ -78,14 +78,14 @@ protected function setUp() public function testNotifySuccess() { $historyCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\Collection', + \Magento\Sales\Model\ResourceModel\Order\Status\History\Collection::class, ['getUnnotifiedForInstance', 'save', 'setIsCustomerNotified'], [], '', false ); $historyItem = $this->getMock( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, ['setIsCustomerNotified', 'save', '__wakeUp'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php index 90b11f6e7fd2b..0cbb94dc01a82 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php @@ -12,6 +12,8 @@ /** * Class OrderRepositoryTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrderRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -42,14 +44,14 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $className = 'Magento\Sales\Model\ResourceModel\Metadata'; + $className = \Magento\Sales\Model\ResourceModel\Metadata::class; $this->metadata = $this->getMock($className, [], [], '', false); - $className = 'Magento\Sales\Api\Data\OrderSearchResultInterfaceFactory'; + $className = \Magento\Sales\Api\Data\OrderSearchResultInterfaceFactory::class; $this->searchResultFactory = $this->getMock($className, ['create'], [], '', false); $this->model = $this->objectManager->getObject( - '\Magento\Sales\Model\OrderRepository', + \Magento\Sales\Model\OrderRepository::class, [ 'metadata' => $this->metadata, 'searchResultFactory' => $this->searchResultFactory, @@ -64,24 +66,24 @@ protected function setUp() public function testGetList() { $fieldName = 'field'; - $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); - $collectionMock = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Collection', [], [], '', false); + $collectionMock = $this->getMock(\Magento\Sales\Model\ResourceModel\Order\Collection::class, [], [], '', false); - $filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $filterGroupFilterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); - $sortOrderMock = $this->getMock('\Magento\Framework\Api\SortOrder', [], [], '', false); - $itemsMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $filterGroupMock = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); + $filterGroupFilterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $sortOrderMock = $this->getMock(\Magento\Framework\Api\SortOrder::class, [], [], '', false); + $itemsMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $extensionAttributes = $this->getMock( - '\Magento\Sales\Api\Data\OrderExtension', + \Magento\Sales\Api\Data\OrderExtension::class, ['getShippingAssignments'], [], '', false ); $shippingAssignmentBuilder = $this->getMock( - '\Magento\Sales\Model\Order\ShippingAssignmentBuilder', + \Magento\Sales\Model\Order\ShippingAssignmentBuilder::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index 399092745977a..645ae261665cc 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -10,6 +10,8 @@ /** * Test class for \Magento\Sales\Model\Order + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrderTest extends \PHPUnit_Framework_TestCase { @@ -67,45 +69,52 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->paymentCollectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Payment\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Payment\CollectionFactory::class, ['create'], [], '', false ); $this->orderItemCollectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory::class, ['create'], [], '', false ); $this->historyCollectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory::class, ['create'], [], '', false ); $this->salesOrderCollectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class, ['create'], [], '', false ); $this->item = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Item', + \Magento\Sales\Model\ResourceModel\Order\Item::class, ['isDeleted', 'getQtyToInvoice', 'getParentItemId', 'getQuoteItemId', 'getLockedDoInvoice'], [], '', false ); - $this->salesOrderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Collection') - ->disableOriginalConstructor() + $this->salesOrderCollectionMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Collection::class + )->disableOriginalConstructor() ->setMethods(['addFieldToFilter', 'load', 'getFirstItem']) ->getMock(); - $collection = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Item\Collection', [], [], '', false); + $collection = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Item\Collection::class, + [], + [], + '', + false + ); $collection->expects($this->any()) ->method('setOrderFilter') ->willReturnSelf(); @@ -117,7 +126,7 @@ protected function setUp() ->willReturn($collection); $this->priceCurrency = $this->getMockForAbstractClass( - 'Magento\Framework\Pricing\PriceCurrencyInterface', + \Magento\Framework\Pricing\PriceCurrencyInterface::class, [], '', false, @@ -127,14 +136,14 @@ protected function setUp() ); $this->incrementId = '#00000001'; - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); - $context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); + $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); + $context = $this->getMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false); $context->expects($this->any()) ->method('getEventDispatcher') ->willReturn($this->eventManager); $this->order = $helper->getObject( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ 'paymentCollectionFactory' => $this->paymentCollectionFactoryMock, 'orderItemCollectionFactory' => $this->orderItemCollectionFactoryMock, @@ -153,7 +162,7 @@ public function testGetItemById() $fakeOrderItemId = 2; $orderItem = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, [], [], '', @@ -353,7 +362,7 @@ public function testCanNotCreditMemoWithForced() public function testCanEditIfHasInvoices() { - $invoiceCollection = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice\Collection') + $invoiceCollection = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Invoice\Collection::class) ->disableOriginalConstructor() ->setMethods(['count']) ->getMock(); @@ -370,7 +379,7 @@ public function testCanEditIfHasInvoices() public function testCanCancelCanReviewPayment() { - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); @@ -388,7 +397,7 @@ public function testCanCancelCanReviewPayment() public function testCanCancelAllInvoiced() { - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); @@ -399,7 +408,7 @@ public function testCanCancelAllInvoiced() ->method('canFetchTransactionInfo') ->will($this->returnValue(false)); $collectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Item\Collection', + \Magento\Sales\Model\ResourceModel\Order\Item\Collection::class, ['getItems', 'setOrderFilter'], [], '', @@ -430,7 +439,7 @@ public function testCanCancelAllInvoiced() public function testCanCancelState() { - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); @@ -455,7 +464,7 @@ public function testCanCancelState() */ public function testCanCancelActionFlag($cancelActionFlag) { - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); @@ -498,7 +507,7 @@ public function testCanVoidPayment($actionFlags, $orderState) { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var Order $order */ - $order = $helper->getObject('Magento\Sales\Model\Order'); + $order = $helper->getObject(\Magento\Sales\Model\Order::class); foreach ($actionFlags as $action => $flag) { $order->setActionFlag($action, $flag); } @@ -543,7 +552,7 @@ protected function preparePaymentMock($paymentMock) { $iterator = new \ArrayIterator([$paymentMock]); - $collectionMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment\Collection::class) ->disableOriginalConstructor() ->setMethods(['setOrderFilter', 'getIterator']) ->getMock(); @@ -568,7 +577,9 @@ protected function preparePaymentMock($paymentMock) */ protected function _prepareOrderPayment($order, $mockedMethods = []) { - $payment = $this->getMockBuilder('Magento\Sales\Model\Order\Payment')->disableOriginalConstructor()->getMock(); + $payment = $this->getMockBuilder( + \Magento\Sales\Model\Order\Payment::class + )->disableOriginalConstructor()->getMock(); foreach ($mockedMethods as $method => $value) { $payment->expects($this->any())->method($method)->will($this->returnValue($value)); } @@ -621,7 +632,7 @@ protected function _getOrderStatuses() */ protected function prepareItemMock($qtyInvoiced) { - $itemMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Item') + $itemMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Item::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'filterByTypes', 'filterByParent', 'getQtyToInvoice', '__wakeUp']) ->getMock(); @@ -632,7 +643,7 @@ protected function prepareItemMock($qtyInvoiced) $iterator = new \ArrayIterator([$itemMock]); - $itemCollectionMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Item\Collection') + $itemCollectionMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Item\Collection::class) ->disableOriginalConstructor() ->setMethods(['setOrderFilter', 'getIterator', 'getItems']) ->getMock(); @@ -688,7 +699,7 @@ public function testGetEntityType() public function testGetStatusHistories() { $itemMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderStatusHistoryInterface', + \Magento\Sales\Api\Data\OrderStatusHistoryInterface::class, [], '', false, @@ -696,12 +707,12 @@ public function testGetStatusHistories() true, ['setOrder'] ); - $dbMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $dbMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->setMethods(['setOrder']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $collectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\History\Collection', + \Magento\Sales\Model\ResourceModel\Order\Status\History\Collection::class, [ 'setOrderFilter', 'setOrder', diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/AttributeTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/AttributeTest.php index bccaa55701839..ff2e492df8d09 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/AttributeTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/AttributeTest.php @@ -38,14 +38,14 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -54,7 +54,7 @@ protected function setUp() [] ); $this->modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', + \Magento\Sales\Model\AbstractModel::class, [], '', false, @@ -63,7 +63,7 @@ protected function setUp() ['__wakeup', 'getId', 'getEventPrefix', 'getEventObject'] ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['describeTable', 'insert', 'lastInsertId', 'beginTransaction', 'rollback', 'commit'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/GridPoolTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/GridPoolTest.php index b88ea9fd931c2..75f5e0319bd3c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/GridPoolTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/GridPoolTest.php @@ -43,19 +43,19 @@ class GridPoolTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->orderGridMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Grid', [], [], '', false + $this->orderGridMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Grid::class, [], [], '', false ); - $this->invoiceGridMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Grid', [], [], '', false + $this->invoiceGridMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Grid::class, [], [], '', false ); - $this->shipmentGridMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Grid', [], [], '', false + $this->shipmentGridMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Grid::class, [], [], '', false ); - $this->creditmemoGridMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Grid', [], [], '', false + $this->creditmemoGridMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Grid::class, [], [], '', false ); - $this->statementMock = $this->getMockForAbstractClass('Zend_Db_Statement_Interface'); + $this->statementMock = $this->getMockForAbstractClass(\Zend_Db_Statement_Interface::class); $grids = [ 'order_grid' => $this->orderGridMock, 'invoice_grid' => $this->invoiceGridMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/HelperTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/HelperTest.php index 054176bcbdbb9..a27a6f727f501 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/HelperTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/HelperTest.php @@ -39,7 +39,7 @@ protected function setUp() { $objectManager = new ObjectManagerHelper($this); $this->appResource = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -47,7 +47,7 @@ protected function setUp() ); $this->resourceHelper = $this->getMock( - 'Magento\Reports\Model\ResourceModel\Helper', + \Magento\Reports\Model\ResourceModel\Helper::class, [], [], '', @@ -55,7 +55,7 @@ protected function setUp() ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', @@ -63,7 +63,7 @@ protected function setUp() ); $this->helper = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Helper', + \Magento\Sales\Model\ResourceModel\Helper::class, [ 'resource' => $this->appResource, 'reportsResourceHelper' => $this->resourceHelper diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php index 5840f6f4a9687..f2a2184f73144 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php @@ -48,42 +48,42 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['__wakeup', 'getParentId', 'hasDataChanges', 'beforeSave', 'afterSave', 'validateBeforeSave', 'getOrder'], [], '', false ); $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['__wakeup', 'getId'], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->validatorMock = $this->getMock( - 'Magento\Sales\Model\Order\Address\Validator', + \Magento\Sales\Model\Order\Address\Validator::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -101,7 +101,7 @@ protected function setUp() $this->connectionMock->expects($this->any()) ->method('lastInsertId'); $this->addressResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Address', + \Magento\Sales\Model\ResourceModel\Order\Address::class, [ 'resource' => $this->appResourceMock, 'validator' => $this->validatorMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/CommentTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/CommentTest.php index 6d5081b194b9e..05a940be5fa3a 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/CommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/CommentTest.php @@ -34,6 +34,7 @@ class CommentTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Creditmemo\Comment\Validator|\PHPUnit_Framework_MockObject_MockObject */ protected $validatorMock; + /** * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot|\PHPUnit_Framework_MockObject_MockObject */ @@ -45,35 +46,35 @@ class CommentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->commentModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo\Comment', + \Magento\Sales\Model\Order\Creditmemo\Comment::class, [], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->validatorMock = $this->getMock( - 'Magento\Sales\Model\Order\Creditmemo\Comment\Validator', + \Magento\Sales\Model\Order\Creditmemo\Comment\Validator::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -94,20 +95,20 @@ protected function setUp() $this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true)); $relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->commentResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment', + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment::class, [ 'context' => $contextMock, 'validator' => $this->validatorMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/Relation/RefundTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/Relation/RefundTest.php index 459ff836584ee..a83053d343336 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/Relation/RefundTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/Relation/RefundTest.php @@ -35,21 +35,21 @@ class RefundTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface') + $this->orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->invoiceRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') + $this->invoiceRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->priceCurrencyMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface') + $this->priceCurrencyMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->refundResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Creditmemo\Relation\Refund', + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Relation\Refund::class, [ 'orderRepository' => $this->orderRepositoryMock, 'invoiceRepository' => $this->invoiceRepositoryMock, @@ -60,18 +60,18 @@ protected function setUp() public function testProcessRelation() { - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->getMock(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); $orderMock->expects($this->once()) ->method('getPayment') ->willReturn($paymentMock); - $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $creditmemoMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/RelationTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/RelationTest.php index f833fb765545e..324a8a3c1083b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/RelationTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Creditmemo/RelationTest.php @@ -43,7 +43,7 @@ class RelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->itemResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item') + $this->itemResourceMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item::class) ->disableOriginalConstructor() ->setMethods( [ @@ -51,7 +51,9 @@ protected function setUp() ] ) ->getMock(); - $this->commentResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment') + $this->commentResourceMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment::class + ) ->disableOriginalConstructor() ->setMethods( [ @@ -59,7 +61,7 @@ protected function setUp() ] ) ->getMock(); - $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->creditmemoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->setMethods( [ @@ -69,7 +71,7 @@ protected function setUp() ] ) ->getMock(); - $this->itemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods( [ @@ -77,7 +79,7 @@ protected function setUp() ] ) ->getMock(); - $this->commentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + $this->commentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Creditmemo::class) ->disableOriginalConstructor() ->getMock(); $this->relationProcessor = new \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Relation( diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/AddressTest.php index f7a23722c4445..c257ad3b8893a 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/AddressTest.php @@ -38,14 +38,14 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->attributeMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Attribute', + \Magento\Sales\Model\ResourceModel\Attribute::class, [], [], '', false ); $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ '__wakeup', 'getAddresses', @@ -66,14 +66,14 @@ protected function setUp() false ); $this->addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [], [], '', false ); $this->addressCollectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Address\Collection', + \Magento\Sales\Model\ResourceModel\Order\Address\Collection::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php index cce9ba279d008..1437cf1ad9af1 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php @@ -25,7 +25,7 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderMock = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [ '__wakeup', 'getId', @@ -52,14 +52,14 @@ protected function setUp() ->method('getConfig') ->willReturnSelf(); $this->addressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, [], [], '', false ); $this->addressCollectionMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Address\Collection', + \Magento\Sales\Model\ResourceModel\Order\Address\Collection::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/CommentTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/CommentTest.php index 120d4a6b821d2..e94ba626bd5e0 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/CommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/CommentTest.php @@ -34,6 +34,7 @@ class CommentTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Invoice\Comment\Validator|\PHPUnit_Framework_MockObject_MockObject */ protected $validatorMock; + /** * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot|\PHPUnit_Framework_MockObject_MockObject */ @@ -45,35 +46,35 @@ class CommentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->commentModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice\Comment', + \Magento\Sales\Model\Order\Invoice\Comment::class, [], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->validatorMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice\Comment\Validator', + \Magento\Sales\Model\Order\Invoice\Comment\Validator::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -93,20 +94,20 @@ protected function setUp() $this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true)); $relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->commentResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Invoice\Comment', + \Magento\Sales\Model\ResourceModel\Order\Invoice\Comment::class, [ 'context' => $contextMock, 'validator' => $this->validatorMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/RelationTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/RelationTest.php index 32e2c48494c33..e2e8a01763644 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/RelationTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Invoice/RelationTest.php @@ -48,7 +48,9 @@ class RelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->invoiceItemResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice\Item') + $this->invoiceItemResourceMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Invoice\Item::class + ) ->disableOriginalConstructor() ->setMethods( [ @@ -57,7 +59,7 @@ protected function setUp() ) ->getMock(); $this->invoiceCommentResourceMock = - $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Invoice\Comment') + $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Invoice\Comment::class) ->disableOriginalConstructor() ->setMethods( [ @@ -65,7 +67,7 @@ protected function setUp() ] ) ->getMock(); - $this->invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $this->invoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() ->setMethods( [ @@ -75,15 +77,15 @@ protected function setUp() ] ) ->getMock(); - $this->invoiceItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice\Item') + $this->invoiceItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice\Item::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->invoiceCommentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice\Comment') + $this->invoiceCommentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice\Comment::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $this->orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/RelationTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/RelationTest.php index 7ece741c488f4..5592beaee55da 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/RelationTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/RelationTest.php @@ -63,40 +63,27 @@ class RelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->addressHandlerMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Handler\Address') + $this->addressHandlerMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Handler\Address::class + ) ->disableOriginalConstructor() - ->setMethods( - [ - 'removeEmptyAddresses', - 'process' - ] - ) + ->setMethods(['removeEmptyAddresses', 'process']) ->getMock(); - $this->orderItemRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderItemRepositoryInterface') + $this->orderItemRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderItemRepositoryInterface::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'save' - ] - ) + ->setMethods(['save']) ->getMockForAbstractClass(); - $this->orderPaymentResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment') + $this->orderPaymentResourceMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'save' - ] - ) + ->setMethods(['save']) ->getMock(); - $this->statusHistoryResource = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Status\History') + $this->statusHistoryResource = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Status\History::class + ) ->disableOriginalConstructor() - ->setMethods( - [ - 'save' - ] - ) + ->setMethods(['save']) ->getMock(); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods( [ @@ -108,50 +95,25 @@ protected function setUp() ] ) ->getMock(); - $this->orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $this->orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'setOrderId', - 'setOrder' - ] - ) + ->setMethods(['setOrderId', 'setOrder']) ->getMock(); - $this->orderPaymentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $this->orderPaymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'setParentId', - 'setOrder' - ] - ) + ->setMethods(['setParentId', 'setOrder']) ->getMock(); - $this->orderStatusHistoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $this->orderStatusHistoryMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'setParentId', - 'setOrder' - ] - ) + ->setMethods(['setParentId', 'setOrder']) ->getMock(); - $this->orderStatusHistoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\Status\History') + $this->orderStatusHistoryMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Status\History::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'setParentId', - 'setOrder' - ] - ) + ->setMethods(['setParentId', 'setOrder']) ->getMock(); - $this->orderInvoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + $this->orderInvoiceMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'setOrder', - 'save' - ] - ) + ->setMethods(['setOrder', 'save']) ->getMock(); $this->relationProcessor = new \Magento\Sales\Model\ResourceModel\Order\Relation( $this->addressHandlerMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/CommentTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/CommentTest.php index 650592762533b..d7dc8dc8b812f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/CommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/CommentTest.php @@ -34,6 +34,7 @@ class CommentTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Shipment\Comment\Validator|\PHPUnit_Framework_MockObject_MockObject */ protected $validatorMock; + /** * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot|\PHPUnit_Framework_MockObject_MockObject */ @@ -45,35 +46,35 @@ class CommentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->commentModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Comment', + \Magento\Sales\Model\Order\Shipment\Comment::class, [], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->validatorMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Comment\Validator', + \Magento\Sales\Model\Order\Shipment\Comment\Validator::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -93,20 +94,20 @@ protected function setUp() $this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true)); $relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->commentResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Shipment\Comment', + \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment::class, [ 'context' => $contextMock, 'validator' => $this->validatorMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/RelationTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/RelationTest.php index 98d83011853bd..a8193181f3de2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/RelationTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/RelationTest.php @@ -53,7 +53,7 @@ class RelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->itemResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Shipment\Item') + $this->itemResourceMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Shipment\Item::class) ->disableOriginalConstructor() ->setMethods( [ @@ -61,7 +61,9 @@ protected function setUp() ] ) ->getMock(); - $this->commentResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Shipment\Comment') + $this->commentResourceMock = $this->getMockBuilder( + \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment::class + ) ->disableOriginalConstructor() ->setMethods( [ @@ -69,7 +71,7 @@ protected function setUp() ] ) ->getMock(); - $this->trackResourceMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Shipment\Track') + $this->trackResourceMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Shipment\Track::class) ->disableOriginalConstructor() ->setMethods( [ @@ -77,7 +79,7 @@ protected function setUp() ] ) ->getMock(); - $this->shipmentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment') + $this->shipmentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Shipment::class) ->disableOriginalConstructor() ->setMethods( [ @@ -88,7 +90,7 @@ protected function setUp() ] ) ->getMock(); - $this->itemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) ->disableOriginalConstructor() ->setMethods( [ @@ -96,10 +98,10 @@ protected function setUp() ] ) ->getMock(); - $this->trackMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment\Track') + $this->trackMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Shipment\Track::class) ->disableOriginalConstructor() ->getMock(); - $this->commentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment') + $this->commentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Shipment::class) ->disableOriginalConstructor() ->getMock(); $this->relationProcessor = new \Magento\Sales\Model\ResourceModel\Order\Shipment\Relation( diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/TrackTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/TrackTest.php index bfe51feefdeb9..1dece779b5264 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/TrackTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/TrackTest.php @@ -34,6 +34,7 @@ class TrackTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Shipment\Track\Validator|\PHPUnit_Framework_MockObject_MockObject */ protected $validatorMock; + /** * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot|\PHPUnit_Framework_MockObject_MockObject */ @@ -45,35 +46,35 @@ class TrackTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->trackModelMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Track', + \Magento\Sales\Model\Order\Shipment\Track::class, [], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->validatorMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment\Track\Validator', + \Magento\Sales\Model\Order\Shipment\Track\Validator::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -93,20 +94,20 @@ protected function setUp() $this->trackModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true)); $relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->trackResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Shipment\Track', + \Magento\Sales\Model\ResourceModel\Order\Shipment\Track::class, [ 'context' => $contextMock, 'validator' => $this->validatorMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/History/CollectionTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/History/CollectionTest.php index 9b47ca23f29c1..a5d02ffeb5782 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/History/CollectionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/History/CollectionTest.php @@ -6,6 +6,9 @@ namespace Magento\Sales\Test\Unit\Model\ResourceModel\Order\Status\History; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CollectionTest extends \PHPUnit_Framework_TestCase { /** @@ -55,18 +58,18 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); - $this->selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $this->historyItemMock = $this->getMock( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, ['__wakeup', 'addData'], [], '', false ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\ResourceModel\EntityAbstract', + \Magento\Sales\Model\ResourceModel\EntityAbstract::class, [], '', false, @@ -75,16 +78,22 @@ protected function setUp() ['getConnection', 'getMainTable', 'getTable', '__wakeup'] ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', false ); $this->fetchStrategyMock = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\Db\FetchStrategyInterface' + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class + ); + $this->entityFactoryMock = $this->getMock( + \Magento\Framework\Data\Collection\EntityFactory::class, + [], + [], + '', + false ); - $this->entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false); $this->resourceMock->expects($this->any())->method('getConnection')->will( $this->returnValue($this->connectionMock) @@ -110,7 +119,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->historyItemMock)); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); $this->collection = new \Magento\Sales\Model\ResourceModel\Order\Status\History\Collection( $this->entityFactoryMock, $logger, @@ -127,7 +136,15 @@ public function testGetUnnotifiedForInstance() $orderId = 100000512; $entityType = 'order'; - $order = $this->getMock('Magento\Sales\Model\Order', ['__wakeup', 'getEntityType', 'getId'], [], '', false); + $order = $this->getMock( + \Magento\Sales\Model\Order::class, + ['__wakeup', + 'getEntityType', + 'getId'], + [], + '', + false + ); $order->expects($this->once()) ->method('getEntityType') ->will($this->returnValue($entityType)); diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/HistoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/HistoryTest.php index 0b7ee7118d727..ef231c823a46d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/HistoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Status/HistoryTest.php @@ -44,28 +44,28 @@ class HistoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->validatorMock = $this->getMock( - 'Magento\Sales\Model\Order\Status\History\Validator', + \Magento\Sales\Model\Order\Status\History\Validator::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', @@ -84,19 +84,19 @@ protected function setUp() ->method('lastInsertId'); $relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock); $this->historyResource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Status\History', + \Magento\Sales\Model\ResourceModel\Order\Status\History::class, [ 'context' => $contextMock, 'validator' => $this->validatorMock, @@ -111,7 +111,7 @@ protected function setUp() public function testSave() { $historyMock = $this->getMock( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, [], [], '', @@ -135,7 +135,7 @@ public function testSave() public function testValidate() { $historyMock = $this->getMock( - 'Magento\Sales\Model\Order\Status\History', + \Magento\Sales\Model\Order\Status\History::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/StatusTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/StatusTest.php index e073d7064f71b..af19010b19fe3 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/StatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/StatusTest.php @@ -42,12 +42,12 @@ class StatusTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $this->selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $this->selectMock->expects($this->any())->method('where'); - $this->connectionMock = $this->getMock( - '\Magento\Framework\DB\Adapter\Pdo\Mysql', + $this->connectionMock = $this->getMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['update', 'insertOnDuplicate'], [], '', @@ -55,8 +55,8 @@ protected function setUp() ); $this->connectionMock->expects($this->any())->method('select')->will($this->returnValue($this->selectMock)); - $this->resourceMock = $this->getMock( - '\Magento\Framework\App\ResourceConnection', + $this->resourceMock = $this->getMock( + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -73,9 +73,10 @@ protected function setUp() $this->returnValue($this->connectionMock) ); - $this->configMock = $this->getMock('\Magento\Eav\Model\Config', ['getConnectionName'], [], '', false); + $this->configMock = $this->getMock(\Magento\Eav\Model\Config::class, ['getConnectionName'], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Sales\Model\ResourceModel\Order\Status', + $this->model = $objectManager->getObject( + \Magento\Sales\Model\ResourceModel\Order\Status::class, ['resource' => $this->resourceMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Tax/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Tax/ItemTest.php index 9695bcb423cf0..e88e4cbbe62d9 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Tax/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Tax/ItemTest.php @@ -31,14 +31,14 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -50,7 +50,7 @@ protected function setUp() $this->appResourceMock->expects($this->any())->method('getTableName')->willReturnArgument(0); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->taxItem = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order\Tax\Item', + \Magento\Sales\Model\ResourceModel\Order\Tax\Item::class, [ 'resource' => $this->appResourceMock ] @@ -72,7 +72,7 @@ public function testGetTaxItemsByOrderId() ] ]; $select = $this->getMock( - 'Magento\Framework\DB\Select', + \Magento\Framework\DB\Select::class, [], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/OrderTest.php index bd8b02be0d6ce..17423c4c2394d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/OrderTest.php @@ -88,32 +88,32 @@ class OrderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->orderMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $this->orderItemMock = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, ['getQuoteParentItemId', 'setTotalItemCount', 'getChildrenItems'], [], '', false ); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeGroupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['getName', 'getDefaultStoreId'], [], '', false ); $this->websiteMock = $this->getMock( - 'Magento\Store\Model\Website', + \Magento\Store\Model\Website::class, ['getName'], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ 'describeTable', 'insert', @@ -129,35 +129,35 @@ protected function setUp() false ); $this->salesSequenceManagerMock = $this->getMock( - 'Magento\SalesSequence\Model\Manager', + \Magento\SalesSequence\Model\Manager::class, [], [], '', false ); - $this->salesSequenceMock = $this->getMock('Magento\SalesSequence\Model\Sequence', [], [], '', false); + $this->salesSequenceMock = $this->getMock(\Magento\SalesSequence\Model\Sequence::class, [], [], '', false); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', false ); $this->relationCompositeMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class, [], [], '', false ); $this->objectRelationProcessorMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $contextMock->expects($this->once()) ->method('getObjectRelationProcessor') @@ -165,7 +165,7 @@ protected function setUp() $objectManager = new ObjectManagerHelper($this); $this->resource = $objectManager->getObject( - 'Magento\Sales\Model\ResourceModel\Order', + \Magento\Sales\Model\ResourceModel\Order::class, [ 'context' => $contextMock, 'sequenceManager' => $this->salesSequenceManagerMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Rss/NewOrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Rss/NewOrderTest.php index f208cf4385f79..42fe9a1402e33 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Rss/NewOrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Rss/NewOrderTest.php @@ -10,6 +10,7 @@ /** * Class NewOrderTest * @package Magento\Sales\Model\Rss + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class NewOrderTest extends \PHPUnit_Framework_TestCase { @@ -82,19 +83,19 @@ class NewOrderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); - $this->urlBuiler = $this->getMock('Magento\Framework\UrlInterface'); - $this->timezoneInterface = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); - $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); - $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->layout = $this->getMock('Magento\Framework\View\LayoutInterface'); - $this->rssUrlBuilderInterface = $this->getMockBuilder('Magento\Framework\App\Rss\UrlBuilderInterface') + $this->orderFactory = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); + $this->urlBuiler = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->timezoneInterface = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime::class); + $this->scopeConfigInterface = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $this->rssUrlBuilderInterface = $this->getMockBuilder(\Magento\Framework\App\Rss\UrlBuilderInterface::class) ->setMethods(['getUrl']) ->disableOriginalConstructor()->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( - 'Magento\Sales\Model\Rss\NewOrder', + \Magento\Sales\Model\Rss\NewOrder::class, [ 'orderFactory' => $this->orderFactory, 'urlBuilder' => $this->urlBuiler, @@ -124,14 +125,14 @@ public function testGetData() $this->timezoneInterface->expects($this->once())->method('formatDate') ->will($this->returnValue('2014-09-10 17:39:50')); - $order = $this->getMockBuilder('Magento\Sales\Model\Order') + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods(['__sleep', '__wakeup', 'getResourceCollection', 'getIncrementId', 'getId', 'getCreatedAt']) ->disableOriginalConstructor()->getMock(); $order->expects($this->once())->method('getId')->will($this->returnValue(1)); $order->expects($this->once())->method('getIncrementId')->will($this->returnValue('100000001')); $order->expects($this->once())->method('getCreatedAt')->will($this->returnValue(time())); - $collection = $this->getMockBuilder('\Magento\Sales\Model\ResourceModel\Order\Collection') + $collection = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Collection::class) ->setMethods(['addAttributeToFilter', 'addAttributeToSort', 'getIterator']) ->disableOriginalConstructor()->getMock(); $collection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf()); @@ -144,7 +145,13 @@ public function testGetData() $this->eventManager->expects($this->once())->method('dispatch')->will($this->returnSelf()); - $block = $this->getMock('Magento\Sales\Block\Adminhtml\Order\Details', ['setOrder', 'toHtml'], [], '', false); + $block = $this->getMock( + \Magento\Sales\Block\Adminhtml\Order\Details::class, + ['setOrder', 'toHtml'], + [], + '', + false + ); $block->expects($this->once())->method('setOrder')->with($order)->will($this->returnSelf()); $block->expects($this->once())->method('toHtml')->will($this->returnValue('Order Description')); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Rss/OrderStatusTest.php b/app/code/Magento/Sales/Test/Unit/Model/Rss/OrderStatusTest.php index 8c07b2f592a3d..2272f97777bd4 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Rss/OrderStatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Rss/OrderStatusTest.php @@ -10,6 +10,7 @@ /** * Class OrderStatusTest * @package Magento\Sales\Model\Rss + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrderStatusTest extends \PHPUnit_Framework_TestCase { @@ -62,6 +63,7 @@ class OrderStatusTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ protected $order; + /** * @var array */ @@ -86,19 +88,19 @@ class OrderStatusTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->urlInterface = $this->getMock('Magento\Framework\UrlInterface'); - $this->requestInterface = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->urlInterface = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->requestInterface = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->orderStatusFactory = - $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Rss\OrderStatusFactory') + $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Rss\OrderStatusFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->timezoneInterface = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); - $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); - $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->timezoneInterface = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->orderFactory = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); + $this->scopeConfigInterface = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->order = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods([ '__sleep', '__wakeup', @@ -120,7 +122,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( - 'Magento\Sales\Model\Rss\OrderStatus', + \Magento\Sales\Model\Rss\OrderStatus::class, [ 'objectManager' => $this->objectManager, 'urlBuilder' => $this->urlInterface, @@ -140,7 +142,7 @@ public function testGetRssData() $this->requestInterface->expects($this->any())->method('getParam')->with('data')->willReturn($requestData); - $resource = $this->getMockBuilder('\Magento\Sales\Model\ResourceModel\Order\Rss\OrderStatus') + $resource = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Rss\OrderStatus::class) ->setMethods(['getAllCommentCollection']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php index a9fe8e4a1ed35..e1f4b9dc7d378 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php @@ -50,33 +50,33 @@ protected function setUp() $objectManager = new ObjectManagerHelper($this); $this->creditmemoRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\CreditmemoRepositoryInterface', + \Magento\Sales\Api\CreditmemoRepositoryInterface::class, ['get'], '', false ); $this->creditmemoCommentRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\CreditmemoCommentRepositoryInterface', + \Magento\Sales\Api\CreditmemoCommentRepositoryInterface::class, [], '', false ); $this->searchCriteriaBuilderMock = $this->getMock( - 'Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, ['create', 'addFilters'], [], '', false ); $this->filterBuilderMock = $this->getMock( - 'Magento\Framework\Api\FilterBuilder', + \Magento\Framework\Api\FilterBuilder::class, ['setField', 'setValue', 'setConditionType', 'create'], [], '', false ); $this->creditmemoNotifierMock = $this->getMock( - 'Magento\Sales\Model\Order\CreditmemoNotifier', + \Magento\Sales\Model\Order\CreditmemoNotifier::class, [], [], '', @@ -84,7 +84,7 @@ protected function setUp() ); $this->creditmemoService = $objectManager->getObject( - 'Magento\Sales\Model\Service\CreditmemoService', + \Magento\Sales\Model\Service\CreditmemoService::class, [ 'creditmemoRepository' => $this->creditmemoRepositoryMock, 'creditmemoCommentRepository' => $this->creditmemoCommentRepositoryMock, @@ -114,14 +114,14 @@ public function testGetCommentsList() $returnValue = 'return-value'; $filterMock = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, [], [], '', false ); $searchCriteriaMock = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, [], [], '', @@ -166,7 +166,7 @@ public function testNotify() $returnValue = 'return-value'; $modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', + \Magento\Sales\Model\AbstractModel::class, [], '', false diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php index 418c4715afd69..c28f0b562cb38 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php @@ -60,33 +60,33 @@ protected function setUp() $objectManager = new ObjectManagerHelper($this); $this->repositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\InvoiceRepositoryInterface', + \Magento\Sales\Api\InvoiceRepositoryInterface::class, ['get'], '', false ); $this->commentRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\InvoiceCommentRepositoryInterface', + \Magento\Sales\Api\InvoiceCommentRepositoryInterface::class, ['getList'], '', false ); $this->searchCriteriaBuilderMock = $this->getMock( - 'Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, ['create', 'addFilters'], [], '', false ); $this->filterBuilderMock = $this->getMock( - 'Magento\Framework\Api\FilterBuilder', + \Magento\Framework\Api\FilterBuilder::class, ['setField', 'setValue', 'setConditionType', 'create'], [], '', false ); $this->invoiceNotifierMock = $this->getMock( - 'Magento\Sales\Model\Order\InvoiceNotifier', + \Magento\Sales\Model\Order\InvoiceNotifier::class, ['notify'], [], '', @@ -94,7 +94,7 @@ protected function setUp() ); $this->invoiceService = $objectManager->getObject( - 'Magento\Sales\Model\Service\InvoiceService', + \Magento\Sales\Model\Service\InvoiceService::class, [ 'repository' => $this->repositoryMock, 'commentRepository' => $this->commentRepositoryMock, @@ -114,7 +114,7 @@ public function testSetCapture() $returnValue = true; $invoiceMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, ['capture'], [], '', @@ -141,14 +141,14 @@ public function testGetCommentsList() $returnValue = 'return-value'; $filterMock = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, [], [], '', false ); $searchCriteriaMock = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, [], [], '', @@ -193,7 +193,7 @@ public function testNotify() $returnValue = 'return-value'; $modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', + \Magento\Sales\Model\AbstractModel::class, [], '', false @@ -220,7 +220,7 @@ public function testSetVoid() $returnValue = true; $invoiceMock = $this->getMock( - 'Magento\Sales\Model\Order\Invoice', + \Magento\Sales\Model\Order\Invoice::class, ['void'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php index bb7df9026b8b8..442f01d4214fa 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php @@ -7,6 +7,8 @@ /** * Class OrderUnHoldTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrderServiceTest extends \PHPUnit_Framework_TestCase { @@ -78,62 +80,62 @@ class OrderServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderRepositoryMock = $this->getMockBuilder( - 'Magento\Sales\Api\OrderRepositoryInterface' + \Magento\Sales\Api\OrderRepositoryInterface::class ) ->disableOriginalConstructor() ->getMock(); $this->orderStatusHistoryRepositoryMock = $this->getMockBuilder( - 'Magento\Sales\Api\OrderStatusHistoryRepositoryInterface' + \Magento\Sales\Api\OrderStatusHistoryRepositoryInterface::class ) ->disableOriginalConstructor() ->getMock(); $this->searchCriteriaBuilderMock = $this->getMockBuilder( - 'Magento\Framework\Api\SearchCriteriaBuilder' + \Magento\Framework\Api\SearchCriteriaBuilder::class ) ->disableOriginalConstructor() ->getMock(); $this->searchCriteriaMock = $this->getMockBuilder( - 'Magento\Framework\Api\SearchCriteria' + \Magento\Framework\Api\SearchCriteria::class ) ->disableOriginalConstructor() ->getMock(); $this->filterBuilderMock = $this->getMockBuilder( - 'Magento\Framework\Api\FilterBuilder' + \Magento\Framework\Api\FilterBuilder::class ) ->disableOriginalConstructor() ->getMock(); $this->filterMock = $this->getMockBuilder( - 'Magento\Framework\Api\Filter' + \Magento\Framework\Api\Filter::class ) ->disableOriginalConstructor() ->getMock(); $this->orderNotifierMock = $this->getMockBuilder( - 'Magento\Sales\Model\OrderNotifier' + \Magento\Sales\Model\OrderNotifier::class ) ->disableOriginalConstructor() ->getMock(); $this->orderMock = $this->getMockBuilder( - 'Magento\Sales\Model\Order' + \Magento\Sales\Model\Order::class ) ->disableOriginalConstructor() ->getMock(); $this->orderStatusHistoryMock = $this->getMockBuilder( - 'Magento\Sales\Model\Order\Status\History' + \Magento\Sales\Model\Order\Status\History::class ) ->disableOriginalConstructor() ->getMock(); $this->orderSearchResultMock = $this->getMockBuilder( - 'Magento\Sales\Api\Data\OrderStatusHistorySearchResultInterface' + \Magento\Sales\Api\Data\OrderStatusHistorySearchResultInterface::class ) ->disableOriginalConstructor() ->getMock(); $this->eventManagerMock = $this->getMockBuilder( - 'Magento\Framework\Event\ManagerInterface' + \Magento\Framework\Event\ManagerInterface::class ) ->disableOriginalConstructor() ->getMock(); $this->orderCommentSender = $this->getMockBuilder( - 'Magento\Sales\Model\Order\Email\Sender\OrderCommentSender' + \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php index f67d4ec6b8be3..e8e56fe96771d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php @@ -60,33 +60,33 @@ protected function setUp() $objectManager = new ObjectManagerHelper($this); $this->commentRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\ShipmentCommentRepositoryInterface', + \Magento\Sales\Api\ShipmentCommentRepositoryInterface::class, ['getList'], '', false ); $this->searchCriteriaBuilderMock = $this->getMock( - 'Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, ['create', 'addFilters'], [], '', false ); $this->filterBuilderMock = $this->getMock( - 'Magento\Framework\Api\FilterBuilder', + \Magento\Framework\Api\FilterBuilder::class, ['setField', 'setValue', 'setConditionType', 'create'], [], '', false ); $this->repositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\ShipmentRepositoryInterface', + \Magento\Sales\Api\ShipmentRepositoryInterface::class, ['get'], '', false ); $this->notifierMock = $this->getMock( - 'Magento\Shipping\Model\ShipmentNotifier', + \Magento\Shipping\Model\ShipmentNotifier::class, ['notify'], [], '', @@ -94,7 +94,7 @@ protected function setUp() ); $this->shipmentService = $objectManager->getObject( - 'Magento\Sales\Model\Service\ShipmentService', + \Magento\Sales\Model\Service\ShipmentService::class, [ 'commentRepository' => $this->commentRepositoryMock, 'criteriaBuilder' => $this->searchCriteriaBuilderMock, @@ -114,7 +114,7 @@ public function testGetLabel() $returnValue = 'return-value'; $shipmentMock = $this->getMock( - 'Magento\Sales\Model\Order\Shipment', + \Magento\Sales\Model\Order\Shipment::class, ['getShippingLabel'], [], '', @@ -141,14 +141,14 @@ public function testGetCommentsList() $returnValue = 'return-value'; $filterMock = $this->getMock( - 'Magento\Framework\Api\Filter', + \Magento\Framework\Api\Filter::class, [], [], '', false ); $searchCriteriaMock = $this->getMock( - 'Magento\Framework\Api\SearchCriteria', + \Magento\Framework\Api\SearchCriteria::class, [], [], '', @@ -193,7 +193,7 @@ public function testNotify() $returnValue = 'return-value'; $modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', + \Magento\Sales\Model\AbstractModel::class, [], '', false diff --git a/app/code/Magento/Sales/Test/Unit/Model/Status/ListStatusTest.php b/app/code/Magento/Sales/Test/Unit/Model/Status/ListStatusTest.php index c3d17e6f8e0d1..bd0d2848c3838 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Status/ListStatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Status/ListStatusTest.php @@ -36,7 +36,7 @@ public function testAddAndGetItem() $result = $this->listStatus->addItem($origin, $code, $message, $additionalData); $items = $this->listStatus->getItems(); $this->assertEquals($mockItems, $items); - $this->assertInstanceOf('\Magento\Sales\Model\Status\ListStatus', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Status\ListStatus::class, $result); } public function testRemovePresentAndAbsentItems() @@ -60,7 +60,7 @@ public function testClear() $this->addItems(); $expected = []; $result = $this->listStatus->clear(); - $this->assertInstanceOf('\Magento\Sales\Model\Status\ListStatus', $result); + $this->assertInstanceOf(\Magento\Sales\Model\Status\ListStatus::class, $result); $this->assertEquals($expected, $result->getItems()); } diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogPriceRuleTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogPriceRuleTest.php index e54d37dd0dcfb..fa6002799104e 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogPriceRuleTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogPriceRuleTest.php @@ -27,8 +27,8 @@ class CatalogPriceRuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eventObserverMock = $this->getMock('Magento\Framework\Event\Observer'); - $this->_quoteMock = $this->getMock('Magento\Quote\Model\ResourceModel\Quote', [], [], '', false); + $this->eventObserverMock = $this->getMock(\Magento\Framework\Event\Observer::class); + $this->_quoteMock = $this->getMock(\Magento\Quote\Model\ResourceModel\Quote::class, [], [], '', false); $this->_model = new CatalogPriceRule($this->_quoteMock); } diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogProductSaveAfterObserverTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogProductSaveAfterObserverTest.php index a83d0d967ecdc..15e99dac2680d 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogProductSaveAfterObserverTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Backend/CatalogProductSaveAfterObserverTest.php @@ -31,10 +31,10 @@ class CatalogProductSaveAfterObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_quoteMock = $this->getMock('Magento\Quote\Model\ResourceModel\Quote', [], [], '', false); - $this->_observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->_quoteMock = $this->getMock(\Magento\Quote\Model\ResourceModel\Quote::class, [], [], '', false); + $this->_observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $this->_eventMock = $this->getMock( - 'Magento\Framework\Event', + \Magento\Framework\Event::class, ['getProduct', 'getStatus', 'getProductId'], [], '', @@ -52,7 +52,7 @@ protected function setUp() public function testSaveProduct($productId, $productStatus) { $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId', 'getStatus', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Backend/SubtractQtyFromQuotesObserverTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Backend/SubtractQtyFromQuotesObserverTest.php index a7294a77fcf1f..7acbe15c2169b 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Backend/SubtractQtyFromQuotesObserverTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Backend/SubtractQtyFromQuotesObserverTest.php @@ -31,10 +31,10 @@ class SubtractQtyFromQuotesObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_quoteMock = $this->getMock('Magento\Quote\Model\ResourceModel\Quote', [], [], '', false); - $this->_observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->_quoteMock = $this->getMock(\Magento\Quote\Model\ResourceModel\Quote::class, [], [], '', false); + $this->_observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $this->_eventMock = $this->getMock( - 'Magento\Framework\Event', + \Magento\Framework\Event::class, ['getProduct', 'getStatus', 'getProductId'], [], '', @@ -47,7 +47,7 @@ protected function setUp() public function testSubtractQtyFromQuotes() { $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId', 'getStatus', '__wakeup'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php index 24d5e773e74ae..e65d28d91285d 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php @@ -24,7 +24,7 @@ class AddVatRequestParamsOrderCommentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') + $this->customerAddressHelperMock = $this->getMockBuilder(\Magento\Customer\Helper\Address::class) ->disableOriginalConstructor() ->getMock(); @@ -51,7 +51,7 @@ public function testAddVatRequestParamsOrderComment( ->will($this->returnValue($configAddressType)); $orderAddressMock = $this->getMock( - 'Magento\Sales\Model\Order\Address', + \Magento\Sales\Model\Order\Address::class, ['getVatRequestId', 'getVatRequestDate', '__wakeup'], [], '', @@ -64,7 +64,7 @@ public function testAddVatRequestParamsOrderComment( ->method('getVatRequestDate') ->will($this->returnValue($vatRequestDate)); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['getShippingAddress', '__wakeup', 'addStatusHistoryComment', 'getBillingAddress']) ->getMock(); @@ -79,7 +79,7 @@ public function testAddVatRequestParamsOrderComment( ->method('addStatusHistoryComment') ->with($orderHistoryComment, false); } - $observer = $this->getMock('Magento\Framework\Event\Observer', ['getOrder'], [], '', false); + $observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getOrder'], [], '', false); $observer->expects($this->once()) ->method('getOrder') ->will($this->returnValue($orderMock)); diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php index ca4e8c5267cf7..62596621c51b6 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php @@ -24,7 +24,7 @@ class RestoreCustomerGroupIdTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerAddressHelperMock = $this->getMock('\Magento\Customer\Helper\Address', [], [], '', false); + $this->customerAddressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); $this->quote = new RestoreCustomerGroupId($this->customerAddressHelperMock); } @@ -34,21 +34,27 @@ protected function setUp() */ public function testExecute($configAddressType) { - $eventMock = $this->getMock('\Magento\Framework\Event', ['getShippingAssignment', 'getQuote'], [], '', false); - $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); + $eventMock = $this->getMock( + \Magento\Framework\Event::class, + ['getShippingAssignment', 'getQuote'], + [], + '', + false + ); + $observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); $observer->expects($this->exactly(2))->method('getEvent')->willReturn($eventMock); - $shippingAssignmentMock = $this->getMock('\Magento\Quote\Api\Data\ShippingAssignmentInterface'); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $shippingAssignmentMock = $this->getMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $eventMock->expects($this->once())->method('getShippingAssignment')->willReturn($shippingAssignmentMock); $eventMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); - $shippingMock = $this->getMock('\Magento\Quote\Api\Data\ShippingInterface'); + $shippingMock = $this->getMock(\Magento\Quote\Api\Data\ShippingInterface::class); $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock); $quoteAddress = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getPrevQuoteCustomerGroupId', 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId'], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Observer/GridProcessAddressChangeTest.php b/app/code/Magento/Sales/Test/Unit/Observer/GridProcessAddressChangeTest.php index 8801b7ab112b1..9c3350ac8b432 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/GridProcessAddressChangeTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/GridProcessAddressChangeTest.php @@ -28,10 +28,10 @@ class GridProcessAddressChangeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->gridPoolMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\GridPool') + $this->gridPoolMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\GridPool::class) ->disableOriginalConstructor() ->getMock(); - $this->eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $this->eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods(['getOrderId']) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Observer/GridSyncInsertObserverTest.php b/app/code/Magento/Sales/Test/Unit/Observer/GridSyncInsertObserverTest.php index 4d208f59cfdaf..25bed6adda646 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/GridSyncInsertObserverTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/GridSyncInsertObserverTest.php @@ -38,9 +38,9 @@ class GridSyncInsertObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->gridAggregatorMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\GridInterface') + $this->gridAggregatorMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\GridInterface::class) ->getMockForAbstractClass(); - $this->eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $this->eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods( [ @@ -49,7 +49,7 @@ protected function setUp() ] ) ->getMock(); - $this->salesModelMock = $this->getMockBuilder('Magento\Sales\Model\AbstractModel') + $this->salesModelMock = $this->getMockBuilder(\Magento\Sales\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods( [ @@ -57,7 +57,7 @@ protected function setUp() ] ) ->getMockForAbstractClass(); - $this->scopeConfigurationMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigurationMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); $this->unit = new \Magento\Sales\Observer\GridSyncInsertObserver( diff --git a/app/code/Magento/Sales/Test/Unit/Observer/GridSyncRemoveObserverTest.php b/app/code/Magento/Sales/Test/Unit/Observer/GridSyncRemoveObserverTest.php index 80f985b9cdb09..e3fd9285ae397 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/GridSyncRemoveObserverTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/GridSyncRemoveObserverTest.php @@ -33,9 +33,9 @@ class GridSyncRemoveObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->gridAggregatorMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\GridInterface') + $this->gridAggregatorMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\GridInterface::class) ->getMockForAbstractClass(); - $this->eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $this->eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->setMethods( [ @@ -44,7 +44,7 @@ protected function setUp() ] ) ->getMock(); - $this->salesModelMock = $this->getMockBuilder('Magento\Sales\Model\AbstractModel') + $this->salesModelMock = $this->getMockBuilder(\Magento\Sales\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods( [ diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php index 8a9cebcf5320b..bfd7c1520dd70 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php @@ -27,15 +27,15 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); - $this->escaper = $this->getMock('Magento\Framework\Escaper', ['escapeHtml'], [], '', false); + $this->escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); $this->model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\Address', + \Magento\Sales\Ui\Component\Listing\Column\Address::class, [ 'context' => $contextMock, 'escaper' => $this->escaper, diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php index c22cd3250771b..0f58d5f44de0b 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php @@ -27,15 +27,15 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); - $this->groupRepository = $this->getMockForAbstractClass('Magento\Customer\Api\GroupRepositoryInterface'); + $this->groupRepository = $this->getMockForAbstractClass(\Magento\Customer\Api\GroupRepositoryInterface::class); $this->model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\CustomerGroup', + \Magento\Sales\Ui\Component\Listing\Column\CustomerGroup::class, ['groupRepository' => $this->groupRepository, 'context' => $contextMock] ); } @@ -53,7 +53,7 @@ public function testPrepareDataSource() ] ]; - $group = $this->getMockForAbstractClass('Magento\Customer\Api\Data\GroupInterface'); + $group = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\GroupInterface::class); $group->expects($this->once()) ->method('getCode') ->willReturn($newItemValue); diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php index 64628a5dd917b..5db1227f0b544 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php @@ -27,15 +27,15 @@ class PaymentMethodTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); - $this->paymentHelper = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->paymentHelper = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\PaymentMethod', + \Magento\Sales\Ui\Component\Listing\Column\PaymentMethod::class, ['paymentHelper' => $this->paymentHelper, 'context' => $contextMock] ); } @@ -53,7 +53,7 @@ public function testPrepareDataSource() ] ]; - $payment = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $payment = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class); $payment->expects($this->once()) ->method('getTitle') ->willReturn($newItemValue); diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php index 32d370668938d..22387aee3f975 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php @@ -27,15 +27,17 @@ class PriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); - $this->priceFormatterMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceFormatterMock = $this->getMockForAbstractClass( + \Magento\Framework\Pricing\PriceCurrencyInterface::class + ); $this->model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\Price', + \Magento\Sales\Ui\Component\Listing\Column\Price::class, ['priceFormatter' => $this->priceFormatterMock, 'context' => $contextMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PurchasedPriceTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PurchasedPriceTest.php index bfcda4160c56d..1077392b3875d 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PurchasedPriceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PurchasedPriceTest.php @@ -27,15 +27,17 @@ class PurchasedPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); - $this->priceFormatterMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceFormatterMock = $this->getMockForAbstractClass( + \Magento\Framework\Pricing\PriceCurrencyInterface::class + ); $this->model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice', + \Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice::class, ['priceFormatter' => $this->priceFormatterMock, 'context' => $contextMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php index a5c1951a4890d..fb7f22149f5ad 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php @@ -28,14 +28,14 @@ protected function setUp() { $objectManager = new ObjectManager($this); $this->collectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory::class, ['create'], [], '', false ); $this->model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\Status\Options', + \Magento\Sales\Ui\Component\Listing\Column\Status\Options::class, ['collectionFactory' => $this->collectionFactoryMock] ); } @@ -43,7 +43,7 @@ protected function setUp() public function testToOptionArray() { $collectionMock = - $this->getMock('Magento\Sales\Model\ResourceModel\Order\Status\Collection', [], [], '', false); + $this->getMock(\Magento\Sales\Model\ResourceModel\Order\Status\Collection::class, [], [], '', false); $options = ['options']; $this->collectionFactoryMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php index a46d37ece0a27..268704008c581 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php @@ -26,13 +26,19 @@ public function testPrepareDataSource() ] ] ]; - $collection = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Status\Collection', [], [], '', false); + $collection = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Status\Collection::class, + [], + [], + '', + false + ); $collection->expects($this->once()) ->method('toOptionHash') ->willReturn($itemMapping); $collectionFactoryMock = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory::class, ['create'], [], '', @@ -43,14 +49,14 @@ public function testPrepareDataSource() ->willReturn($collection); $objectManager = new ObjectManager($this); - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $model = $objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\Status', + \Magento\Sales\Ui\Component\Listing\Column\Status::class, ['collectionFactory' => $collectionFactoryMock, 'context' => $contextMock] ); $model->setData('name', $itemName); diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index bcbd823834864..14e823637e9ad 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -32,7 +32,7 @@ class ViewActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->urlBuilder = $this->getMockForAbstractClass('Magento\Framework\UrlInterface'); + $this->urlBuilder = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class); } /** @@ -50,14 +50,14 @@ public function testPrepareDataSource( $expectedUrlPath, $expectedUrlParam ) { - $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + $contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->getMockForAbstractClass(); - $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class) ->disableOriginalConstructor() ->getMock(); $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->model = $this->objectManager->getObject( - 'Magento\Sales\Ui\Component\Listing\Column\ViewAction', + \Magento\Sales\Ui\Component\Listing\Column\ViewAction::class, [ 'urlBuilder' => $this->urlBuilder, 'data' => $data, From eb0ce03321aaf8e9447ac028d5c733b47ad9e3b1 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:28:19 +0300 Subject: [PATCH 16/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Adminhtml/Category/AssignProducts.php | 3 +- .../Catalog/Block/Adminhtml/Category/Tree.php | 6 +- .../Adminhtml/Category/Widget/Chooser.php | 2 +- .../Magento/Catalog/Block/Adminhtml/Form.php | 6 +- .../Block/Adminhtml/Helper/Form/Wysiwyg.php | 2 +- .../Catalog/Block/Adminhtml/Product.php | 2 +- .../Product/Attribute/Edit/Tab/Front.php | 2 +- .../Product/Attribute/Edit/Tab/Main.php | 2 +- .../NewAttribute/Product/Attributes.php | 6 +- .../Adminhtml/Product/Attribute/Set/Main.php | 21 +-- .../Attribute/Set/Main/Formattribute.php | 2 +- .../Product/Attribute/Set/Main/Formgroup.php | 2 +- .../Product/Attribute/Set/Toolbar/Add.php | 6 +- .../Product/Attribute/Set/Toolbar/Main.php | 2 +- .../Catalog/Block/Adminhtml/Product/Edit.php | 10 +- .../Product/Edit/Action/Attribute.php | 6 +- .../Edit/Action/Attribute/Tab/Attributes.php | 8 +- .../Adminhtml/Product/Edit/Tab/Alerts.php | 7 +- .../Adminhtml/Product/Edit/Tab/Attributes.php | 18 +-- .../Adminhtml/Product/Edit/Tab/Options.php | 6 +- .../Product/Edit/Tab/Options/Option.php | 7 +- .../Edit/Tab/Options/Type/AbstractType.php | 2 +- .../Product/Edit/Tab/Options/Type/Select.php | 4 +- .../Adminhtml/Product/Edit/Tab/Price.php | 2 +- .../Adminhtml/Product/Edit/Tab/Price/Tier.php | 2 +- .../Block/Adminhtml/Product/Edit/Tabs.php | 4 +- .../Product/Helper/Form/Category.php | 4 +- .../Product/Helper/Form/Gallery/Content.php | 2 +- .../Block/Adminhtml/Product/Options/Ajax.php | 2 +- .../Adminhtml/Product/Widget/Chooser.php | 2 +- .../Magento/Catalog/Block/Category/View.php | 4 +- .../Catalog/Block/Product/ListProduct.php | 2 +- .../Magento/Catalog/Block/Product/View.php | 2 +- .../Block/Product/View/Options/Type/Date.php | 4 +- .../Product/View/Options/Type/Select.php | 2 +- .../Block/Product/Widget/NewWidget.php | 2 +- .../Magento/Catalog/Block/Rss/Category.php | 2 +- .../Catalog/Block/Rss/Product/NewProducts.php | 2 +- .../Catalog/Controller/Adminhtml/Category.php | 14 +- .../Controller/Adminhtml/Category/Add.php | 2 +- .../Adminhtml/Category/CategoriesJson.php | 6 +- .../Controller/Adminhtml/Category/Edit.php | 2 +- .../Controller/Adminhtml/Category/Grid.php | 2 +- .../Adminhtml/Category/RefreshPath.php | 2 +- .../Adminhtml/Category/SuggestCategories.php | 2 +- .../Controller/Adminhtml/Category/Tree.php | 4 +- .../Controller/Adminhtml/Category/Widget.php | 19 +-- .../Category/Widget/CategoriesJson.php | 2 +- .../Adminhtml/Product/Action/Attribute.php | 3 +- .../Product/Action/Attribute/Save.php | 16 +- .../Product/Action/Attribute/Validate.php | 6 +- .../Product/AddAttributeToTemplate.php | 18 +-- .../Adminhtml/Product/Attribute.php | 4 +- .../Adminhtml/Product/Attribute/Delete.php | 2 +- .../Adminhtml/Product/Attribute/Edit.php | 4 +- .../Adminhtml/Product/Attribute/Index.php | 2 +- .../Adminhtml/Product/Attribute/Validate.php | 6 +- .../Controller/Adminhtml/Product/Builder.php | 2 +- .../Adminhtml/Product/Duplicate.php | 2 +- .../Controller/Adminhtml/Product/Edit.php | 4 +- .../Adminhtml/Product/Gallery/Upload.php | 10 +- .../Adminhtml/Product/Group/Save.php | 2 +- .../Product/Initialization/Helper.php | 6 +- .../Initialization/Helper/HandlerFactory.php | 4 +- .../Adminhtml/Product/MassStatus.php | 7 +- .../Controller/Adminhtml/Product/Save.php | 16 +- .../Controller/Adminhtml/Product/Set.php | 2 +- .../Controller/Adminhtml/Product/Set/Add.php | 4 +- .../Controller/Adminhtml/Product/Set/Edit.php | 2 +- .../Controller/Adminhtml/Product/Set/Save.php | 6 +- .../Adminhtml/Product/SuggestAttributes.php | 2 +- .../Controller/Adminhtml/Product/Validate.php | 2 +- .../Adminhtml/Product/Widget/Chooser.php | 6 +- .../Controller/Adminhtml/Product/Wysiwyg.php | 23 +-- .../Catalog/Controller/Category/View.php | 4 +- .../Magento/Catalog/Controller/Product.php | 2 +- .../Controller/Product/Compare/Add.php | 6 +- .../Controller/Product/Compare/Clear.php | 2 +- .../Controller/Product/Compare/Remove.php | 4 +- .../Catalog/Controller/Product/View.php | 4 +- app/code/Magento/Catalog/Helper/Product.php | 4 +- .../Helper/Product/ConfigurationPool.php | 2 +- .../Magento/Catalog/Model/AbstractModel.php | 2 +- .../Catalog/Model/Attribute/Config/Reader.php | 2 +- .../Attribute/LockValidatorComposite.php | 2 +- app/code/Magento/Catalog/Model/Category.php | 4 +- .../Category/Attribute/Backend/Image.php | 2 +- .../Catalog/Model/CategoryLinkManagement.php | 8 +- .../Catalog/Model/CategoryRepository.php | 6 +- app/code/Magento/Catalog/Model/Config.php | 2 +- .../Indexer/Category/Flat/AbstractAction.php | 4 +- .../Category/Product/AbstractAction.php | 2 +- .../Category/Product/Action/RowsFactory.php | 2 +- .../Product/Category/Action/RowsFactory.php | 2 +- .../Indexer/Product/Flat/AbstractAction.php | 2 +- .../Indexer/Product/Flat/Action/Indexer.php | 2 +- .../Indexer/Product/Flat/FlatTableBuilder.php | 2 +- .../Indexer/Product/Flat/TableBuilder.php | 2 +- .../Category/FilterableAttributeList.php | 2 +- .../Catalog/Model/Layer/FilterList.php | 8 +- app/code/Magento/Catalog/Model/Product.php | 10 +- .../Magento/Catalog/Model/Product/Action.php | 2 +- .../Backend/GroupPrice/AbstractGroupPrice.php | 2 +- .../Backend/Media/ImageEntryConverter.php | 2 +- .../Model/Product/Attribute/Repository.php | 2 +- .../Model/Product/Attribute/TypesList.php | 2 +- .../Catalog/Model/Product/Compare/Item.php | 2 +- .../Magento/Catalog/Model/Product/Copier.php | 2 +- .../Model/Product/CopyConstructorFactory.php | 2 +- .../Model/Product/Gallery/CreateHandler.php | 4 +- .../Model/Product/Gallery/Processor.php | 4 +- .../Model/Product/Gallery/ReadHandler.php | 4 +- .../Magento/Catalog/Model/Product/Link.php | 4 +- .../Catalog/Model/Product/Media/Config.php | 2 +- .../Magento/Catalog/Model/Product/Option.php | 6 +- .../Model/Product/Option/Repository.php | 6 +- .../Catalog/Model/Product/Option/Value.php | 2 +- .../Magento/Catalog/Model/Product/Type.php | 4 +- .../Magento/Catalog/Model/Product/Website.php | 2 +- .../Catalog/Model/ProductLink/Link.php | 2 +- .../Catalog/Model/ProductLink/Repository.php | 12 +- .../Model/ProductOptions/Config/Reader.php | 2 +- .../Catalog/Model/ProductRepository.php | 6 +- .../Model/ProductTypes/Config/Reader.php | 2 +- .../Model/ResourceModel/AbstractResource.php | 2 +- .../Catalog/Model/ResourceModel/Attribute.php | 2 +- .../Catalog/Model/ResourceModel/Category.php | 4 +- .../ResourceModel/Category/Collection.php | 2 +- .../Category/Collection/Factory.php | 2 +- .../Category/Flat/Collection.php | 5 +- .../Model/ResourceModel/Category/Tree.php | 2 +- .../Model/ResourceModel/Eav/Attribute.php | 6 +- .../Catalog/Model/ResourceModel/Product.php | 4 +- .../Product/Attribute/Collection.php | 4 +- .../ResourceModel/Product/Collection.php | 8 +- .../Product/Compare/Item/Collection.php | 7 +- .../Model/ResourceModel/Product/Gallery.php | 2 +- .../Product/Indexer/AbstractIndexer.php | 2 +- .../ResourceModel/Product/Link/Collection.php | 5 +- .../Product/Link/SaveHandler.php | 2 +- .../Model/ResourceModel/Product/Option.php | 2 +- .../Product/Option/Collection.php | 9 +- .../Product/Option/Value/Collection.php | 4 +- .../Catalog/Model/ResourceModel/Url.php | 2 +- .../Magento/Catalog/Setup/CategorySetup.php | 118 +++++++------- .../Magento/Catalog/Setup/InstallData.php | 7 +- .../Magento/Catalog/Setup/UpgradeData.php | 17 +- .../Category/AbstractCategoryTest.php | 15 +- .../Attribute/Edit/Tab/AdvancedTest.php | 29 ++-- .../Adminhtml/Product/Attribute/GridTest.php | 10 +- .../Composite/Fieldset/OptionsTest.php | 29 ++-- .../Action/Attribute/Tab/InventoryTest.php | 10 +- .../Adminhtml/Product/Edit/Tab/AlertsTest.php | 4 +- .../Product/Edit/Tab/InventoryTest.php | 46 +++--- .../Product/Helper/Form/CategoryTest.php | 6 +- .../Helper/Form/Gallery/ContentTest.php | 12 +- .../Product/Helper/Form/GalleryTest.php | 10 +- .../Product/Helper/Form/WeightTest.php | 12 +- .../Adminhtml/Product/Options/AjaxTest.php | 27 ++-- .../Block/Adminhtml/Rss/Grid/LinkTest.php | 4 +- .../Block/Adminhtml/Rss/NotifyStockTest.php | 11 +- .../Test/Unit/Block/Category/Rss/LinkTest.php | 22 ++- .../Test/Unit/Block/Category/ViewTest.php | 4 +- .../Test/Unit/Block/NavigationTest.php | 20 +-- .../Block/Product/AbstractProductTest.php | 30 ++-- .../Block/Product/Compare/ListCompareTest.php | 10 +- .../Test/Unit/Block/Product/ContextTest.php | 8 +- .../Unit/Block/Product/ImageBuilderTest.php | 20 +-- .../Unit/Block/Product/ListProductTest.php | 28 ++-- .../Test/Unit/Block/Product/ListTest.php | 2 +- .../Unit/Block/Product/NewProductTest.php | 2 +- .../Test/Unit/Block/Product/PriceTest.php | 4 +- .../Block/Product/ProductList/RelatedTest.php | 10 +- .../Block/Product/ProductList/ToolbarTest.php | 27 ++-- .../Block/Product/ProductList/UpsellTest.php | 6 +- .../Unit/Block/Product/View/GalleryTest.php | 20 +-- .../Unit/Block/Product/View/OptionsTest.php | 29 ++-- .../Test/Unit/Block/Product/View/TabsTest.php | 6 +- .../Test/Unit/Block/Product/ViewTest.php | 14 +- .../Block/Product/Widget/NewWidgetTest.php | 42 +++-- .../Test/Unit/Block/Rss/CategoryTest.php | 44 +++--- .../Block/Rss/Product/NewProductsTest.php | 22 +-- .../Unit/Block/Rss/Product/SpecialTest.php | 34 ++-- .../Test/Unit/Block/Widget/LinkTest.php | 24 +-- .../Command/ImagesResizeCommandTest.php | 19 ++- .../Adminhtml/Category/DeleteTest.php | 27 ++-- .../Adminhtml/Category/EditTest.php | 38 ++--- .../Adminhtml/Category/SaveTest.php | 54 +++---- .../Category/Widget/CategoriesJsonTest.php | 31 ++-- .../Adminhtml/Category/Widget/ChooserTest.php | 25 +-- .../Product/Action/Attribute/EditTest.php | 44 +++--- .../Product/Action/Attribute/SaveTest.php | 82 +++++----- .../Adminhtml/Product/Attribute/EditTest.php | 36 ++--- .../Product/Attribute/ValidateTest.php | 23 +-- .../Adminhtml/Product/BuilderTest.php | 19 ++- .../Helper/HandlerFactoryTest.php | 12 +- .../Helper/Plugin/Handler/CompositeTest.php | 6 +- .../Initialization/StockDataFilterTest.php | 4 +- .../Adminhtml/Product/MassStatusTest.php | 22 +-- .../Adminhtml/Product/NewActionTest.php | 12 +- .../Controller/Adminhtml/Product/SaveTest.php | 27 ++-- .../Product/ShowUpdateResultTest.php | 38 +++-- .../Adminhtml/Product/ValidateTest.php | 31 ++-- .../Unit/Controller/Adminhtml/ProductTest.php | 33 ++-- .../Unit/Controller/Category/ViewTest.php | 42 ++--- .../Controller/Product/Compare/IndexTest.php | 52 ++++--- .../Unit/Cron/RefreshSpecialPricesTest.php | 27 ++-- .../Catalog/Test/Unit/Helper/ImageTest.php | 30 ++-- .../Test/Unit/Helper/Product/CompareTest.php | 24 +-- .../Helper/Product/ConfigurationPoolTest.php | 2 +- .../Product/Edit/Action/AttributeTest.php | 6 +- .../Unit/Helper/Product/Flat/IndexerTest.php | 27 ++-- .../Catalog/Test/Unit/Helper/ProductTest.php | 15 +- .../Backend/CustomlayoutupdateTest.php | 10 +- .../Model/Attribute/Config/ReaderTest.php | 8 +- .../Attribute/Config/SchemaLocatorTest.php | 2 +- .../Unit/Model/Attribute/Config/XsdTest.php | 8 +- .../Test/Unit/Model/Attribute/ConfigTest.php | 2 +- .../Attribute/LockValidatorCompositeTest.php | 12 +- .../Category/Attribute/Backend/SortbyTest.php | 22 +-- .../Category/Attribute/Source/LayoutTest.php | 7 +- .../Category/Attribute/Source/PageTest.php | 6 +- .../Category/Attribute/Source/SortbyTest.php | 4 +- .../Category/AttributeRepositoryTest.php | 25 +-- .../Test/Unit/Model/Category/TreeTest.php | 44 +++--- .../Unit/Model/CategoryLinkManagementTest.php | 30 ++-- .../Unit/Model/CategoryLinkRepositoryTest.php | 30 ++-- .../Unit/Model/CategoryManagementTest.php | 30 ++-- .../Unit/Model/CategoryRepositoryTest.php | 51 +++--- .../Catalog/Test/Unit/Model/CategoryTest.php | 104 +++++++------ .../Config/CatalogClone/Media/ImageTest.php | 14 +- .../Unit/Model/Config/Source/CategoryTest.php | 15 +- .../Model/Config/Source/GridPerPageTest.php | 2 +- .../Model/Config/Source/ListPerPageTest.php | 2 +- .../Unit/Model/Config/Source/ListSortTest.php | 7 +- .../Source/Product/Options/TypeTest.php | 4 +- .../Catalog/Test/Unit/Model/ConfigTest.php | 55 ++++--- .../CustomOptionProcessorTest.php | 27 ++-- .../Model/CustomOptions/CustomOptionTest.php | 20 +-- .../Test/Unit/Model/Entity/AttributeTest.php | 44 +++--- .../Catalog/Test/Unit/Model/FactoryTest.php | 6 +- .../Flat/Plugin/IndexerConfigDataTest.php | 4 +- .../Category/Flat/Plugin/StoreGroupTest.php | 12 +- .../Category/Flat/Plugin/StoreViewTest.php | 14 +- .../Model/Indexer/Category/Flat/StateTest.php | 8 +- .../Category/Flat/System/Config/ModeTest.php | 10 +- .../Unit/Model/Indexer/Category/FlatTest.php | 12 +- .../Category/Product/Plugin/ImportTest.php | 4 +- .../Product/Plugin/MviewStateTest.php | 32 ++-- .../Product/Plugin/StoreGroupTest.php | 12 +- .../Category/Product/Plugin/StoreViewTest.php | 14 +- .../Model/Indexer/Category/ProductTest.php | 12 +- .../Product/Category/Plugin/ImportTest.php | 4 +- .../Model/Indexer/Product/CategoryTest.php | 12 +- .../Product/Eav/AbstractActionTest.php | 14 +- .../Indexer/Product/Eav/Action/FullTest.php | 6 +- .../Indexer/Product/Eav/Action/RowTest.php | 2 +- .../Indexer/Product/Eav/Action/RowsTest.php | 2 +- .../IndexableAttributeFilterTest.php | 14 +- .../Product/Eav/Plugin/AttributeSetTest.php | 6 +- .../Indexer/Product/Eav/Plugin/ImportTest.php | 4 +- .../Product/Eav/Plugin/StoreViewTest.php | 6 +- .../Unit/Model/Indexer/Product/EavTest.php | 12 +- .../Product/Flat/Action/EraserTest.php | 16 +- .../Indexer/Product/Flat/Action/RowTest.php | 27 ++-- .../Flat/Action/Rows/TableDataTest.php | 12 +- .../Indexer/Product/Flat/Action/RowsTest.php | 27 ++-- .../Flat/Plugin/IndexerConfigDataTest.php | 4 +- .../Product/Flat/Plugin/StoreGroupTest.php | 6 +- .../Indexer/Product/Flat/Plugin/StoreTest.php | 6 +- .../Indexer/Product/Flat/ProcessorTest.php | 19 ++- .../Model/Indexer/Product/Flat/StateTest.php | 13 +- .../Product/Flat/System/Config/ModeTest.php | 10 +- .../Indexer/Product/Flat/TableDataTest.php | 6 +- .../Unit/Model/Indexer/Product/FlatTest.php | 14 +- .../Indexer/Product/Price/Action/RowTest.php | 2 +- .../Indexer/Product/Price/Action/RowsTest.php | 2 +- .../Price/Plugin/CustomerGroupTest.php | 20 ++- .../Product/Price/Plugin/WebsiteTest.php | 6 +- .../Price/System/Config/PriceScopeTest.php | 14 +- .../Layer/Category/AvailabilityFlagTest.php | 6 +- .../Layer/Category/CollectionFilterTest.php | 12 +- .../Category/FilterableAttributeListTest.php | 15 +- .../Model/Layer/Category/StateKeyTest.php | 8 +- .../Unit/Model/Layer/Filter/AttributeTest.php | 31 ++-- .../Unit/Model/Layer/Filter/CategoryTest.php | 43 +++-- .../Filter/DataProvider/CategoryTest.php | 12 +- .../Layer/Filter/DataProvider/DecimalTest.php | 6 +- .../Layer/Filter/DataProvider/PriceTest.php | 16 +- .../Unit/Model/Layer/Filter/DecimalTest.php | 8 +- .../Unit/Model/Layer/Filter/FactoryTest.php | 8 +- .../Layer/Filter/Item/DataBuilderTest.php | 2 +- .../Unit/Model/Layer/Filter/PriceTest.php | 31 ++-- .../Test/Unit/Model/Layer/FilterListTest.php | 12 +- .../Layer/Search/CollectionFilterTest.php | 12 +- .../Search/FilterableAttributeListTest.php | 15 +- .../Unit/Model/Layer/Search/StateKeyTest.php | 12 +- .../Test/Unit/Model/Layer/StateTest.php | 4 +- .../Catalog/Test/Unit/Model/LayerTest.php | 58 +++---- .../Model/Layout/DepersonalizePluginTest.php | 14 +- .../Test/Unit/Model/Plugin/LogTest.php | 12 +- .../TransactionWrapperTest.php | 6 +- .../Plugin/QuoteItemProductOptionTest.php | 12 +- .../Test/Unit/Model/Product/ActionTest.php | 18 +-- .../Attribute/Backend/CategoryTest.php | 4 +- .../Backend/GroupPrice/AbstractTest.php | 35 +++-- .../Backend/Media/EntryConverterPoolTest.php | 16 +- .../Backend/Media/ImageEntryConverterTest.php | 18 ++- .../Product/Attribute/Backend/PriceTest.php | 26 +++- .../Product/Attribute/Backend/StockTest.php | 10 +- .../Product/Attribute/Backend/WeightTest.php | 26 +++- .../Product/Attribute/Frontend/ImageTest.php | 10 +- .../Model/Product/Attribute/GroupTest.php | 6 +- .../Product/Attribute/ManagementTest.php | 4 +- .../Attribute/OptionManagementTest.php | 4 +- .../Product/Attribute/RepositoryTest.php | 47 +++--- .../Product/Attribute/SetManagementTest.php | 18 +-- .../Product/Attribute/SetRepositoryTest.php | 35 +++-- .../Source/CountryofmanufactureTest.php | 8 +- .../Attribute/Source/InputtypeTest.php | 4 +- .../Product/Attribute/Source/LayoutTest.php | 6 +- .../Product/Attribute/Source/StatusTest.php | 13 +- .../Model/Product/Attribute/TypesListTest.php | 22 ++- .../Model/Product/CartConfigurationTest.php | 2 +- .../Unit/Model/Product/CatalogPriceTest.php | 6 +- .../Unit/Model/Product/Compare/ItemTest.php | 2 +- .../Test/Unit/Model/Product/ConditionTest.php | 12 +- .../Test/Unit/Model/Product/CopierTest.php | 12 +- .../Product/CopyConstructor/CompositeTest.php | 8 +- .../Product/CopyConstructor/CrossSellTest.php | 10 +- .../Product/CopyConstructor/RelatedTest.php | 10 +- .../Product/CopyConstructor/UpSellTest.php | 10 +- .../Product/CopyConstructorFactoryTest.php | 8 +- .../Product/Gallery/GalleryManagementTest.php | 58 ++++--- .../Model/Product/Gallery/ProcessorTest.php | 22 +-- .../Unit/Model/Product/Image/CacheTest.php | 21 +-- .../Test/Unit/Model/Product/ImageTest.php | 44 +++--- .../Helper/ProductLinksTest.php | 6 +- .../Test/Unit/Model/Product/LinkTest.php | 20 +-- .../Model/Product/LinkTypeProviderTest.php | 22 +-- .../Product/Media/AttributeManagementTest.php | 10 +- .../Model/Product/Option/RepositoryTest.php | 33 ++-- .../Model/Product/Option/Type/FactoryTest.php | 8 +- .../Model/Product/Option/Type/FileTest.php | 10 +- .../Model/Product/Option/UrlBuilderTest.php | 4 +- .../Option/Validator/DefaultValidatorTest.php | 8 +- .../Product/Option/Validator/FileTest.php | 4 +- .../Product/Option/Validator/PoolTest.php | 4 +- .../Product/Option/Validator/SelectTest.php | 4 +- .../Product/Option/Validator/TextTest.php | 4 +- .../Unit/Model/Product/Option/ValueTest.php | 38 ++--- .../Test/Unit/Model/Product/OptionTest.php | 8 +- .../Product/PriceModifier/CompositeTest.php | 6 +- .../Unit/Model/Product/PriceModifierTest.php | 7 +- .../Model/Product/ProductList/ToolbarTest.php | 4 +- .../Product/ReservedAttributeListTest.php | 8 +- .../Model/Product/TierPriceManagementTest.php | 37 +++-- .../Model/Product/Type/AbstractTypeTest.php | 8 +- .../Unit/Model/Product/Type/PriceTest.php | 31 ++-- .../Unit/Model/Product/Type/SimpleTest.php | 20 ++- .../Unit/Model/Product/Type/VirtualTest.php | 20 ++- .../Test/Unit/Model/Product/TypeTest.php | 32 ++-- .../Product/TypeTransitionManagerTest.php | 6 +- .../Test/Unit/Model/Product/UrlTest.php | 18 +-- .../Test/Unit/Model/Product/ValidatorTest.php | 6 +- .../Unit/Model/Product/VisibilityTest.php | 4 +- .../ProductAttributeGroupRepositoryTest.php | 26 ++-- .../Unit/Model/ProductLink/ManagementTest.php | 30 ++-- .../Unit/Model/ProductLink/RepositoryTest.php | 61 ++++---- .../Test/Unit/Model/ProductManagementTest.php | 18 ++- .../Unit/Model/ProductOptionProcessorTest.php | 19 ++- .../Test/Unit/Model/ProductRepositoryTest.php | 106 ++++++++----- .../Catalog/Test/Unit/Model/ProductTest.php | 147 ++++++++++-------- .../Test/Unit/Model/ProductTypeListTest.php | 6 +- .../ProductTypes/Config/SchemaLocatorTest.php | 2 +- .../Unit/Model/ProductTypes/ConfigTest.php | 4 +- .../Unit/Model/ResourceModel/AbstractTest.php | 12 +- .../Category/Collection/FactoryTest.php | 8 +- .../Model/ResourceModel/Category/TreeTest.php | 49 +++--- .../Model/ResourceModel/Eav/AttributeTest.php | 44 ++++-- .../ResourceModel/Product/CollectionTest.php | 57 +++---- .../Model/ResourceModel/Product/FlatTest.php | 10 +- .../ResourceModel/Product/GalleryTest.php | 24 +-- .../Product/Link/Product/CollectionTest.php | 73 +++++---- .../Model/ResourceModel/Product/LinkTest.php | 9 +- .../Product/Option/CollectionTest.php | 45 ++++-- .../Unit/Model/ResourceModel/ProductTest.php | 12 +- .../Test/Unit/Model/Rss/CategoryTest.php | 20 +-- .../Model/Rss/Product/NewProductsTest.php | 14 +- .../Model/Rss/Product/NotifyStockTest.php | 17 +- .../Unit/Model/Rss/Product/SpecialTest.php | 12 +- .../System/Config/Source/InputtypeTest.php | 2 +- .../Model/Template/Filter/FactoryTest.php | 8 +- .../Unit/Observer/MenuCategoryDataTest.php | 13 +- .../Test/Unit/Plugin/Block/TopmenuTest.php | 19 +-- .../Indexer/Category/Product/ExecuteTest.php | 12 +- .../Action/UpdateAttributesFlushCacheTest.php | 9 +- .../ResourceModel/Attribute/SaveTest.php | 12 +- .../Plugin/Model/ResourceModel/ConfigTest.php | 8 +- .../Test/Unit/Pricing/Price/BasePriceTest.php | 21 ++- .../Pricing/Price/ConfiguredPriceTest.php | 22 +-- .../Pricing/Price/CustomOptionPriceTest.php | 26 ++-- .../Unit/Pricing/Price/FinalPriceTest.php | 10 +- .../Unit/Pricing/Price/RegularPriceTest.php | 15 +- .../Unit/Pricing/Price/SpecialPriceTest.php | 10 +- .../Test/Unit/Pricing/Price/TierPriceTest.php | 44 ++++-- .../Unit/Pricing/Render/FinalPriceBoxTest.php | 54 ++++--- .../Test/Unit/Pricing/Render/PriceBoxTest.php | 14 +- .../Catalog/Test/Unit/Pricing/RenderTest.php | 24 ++- .../Test/Unit/Setup/CategorySetupTest.php | 2 +- .../Product/Form/Modifier/EavTest.php | 2 +- .../Product/Form/Modifier/FactoryTest.php | 7 +- .../Product/Form/Modifier/WebsitesTest.php | 37 +++-- 413 files changed, 3166 insertions(+), 2578 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/AssignProducts.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/AssignProducts.php index 21be0850a9c7d..dbc5591c588a4 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/AssignProducts.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/AssignProducts.php @@ -59,7 +59,7 @@ public function getBlockGrid() { if (null === $this->blockGrid) { $this->blockGrid = $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Category\Tab\Product', + \Magento\Catalog\Block\Adminhtml\Category\Tab\Product::class, 'category.product.grid' ); } @@ -87,6 +87,7 @@ public function getProductsJson() } return '{}'; } + /** * Retrieve current category instance * diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php index c66dfbf9896e6..a688d10558ade 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php @@ -87,8 +87,7 @@ protected function _prepareLayout() $addUrl = $this->getUrl("*/*/add", ['_current' => false, 'id' => null, '_query' => false]); if ($this->getStore()->getId() == Store::DEFAULT_STORE_ID) { $this->addChild( - 'add_sub_button', - 'Magento\Backend\Block\Widget\Button', + 'add_sub_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Add Subcategory'), 'onclick' => "addNew('" . $addUrl . "', false)", @@ -100,8 +99,7 @@ protected function _prepareLayout() if ($this->canAddRootCategory()) { $this->addChild( - 'add_root_button', - 'Magento\Backend\Block\Widget\Button', + 'add_root_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Add Root Category'), 'onclick' => "addNew('" . $addUrl . "', true)", diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php index e6520e58cdd92..172d1cf65d2fb 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php @@ -73,7 +73,7 @@ public function prepareElementHtml(\Magento\Framework\Data\Form\Element\Abstract ); $chooser = $this->getLayout()->createBlock( - 'Magento\Widget\Block\Adminhtml\Widget\Chooser' + \Magento\Widget\Block\Adminhtml\Widget\Chooser::class )->setElement( $element )->setConfig( diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Form.php b/app/code/Magento/Catalog/Block/Adminhtml/Form.php index 0bb3350d0a7c3..afde425cc2f4d 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Form.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Form.php @@ -22,19 +22,19 @@ protected function _prepareLayout() { \Magento\Framework\Data\Form::setElementRenderer( $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Renderer\Element', + \Magento\Backend\Block\Widget\Form\Renderer\Element::class, $this->getNameInLayout() . '_element' ) ); \Magento\Framework\Data\Form::setFieldsetRenderer( $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Renderer\Fieldset', + \Magento\Backend\Block\Widget\Form\Renderer\Fieldset::class, $this->getNameInLayout() . '_fieldset' ) ); \Magento\Framework\Data\Form::setFieldsetElementRenderer( $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Form\Renderer\Fieldset\Element', + \Magento\Catalog\Block\Adminhtml\Form\Renderer\Fieldset\Element::class, $this->getNameInLayout() . '_fieldset_element' ) ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php index 80b8f0c0c5ecf..a0fbf71e627a0 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php @@ -78,7 +78,7 @@ public function getAfterElementHtml() if ($this->getIsWysiwygEnabled()) { $disabled = $this->getDisabled() || $this->getReadonly(); $html .= $this->_layout->createBlock( - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, '', [ 'data' => [ diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product.php b/app/code/Magento/Catalog/Block/Adminhtml/Product.php index af6c72d2409e2..0c8cc28af9f2f 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product.php @@ -53,7 +53,7 @@ protected function _prepareLayout() 'label' => __('Add Product'), 'class' => 'add', 'button_class' => '', - 'class_name' => 'Magento\Backend\Block\Widget\Button\SplitButton', + 'class_name' => \Magento\Backend\Block\Widget\Button\SplitButton::class, 'options' => $this->_getAddProductButtonOptions(), ]; $this->buttonList->add('add_new', $addButtonProps); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php index 6e909440666b3..0e4112d0aad14 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php @@ -190,7 +190,7 @@ protected function _prepareForm() $this->setChild( 'form_after', $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Form\Element\Dependence' + \Magento\Backend\Block\Widget\Form\Element\Dependence::class )->addFieldMap( "is_wysiwyg_enabled", 'wysiwyg_enabled' diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php index 8fe925252dc42..065efc5e32955 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php @@ -85,6 +85,6 @@ protected function _prepareForm() */ protected function _getAdditionalElementTypes() { - return ['apply' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply']; + return ['apply' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply::class]; } } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php index 5f8ffb6c4fbde..ff23ae75eb91b 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php @@ -61,9 +61,9 @@ protected function _prepareForm() protected function _getAdditionalElementTypes() { $result = [ - 'price' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Price', - 'image' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Image', - 'boolean' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Boolean', + 'price' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Price::class, + 'image' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Image::class, + 'boolean' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Boolean::class, ]; $response = new \Magento\Framework\DataObject(); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php index 110e2a282e403..d62eee5684748 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php @@ -12,6 +12,9 @@ */ use Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Main extends \Magento\Backend\Block\Template { /** @@ -89,25 +92,25 @@ protected function _prepareLayout() { $setId = $this->_getSetId(); - $this->addChild('group_tree', 'Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Tree\Group'); + $this->addChild('group_tree', \Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Tree\Group::class); - $this->addChild('edit_set_form', 'Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Formset'); + $this->addChild('edit_set_form', \Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Formset::class); $this->addChild( 'delete_group_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Delete Selected Group'), 'onclick' => 'editSet.submit();', 'class' => 'delete'] ); $this->addChild( 'add_group_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Add New'), 'onclick' => 'editSet.addGroup();', 'class' => 'add'] ); $this->getToolbar()->addChild( 'back_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/') . '\')', @@ -117,14 +120,14 @@ protected function _prepareLayout() $this->getToolbar()->addChild( 'reset_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Reset'), 'onclick' => 'window.location.reload()', 'class' => 'reset'] ); if (!$this->getIsCurrentSetDefault()) { $this->getToolbar()->addChild( 'delete_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Delete'), 'onclick' => 'deleteConfirm(\'' . $this->escapeJsQuote( @@ -143,7 +146,7 @@ protected function _prepareLayout() $this->getToolbar()->addChild( 'save_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save'), 'onclick' => 'editSet.save();', @@ -153,7 +156,7 @@ protected function _prepareLayout() $this->addChild( 'rename_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('New Set Name'), 'onclick' => 'editSet.rename()'] ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php index ce0c4cf837a06..0db5855d77074 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php @@ -34,7 +34,7 @@ protected function _prepareForm() 'note', [ 'text' => $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( ['label' => __('Add Attribute'), 'onclick' => 'this.form.submit();', 'class' => 'add'] )->toHtml() diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php index c08952391cac9..b87ba8692aa51 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php @@ -57,7 +57,7 @@ protected function _prepareForm() 'note', [ 'text' => $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( ['label' => __('Add Group'), 'onclick' => 'this.form.submit();', 'class' => 'add'] )->toHtml() diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php index 75328e38e77ec..fb44fb0f58029 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php @@ -28,7 +28,7 @@ protected function _prepareLayout() if ($this->getToolbar()) { $this->getToolbar()->addChild( 'save_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save'), 'class' => 'save primary save-attribute-set', @@ -39,7 +39,7 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( 'back_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/') . '\')', @@ -48,7 +48,7 @@ protected function _prepareLayout() ); } - $this->addChild('setForm', 'Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Formset'); + $this->addChild('setForm', \Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Formset::class); return parent::_prepareLayout(); } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php index 84ec135e93419..6e9670142d8ef 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php @@ -25,7 +25,7 @@ protected function _prepareLayout() { $this->getToolbar()->addChild( 'addButton', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Add Attribute Set'), 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/add') . '\')', diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php index 6c5cf32e877fa..a253b2c7c7a09 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php @@ -95,7 +95,7 @@ protected function _prepareLayout() if ($this->getToolbar()) { $this->getToolbar()->addChild( 'back_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'title' => __('Back'), @@ -110,7 +110,7 @@ protected function _prepareLayout() } else { $this->addChild( 'back_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Close Window'), 'onclick' => 'window.close()', 'class' => 'cancel'] ); } @@ -118,7 +118,7 @@ protected function _prepareLayout() if (!$this->getProduct()->isReadonly()) { $this->addChild( 'reset_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Reset'), 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/*', ['_current' => true]) . '\')' @@ -129,11 +129,11 @@ protected function _prepareLayout() if (!$this->getProduct()->isReadonly() && $this->getToolbar()) { $this->getToolbar()->addChild( 'save-split-button', - 'Magento\Backend\Block\Widget\Button\SplitButton', + \Magento\Backend\Block\Widget\Button\SplitButton::class, [ 'id' => 'save-split-button', 'label' => __('Save'), - 'class_name' => 'Magento\Backend\Block\Widget\Button\SplitButton', + 'class_name' => \Magento\Backend\Block\Widget\Button\SplitButton::class, 'button_class' => 'widget-button-save', 'options' => $this->_getSaveSplitButtonOptions() ] diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php index 86a8c6238143b..35069f4cd4cb5 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php @@ -44,7 +44,7 @@ protected function _prepareLayout() { $this->getToolbar()->addChild( 'back_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'onclick' => 'setLocation(\'' . $this->getUrl( @@ -57,7 +57,7 @@ protected function _prepareLayout() $this->getToolbar()->addChild( 'reset_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Reset'), 'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/*', ['_current' => true]) . '\')', @@ -67,7 +67,7 @@ protected function _prepareLayout() $this->getToolbar()->addChild( 'save_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save'), 'class' => 'save primary', diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php index 9c5d72fac3610..133fda51408ba 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php @@ -113,10 +113,10 @@ public function getAttributes() protected function _getAdditionalElementTypes() { return [ - 'price' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Price', - 'weight' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight', - 'image' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Image', - 'boolean' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Boolean' + 'price' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Price::class, + 'weight' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight::class, + 'image' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Image::class, + 'boolean' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Boolean::class ]; } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php index 0ab68134a85a6..b6746106aea14 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php @@ -25,7 +25,8 @@ class Alerts extends \Magento\Backend\Block\Widget\Tab */ protected function _prepareLayout() { - $accordion = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Accordion')->setId('productAlerts'); + $accordion = $this->getLayout()->createBlock( + \Magento\Backend\Block\Widget\Accordion::class)->setId('productAlerts'); /* @var $accordion \Magento\Backend\Block\Widget\Accordion */ $alertPriceAllow = $this->_scopeConfig->getValue('catalog/productalert/allow_price', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); @@ -37,7 +38,7 @@ protected function _prepareLayout() [ 'title' => __('Price Alert Subscriptions'), 'content' => $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts\Price' + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts\Price::class )->toHtml() . '
', 'open' => true ] @@ -49,7 +50,7 @@ protected function _prepareLayout() [ 'title' => __('Stock Alert Subscriptions'), 'content' => $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts\Stock' + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts\Stock::class ), 'open' => true ] diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php index be793a54e715f..ad8923eb829ed 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php @@ -53,7 +53,7 @@ protected function _prepareForm() $tierPrice = $form->getElement('tier_price'); if ($tierPrice) { $tierPrice->setRenderer( - $this->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Tier') + $this->getLayout()->createBlock(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Tier::class) ); } @@ -65,7 +65,7 @@ protected function _prepareForm() ) && $isWrapped ) { $attributeCreate = $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Create' + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Create::class ); $attributeCreate->getConfig()->setAttributeGroupCode( @@ -85,7 +85,7 @@ protected function _prepareForm() ); $attributeSearch = $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Search' + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Search::class )->setGroupId( $group->getId() )->setGroupCode( @@ -138,12 +138,12 @@ protected function _prepareForm() protected function _getAdditionalElementTypes() { $result = [ - 'price' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Price', - 'weight' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight', - 'gallery' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery', - 'image' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Image', - 'boolean' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Boolean', - 'textarea' => 'Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg', + 'price' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Price::class, + 'weight' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight::class, + 'gallery' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery::class, + 'image' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Image::class, + 'boolean' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Boolean::class, + 'textarea' => \Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg::class, ]; $response = new \Magento\Framework\DataObject(); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php index 3f8cde336060d..2a758b7a95fcb 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php @@ -27,15 +27,15 @@ protected function _prepareLayout() { $this->addChild( 'add_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Add New Option'), 'class' => 'add', 'id' => 'add_new_defined_option'] ); - $this->addChild('options_box', 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option'); + $this->addChild('options_box', \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option::class); $this->addChild( 'import_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Import Options'), 'class' => 'add', 'id' => 'import_new_defined_option'] ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php index aa16cd63dfa66..1a5e5e219e78d 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php @@ -14,6 +14,9 @@ use Magento\Backend\Block\Widget; use Magento\Catalog\Model\Product; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Option extends Widget { /** @@ -206,7 +209,7 @@ public function getAddButtonId() public function getTypeSelectHtml() { $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' + \Magento\Framework\View\Element\Html\Select::class )->setData( [ 'id' => $this->getFieldId() . '_<%- data.id %>_type', @@ -227,7 +230,7 @@ public function getTypeSelectHtml() public function getRequireSelectHtml() { $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' + \Magento\Framework\View\Element\Html\Select::class )->setData( ['id' => $this->getFieldId() . '_<%- data.id %>_is_require', 'class' => 'select'] )->setName( diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php index 3aaddc19c3500..c5e22cd899838 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php @@ -45,7 +45,7 @@ protected function _prepareLayout() $this->setChild( 'option_price_type', $this->getLayout()->addBlock( - 'Magento\Framework\View\Element\Html\Select', + \Magento\Framework\View\Element\Html\Select::class, $this->getNameInLayout() . '.option_price_type', $this->getNameInLayout() )->setData( diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php index 92a1da98a0c55..599d0faadf7de 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php @@ -38,7 +38,7 @@ protected function _prepareLayout() { $this->addChild( 'add_select_row_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Add New Row'), 'class' => 'add add-select-row', @@ -48,7 +48,7 @@ protected function _prepareLayout() $this->addChild( 'delete_select_row_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Delete Row'), 'class' => 'delete delete-select-row icon-btn', diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php index e23be364b660f..37190924d6c4e 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php @@ -43,7 +43,7 @@ protected function _prepareForm() $form->getElement( 'tier_price' )->setRenderer( - $this->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Tier') + $this->getLayout()->createBlock(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Tier::class) ); $this->setForm($form); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php index 345f61e9e34a8..9b5d04e065388 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php @@ -69,7 +69,7 @@ protected function _sortTierPrices($a, $b) protected function _prepareLayout() { $button = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( ['label' => __('Add Price'), 'onclick' => 'return tierPriceControl.addItem()', 'class' => 'add'] ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index 3849f727496be..b72da44b72a0e 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -31,7 +31,7 @@ class Tabs extends WigetTabs /** * @var string */ - protected $_attributeTabBlock = 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes'; + protected $_attributeTabBlock = \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes::class; /** * @var string @@ -189,7 +189,7 @@ protected function _prepareLayout() 'label' => __('Websites'), 'content' => $this->_translateHtml( $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Websites' + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Websites::class )->toHtml() ), 'group_code' => self::BASIC_TAB_GROUP_CODE diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php index cec013d19254b..64ff3ec265b22 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php @@ -125,8 +125,8 @@ public function getAfterElementHtml() $selectorOptions = $this->_jsonEncoder->encode($this->_getSelectorOptions()); $newCategoryCaption = __('New Category'); - $button = $this->_layout->createBlock( - 'Magento\Backend\Block\Widget\Button' + $button = $this->_layout->createBlock( + \Magento\Backend\Block\Widget\Button::class )->setData( [ 'id' => 'add_category_button', diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php index f61f9071155aa..42a1d69ee7e21 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php @@ -56,7 +56,7 @@ public function __construct( */ protected function _prepareLayout() { - $this->addChild('uploader', 'Magento\Backend\Block\Media\Uploader'); + $this->addChild('uploader', \Magento\Backend\Block\Media\Uploader::class); $this->getUploader()->getConfig()->setUrl( $this->_urlBuilder->addSessionParam()->getUrl('catalog/product_gallery/upload') diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Options/Ajax.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Options/Ajax.php index fb15a5b80d741..d6018252c4f98 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Options/Ajax.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Options/Ajax.php @@ -62,7 +62,7 @@ protected function _toHtml() $results = []; /** @var $optionsBlock \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option */ $optionsBlock = $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option' + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option::class )->setIgnoreCaching( true ); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php index 53bc69cf52699..7012a80ed935a 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php @@ -95,7 +95,7 @@ public function prepareElementHtml(AbstractElement $element) ); $chooser = $this->getLayout()->createBlock( - 'Magento\Widget\Block\Adminhtml\Widget\Chooser' + \Magento\Widget\Block\Adminhtml\Widget\Chooser::class )->setElement( $element )->setConfig( diff --git a/app/code/Magento/Catalog/Block/Category/View.php b/app/code/Magento/Catalog/Block/Category/View.php index 74ee26e6978d1..87d2d3155495d 100644 --- a/app/code/Magento/Catalog/Block/Category/View.php +++ b/app/code/Magento/Catalog/Block/Category/View.php @@ -57,7 +57,7 @@ protected function _prepareLayout() { parent::_prepareLayout(); - $this->getLayout()->createBlock('Magento\Catalog\Block\Breadcrumbs'); + $this->getLayout()->createBlock(\Magento\Catalog\Block\Breadcrumbs::class); $category = $this->getCurrentCategory(); if ($category) { @@ -118,7 +118,7 @@ public function getCmsBlockHtml() { if (!$this->getData('cms_block_html')) { $html = $this->getLayout()->createBlock( - 'Magento\Cms\Block\Block' + \Magento\Cms\Block\Block::class )->setBlockId( $this->getCurrentCategory()->getLandingPage() )->toHtml(); diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 996dbc191dfd1..22fb37f5d0da0 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -24,7 +24,7 @@ class ListProduct extends AbstractProduct implements IdentityInterface * * @var string */ - protected $_defaultToolbarBlock = 'Magento\Catalog\Block\Product\ProductList\Toolbar'; + protected $_defaultToolbarBlock = \Magento\Catalog\Block\Product\ProductList\Toolbar::class; /** * Product Collection diff --git a/app/code/Magento/Catalog/Block/Product/View.php b/app/code/Magento/Catalog/Block/Product/View.php index a42ba1dd55202..37dc6f594a9b1 100644 --- a/app/code/Magento/Catalog/Block/Product/View.php +++ b/app/code/Magento/Catalog/Block/Product/View.php @@ -122,7 +122,7 @@ public function getWishlistOptions() */ protected function _prepareLayout() { - $this->getLayout()->createBlock('Magento\Catalog\Block\Breadcrumbs'); + $this->getLayout()->createBlock(\Magento\Catalog\Block\Breadcrumbs::class); $product = $this->getProduct(); if (!$product) { return parent::_prepareLayout(); diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php index ea391090c89e5..eca5f8a18b154 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php @@ -83,7 +83,7 @@ public function getCalendarDateHtml() $yearEnd = $this->_catalogProductOptionTypeDate->getYearEnd(); $calendar = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Date' + \Magento\Framework\View\Element\Html\Date::class )->setId( 'options_' . $this->getOption()->getId() . '_date' )->setName( @@ -185,7 +185,7 @@ protected function _getHtmlSelect($name, $value = null) // $require = $this->getOption()->getIsRequire() ? ' required-entry' : ''; $require = ''; $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' + \Magento\Framework\View\Element\Html\Select::class )->setId( 'options_' . $this->getOption()->getId() . '_' . $name )->setClass( diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Select.php b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Select.php index e59d707eedd38..ca8e2daf13245 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Select.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Select.php @@ -36,7 +36,7 @@ public function getValuesHtml() $require = $_option->getIsRequire() ? ' required' : ''; $extraParams = ''; $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' + \Magento\Framework\View\Element\Html\Select::class )->setData( [ 'id' => 'select_' . $_option->getId(), diff --git a/app/code/Magento/Catalog/Block/Product/Widget/NewWidget.php b/app/code/Magento/Catalog/Block/Product/Widget/NewWidget.php index 9c6c2af60a5dd..61985c2cb1b9c 100644 --- a/app/code/Magento/Catalog/Block/Product/Widget/NewWidget.php +++ b/app/code/Magento/Catalog/Block/Product/Widget/NewWidget.php @@ -183,7 +183,7 @@ public function getPagerHtml() if ($this->showPager()) { if (!$this->_pager) { $this->_pager = $this->getLayout()->createBlock( - 'Magento\Catalog\Block\Product\Widget\Html\Pager', + \Magento\Catalog\Block\Product\Widget\Html\Pager::class, 'widget.new.product.list.pager' ); diff --git a/app/code/Magento/Catalog/Block/Rss/Category.php b/app/code/Magento/Catalog/Block/Rss/Category.php index e1b1e67dca8f4..4cf0962b962e0 100644 --- a/app/code/Magento/Catalog/Block/Rss/Category.php +++ b/app/code/Magento/Catalog/Block/Rss/Category.php @@ -164,7 +164,7 @@ protected function renderPriceHtml(\Magento\Catalog\Model\Product $product) $priceRender = $this->getLayout()->getBlock('product.price.render.default'); if (!$priceRender) { $priceRender = $this->getLayout()->createBlock( - 'Magento\Framework\Pricing\Render', + \Magento\Framework\Pricing\Render::class, 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']] ); diff --git a/app/code/Magento/Catalog/Block/Rss/Product/NewProducts.php b/app/code/Magento/Catalog/Block/Rss/Product/NewProducts.php index 0e511c344836e..a7ff6fadf2ea7 100644 --- a/app/code/Magento/Catalog/Block/Rss/Product/NewProducts.php +++ b/app/code/Magento/Catalog/Block/Rss/Product/NewProducts.php @@ -155,7 +155,7 @@ protected function renderPriceHtml(\Magento\Catalog\Model\Product $product) $priceRender = $this->getLayout()->getBlock('product.price.render.default'); if (!$priceRender) { $priceRender = $this->getLayout()->createBlock( - 'Magento\Framework\Pricing\Render', + \Magento\Framework\Pricing\Render::class, 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']] ); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index 366202df27ee7..8f8f21e207bf5 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -33,14 +33,14 @@ protected function _initCategory($getRootInstead = false) { $categoryId = (int)$this->getRequest()->getParam('id', false); $storeId = (int)$this->getRequest()->getParam('store'); - $category = $this->_objectManager->create('Magento\Catalog\Model\Category'); + $category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class); $category->setStoreId($storeId); if ($categoryId) { $category->load($categoryId); if ($storeId) { $rootId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + \Magento\Store\Model\StoreManagerInterface::class )->getStore( $storeId )->getRootCategoryId(); @@ -55,9 +55,9 @@ protected function _initCategory($getRootInstead = false) } } - $this->_objectManager->get('Magento\Framework\Registry')->register('category', $category); - $this->_objectManager->get('Magento\Framework\Registry')->register('current_category', $category); - $this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config') + $this->_objectManager->get(\Magento\Framework\Registry::class)->register('category', $category); + $this->_objectManager->get(\Magento\Framework\Registry::class)->register('current_category', $category); + $this->_objectManager->get(\Magento\Cms\Model\Wysiwyg\Config::class) ->setStoreId($this->getRequest()->getParam('store')); return $category; } @@ -79,7 +79,7 @@ protected function ajaxRequestResponse($category, $resultPage) if (empty($breadcrumbsPath)) { // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session $breadcrumbsPath = $this->_objectManager->get( - 'Magento\Backend\Model\Auth\Session' + \Magento\Backend\Model\Auth\Session::class )->getDeletedPath( true ); @@ -107,7 +107,7 @@ protected function ajaxRequestResponse($category, $resultPage) ['response' => $eventResponse, 'controller' => $this] ); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ - $resultJson = $this->_objectManager->get('Magento\Framework\Controller\Result\Json'); + $resultJson = $this->_objectManager->get(\Magento\Framework\Controller\Result\Json::class); $resultJson->setHeader('Content-type', 'application/json', true); $resultJson->setData($eventResponse->getData()); return $resultJson; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Add.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Add.php index c66fe32bcce2d..663bf6a5b0915 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Add.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Add.php @@ -59,7 +59,7 @@ public function execute() $category->addData($categoryData); } - $resultPageFactory = $this->_objectManager->get('Magento\Framework\View\Result\PageFactory'); + $resultPageFactory = $this->_objectManager->get(\Magento\Framework\View\Result\PageFactory::class); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $resultPageFactory->create(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php index 6c7bd754e5b32..1bad378d0895a 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php @@ -41,9 +41,9 @@ public function __construct( public function execute() { if ($this->getRequest()->getParam('expand_all')) { - $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->setIsTreeWasExpanded(true); + $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class)->setIsTreeWasExpanded(true); } else { - $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->setIsTreeWasExpanded(false); + $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class)->setIsTreeWasExpanded(false); } $categoryId = (int)$this->getRequest()->getPost('id'); if ($categoryId) { @@ -58,7 +58,7 @@ public function execute() /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setJsonData( - $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree') + $this->layoutFactory->create()->createBlock(\Magento\Catalog\Block\Adminhtml\Category\Tree::class) ->getTreeJson($category) ); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 1f5a68969037a..b2722ec019785 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -119,7 +119,7 @@ private function getStoreManager() { if (null === $this->storeManager) { $this->storeManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Store\Model\StoreManagerInterface'); + ->get(\Magento\Store\Model\StoreManagerInterface::class); } return $this->storeManager; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Grid.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Grid.php index 3dddcdad76192..4b2fa125ac137 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Grid.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Grid.php @@ -51,7 +51,7 @@ public function execute() $resultRaw = $this->resultRawFactory->create(); return $resultRaw->setContents( $this->layoutFactory->create()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Category\Tab\Product', + \Magento\Catalog\Block\Adminhtml\Category\Tab\Product::class, 'category.product.grid' )->toHtml() ); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php index 70ef92be4dc2c..4202d21089563 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php @@ -34,7 +34,7 @@ public function execute() { $categoryId = (int)$this->getRequest()->getParam('id'); if ($categoryId) { - $category = $this->_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId); + $category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class)->load($categoryId); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php index a57e6a2beb2cd..9ab7e84cead06 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php @@ -43,7 +43,7 @@ public function execute() /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setJsonData( - $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree') + $this->layoutFactory->create()->createBlock(\Magento\Catalog\Block\Adminhtml\Category\Tree::class) ->getSuggestedCategoriesJson($this->getRequest()->getParam('label_part')) ); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php index 3949776546b46..339699e5fd5e5 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php @@ -47,7 +47,7 @@ public function execute() if ($storeId) { if (!$categoryId) { $store = $this->_objectManager - ->get('Magento\Store\Model\StoreManagerInterface') + ->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore($storeId); $rootId = $store->getRootCategoryId(); $this->getRequest()->setParam('id', $rootId); @@ -61,7 +61,7 @@ public function execute() return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]); } - $block = $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree'); + $block = $this->layoutFactory->create()->createBlock(\Magento\Catalog\Block\Adminhtml\Category\Tree::class); $root = $block->getRoot(); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php index 0d4ff10c49af0..643300cc95bcf 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php @@ -36,15 +36,16 @@ public function __construct( */ protected function _getCategoryTreeBlock() { - return $this->layoutFactory->create()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser', - '', - [ - 'data' => [ - 'id' => $this->getRequest()->getParam('uniq_id'), - 'use_massaction' => $this->getRequest()->getParam('use_massaction', false), + return $this->layoutFactory->create() + ->createBlock( + \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser::class, + '', + [ + 'data' => [ + 'id' => $this->getRequest()->getParam('uniq_id'), + 'use_massaction' => $this->getRequest()->getParam('use_massaction', false), + ] ] - ] - ); + ); } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php index 0ea10455fe49c..8e101f3a82379 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php @@ -47,7 +47,7 @@ public function execute() $categoryId = (int)$this->getRequest()->getPost('id'); if ($categoryId) { $selected = $this->getRequest()->getPost('selected', ''); - $category = $this->_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId); + $category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class)->load($categoryId); if ($category->getId()) { $this->_coreRegistry->register('category', $category); $this->_coreRegistry->register('current_category', $category); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php index bc52f710471ca..5ad7057e48fb1 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php @@ -50,7 +50,8 @@ protected function _validateProducts() $productIds = $this->attributeHelper->getProductIds(); if (!is_array($productIds)) { $error = __('Please select products for attributes update.'); - } elseif (!$this->_objectManager->create('Magento\Catalog\Model\Product')->isProductsHasSku($productIds)) { + } elseif (!$this->_objectManager->create( + \Magento\Catalog\Model\Product::class)->isProductsHasSku($productIds)) { $error = __('Please make sure to define SKU values for all processed products.'); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index abe72e14dd310..764040e9cfeb8 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -98,7 +98,7 @@ public function execute() $websiteAddData = $this->getRequest()->getParam('add_website_ids', []); /* Prepare inventory data item options (use config settings) */ - $options = $this->_objectManager->get('Magento\CatalogInventory\Api\StockConfigurationInterface') + $options = $this->_objectManager->get(\Magento\CatalogInventory\Api\StockConfigurationInterface::class) ->getConfigItemOptions(); foreach ($options as $option) { if (isset($inventoryData[$option]) && !isset($inventoryData['use_config_' . $option])) { @@ -109,11 +109,11 @@ public function execute() try { $storeId = $this->attributeHelper->getSelectedStoreId(); if ($attributesData) { - $dateFormat = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $dateFormat = $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getDateFormat(\IntlDateFormatter::SHORT); foreach ($attributesData as $attributeCode => $value) { - $attribute = $this->_objectManager->get('Magento\Eav\Model\Config') + $attribute = $this->_objectManager->get(\Magento\Eav\Model\Config::class) ->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); if (!$attribute->getAttributeId()) { unset($attributesData[$attributeCode]); @@ -144,7 +144,7 @@ public function execute() } } - $this->_objectManager->get('Magento\Catalog\Model\Product\Action') + $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class) ->updateAttributes($this->attributeHelper->getProductIds(), $attributesData, $storeId); } @@ -152,10 +152,10 @@ public function execute() // TODO why use ObjectManager? /** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */ $stockRegistry = $this->_objectManager - ->create('Magento\CatalogInventory\Api\StockRegistryInterface'); + ->create(\Magento\CatalogInventory\Api\StockRegistryInterface::class); /** @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository */ $stockItemRepository = $this->_objectManager - ->create('Magento\CatalogInventory\Api\StockItemRepositoryInterface'); + ->create(\Magento\CatalogInventory\Api\StockItemRepositoryInterface::class); foreach ($this->attributeHelper->getProductIds() as $productId) { $stockItemDo = $stockRegistry->getStockItem( $productId, @@ -169,7 +169,7 @@ public function execute() $this->dataObjectHelper->populateWithArray( $stockItemDo, $inventoryData, - '\Magento\CatalogInventory\Api\Data\StockItemInterface' + \Magento\CatalogInventory\Api\Data\StockItemInterface::class ); $stockItemDo->setItemId($stockItemId); $stockItemRepository->save($stockItemDo); @@ -179,7 +179,7 @@ public function execute() if ($websiteAddData || $websiteRemoveData) { /* @var $actionModel \Magento\Catalog\Model\Product\Action */ - $actionModel = $this->_objectManager->get('Magento\Catalog\Model\Product\Action'); + $actionModel = $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class); $productIds = $this->attributeHelper->getProductIds(); if ($websiteRemoveData) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php index 2bc7fc2543863..803e2672f4249 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php @@ -42,15 +42,15 @@ public function __construct( */ public function execute() { - $response = $this->_objectManager->create('Magento\Framework\DataObject'); + $response = $this->_objectManager->create(\Magento\Framework\DataObject::class); $response->setError(false); $attributesData = $this->getRequest()->getParam('attributes', []); - $data = $this->_objectManager->create('Magento\Catalog\Model\Product'); + $data = $this->_objectManager->create(\Magento\Catalog\Model\Product::class); try { if ($attributesData) { foreach ($attributesData as $attributeCode => $value) { - $attribute = $this->_objectManager->get('Magento\Eav\Model\Config') + $attribute = $this->_objectManager->get(\Magento\Eav\Model\Config::class) ->getAttribute('catalog_product', $attributeCode); if (!$attribute->getAttributeId()) { unset($attributesData[$attributeCode]); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 5f215a8594bd9..8a2b76b1bbd56 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -199,7 +199,7 @@ private function getAttributeRepository() { if (null === $this->attributeRepository) { $this->attributeRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Eav\Api\AttributeRepositoryInterface'); + ->get(\Magento\Eav\Api\AttributeRepositoryInterface::class); } return $this->attributeRepository; } @@ -211,7 +211,7 @@ private function getAttributeSetRepository() { if (null === $this->attributeSetRepository) { $this->attributeSetRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\AttributeSetRepositoryInterface'); + ->get(\Magento\Catalog\Api\AttributeSetRepositoryInterface::class); } return $this->attributeSetRepository; } @@ -223,7 +223,7 @@ private function getAttributeGroupRepository() { if (null === $this->attributeGroupRepository) { $this->attributeGroupRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Eav\Api\AttributeGroupRepositoryInterface'); + ->get(\Magento\Eav\Api\AttributeGroupRepositoryInterface::class); } return $this->attributeGroupRepository; } @@ -235,7 +235,7 @@ private function getAttributeGroupFactory() { if (null === $this->attributeGroupFactory) { $this->attributeGroupFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Eav\Api\Data\AttributeGroupInterfaceFactory'); + ->get(\Magento\Eav\Api\Data\AttributeGroupInterfaceFactory::class); } return $this->attributeGroupFactory; } @@ -247,7 +247,7 @@ private function getSearchCriteriaBuilder() { if (null === $this->searchCriteriaBuilder) { $this->searchCriteriaBuilder = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\Api\SearchCriteriaBuilder'); + ->get(\Magento\Framework\Api\SearchCriteriaBuilder::class); } return $this->searchCriteriaBuilder; } @@ -259,7 +259,7 @@ private function getSortOrderBuilder() { if (null === $this->sortOrderBuilder) { $this->sortOrderBuilder = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\Api\SortOrderBuilder'); + ->get(\Magento\Framework\Api\SortOrderBuilder::class); } return $this->sortOrderBuilder; } @@ -271,7 +271,7 @@ private function getAttributeManagement() { if (null === $this->attributeManagement) { $this->attributeManagement = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Eav\Api\AttributeManagementInterface'); + ->get(\Magento\Eav\Api\AttributeManagementInterface::class); } return $this->attributeManagement; } @@ -283,7 +283,7 @@ private function getLogger() { if (null === $this->logger) { $this->logger = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Psr\Log\LoggerInterface'); + ->get(\Psr\Log\LoggerInterface::class); } return $this->logger; } @@ -295,7 +295,7 @@ private function getExtensionAttributesFactory() { if (null === $this->extensionAttributesFactory) { $this->extensionAttributesFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\Api\ExtensionAttributesFactory'); + ->get(\Magento\Framework\Api\ExtensionAttributesFactory::class); } return $this->extensionAttributesFactory; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php index 5409d2cf73b88..bd82e526c7b12 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php @@ -72,7 +72,7 @@ public function __construct( public function dispatch(\Magento\Framework\App\RequestInterface $request) { $this->_entityTypeId = $this->_objectManager->create( - 'Magento\Eav\Model\Entity' + \Magento\Eav\Model\Entity::class )->setType( \Magento\Catalog\Model\Product::ENTITY )->getTypeId(); @@ -119,7 +119,7 @@ protected function generateCode($label) preg_replace( '/[^a-z_0-9]/', '_', - $this->_objectManager->create('Magento\Catalog\Model\Product\Url')->formatUrlKey($label) + $this->_objectManager->create(\Magento\Catalog\Model\Product\Url::class)->formatUrlKey($label) ), 0, 30 diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Delete.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Delete.php index e253783ed1a60..76e86dc6bfda9 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Delete.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Delete.php @@ -16,7 +16,7 @@ public function execute() $id = $this->getRequest()->getParam('attribute_id'); $resultRedirect = $this->resultRedirectFactory->create(); if ($id) { - $model = $this->_objectManager->create('Magento\Catalog\Model\ResourceModel\Eav\Attribute'); + $model = $this->_objectManager->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); // entity type check $model->load($id); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php index d701bc774953a..e308055a44192 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Edit.php @@ -17,7 +17,7 @@ public function execute() $id = $this->getRequest()->getParam('attribute_id'); /** @var $model \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ $model = $this->_objectManager->create( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class )->setEntityTypeId( $this->_entityTypeId ); @@ -39,7 +39,7 @@ public function execute() } // set entered data if was error when we do save - $data = $this->_objectManager->get('Magento\Backend\Model\Session')->getAttributeData(true); + $data = $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getAttributeData(true); if (!empty($data)) { $model->addData($data); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Index.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Index.php index 8c5f833c8dd48..b30d8aa30391d 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Index.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Index.php @@ -15,7 +15,7 @@ public function execute() { $resultPage = $this->createActionPage(); $resultPage->addContent( - $resultPage->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Product\Attribute') + $resultPage->getLayout()->createBlock(\Magento\Catalog\Block\Adminhtml\Product\Attribute::class) ); return $resultPage; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php index 991f448b4e497..8d0cf2bfe049d 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php @@ -58,7 +58,7 @@ public function execute() $attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]); $attributeId = $this->getRequest()->getParam('attribute_id'); $attribute = $this->_objectManager->create( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class )->loadByCode( $this->_entityTypeId, $attributeCode @@ -77,10 +77,10 @@ public function execute() if ($this->getRequest()->has('new_attribute_set_name')) { $setName = $this->getRequest()->getParam('new_attribute_set_name'); /** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */ - $attributeSet = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Set'); + $attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class); $attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name'); if ($attributeSet->getId()) { - $setName = $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($setName); + $setName = $this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($setName); $this->messageManager->addError(__('An attribute set named \'%1\' already exists.', $setName)); $layout = $this->layoutFactory->create(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php index 7004413c5c569..6915209d4d895 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php @@ -107,7 +107,7 @@ private function getStoreFactory() { if (null === $this->storeFactory) { $this->storeFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Store\Model\StoreFactory'); + ->get(\Magento\Store\Model\StoreFactory::class); } return $this->storeFactory; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php index 0dba9a32d39ef..4232416e80849 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php @@ -46,7 +46,7 @@ public function execute() $this->messageManager->addSuccess(__('You duplicated the product.')); $resultRedirect->setPath('catalog/*/edit', ['_current' => true, 'id' => $newProduct->getId()]); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addError($e->getMessage()); $resultRedirect->setPath('catalog/*/edit', ['_current' => true]); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php index 9970a42a3a484..256ccf01753bd 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php @@ -42,7 +42,7 @@ public function __construct( public function execute() { /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); $storeId = (int) $this->getRequest()->getParam('store', 0); $store = $storeManager->getStore($storeId); $storeManager->setCurrentStore($store->getCode()); @@ -65,7 +65,7 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Products')); $resultPage->getConfig()->getTitle()->prepend($product->getName()); - if (!$this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->isSingleStoreMode() + if (!$this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->isSingleStoreMode() && ($switchBlock = $resultPage->getLayout()->getBlock('store_switcher')) ) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php index 6f03c6a003f7b..f03441b2fdd9a 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php @@ -41,19 +41,19 @@ public function execute() { try { $uploader = $this->_objectManager->create( - 'Magento\MediaStorage\Model\File\Uploader', + \Magento\MediaStorage\Model\File\Uploader::class, ['fileId' => 'image'] ); $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']); /** @var \Magento\Framework\Image\Adapter\AdapterInterface $imageAdapter */ - $imageAdapter = $this->_objectManager->get('Magento\Framework\Image\AdapterFactory')->create(); + $imageAdapter = $this->_objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create(); $uploader->addValidateCallback('catalog_product_image', $imageAdapter, 'validateUploadFile'); $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(true); /** @var \Magento\Framework\Filesystem\Directory\Read $mediaDirectory */ - $mediaDirectory = $this->_objectManager->get('Magento\Framework\Filesystem') + $mediaDirectory = $this->_objectManager->get(\Magento\Framework\Filesystem::class) ->getDirectoryRead(DirectoryList::MEDIA); - $config = $this->_objectManager->get('Magento\Catalog\Model\Product\Media\Config'); + $config = $this->_objectManager->get(\Magento\Catalog\Model\Product\Media\Config::class); $result = $uploader->save($mediaDirectory->getAbsolutePath($config->getBaseTmpMediaPath())); $this->_eventManager->dispatch( @@ -64,7 +64,7 @@ public function execute() unset($result['tmp_name']); unset($result['path']); - $result['url'] = $this->_objectManager->get('Magento\Catalog\Model\Product\Media\Config') + $result['url'] = $this->_objectManager->get(\Magento\Catalog\Model\Product\Media\Config::class) ->getTmpMediaUrl($result['file']); $result['file'] = $result['file'] . '.tmp'; } catch (\Exception $e) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group/Save.php index 5557bcc72a0d3..643d00ca66d55 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group/Save.php @@ -20,7 +20,7 @@ class Save extends \Magento\Backend\App\Action */ public function execute() { - $model = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Group'); + $model = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Group::class); $model->setAttributeGroupName( $this->getRequest()->getParam('attribute_group_name') diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index 12ca8aa4e5e95..47d86cd0cd680 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -330,7 +330,7 @@ private function getCustomOptionFactory() { if (null === $this->customOptionFactory) { $this->customOptionFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory'); + ->get(\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory::class); } return $this->customOptionFactory; } @@ -342,7 +342,7 @@ private function getProductLinkFactory() { if (null === $this->productLinkFactory) { $this->productLinkFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\Data\ProductLinkInterfaceFactory'); + ->get(\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory::class); } return $this->productLinkFactory; } @@ -354,7 +354,7 @@ private function getProductRepository() { if (null === $this->productRepository) { $this->productRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\ProductRepositoryInterface\Proxy'); + ->get(\Magento\Catalog\Api\ProductRepositoryInterface\Proxy::class); } return $this->productRepository; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactory.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactory.php index 09d324bc1d5aa..f282df484b076 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactory.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactory.php @@ -34,13 +34,13 @@ public function create($instance, array $arguments = []) { if (!is_subclass_of( $instance, - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface' + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class ) ) { throw new \InvalidArgumentException( $instance . ' does not implement ' . - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface' + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class ); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php index 1f3345ee2f807..6dae249865157 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php @@ -12,6 +12,9 @@ use Magento\Ui\Component\MassAction\Filter; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MassStatus extends \Magento\Catalog\Controller\Adminhtml\Product { /** @@ -62,7 +65,7 @@ public function __construct( public function _validateMassStatus(array $productIds, $status) { if ($status == \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) { - if (!$this->_objectManager->create('Magento\Catalog\Model\Product')->isProductsHasSku($productIds)) { + if (!$this->_objectManager->create(\Magento\Catalog\Model\Product::class)->isProductsHasSku($productIds)) { throw new \Magento\Framework\Exception\LocalizedException( __('Please make sure to define SKU values for all processed products.') ); @@ -84,7 +87,7 @@ public function execute() try { $this->_validateMassStatus($productIds, $status); - $this->_objectManager->get('Magento\Catalog\Model\Product\Action') + $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class) ->updateAttributes($productIds, ['status' => $status], $storeId); $this->messageManager->addSuccess(__('A total of %1 record(s) have been updated.', count($productIds))); $this->_productPriceIndexerProcessor->reindexList($productIds); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php index 56a26da63e469..44bc94182f670 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php @@ -125,8 +125,12 @@ public function execute() $this->messageManager->addNotice( __( 'SKU for product %1 has been changed to %2.', - $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($product->getName()), - $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($product->getSku()) + $this->_objectManager->get( + \Magento\Framework\Escaper::class + )->escapeHtml($product->getName()), + $this->_objectManager->get( + \Magento\Framework\Escaper::class + )->escapeHtml($product->getSku()) ) ); } @@ -145,7 +149,7 @@ public function execute() $this->getDataPersistor()->set('catalog_product', $data); $redirectBack = $productId ? true : 'new'; } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addError($e->getMessage()); $this->_session->setProductData($data); $this->getDataPersistor()->set('catalog_product', $data); @@ -224,7 +228,7 @@ protected function copyToStores($data, $productId) $copyFrom = (isset($store['copy_from'])) ? $store['copy_from'] : 0; $copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0; if ($copyTo) { - $this->_objectManager->create('Magento\Catalog\Model\Product') + $this->_objectManager->create(\Magento\Catalog\Model\Product::class) ->setStoreId($copyFrom) ->load($productId) ->setStoreId($copyTo) @@ -244,7 +248,7 @@ private function getCategoryLinkManagement() { if (null === $this->categoryLinkManagement) { $this->categoryLinkManagement = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\CategoryLinkManagementInterface'); + ->get(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); } return $this->categoryLinkManagement; } @@ -257,7 +261,7 @@ private function getStoreManager() { if (null === $this->storeManager) { $this->storeManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Store\Model\StoreManagerInterface'); + ->get(\Magento\Store\Model\StoreManagerInterface::class); } return $this->storeManager; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php index 72d6e98a7adbf..a5da975c6aa50 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php @@ -45,7 +45,7 @@ protected function _setTypeId() { $this->_coreRegistry->register( 'entityType', - $this->_objectManager->create('Magento\Catalog\Model\Product')->getResource()->getTypeId() + $this->_objectManager->create(\Magento\Catalog\Model\Product::class)->getResource()->getTypeId() ); } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Add.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Add.php index 56f409c5f999e..48f5126f2ce60 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Add.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Add.php @@ -39,7 +39,9 @@ public function execute() $resultPage->setActiveMenu('Magento_Catalog::catalog_attributes_sets'); $resultPage->getConfig()->getTitle()->prepend(__('New Attribute Set')); $resultPage->addContent( - $resultPage->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Toolbar\Add') + $resultPage->getLayout()->createBlock( + \Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Toolbar\Add::class + ) ); return $resultPage; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php index 6e293c783971a..10b263bee33dd 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php @@ -33,7 +33,7 @@ public function __construct( public function execute() { $this->_setTypeId(); - $attributeSet = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') + $attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) ->load($this->getRequest()->getParam('id')); if (!$attributeSet->getId()) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php index a8c82d538b7d6..c984840e2067d 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php @@ -65,11 +65,11 @@ public function execute() $isNewSet = $this->getRequest()->getParam('gotoEdit', false) == '1'; /* @var $model \Magento\Eav\Model\Entity\Attribute\Set */ - $model = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') + $model = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) ->setEntityTypeId($entityTypeId); /** @var $filterManager \Magento\Framework\Filter\FilterManager */ - $filterManager = $this->_objectManager->get('Magento\Framework\Filter\FilterManager'); + $filterManager = $this->_objectManager->get(\Magento\Framework\Filter\FilterManager::class); try { if ($isNewSet) { @@ -85,7 +85,7 @@ public function execute() __('This attribute set no longer exists.') ); } - $data = $this->_objectManager->get('Magento\Framework\Json\Helper\Data') + $data = $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class) ->jsonDecode($this->getRequest()->getPost('data')); //filter html tags diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php index e3e474db01b2c..08369f7642a0a 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php @@ -50,7 +50,7 @@ public function execute() $resultJson = $this->resultJsonFactory->create(); $resultJson->setData( $this->layoutFactory->create() - ->createBlock('Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Search') + ->createBlock(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Search::class) ->getSuggestedAttributes($this->getRequest()->getParam('label_part')) ); return $resultJson; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php index 1938bec01b039..ca15faa99076f 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php @@ -153,7 +153,7 @@ private function getStoreManager() { if (null === $this->storeManager) { $this->storeManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Store\Model\StoreManagerInterface'); + ->get(\Magento\Store\Model\StoreManagerInterface::class); } return $this->storeManager; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget/Chooser.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget/Chooser.php index 8036ac1b146be..b1281c8b03d7b 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget/Chooser.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget/Chooser.php @@ -46,7 +46,7 @@ public function execute() $layout = $this->layoutFactory->create(); $productsGrid = $layout->createBlock( - 'Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser', + \Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser::class, '', [ 'data' => [ @@ -62,7 +62,7 @@ public function execute() if (!$this->getRequest()->getParam('products_grid')) { $categoriesTree = $layout->createBlock( - 'Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser', + \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser::class, '', [ 'data' => [ @@ -73,7 +73,7 @@ public function execute() ] ); - $html = $layout->createBlock('Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser\Container') + $html = $layout->createBlock(\Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser\Container::class) ->setTreeHtml($categoriesTree->toHtml()) ->setGridHtml($html) ->toHtml(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php index 0938374693fd9..3abc4f43ed590 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php @@ -44,21 +44,22 @@ public function execute() { $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); - $storeMediaUrl = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') + $storeMediaUrl = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class) ->getStore($storeId) ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); - $content = $this->layoutFactory->create()->createBlock( - 'Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg\Content', - '', - [ - 'data' => [ - 'editor_element_id' => $elementId, - 'store_id' => $storeId, - 'store_media_url' => $storeMediaUrl, + $content = $this->layoutFactory->create() + ->createBlock( + \Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg\Content::class, + '', + [ + 'data' => [ + 'editor_element_id' => $elementId, + 'store_id' => $storeId, + 'store_media_url' => $storeMediaUrl, + ] ] - ] - ); + ); /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultRawFactory->create(); diff --git a/app/code/Magento/Catalog/Controller/Category/View.php b/app/code/Magento/Catalog/Controller/Category/View.php index af67087d39cc1..9cdb6cc99d3aa 100644 --- a/app/code/Magento/Catalog/Controller/Category/View.php +++ b/app/code/Magento/Catalog/Controller/Category/View.php @@ -125,7 +125,7 @@ protected function _initCategory() } catch (NoSuchEntityException $e) { return false; } - if (!$this->_objectManager->get('Magento\Catalog\Helper\Category')->canShow($category)) { + if (!$this->_objectManager->get(\Magento\Catalog\Helper\Category::class)->canShow($category)) { return false; } $this->_catalogSession->setLastVisitedCategoryId($category->getId()); @@ -136,7 +136,7 @@ protected function _initCategory() ['category' => $category, 'controller_action' => $this] ); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); return false; } diff --git a/app/code/Magento/Catalog/Controller/Product.php b/app/code/Magento/Catalog/Controller/Product.php index a27783be62804..215976917e678 100644 --- a/app/code/Magento/Catalog/Controller/Product.php +++ b/app/code/Magento/Catalog/Controller/Product.php @@ -26,7 +26,7 @@ protected function _initProduct() $params->setCategoryId($categoryId); /** @var \Magento\Catalog\Helper\Product $product */ - $product = $this->_objectManager->get('Magento\Catalog\Helper\Product'); + $product = $this->_objectManager->get(\Magento\Catalog\Helper\Product::class); return $product->initProduct($productId, $this, $params); } } diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php index 66d53773a130e..d9a257273e139 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php @@ -33,12 +33,14 @@ public function execute() if ($product) { $this->_catalogProductCompareList->addProduct($product); - $productName = $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($product->getName()); + $productName = $this->_objectManager->get( + \Magento\Framework\Escaper::class + )->escapeHtml($product->getName()); $this->messageManager->addSuccess(__('You added product %1 to the comparison list.', $productName)); $this->_eventManager->dispatch('catalog_product_compare_add_product', ['product' => $product]); } - $this->_objectManager->get('Magento\Catalog\Helper\Product\Compare')->calculate(); + $this->_objectManager->get(\Magento\Catalog\Helper\Product\Compare::class)->calculate(); } return $resultRedirect->setRefererOrBaseUrl(); } diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php b/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php index 0f94314be90ec..8ca75e9ba5e70 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php @@ -31,7 +31,7 @@ public function execute() try { $items->clear(); $this->messageManager->addSuccess(__('You cleared the comparison list.')); - $this->_objectManager->get('Magento\Catalog\Helper\Product\Compare')->calculate(); + $this->_objectManager->get(\Magento\Catalog\Helper\Product\Compare::class)->calculate(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php index 2bbe4b1329e1a..fb17d7c83dd81 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php @@ -39,10 +39,10 @@ public function execute() $item->loadByProduct($product); /** @var $helper \Magento\Catalog\Helper\Product\Compare */ - $helper = $this->_objectManager->get('Magento\Catalog\Helper\Product\Compare'); + $helper = $this->_objectManager->get(\Magento\Catalog\Helper\Product\Compare::class); if ($item->getId()) { $item->delete(); - $productName = $this->_objectManager->get('Magento\Framework\Escaper') + $productName = $this->_objectManager->get(\Magento\Framework\Escaper::class) ->escapeHtml($product->getName()); $this->messageManager->addSuccess( __('You removed product %1 from the comparison list.', $productName) diff --git a/app/code/Magento/Catalog/Controller/Product/View.php b/app/code/Magento/Catalog/Controller/Product/View.php index 44036f719daae..4b602bd24b398 100644 --- a/app/code/Magento/Catalog/Controller/Product/View.php +++ b/app/code/Magento/Catalog/Controller/Product/View.php @@ -87,7 +87,7 @@ public function execute() } if ($this->getRequest()->isAjax()) { $this->getResponse()->representJson( - $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode([ + $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonEncode([ 'backUrl' => $this->_redirect->getRedirectUrl() ]) ); @@ -111,7 +111,7 @@ public function execute() } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { return $this->noProductRedirect(); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php index ae0dbbc16b0a7..7d44bfadc9db5 100644 --- a/app/code/Magento/Catalog/Helper/Product.php +++ b/app/code/Magento/Catalog/Helper/Product.php @@ -338,8 +338,8 @@ public function getAttributeInputTypes($inputType = null) * @todo specify there all relations for properties depending on input type */ $inputTypes = [ - 'multiselect' => ['backend_model' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend'], - 'boolean' => ['source_model' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean'], + 'multiselect' => ['backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class], + 'boolean' => ['source_model' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class], ]; if ($inputType === null) { diff --git a/app/code/Magento/Catalog/Helper/Product/ConfigurationPool.php b/app/code/Magento/Catalog/Helper/Product/ConfigurationPool.php index 73fe1e879a102..e8bcecbd7311d 100644 --- a/app/code/Magento/Catalog/Helper/Product/ConfigurationPool.php +++ b/app/code/Magento/Catalog/Helper/Product/ConfigurationPool.php @@ -47,7 +47,7 @@ public function get($className) ) { throw new \LogicException( "{$className} doesn't implement " . - "\\Magento\\Catalog\\Helper\\Product\\Configuration\\ConfigurationInterface" + \Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface::class ); } $this->_instances[$className] = $helperInstance; diff --git a/app/code/Magento/Catalog/Model/AbstractModel.php b/app/code/Magento/Catalog/Model/AbstractModel.php index 4eaa949b7d78f..40188c4efc9df 100644 --- a/app/code/Magento/Catalog/Model/AbstractModel.php +++ b/app/code/Magento/Catalog/Model/AbstractModel.php @@ -302,7 +302,7 @@ private function getAttributeScopeOverriddenValue() { if ($this->scopeOverriddenValue === null) { $this->scopeOverriddenValue = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Attribute\ScopeOverriddenValue'); + ->get(\Magento\Catalog\Model\Attribute\ScopeOverriddenValue::class); } return $this->scopeOverriddenValue; } diff --git a/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php b/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php index 84bc19f70cdb2..96b77ae923e19 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php +++ b/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php @@ -36,7 +36,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'catalog_attributes.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php b/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php index 455d32cac9ddc..3226182590e90 100644 --- a/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php +++ b/app/code/Magento/Catalog/Model/Attribute/LockValidatorComposite.php @@ -22,7 +22,7 @@ class LockValidatorComposite implements LockValidatorInterface public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, array $validators = []) { foreach ($validators as $validator) { - if (!is_subclass_of($validator, 'Magento\Catalog\Model\Attribute\LockValidatorInterface')) { + if (!is_subclass_of($validator, \Magento\Catalog\Model\Attribute\LockValidatorInterface::class)) { throw new \InvalidArgumentException($validator . ' does not implements LockValidatorInterface'); } $this->validators[] = $objectManager->get($validator); diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 7e0507545c65a..b1f9dbf8c327a 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -306,10 +306,10 @@ protected function _construct() { // If Flat Index enabled then use it but only on frontend if ($this->flatState->isAvailable()) { - $this->_init('Magento\Catalog\Model\ResourceModel\Category\Flat'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Category\Flat::class); $this->_useFlatResource = true; } else { - $this->_init('Magento\Catalog\Model\ResourceModel\Category'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Category::class); } } diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php index 6c114089789c6..cb45ef3f01192 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php @@ -80,7 +80,7 @@ private function getImageUploader() { if ($this->imageUploader === null) { $this->imageUploader = \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Catalog\CategoryImageUpload' + \Magento\Catalog\CategoryImageUpload::class ); } return $this->imageUploader; diff --git a/app/code/Magento/Catalog/Model/CategoryLinkManagement.php b/app/code/Magento/Catalog/Model/CategoryLinkManagement.php index da6901ec88d13..8df6a7d5a14d9 100644 --- a/app/code/Magento/Catalog/Model/CategoryLinkManagement.php +++ b/app/code/Magento/Catalog/Model/CategoryLinkManagement.php @@ -120,7 +120,7 @@ private function getProductRepository() { if (null === $this->productRepository) { $this->productRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\ProductRepositoryInterface'); + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); } return $this->productRepository; } @@ -134,7 +134,7 @@ private function getProductResource() { if (null === $this->productResource) { $this->productResource = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\ResourceModel\Product'); + ->get(\Magento\Catalog\Model\ResourceModel\Product::class); } return $this->productResource; } @@ -148,7 +148,7 @@ private function getCategoryLinkRepository() { if (null === $this->categoryLinkRepository) { $this->categoryLinkRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\CategoryLinkRepositoryInterface'); + ->get(\Magento\Catalog\Api\CategoryLinkRepositoryInterface::class); } return $this->categoryLinkRepository; } @@ -162,7 +162,7 @@ private function getIndexerRegistry() { if (null === $this->indexerRegistry) { $this->indexerRegistry = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\Indexer\IndexerRegistry'); + ->get(\Magento\Framework\Indexer\IndexerRegistry::class); } return $this->indexerRegistry; } diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index 7d4a74176a4f6..1bbce76a53dd7 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -76,7 +76,7 @@ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category) { $storeId = (int)$this->storeManager->getStore()->getId(); $existingData = $this->getExtensibleDataObjectConverter() - ->toNestedArray($category, [], 'Magento\Catalog\Api\Data\CategoryInterface'); + ->toNestedArray($category, [], \Magento\Catalog\Api\Data\CategoryInterface::class); $existingData = array_diff_key($existingData, array_flip(['path', 'level', 'parent_id'])); $existingData['store_id'] = $storeId; @@ -209,7 +209,7 @@ private function getExtensibleDataObjectConverter() { if ($this->extensibleDataObjectConverter === null) { $this->extensibleDataObjectConverter = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\Api\ExtensibleDataObjectConverter'); + ->get(\Magento\Framework\Api\ExtensibleDataObjectConverter::class); } return $this->extensibleDataObjectConverter; } @@ -221,7 +221,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php index 3f8c916112ade..dec29a925cc4d 100644 --- a/app/code/Magento/Catalog/Model/Config.php +++ b/app/code/Magento/Catalog/Model/Config.php @@ -167,7 +167,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Config'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Config::class); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php index 377eb63110404..b7ba356746269 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php @@ -473,7 +473,7 @@ private function getCategoryMetadata() { if (null === $this->categoryMetadata) { $metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); $this->categoryMetadata = $metadataPool->getMetadata(\Magento\Catalog\Api\Data\CategoryInterface::class); } return $this->categoryMetadata; @@ -486,7 +486,7 @@ private function getSkipStaticColumns() { if (null === $this->skipStaticColumns) { $provider = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Indexer\Category\Flat\SkipStaticColumnsProvider'); + ->get(\Magento\Catalog\Model\Indexer\Category\Flat\SkipStaticColumnsProvider::class); $this->skipStaticColumns = $provider->get(); } return $this->skipStaticColumns; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php index 03e733938dda8..f0443fbb2ce87 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php @@ -634,7 +634,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/RowsFactory.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/RowsFactory.php index df09856ad86e6..9ec8b69336229 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/RowsFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/RowsFactory.php @@ -32,7 +32,7 @@ class RowsFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Catalog\Model\Indexer\Category\Product\Action\Rows' + $instanceName = \Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class ) { $this->objectManager = $objectManager; $this->instanceName = $instanceName; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/RowsFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/RowsFactory.php index 7cb854531e5d5..a1540d21df869 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/RowsFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/RowsFactory.php @@ -18,7 +18,7 @@ class RowsFactory extends \Magento\Catalog\Model\Indexer\Category\Product\Action */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Catalog\Model\Indexer\Product\Category\Action\Rows' + $instanceName = \Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class ) { parent::__construct($objectManager, $instanceName); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php index a4607fa55176c..dae7a1bc6745b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php @@ -341,7 +341,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Indexer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Indexer.php index 9e829d42a7765..607c73e1ca4b5 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Indexer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Indexer.php @@ -186,7 +186,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php index c302ed823f898..0036b3b2ab54a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php @@ -371,7 +371,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php index 9cd9a0724f042..fdc405b27d3fd 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php @@ -340,7 +340,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php b/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php index cd027ccc4e125..8b00012dd7d37 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php +++ b/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php @@ -44,7 +44,7 @@ public function getList() { /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection */ $collection = $this->collectionFactory->create(); - $collection->setItemObjectClass('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + $collection->setItemObjectClass(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->addStoreLabel($this->storeManager->getStore()->getId()) ->setOrder('position', 'ASC'); $collection = $this->_prepareAttributeCollection($collection); diff --git a/app/code/Magento/Catalog/Model/Layer/FilterList.php b/app/code/Magento/Catalog/Model/Layer/FilterList.php index 3113bd687eafd..04179bc19c085 100644 --- a/app/code/Magento/Catalog/Model/Layer/FilterList.php +++ b/app/code/Magento/Catalog/Model/Layer/FilterList.php @@ -30,10 +30,10 @@ class FilterList * @var string[] */ protected $filterTypes = [ - self::CATEGORY_FILTER => 'Magento\Catalog\Model\Layer\Filter\Category', - self::ATTRIBUTE_FILTER => 'Magento\Catalog\Model\Layer\Filter\Attribute', - self::PRICE_FILTER => 'Magento\Catalog\Model\Layer\Filter\Price', - self::DECIMAL_FILTER => 'Magento\Catalog\Model\Layer\Filter\Decimal', + self::CATEGORY_FILTER => \Magento\Catalog\Model\Layer\Filter\Category::class, + self::ATTRIBUTE_FILTER => \Magento\Catalog\Model\Layer\Filter\Attribute::class, + self::PRICE_FILTER => \Magento\Catalog\Model\Layer\Filter\Price::class, + self::DECIMAL_FILTER => \Magento\Catalog\Model\Layer\Filter\Decimal::class, ]; /** diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index d1f91a90e105c..f324f8e6845a3 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -477,7 +477,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product::class); } /** @@ -1806,7 +1806,7 @@ public function fromArray(array $data) $this->dataObjectHelper->populateWithArray( $stockItem, $data['stock_item'], - '\Magento\CatalogInventory\Api\Data\StockItemInterface' + \Magento\CatalogInventory\Api\Data\StockItemInterface::class ); $stockItem->setProduct($this); $this->setStockItem($stockItem); @@ -2481,7 +2481,7 @@ public function getExtensionAttributes() { $extensionAttributes = $this->_getExtensionAttributes(); if (!$extensionAttributes) { - return $this->extensionAttributesFactory->create('Magento\Catalog\Api\Data\ProductInterface'); + return $this->extensionAttributesFactory->create(\Magento\Catalog\Api\Data\ProductInterface::class); } return $extensionAttributes; } @@ -2593,7 +2593,7 @@ private function getLinkRepository() { if (null === $this->linkRepository) { $this->linkRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\ProductLinkRepositoryInterface'); + ->get(\Magento\Catalog\Api\ProductLinkRepositoryInterface::class); } return $this->linkRepository; } @@ -2605,7 +2605,7 @@ private function getMediaGalleryProcessor() { if (null === $this->mediaGalleryProcessor) { $this->mediaGalleryProcessor = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\Gallery\Processor'); + ->get(\Magento\Catalog\Model\Product\Gallery\Processor::class); } return $this->mediaGalleryProcessor; } diff --git a/app/code/Magento/Catalog/Model/Product/Action.php b/app/code/Magento/Catalog/Model/Product/Action.php index f1d9fea22e707..45194cbee0261 100644 --- a/app/code/Magento/Catalog/Model/Product/Action.php +++ b/app/code/Magento/Catalog/Model/Product/Action.php @@ -71,7 +71,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product\Action'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Action::class); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php index 56577d603c34d..d104dc2ab687f 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php @@ -469,7 +469,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media/ImageEntryConverter.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media/ImageEntryConverter.php index 243db55837e77..847c93a2d78ed 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media/ImageEntryConverter.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media/ImageEntryConverter.php @@ -66,7 +66,7 @@ public function convertTo(Product $product, array $rowData) $this->dataObjectHelper->populateWithArray( $entry, $image, - '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface' + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class ); if (isset($image['value_id'])) { $entry->setId($image['value_id']); diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php index 3d5e49985d27b..a41a89a4ac9f7 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php @@ -265,7 +265,7 @@ private function getOptionManagement() { if (null === $this->optionManagement) { $this->optionManagement = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\ProductAttributeOptionManagementInterface'); + ->get(\Magento\Catalog\Api\ProductAttributeOptionManagementInterface::class); } return $this->optionManagement; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/TypesList.php b/app/code/Magento/Catalog/Model/Product/Attribute/TypesList.php index a6ae0e73ad60b..8f18df4f82f85 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/TypesList.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/TypesList.php @@ -51,7 +51,7 @@ public function getItems() $this->dataObjectHelper->populateWithArray( $type, $option, - '\Magento\Catalog\Api\Data\ProductAttributeTypeInterface' + \Magento\Catalog\Api\Data\ProductAttributeTypeInterface::class ); $types[] = $type; } diff --git a/app/code/Magento/Catalog/Model/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Product/Compare/Item.php index 92fb352ff433a..9e3d2bcdd4645 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/Item.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/Item.php @@ -105,7 +105,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product\Compare\Item'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Compare\Item::class); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Copier.php b/app/code/Magento/Catalog/Model/Product/Copier.php index 129d8c0850db8..4a0bd3de26ecd 100644 --- a/app/code/Magento/Catalog/Model/Product/Copier.php +++ b/app/code/Magento/Catalog/Model/Product/Copier.php @@ -86,7 +86,7 @@ private function getOptionRepository() { if (null === $this->optionRepository) { $this->optionRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\Option\Repository'); + ->get(\Magento\Catalog\Model\Product\Option\Repository::class); } return $this->optionRepository; } diff --git a/app/code/Magento/Catalog/Model/Product/CopyConstructorFactory.php b/app/code/Magento/Catalog/Model/Product/CopyConstructorFactory.php index 7ab4add447c7b..ae32a63c0a57e 100644 --- a/app/code/Magento/Catalog/Model/Product/CopyConstructorFactory.php +++ b/app/code/Magento/Catalog/Model/Product/CopyConstructorFactory.php @@ -30,7 +30,7 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create($instance, array $arguments = []) { - if (!is_subclass_of($instance, '\Magento\Catalog\Model\Product\CopyConstructorInterface')) { + if (!is_subclass_of($instance, \Magento\Catalog\Model\Product\CopyConstructorInterface::class)) { throw new \InvalidArgumentException( $instance . ' does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface' ); diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php index 527caa14c8b97..f520292fabc75 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php @@ -75,7 +75,7 @@ public function __construct( \Magento\Framework\Filesystem $filesystem, \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb ) { - $this->metadata = $metadataPool->getMetadata('Magento\Catalog\Api\Data\ProductInterface'); + $this->metadata = $metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); $this->attributeRepository = $attributeRepository; $this->resourceModel = $resourceModel; $this->jsonHelper = $jsonHelper; @@ -194,7 +194,7 @@ public function getAttribute() { if (!$this->attribute) { $this->attribute = $this->attributeRepository->get( - 'media_gallery' + \media_gallery::class ); } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php index 05efbfa15579c..3c757f8a05a2d 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php @@ -72,9 +72,7 @@ public function __construct( public function getAttribute() { if (!$this->attribute) { - $this->attribute = $this->attributeRepository->get( - 'media_gallery' - ); + $this->attribute = $this->attributeRepository->get('media_gallery'); } return $this->attribute; diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php b/app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php index 7b0355f5e2e21..251a004f491d9 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php @@ -82,9 +82,7 @@ public function execute($entityType, $entity, $arguments = []) public function getAttribute() { if (!$this->attribute) { - $this->attribute = $this->attributeRepository->get( - 'media_gallery' - ); + $this->attribute = $this->attributeRepository->get('media_gallery'); } return $this->attribute; diff --git a/app/code/Magento/Catalog/Model/Product/Link.php b/app/code/Magento/Catalog/Model/Product/Link.php index 00fe7765a1216..40e0ac8f5dfdf 100644 --- a/app/code/Magento/Catalog/Model/Product/Link.php +++ b/app/code/Magento/Catalog/Model/Product/Link.php @@ -93,7 +93,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product\Link'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Link::class); } /** @@ -191,7 +191,7 @@ private function getProductLinkSaveHandler() { if (null === $this->saveProductLinks) { $this->saveProductLinks = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\Link\SaveHandler'); + ->get(\Magento\Catalog\Model\Product\Link\SaveHandler::class); } return $this->saveProductLinks; } diff --git a/app/code/Magento/Catalog/Model/Product/Media/Config.php b/app/code/Magento/Catalog/Model/Product/Media/Config.php index 273a3a53cfc42..75fa1094892cc 100644 --- a/app/code/Magento/Catalog/Model/Product/Media/Config.php +++ b/app/code/Magento/Catalog/Model/Product/Media/Config.php @@ -180,7 +180,7 @@ private function getAttributeHelper() { if (null === $this->attributeHelper) { $this->attributeHelper = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Eav\Model\Entity\Attribute'); + ->get(\Magento\Eav\Model\Entity\Attribute::class); } return $this->attributeHelper; } diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php index cdd318994b924..c17603460c75d 100644 --- a/app/code/Magento/Catalog/Model/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Product/Option.php @@ -187,7 +187,7 @@ protected function _getResource() */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product\Option'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Option::class); parent::_construct(); } @@ -896,7 +896,7 @@ private function getOptionRepository() { if (null === $this->optionRepository) { $this->optionRepository = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\Option\Repository'); + ->get(\Magento\Catalog\Model\Product\Option\Repository::class); } return $this->optionRepository; } @@ -908,7 +908,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Repository.php b/app/code/Magento/Catalog/Model/Product/Option/Repository.php index 385ad1bbbb9e9..3b305d0cb7eeb 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Repository.php @@ -194,7 +194,7 @@ private function getOptionFactory() { if (null === $this->optionFactory) { $this->optionFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\OptionFactory'); + ->get(\Magento\Catalog\Model\Product\OptionFactory::class); } return $this->optionFactory; } @@ -206,7 +206,7 @@ private function getCollectionFactory() { if (null === $this->collectionFactory) { $this->collectionFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory'); + ->get(\Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class); } return $this->collectionFactory; } @@ -218,7 +218,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Product/Option/Value.php index 7a71c67bc5d9c..55a14e2633354 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Value.php @@ -93,7 +93,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product\Option\Value'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Option\Value::class); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Type.php b/app/code/Magento/Catalog/Model/Product/Type.php index 0e97ee183728c..022822a62ae85 100644 --- a/app/code/Magento/Catalog/Model/Product/Type.php +++ b/app/code/Magento/Catalog/Model/Product/Type.php @@ -32,12 +32,12 @@ class Type implements OptionSourceInterface /** * Default product type model */ - const DEFAULT_TYPE_MODEL = 'Magento\Catalog\Model\Product\Type\Simple'; + const DEFAULT_TYPE_MODEL = \Magento\Catalog\Model\Product\Type\Simple::class; /** * Default price model */ - const DEFAULT_PRICE_MODEL = 'Magento\Catalog\Model\Product\Type\Price'; + const DEFAULT_PRICE_MODEL = \Magento\Catalog\Model\Product\Type\Price::class; /** * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface diff --git a/app/code/Magento/Catalog/Model/Product/Website.php b/app/code/Magento/Catalog/Model/Product/Website.php index 84f8f24241047..b7de6cb865873 100644 --- a/app/code/Magento/Catalog/Model/Product/Website.php +++ b/app/code/Magento/Catalog/Model/Product/Website.php @@ -27,7 +27,7 @@ class Website extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Product\Website'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Website::class); } /** diff --git a/app/code/Magento/Catalog/Model/ProductLink/Link.php b/app/code/Magento/Catalog/Model/ProductLink/Link.php index fcd5ab0bf6080..f1953d3e61473 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Link.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Link.php @@ -177,7 +177,7 @@ public function getExtensionAttributes() { if (!$this->_getExtensionAttributes()) { $this->setExtensionAttributes( - $this->extensionAttributesFactory->create('Magento\Catalog\Model\ProductLink\Link') + $this->extensionAttributesFactory->create(\Magento\Catalog\Model\ProductLink\Link::class) ); } return $this->_getExtensionAttributes(); diff --git a/app/code/Magento/Catalog/Model/ProductLink/Repository.php b/app/code/Magento/Catalog/Model/ProductLink/Repository.php index 35d1b605f7200..3af7485169a9e 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Repository.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Repository.php @@ -110,7 +110,7 @@ public function save(\Magento\Catalog\Api\Data\ProductLinkInterface $entity) $links = []; $extensions = $this->dataObjectProcessor->buildOutputDataArray( $entity->getExtensionAttributes(), - 'Magento\Catalog\Api\Data\ProductLinkExtensionInterface' + \Magento\Catalog\Api\Data\ProductLinkExtensionInterface::class ); $extensions = is_array($extensions) ? $extensions : []; $data = $entity->__toArray(); @@ -241,7 +241,7 @@ private function getLinkResource() { if (null === $this->linkResource) { $this->linkResource = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\ResourceModel\Product\Link'); + ->get(\Magento\Catalog\Model\ResourceModel\Product\Link::class); } return $this->linkResource; } @@ -253,7 +253,7 @@ private function getLinkTypeProvider() { if (null === $this->linkTypeProvider) { $this->linkTypeProvider = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\LinkTypeProvider'); + ->get(\Magento\Catalog\Model\Product\LinkTypeProvider::class); } return $this->linkTypeProvider; } @@ -265,7 +265,7 @@ private function getProductLinkFactory() { if (null === $this->productLinkFactory) { $this->productLinkFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\Data\ProductLinkInterfaceFactory'); + ->get(\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory::class); } return $this->productLinkFactory; } @@ -277,7 +277,7 @@ private function getProductLinkExtensionFactory() { if (null === $this->productLinkExtensionFactory) { $this->productLinkExtensionFactory = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Api\Data\ProductLinkExtensionFactory'); + ->get(\Magento\Catalog\Api\Data\ProductLinkExtensionFactory::class); } return $this->productLinkExtensionFactory; } @@ -289,7 +289,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/ProductOptions/Config/Reader.php b/app/code/Magento/Catalog/Model/ProductOptions/Config/Reader.php index 036661c01003e..e67fe845b25e1 100644 --- a/app/code/Magento/Catalog/Model/ProductOptions/Config/Reader.php +++ b/app/code/Magento/Catalog/Model/ProductOptions/Config/Reader.php @@ -31,7 +31,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'product_options.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 501a511c2fae3..29515c00d3c86 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -400,7 +400,7 @@ private function processLinks(\Magento\Catalog\Api\Data\ProductInterface $produc $linksToInitialize = []; foreach ($linksByType as $link) { $linkDataArray = $this->extensibleDataObjectConverter - ->toNestedArray($link, [], 'Magento\Catalog\Api\Data\ProductLinkInterface'); + ->toNestedArray($link, [], \Magento\Catalog\Api\Data\ProductLinkInterface::class); $linkedSku = $link->getLinkedProductSku(); if (!isset($linkedProductIds[$linkedSku])) { throw new NoSuchEntityException( @@ -501,7 +501,7 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO } $productDataArray = $this->extensibleDataObjectConverter - ->toNestedArray($product, [], 'Magento\Catalog\Api\Data\ProductInterface'); + ->toNestedArray($product, [], \Magento\Catalog\Api\Data\ProductInterface::class); $productDataArray = array_replace($productDataArray, $product->getData()); unset($productDataArray['media_gallery']); @@ -674,7 +674,7 @@ private function getMediaGalleryProcessor() { if (null === $this->mediaGalleryProcessor) { $this->mediaGalleryProcessor = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\Product\Gallery\Processor'); + ->get(\Magento\Catalog\Model\Product\Gallery\Processor::class); } return $this->mediaGalleryProcessor; } diff --git a/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php b/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php index c70511f8d0bdd..2fad0ea8cb79d 100644 --- a/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php +++ b/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php @@ -38,7 +38,7 @@ public function __construct( \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'product_types.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'global' ) { parent::__construct( diff --git a/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php b/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php index 0a7f9c2dd9634..19804ff13653c 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php @@ -54,7 +54,7 @@ public function __construct( */ protected function _getDefaultAttributeModel() { - return 'Magento\Catalog\Model\ResourceModel\Eav\Attribute'; + return \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class; } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php index 84e217a9c9ad4..90807e691c6dd 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php @@ -170,7 +170,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index 28cfe6248d2c0..88c98ae457dfa 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -1033,7 +1033,7 @@ private function getEntityManager() { if (null === $this->entityManager) { $this->entityManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\EntityManager'); + ->get(\Magento\Framework\EntityManager\EntityManager::class); } return $this->entityManager; } @@ -1045,7 +1045,7 @@ private function getAggregateCount() { if (null === $this->aggregateCount) { $this->aggregateCount = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\ResourceModel\Category\AggregateCount'); + ->get(\Magento\Catalog\Model\ResourceModel\Category\AggregateCount::class); } return $this->aggregateCount; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php index a7891bbae5aca..dc24154a98371 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php @@ -63,7 +63,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\Catalog\Model\Category', 'Magento\Catalog\Model\ResourceModel\Category'); + $this->_init(\Magento\Catalog\Model\Category::class, \Magento\Catalog\Model\ResourceModel\Category::class); } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection/Factory.php b/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection/Factory.php index e31ea5bbd119e..25b3b4573eee8 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection/Factory.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category/Collection/Factory.php @@ -31,6 +31,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan */ public function create() { - return $this->_objectManager->create('Magento\Catalog\Model\ResourceModel\Category\Collection'); + return $this->_objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class); } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category/Flat/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Category/Flat/Collection.php index 83c14e1b151bf..2688267c2f4c4 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category/Flat/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category/Flat/Collection.php @@ -77,7 +77,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\Category', 'Magento\Catalog\Model\ResourceModel\Category\Flat'); + $this->_init( + \Magento\Catalog\Model\Category::class, + \Magento\Catalog\Model\ResourceModel\Category\Flat::class + ); } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category/Tree.php b/app/code/Magento/Catalog/Model/ResourceModel/Category/Tree.php index 250970f64c9d7..876d27e4f9473 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category/Tree.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category/Tree.php @@ -683,7 +683,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php index 108d02a69fc7a..bf212c6f9e6d3 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php @@ -164,7 +164,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\ResourceModel\Attribute'); + $this->_init(\Magento\Catalog\Model\ResourceModel\Attribute::class); } /** @@ -193,7 +193,7 @@ public function beforeSave() } if ($this->getFrontendInput() == 'price') { if (!$this->getBackendModel()) { - $this->setBackendModel('Magento\Catalog\Model\Product\Attribute\Backend\Price'); + $this->setBackendModel(\Magento\Catalog\Model\Product\Attribute\Backend\Price::class); } } if ($this->getFrontendInput() == 'textarea') { @@ -405,7 +405,7 @@ public function isAllowedForRuleCondition() */ public function _getDefaultSourceModel() { - return 'Magento\Eav\Model\Entity\Attribute\Source\Table'; + return \Magento\Eav\Model\Entity\Attribute\Source\Table::class; } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product.php b/app/code/Magento/Catalog/Model/ResourceModel/Product.php index c0d81c53e623f..9072bf389351c 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product.php @@ -469,7 +469,7 @@ public function getAvailableInCategories($object) */ public function getDefaultAttributeSourceModel() { - return 'Magento\Eav\Model\Entity\Attribute\Source\Table'; + return \Magento\Eav\Model\Entity\Attribute\Source\Table::class; } /** @@ -702,7 +702,7 @@ private function getEntityManager() { if (null === $this->entityManager) { $this->entityManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\EntityManager'); + ->get(\Magento\Framework\EntityManager\EntityManager::class); } return $this->entityManager; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php index 89a3062dace7b..ad229b45578a1 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php @@ -49,8 +49,8 @@ public function __construct( protected function _construct() { $this->_init( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', - 'Magento\Eav\Model\ResourceModel\Entity\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, + \Magento\Eav\Model\ResourceModel\Entity\Attribute::class ); } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 97aefc3622691..dea590c2a3278 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -430,9 +430,9 @@ public function isEnabledFlat() protected function _construct() { if ($this->isEnabledFlat()) { - $this->_init('Magento\Catalog\Model\Product', 'Magento\Catalog\Model\ResourceModel\Product\Flat'); + $this->_init(\Magento\Catalog\Model\Product::class, \Magento\Catalog\Model\ResourceModel\Product\Flat::class); } else { - $this->_init('Magento\Catalog\Model\Product', 'Magento\Catalog\Model\ResourceModel\Product'); + $this->_init(\Magento\Catalog\Model\Product::class, \Magento\Catalog\Model\ResourceModel\Product::class); } $this->_initTables(); } @@ -448,7 +448,7 @@ protected function _construct() protected function _init($model, $entityModel) { if ($this->isEnabledFlat()) { - $entityModel = 'Magento\Catalog\Model\ResourceModel\Product\Flat'; + $entityModel = \Magento\Catalog\Model\ResourceModel\Product\Flat::class; } return parent::_init($model, $entityModel); } @@ -2269,6 +2269,6 @@ public function getPricesCount() private function createLimitationFilters() { return \Magento\Framework\App\ObjectManager::getInstance() - ->create('Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation'); + ->create(\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class); } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php index 49d32cb99a5f2..9b1985407da4d 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php @@ -133,7 +133,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\Product\Compare\Item', 'Magento\Catalog\Model\ResourceModel\Product'); + $this->_init( + \Magento\Catalog\Model\Product\Compare\Item::class, + \Magento\Catalog\Model\ResourceModel\Product::class + ); $this->_initTables(); } @@ -360,7 +363,7 @@ public function loadComparableAttributes() */ public function useProductItem() { - $this->setObject('Magento\Catalog\Model\Product'); + $this->setObject(\Magento\Catalog\Model\Product::class); $this->setFlag('url_data_object', true); $this->setFlag('do_not_use_category_id', true); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php index 53b65fcb93af7..862a2fa219eea 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php @@ -36,7 +36,7 @@ public function __construct( $connectionName = null ) { $this->metadata = $metadataPool->getMetadata( - 'Magento\Catalog\Api\Data\ProductInterface' + \Magento\Catalog\Api\Data\ProductInterface::class ); parent::__construct($context, $connectionName); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/AbstractIndexer.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/AbstractIndexer.php index ec26ad30157ad..44d9b1c0304a8 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/AbstractIndexer.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/AbstractIndexer.php @@ -236,7 +236,7 @@ protected function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Collection.php index 7f1c3fe0436b4..999d70d808102 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Collection.php @@ -40,7 +40,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Catalog\Model\Product\Link', 'Magento\Catalog\Model\ResourceModel\Product\Link'); + $this->_init( + \Magento\Catalog\Model\Product\Link::class, + \Magento\Catalog\Model\ResourceModel\Product\Link::class + ); } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/SaveHandler.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/SaveHandler.php index e09eac8e9dcce..ad987c6c8b4b3 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/SaveHandler.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/SaveHandler.php @@ -84,7 +84,7 @@ public function execute($entityType, $entity) $links = []; $extensions = $this->dataObjectProcessor->buildOutputDataArray( $entity->getExtensionAttributes(), - 'Magento\Catalog\Api\Data\ProductLinkExtensionInterface' + \Magento\Catalog\Api\Data\ProductLinkExtensionInterface::class ); $extensions = is_array($extensions) ? $extensions : []; $data = $entity->__toArray(); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php index 3d123f276c59e..7b23e5979c8b8 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php @@ -567,7 +567,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Collection.php index ef423acfe7359..2d50ead9d56d9 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Collection.php @@ -73,7 +73,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Catalog\Model\Product\Option', 'Magento\Catalog\Model\ResourceModel\Product\Option'); + $this->_init( + \Magento\Catalog\Model\Product\Option::class, + \Magento\Catalog\Model\ResourceModel\Product\Option::class + ); } /** @@ -322,7 +325,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } @@ -334,7 +337,7 @@ private function getJoinProcessor() { if (null === $this->joinProcessor) { $this->joinProcessor = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface'); + ->get(\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class); } return $this->joinProcessor; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value/Collection.php index 6918bbf1df2a0..0924808a7dcac 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value/Collection.php @@ -20,8 +20,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab protected function _construct() { $this->_init( - 'Magento\Catalog\Model\Product\Option\Value', - 'Magento\Catalog\Model\ResourceModel\Product\Option\Value' + \Magento\Catalog\Model\Product\Option\Value::class, + \Magento\Catalog\Model\ResourceModel\Product\Option\Value::class ); } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Url.php b/app/code/Magento/Catalog/Model/ResourceModel/Url.php index a27375d92d3e8..cc7daa73ea2a6 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Url.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Url.php @@ -703,7 +703,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Setup/CategorySetup.php b/app/code/Magento/Catalog/Setup/CategorySetup.php index e8a7a7a90d29d..80495611656d8 100644 --- a/app/code/Magento/Catalog/Setup/CategorySetup.php +++ b/app/code/Magento/Catalog/Setup/CategorySetup.php @@ -15,6 +15,9 @@ use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Catalog\Model\Product\Type; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CategorySetup extends EavSetup { /** @@ -66,11 +69,12 @@ public function getDefaultEntities() { return [ 'catalog_category' => [ - 'entity_model' => 'Magento\Catalog\Model\ResourceModel\Category', - 'attribute_model' => 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + 'entity_model' => \Magento\Catalog\Model\ResourceModel\Category::class, + 'attribute_model' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, 'table' => 'catalog_category_entity', 'additional_attribute_table' => 'catalog_eav_attribute', - 'entity_attribute_collection' => 'Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection', + 'entity_attribute_collection' => + \Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection::class, 'attributes' => [ 'name' => [ 'type' => 'varchar', @@ -84,7 +88,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Is Active', 'input' => 'select', - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'sort_order' => 2, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', @@ -104,7 +108,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Image', 'input' => 'image', - 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image', + 'backend' => \Magento\Catalog\Model\Category\Attribute\Backend\Image::class, 'required' => false, 'sort_order' => 5, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -141,7 +145,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Display Mode', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Mode', + 'source' => \Magento\Catalog\Model\Category\Attribute\Source\Mode::class, 'required' => false, 'sort_order' => 10, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -151,7 +155,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'CMS Block', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page', + 'source' => \Magento\Catalog\Model\Category\Attribute\Source\Page::class, 'required' => false, 'sort_order' => 20, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -161,7 +165,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Is Anchor', 'input' => 'select', - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'required' => false, 'sort_order' => 30, 'group' => 'Display Settings', @@ -207,7 +211,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Custom Design', 'input' => 'select', - 'source' => 'Magento\Theme\Model\Theme\Source\Theme', + 'source' => \Magento\Theme\Model\Theme\Source\Theme::class, 'required' => false, 'sort_order' => 10, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -217,7 +221,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Active From', 'input' => 'date', - 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', + 'backend' => \Magento\Catalog\Model\Attribute\Backend\Startdate::class, 'required' => false, 'sort_order' => 30, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -227,7 +231,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Active To', 'input' => 'date', - 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', + 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class, 'required' => false, 'sort_order' => 40, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -237,7 +241,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Page Layout', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Layout', + 'source' => \Magento\Catalog\Model\Category\Attribute\Source\Layout::class, 'required' => false, 'sort_order' => 50, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -247,7 +251,7 @@ public function getDefaultEntities() 'type' => 'text', 'label' => 'Custom Layout Update', 'input' => 'textarea', - 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate', + 'backend' => \Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate::class, 'required' => false, 'sort_order' => 60, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -273,10 +277,10 @@ public function getDefaultEntities() 'type' => 'text', 'label' => 'Available Product Listing Sort By', 'input' => 'multiselect', - 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Sortby', - 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Sortby', + 'source' => \Magento\Catalog\Model\Category\Attribute\Source\Sortby::class, + 'backend' => \Magento\Catalog\Model\Category\Attribute\Backend\Sortby::class, 'sort_order' => 40, - 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\Available', + 'input_renderer' => \Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\Available::class, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], @@ -284,10 +288,11 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Default Product Listing Sort By', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Sortby', - 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Sortby', + 'source' => \Magento\Catalog\Model\Category\Attribute\Source\Sortby::class, + 'backend' => \Magento\Catalog\Model\Category\Attribute\Backend\Sortby::class, 'sort_order' => 50, - 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\DefaultSortby', + 'input_renderer' => + \Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\DefaultSortby::class, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], @@ -295,7 +300,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Include in Navigation Menu', 'input' => 'select', - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'default' => '1', 'sort_order' => 10, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -305,7 +310,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Use Parent Category Settings', 'input' => 'select', - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'required' => false, 'sort_order' => 5, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -315,7 +320,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Apply To Products', 'input' => 'select', - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'required' => false, 'sort_order' => 6, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -327,18 +332,19 @@ public function getDefaultEntities() 'input' => 'text', 'required' => false, 'sort_order' => 51, - 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Pricestep', + 'input_renderer' => \Magento\Catalog\Block\Adminhtml\Category\Helper\Pricestep::class, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], ], ], 'catalog_product' => [ - 'entity_model' => 'Magento\Catalog\Model\ResourceModel\Product', - 'attribute_model' => 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + 'entity_model' => \Magento\Catalog\Model\ResourceModel\Product::class, + 'attribute_model' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, 'table' => 'catalog_product_entity', 'additional_attribute_table' => 'catalog_eav_attribute', - 'entity_attribute_collection' => 'Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection', + 'entity_attribute_collection' => + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, 'attributes' => [ 'name' => [ 'type' => 'varchar', @@ -357,7 +363,7 @@ public function getDefaultEntities() 'label' => 'SKU', 'input' => 'text', 'frontend_class' => 'validate-length maximum-length-64', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Sku', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Sku::class, 'unique' => true, 'sort_order' => 2, 'searchable' => true, @@ -396,7 +402,7 @@ public function getDefaultEntities() 'type' => 'decimal', 'label' => 'Price', 'input' => 'price', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Price', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Price::class, 'sort_order' => 1, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'searchable' => true, @@ -411,7 +417,7 @@ public function getDefaultEntities() 'type' => 'decimal', 'label' => 'Special Price', 'input' => 'price', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Price', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Price::class, 'required' => false, 'sort_order' => 3, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, @@ -426,7 +432,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Special Price From Date', 'input' => 'date', - 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', + 'backend' => \Magento\Catalog\Model\Attribute\Backend\Startdate::class, 'required' => false, 'sort_order' => 4, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, @@ -441,7 +447,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Special Price To Date', 'input' => 'date', - 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', + 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class, 'required' => false, 'sort_order' => 5, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, @@ -456,7 +462,7 @@ public function getDefaultEntities() 'type' => 'decimal', 'label' => 'Cost', 'input' => 'price', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Price', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Price::class, 'required' => false, 'user_defined' => true, 'sort_order' => 6, @@ -471,8 +477,8 @@ public function getDefaultEntities() 'type' => 'decimal', 'label' => 'Weight', 'input' => 'weight', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Weight', - 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Weight::class, + 'input_renderer' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight::class, 'sort_order' => 5, 'apply_to' => 'simple,virtual', 'is_used_in_grid' => true, @@ -536,8 +542,8 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Base Image', 'input' => 'media_image', - 'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image', - 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\BaseImage', + 'frontend' => \Magento\Catalog\Model\Product\Attribute\Frontend\Image::class, + 'input_renderer' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\BaseImage::class, 'required' => false, 'sort_order' => 0, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -548,7 +554,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Small Image', 'input' => 'media_image', - 'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image', + 'frontend' => \Magento\Catalog\Model\Product\Attribute\Frontend\Image::class, 'required' => false, 'sort_order' => 2, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -559,7 +565,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Thumbnail', 'input' => 'media_image', - 'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image', + 'frontend' => \Magento\Catalog\Model\Product\Attribute\Frontend\Image::class, 'required' => false, 'sort_order' => 3, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -570,7 +576,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Media Gallery', 'input' => 'gallery', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Media', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Media::class, 'required' => false, 'sort_order' => 4, 'group' => 'Images', @@ -580,7 +586,7 @@ public function getDefaultEntities() 'type' => 'decimal', 'label' => 'Tier Price', 'input' => 'text', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Tierprice', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Tierprice::class, 'required' => false, 'sort_order' => 7, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, @@ -606,7 +612,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Set Product as New from Date', 'input' => 'date', - 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', + 'backend' => \Magento\Catalog\Model\Attribute\Backend\Startdate::class, 'required' => false, 'sort_order' => 7, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, @@ -619,7 +625,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Set Product as New to Date', 'input' => 'date', - 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', + 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class, 'required' => false, 'sort_order' => 8, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, @@ -640,7 +646,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Status', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Status', + 'source' => \Magento\Catalog\Model\Product\Attribute\Source\Status::class, 'sort_order' => 9, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'searchable' => true, @@ -661,7 +667,7 @@ public function getDefaultEntities() 'type' => 'int', 'label' => 'Visibility', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Product\Visibility', + 'source' => \Magento\Catalog\Model\Product\Visibility::class, 'default' => '4', 'sort_order' => 12, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -670,7 +676,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Custom Design', 'input' => 'select', - 'source' => 'Magento\Theme\Model\Theme\Source\Theme', + 'source' => \Magento\Theme\Model\Theme\Source\Theme::class, 'required' => false, 'sort_order' => 1, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -683,7 +689,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Active From', 'input' => 'date', - 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', + 'backend' => \Magento\Catalog\Model\Attribute\Backend\Startdate::class, 'required' => false, 'sort_order' => 2, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -696,7 +702,7 @@ public function getDefaultEntities() 'type' => 'datetime', 'label' => 'Active To', 'input' => 'date', - 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', + 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class, 'required' => false, 'sort_order' => 3, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -709,7 +715,7 @@ public function getDefaultEntities() 'type' => 'text', 'label' => 'Custom Layout Update', 'input' => 'textarea', - 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate', + 'backend' => \Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate::class, 'required' => false, 'sort_order' => 4, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -719,7 +725,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Page Layout', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Layout', + 'source' => \Magento\Catalog\Model\Product\Attribute\Source\Layout::class, 'required' => false, 'sort_order' => 5, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, @@ -732,8 +738,8 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Categories', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Category', - 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Category::class, + 'input_renderer' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category::class, 'required' => false, 'sort_order' => 9, 'visible' => true, @@ -743,7 +749,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Display Product Options In', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Entity\Product\Attribute\Design\Options\Container', + 'source' => \Magento\Catalog\Model\Entity\Product\Attribute\Design\Options\Container::class, 'required' => false, 'default' => 'container2', 'sort_order' => 6, @@ -811,7 +817,7 @@ public function getDefaultEntities() 'type' => 'varchar', 'label' => 'Country of Manufacture', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture', + 'source' => \Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture::class, 'required' => false, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, @@ -830,11 +836,11 @@ public function getDefaultEntities() 'quantity_and_stock_status' => [ 'group' => 'General', 'type' => 'int', - 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Stock', + 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Stock::class, 'label' => 'Quantity', 'input' => 'select', - 'input_renderer' => 'Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock', - 'source' => 'Magento\CatalogInventory\Model\Source\Stock', + 'input_renderer' => \Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock::class, + 'source' => \Magento\CatalogInventory\Model\Source\Stock::class, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'default' => \Magento\CatalogInventory\Model\Stock::STOCK_IN_STOCK, 'user_defined' => false, diff --git a/app/code/Magento/Catalog/Setup/InstallData.php b/app/code/Magento/Catalog/Setup/InstallData.php index baad2c756daf8..de7e6238ff8dd 100644 --- a/app/code/Magento/Catalog/Setup/InstallData.php +++ b/app/code/Magento/Catalog/Setup/InstallData.php @@ -13,6 +13,7 @@ /** * @codeCoverageIgnore + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InstallData implements InstallDataInterface { @@ -281,7 +282,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $newGeneralTabName => 100, 'is_required' => 0, 'default_value' => 1, - 'frontend_input_renderer' => 'Magento\Framework\Data\Form\Element\Hidden', + 'frontend_input_renderer' => \Magento\Framework\Data\Form\Element\Hidden::class, ], //Autosettings tab 'short_description' => [$autosettingsTabName => 0, 'is_required' => 0], @@ -327,13 +328,13 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface \Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); $categorySetup->updateAttribute( \Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'frontend_model', - 'Magento\Eav\Model\Entity\Attribute\Frontend\Datetime' + \Magento\Eav\Model\Entity\Attribute\Frontend\Datetime::class ); } } diff --git a/app/code/Magento/Catalog/Setup/UpgradeData.php b/app/code/Magento/Catalog/Setup/UpgradeData.php index ab32e8c5a6c7d..8500c76a2bc9a 100644 --- a/app/code/Magento/Catalog/Setup/UpgradeData.php +++ b/app/code/Magento/Catalog/Setup/UpgradeData.php @@ -16,6 +16,7 @@ /** * Upgrade Data script * @codeCoverageIgnore + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpgradeData implements UpgradeDataInterface { @@ -92,38 +93,38 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $categorySetup->updateEntityType( \Magento\Catalog\Model\Category::ENTITY, 'entity_model', - 'Magento\Catalog\Model\ResourceModel\Category' + \Magento\Catalog\Model\ResourceModel\Category::class ); $categorySetup->updateEntityType( \Magento\Catalog\Model\Category::ENTITY, 'attribute_model', - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); $categorySetup->updateEntityType( \Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', - 'Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection' + \Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection::class ); $categorySetup->updateAttribute( \Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); $categorySetup->updateEntityType( \Magento\Catalog\Model\Product::ENTITY, 'entity_model', - 'Magento\Catalog\Model\ResourceModel\Product' + \Magento\Catalog\Model\ResourceModel\Product::class ); $categorySetup->updateEntityType( \Magento\Catalog\Model\Product::ENTITY, 'attribute_model', - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); $categorySetup->updateEntityType( \Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', - 'Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class ); } @@ -327,7 +328,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface 'type' => 'varchar', 'label' => 'New Layout', 'input' => 'select', - 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Layout', + 'source' => \Magento\Catalog\Model\Product\Attribute\Source\Layout::class, 'required' => false, 'sort_order' => 50, 'global' => ScopedAttributeInterface::SCOPE_STORE, diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php index afa945f9b4392..cb7d1c20b3356 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php @@ -50,14 +50,15 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->contextMock = $this->getMock( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, [], [], '', false ); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder( + \Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -65,11 +66,13 @@ protected function setUp() ->method('getRequest') ->will($this->returnValue($this->requestMock)); - $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $this->urlBuilderMock = $this->getMockBuilder( + \Magento\Framework\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder( + \Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -77,7 +80,7 @@ protected function setUp() ->method('getStoreManager') ->will($this->returnValue($this->storeManagerMock)); - $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); @@ -86,7 +89,7 @@ protected function setUp() ->will($this->returnValue($this->urlBuilderMock)); $this->category = $this->objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Category\AbstractCategory', + \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory::class, [ 'context' => $this->contextMock, ] diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php index 2fc12ad86502a..6db9a4a24007c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Edit\Tab; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AdvancedTest extends \PHPUnit_Framework_TestCase { /** @@ -45,15 +48,15 @@ class AdvancedTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->registry = $this->getMock('\Magento\Framework\Registry'); - $this->formFactory = $this->getMock('Magento\Framework\Data\FormFactory', [], [], '', false); - $this->yesNo = $this->getMock('Magento\Config\Model\Config\Source\Yesno'); - $this->localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); - $this->eavData = $this->getMock('Magento\Eav\Helper\Data', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->formFactory = $this->getMock(\Magento\Framework\Data\FormFactory::class, [], [], '', false); + $this->yesNo = $this->getMock(\Magento\Config\Model\Config\Source\Yesno::class); + $this->localeDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->eavData = $this->getMock(\Magento\Eav\Helper\Data::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->block = $objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced', + \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced::class, [ 'registry' => $this->registry, 'formFactory' => $this->formFactory, @@ -67,12 +70,12 @@ protected function setUp() public function testToHtml() { - $fieldSet = $this->getMock('Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false); - $form = $this->getMock('Magento\Framework\Data\Form', [], [], '', false); - $attributeModel = $this->getMock('\Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); - $entityType = $this->getMock('Magento\Eav\Model\Entity\Type', [], [], '', false); - $formElement = $this->getMock('Magento\Framework\Data\Form\Element\Text', ['setDisabled'], [], '', false); - $directoryReadInterface = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $fieldSet = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false); + $form = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); + $attributeModel = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); + $entityType = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $formElement = $this->getMock(\Magento\Framework\Data\Form\Element\Text::class, ['setDisabled'], [], '', false); + $directoryReadInterface = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->registry->expects($this->any())->method('registry')->with('entity_attribute') ->willReturn($attributeModel); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php index 16b9c3e12b114..8ea68bee3fdab 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php @@ -9,12 +9,12 @@ class GridTest extends \PHPUnit_Framework_TestCase { public function testGetRowUrl() { - $attribute = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); + $attribute = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); $attribute->expects($this->once())->method('getAttributeId')->will($this->returnValue(2)); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); - $urlBuilder = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); $urlBuilder->expects( $this->once() )->method( @@ -26,7 +26,7 @@ public function testGetRowUrl() $this->returnValue('catalog/product_attribute/edit/id/2') ); - $context = $this->getMock('Magento\Backend\Block\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Backend\Block\Template\Context::class, [], [], '', false); $context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); $context->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem)); @@ -34,7 +34,7 @@ public function testGetRowUrl() $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid $block */ - $block = $helper->getObject('Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid', $data); + $block = $helper->getObject(\Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid::class, $data); $this->assertEquals('catalog/product_attribute/edit/id/2', $block->getRowUrl($attribute)); } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php index 68910097c1cf1..4d575c5bab958 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php @@ -9,6 +9,7 @@ * Test class for \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options * * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OptionsTest extends \PHPUnit_Framework_TestCase { @@ -31,7 +32,7 @@ protected function setUp() { $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_optionResource = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Option', + \Magento\Catalog\Model\ResourceModel\Product\Option::class, [], [], '', @@ -42,18 +43,18 @@ protected function setUp() public function testGetOptionHtml() { $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', 'renderElement'], [], '', false ); $context = $this->_objectHelper->getObject( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, ['layout' => $layout] ); $optionFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Option\ValueFactory', + \Magento\Catalog\Model\Product\Option\ValueFactory::class, ['create'], [], '', @@ -61,11 +62,11 @@ public function testGetOptionHtml() ); $option = $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product\Option', + \Magento\Catalog\Model\Product\Option::class, ['resource' => $this->_optionResource, 'optionValueFactory' => $optionFactoryMock] ); $dateBlock = $this->getMock( - 'Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options', + \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options::class, ['setSkipJsReloadPrice'], ['context' => $context, 'option' => $option], '', @@ -78,33 +79,33 @@ public function testGetOptionHtml() $layout->expects($this->any())->method('renderElement')->with('date', false)->will($this->returnValue('html')); $this->_optionsBlock = $this->_objectHelper->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options', + \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options::class, ['context' => $context, 'option' => $option] ); $itemOptFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Configuration\Item\OptionFactory', + \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory::class, ['create'], [], '', false ); $stockItemFactoryMock = $this->getMock( - 'Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory', + \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class, ['create'], [], '', false ); $productFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ProductFactory', + \Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false ); $categoryFactoryMock = $this->getMock( - 'Magento\Catalog\Model\CategoryFactory', + \Magento\Catalog\Model\CategoryFactory::class, ['create'], [], '', @@ -113,10 +114,10 @@ public function testGetOptionHtml() $this->_optionsBlock->setProduct( $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'collectionFactory' => $this->getMock( - 'Magento\Framework\Data\CollectionFactory', + \Magento\Framework\Data\CollectionFactory::class, [], [], '', @@ -131,7 +132,7 @@ public function testGetOptionHtml() ); $option = $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product\Option', + \Magento\Catalog\Model\Product\Option::class, ['resource' => $this->_optionResource, 'optionValueFactory' => $optionFactoryMock] ); $option->setType('date'); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php index eec28fb80a38e..11a63ad462d47 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php @@ -45,27 +45,27 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->contextMock = $this->getMock( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['getRequest'], [], '', false ); $this->backordersMock = $this->getMock( - 'Magento\CatalogInventory\Model\Source\Backorders', + \Magento\CatalogInventory\Model\Source\Backorders::class, [], [], '', false ); $this->stockConfigurationMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\StockConfigurationInterface', + \Magento\CatalogInventory\Api\StockConfigurationInterface::class, [], '', false ); $this->requestMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, ['getParam'], '', false @@ -76,7 +76,7 @@ protected function setUp() ->will($this->returnValue($this->requestMock)); $this->inventory = $objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab\Inventory', + \Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab\Inventory::class, [ 'context' => $this->contextMock, 'backorders' => $this->backordersMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php index 0be4417e9a7af..10bc4bed16c0e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php @@ -20,10 +20,10 @@ class AlertsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->alerts = $helper->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts', + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts::class, ['scopeConfig' => $this->scopeConfigMock] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php index 3c2520a35b508..632e46d95374f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php @@ -7,6 +7,8 @@ /** * Class InventoryTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InventoryTest extends \PHPUnit_Framework_TestCase { @@ -65,54 +67,54 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->contextMock = $this->getMock( - 'Magento\Backend\Block\Template\Context', + \Magento\Backend\Block\Template\Context::class, ['getRequest', 'getStoreManager'], [], '', false ); $this->stockConfigurationMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\StockConfigurationInterface', + \Magento\CatalogInventory\Api\StockConfigurationInterface::class, [], '', false ); $this->stockRegistryMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\StockRegistryInterface', + \Magento\CatalogInventory\Api\StockRegistryInterface::class, [], '', false ); $this->backordersMock = $this->getMock( - 'Magento\CatalogInventory\Model\Source\Backorders', + \Magento\CatalogInventory\Model\Source\Backorders::class, [], [], '', false ); $this->stockMock = $this->getMock( - 'Magento\CatalogInventory\Model\Source\Stock', + \Magento\CatalogInventory\Model\Source\Stock::class, [], [], '', false ); $this->coreRegistryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, [], [], '', false ); $this->moduleManager = $this->getMock( - 'Magento\Framework\Module\Manager', + \Magento\Framework\Module\Manager::class, [], [], '', false ); $this->storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false @@ -123,7 +125,7 @@ protected function setUp() ->will($this->returnValue($this->storeManagerMock)); $this->inventory = $objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Inventory', + \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Inventory::class, [ 'context' => $this->contextMock, 'backorders' => $this->backordersMock, @@ -210,14 +212,14 @@ public function testGetStockItem() $productId = 10; $websiteId = 15; $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId', 'getStore'], [], '', false ); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', @@ -262,7 +264,7 @@ public function testGetFieldValue($stockId, $methods, $result) $fieldName = 'field'; $stockItemMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\Data\StockItemInterface', + \Magento\CatalogInventory\Api\Data\StockItemInterface::class, [], '', false, @@ -271,14 +273,14 @@ public function testGetFieldValue($stockId, $methods, $result) $methods ); $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', false ); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, [], [], '', @@ -337,7 +339,7 @@ public function testGetConfigFieldValue($stockId, $methods, $result) $fieldName = 'field'; $stockItemMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\Data\StockItemInterface', + \Magento\CatalogInventory\Api\Data\StockItemInterface::class, [], '', false, @@ -346,14 +348,14 @@ public function testGetConfigFieldValue($stockId, $methods, $result) $methods ); $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', false ); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, [], [], '', @@ -419,7 +421,7 @@ public function testGetDefaultConfigValue() public function testIsReadonly() { $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getInventoryReadonly'], [], '', @@ -450,7 +452,7 @@ public function testIsReadonly() public function testIsNew($id, $result) { $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId'], [], '', @@ -487,14 +489,14 @@ public function testGetFieldSuffix() public function testCanUseQtyDecimals() { $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getTypeInstance'], [], '', false ); $typeMock = $this->getMockForAbstractClass( - 'Magento\Catalog\Model\Product\Type\AbstractType', + \Magento\Catalog\Model\Product\Type\AbstractType::class, [], '', false, @@ -525,7 +527,7 @@ public function testCanUseQtyDecimals() public function testIsVirtual() { $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getIsVirtual'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php index ec126f3c4e5a1..c4f600b74d94d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php @@ -19,7 +19,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->authorization = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') + $this->authorization = $this->getMockBuilder(\Magento\Framework\AuthorizationInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -35,7 +35,7 @@ public function testIsAllowed($isAllowed) ->method('isAllowed') ->will($this->returnValue($isAllowed)); $model = $this->objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category', + \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category::class, ['authorization' => $this->authorization] ); switch ($isAllowed) { @@ -61,7 +61,7 @@ public function isAllowedDataProvider() public function testGetAfterElementHtml() { $model = $this->objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category', + \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category::class, ['authorization' => $this->authorization] ); $this->authorization->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php index 72a25933efa0b..3ff1108454376 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php @@ -47,23 +47,23 @@ class ContentTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fileSystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->readMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadInterface'); + $this->fileSystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->readMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->galleryMock = $this->getMock( - 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery', + \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery::class, [], [], '', false ); - $this->mediaConfigMock = $this->getMock('Magento\Catalog\Model\Product\Media\Config', [], [], '', false); - $this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->mediaConfigMock = $this->getMock(\Magento\Catalog\Model\Product\Media\Config::class, [], [], '', false); + $this->jsonEncoderMock = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->content = $this->objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content', + \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content::class, [ 'mediaConfig' => $this->mediaConfigMock, 'jsonEncoder' => $this->jsonEncoderMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php index 044b2470d9366..03e6c36a14aa0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php @@ -34,13 +34,13 @@ class GalleryTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', ['getData'], [], '', false); - $this->formMock = $this->getMock('Magento\Framework\Data\Form', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, ['getData'], [], '', false); + $this->formMock = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->gallery = $this->objectManager->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery', + \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery::class, [ 'registry' => $this->registryMock, 'form' => $this->formMock @@ -81,7 +81,7 @@ public function testGetAttributeFieldName() { $name = 'product[image]'; - $attribute = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); + $attribute = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); $attribute->expects($this->once())->method('getAttributeCode')->willReturn('image'); $this->formMock->expects($this->once())->method('addSuffixToName')->willReturn($name); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php index 1009389e4240c..0cf30adb6c8fa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php @@ -38,7 +38,7 @@ protected function setUp() $this->markTestSkipped('MAGETWO-43290: This test fails with Segmentation fault on PHP 5.5.28'); } $this->weightSwitcher = $this->getMock( - 'Magento\Framework\Data\Form\Element\Radios', + \Magento\Framework\Data\Form\Element\Radios::class, ['setId', 'setName', 'setLabel', 'setForm'], [], '', @@ -48,7 +48,7 @@ protected function setUp() $this->weightSwitcher->expects($this->any())->method('setName')->will($this->returnSelf()); $this->weightSwitcher->expects($this->any())->method('setLabel')->will($this->returnSelf()); - $this->factory = $this->getMock('Magento\Framework\Data\Form\Element\Factory', [], [], '', false); + $this->factory = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); $this->factory->expects( $this->once() )->method( @@ -59,7 +59,7 @@ protected function setUp() $this->returnValue($this->weightSwitcher) ); $this->localeFormat = $this->getMock( - '\Magento\Framework\Locale\Format', + \Magento\Framework\Locale\Format::class, [], [], '', @@ -67,7 +67,7 @@ protected function setUp() ); $this->collectionFactory = $this->getMock( - 'Magento\Framework\Data\Form\Element\CollectionFactory', + \Magento\Framework\Data\Form\Element\CollectionFactory::class, ['create'], [], '', @@ -75,7 +75,7 @@ protected function setUp() ); $this->_model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight', + \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight::class, [ 'factoryElement' => $this->factory, 'factoryCollection' => $this->collectionFactory, @@ -86,7 +86,7 @@ protected function setUp() public function testSetForm() { - $form = $this->getMock('Magento\Framework\Data\Form', [], [], '', false); + $form = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); $this->weightSwitcher->expects( $this->any() )->method( diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php index e164bede5da1f..78c50d5925ad7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php @@ -8,6 +8,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AjaxTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Catalog\Block\Adminhtml\Product\Options\Ajax */ @@ -30,13 +33,13 @@ class AjaxTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Backend\Block\Context') + $this->context = $this->getMockBuilder(\Magento\Backend\Block\Context::class) ->setMethods(['getEventManager', 'getScopeConfig', 'getLayout', 'getRequest']) ->disableOriginalConstructor() ->getMock(); - $this->encoderInterface = $this->getMock('Magento\Framework\Json\EncoderInterface'); - $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory', ['create'], [], '', false); - $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->encoderInterface = $this->getMock(\Magento\Framework\Json\EncoderInterface::class); + $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); $this->objectManagerHelper = new ObjectManagerHelper($this); } @@ -46,26 +49,26 @@ protected function setUp() */ public function testToHtml() { - $eventManager = $this->getMockBuilder('Magento\Framework\Event\Manager') + $eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); $eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true)); - $scopeConfig = $this->getMockBuilder('\Magento\Framework\App\Config') + $scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->setMethods(['getValue']) ->disableOriginalConstructor()->getMock(); $scopeConfig->expects($this->once())->method('getValue')->withAnyParameters() ->will($this->returnValue(false)); - $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep']) ->getMock(); $product->expects($this->once())->method('setStoreId')->will($this->returnSelf()); $product->expects($this->once())->method('load')->will($this->returnSelf()); $product->expects($this->once())->method('getId')->will($this->returnValue(1)); - $optionsBlock = $this->getMockBuilder('Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option') + $optionsBlock = $this->getMockBuilder(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option::class) ->setMethods(['setIgnoreCaching', 'setProduct', 'getOptionValues']) ->disableOriginalConstructor() ->getMock(); @@ -73,15 +76,15 @@ public function testToHtml() $optionsBlock->expects($this->once())->method('setProduct')->with($product)->will($this->returnSelf()); $optionsBlock->expects($this->once())->method('getOptionValues')->will($this->returnValue([])); - $layout = $this->getMockBuilder('Magento\Framework\View\Layout\Element\Layout') + $layout = $this->getMockBuilder(\Magento\Framework\View\Layout\Element\Layout::class) ->disableOriginalConstructor() ->setMethods(['createBlock']) ->getMock(); $layout->expects($this->once())->method('createBlock') - ->with('Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option') + ->with(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option::class) ->will($this->returnValue($optionsBlock)); - $request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->setMethods(['getParam']) ->disableOriginalConstructor() ->getMock(); @@ -102,7 +105,7 @@ public function testToHtml() $this->productFactory->expects($this->once())->method('create')->will($this->returnValue($product)); $this->block = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Block\Adminhtml\Product\Options\Ajax', + \Magento\Catalog\Block\Adminhtml\Product\Options\Ajax::class, [ 'context' => $this->context, 'jsonEncoder' => $this->encoderInterface, diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php index eb3ea41a70137..8bc6675933768 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php @@ -30,11 +30,11 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderInterface = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); + $this->urlBuilderInterface = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->link = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Block\Adminhtml\Rss\Grid\Link', + \Magento\Catalog\Block\Adminhtml\Rss\Grid\Link::class, [ 'rssUrlBuilder' => $this->urlBuilderInterface ] diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php index a31ed87f8bc3d..dd98b3e37caac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php @@ -56,20 +56,21 @@ class NotifyStockTest extends \PHPUnit_Framework_TestCase 'title' => 'Low Stock Product', 'description' => 'Low Stock Product has reached a quantity of 1.', 'link' => 'http://magento.com/catalog/product/edit/id/1', + ], ], ]; protected function setUp() { - $this->rssModel = $this->getMockBuilder('Magento\Catalog\Model\Rss\Product\NotifyStock') + $this->rssModel = $this->getMockBuilder(\Magento\Catalog\Model\Rss\Product\NotifyStock::class) ->setMethods(['getProductsCollection', '__wakeup']) ->disableOriginalConstructor()->getMock(); - $this->rssUrlBuilder = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); - $this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface'); + $this->rssUrlBuilder = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); + $this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->block = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Block\Adminhtml\Rss\NotifyStock', + \Magento\Catalog\Block\Adminhtml\Rss\NotifyStock::class, [ 'urlBuilder' => $this->urlBuilder, 'rssModel' => $this->rssModel, @@ -82,7 +83,7 @@ public function testGetRssData() { $this->rssUrlBuilder->expects($this->once())->method('getUrl') ->will($this->returnValue('http://magento.com/rss/feeds/index/type/notifystock')); - $item = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $item = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['__sleep', '__wakeup', 'getId', 'getQty', 'getName']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php index efb0fbaae5429..11505323e3081 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php @@ -45,14 +45,14 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderInterface = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); - $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->storeManagerInterface = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->urlBuilderInterface = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); + $this->scopeConfigInterface = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->storeManagerInterface = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->link = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Block\Category\Rss\Link', + \Magento\Catalog\Block\Category\Rss\Link::class, [ 'rssUrlBuilder' => $this->urlBuilderInterface, 'registry' => $this->registry, @@ -92,7 +92,13 @@ public function testGetLabel() */ public function testIsTopCategory($isTop, $categoryLevel) { - $categoryModel = $this->getMock('\Magento\Catalog\Model\Category', ['__wakeup', 'getLevel'], [], '', false); + $categoryModel = $this->getMock( + \Magento\Catalog\Model\Category::class, + ['__wakeup', 'getLevel'], + [], + '', + false + ); $this->registry->expects($this->once())->method('registry')->will($this->returnValue($categoryModel)); $categoryModel->expects($this->any())->method('getLevel')->will($this->returnValue($categoryLevel)); $this->assertEquals($isTop, $this->link->isTopCategory()); @@ -111,11 +117,11 @@ public function testGetLink() $rssUrl = 'http://rss.magento.com'; $this->urlBuilderInterface->expects($this->once())->method('getUrl')->will($this->returnValue($rssUrl)); - $categoryModel = $this->getMock('\Magento\Catalog\Model\Category', ['__wakeup', 'getId'], [], '', false); + $categoryModel = $this->getMock(\Magento\Catalog\Model\Category::class, ['__wakeup', 'getId'], [], '', false); $this->registry->expects($this->once())->method('registry')->will($this->returnValue($categoryModel)); $categoryModel->expects($this->any())->method('getId')->will($this->returnValue('1')); - $storeModel = $this->getMock('\Magento\Store\Model\Category', ['__wakeup', 'getId'], [], '', false); + $storeModel = $this->getMock(\Magento\Catalog\Model\Category::class, ['__wakeup', 'getId'], [], '', false); $this->storeManagerInterface->expects($this->any())->method('getStore')->will($this->returnValue($storeModel)); $storeModel->expects($this->any())->method('getId')->will($this->returnValue('1')); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php index 2b6bffdb81a0d..b5c1f46dccd87 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php @@ -20,7 +20,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Catalog\Block\Category\View', []); + $this->block = $objectManager->getObject(\Magento\Catalog\Block\Category\View::class, []); } protected function tearDown() @@ -31,7 +31,7 @@ protected function tearDown() public function testGetIdentities() { $categoryTag = ['catalog_category_1']; - $currentCatogoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $currentCatogoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $currentCatogoryMock->expects($this->once())->method('getIdentities')->will($this->returnValue($categoryTag)); $this->block->setCurrentCategory($currentCatogoryMock); $this->assertEquals($categoryTag, $this->block->getIdentities()); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php b/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php index b71b730ae5fef..c2d0eb47227c4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php @@ -36,18 +36,18 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $categoryFactory = $this->getMock( - 'Magento\Catalog\Model\CategoryFactory', + \Magento\Catalog\Model\CategoryFactory::class, ['create'], [], '', false ); - $this->registry = $this->getMock('Magento\Framework\Registry'); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->design = $this->getMock('Magento\Framework\View\DesignInterface'); - $this->httpContext = $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->design = $this->getMock(\Magento\Framework\View\DesignInterface::class); + $this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false); $this->block = $objectManager->getObject( - 'Magento\Catalog\Block\Navigation', + \Magento\Catalog\Block\Navigation::class, [ 'categoryFactory' => $categoryFactory, 'registry' => $this->registry, @@ -69,7 +69,7 @@ public function testGetIdentities() public function testGetCurrentCategoryKey() { $categoryKey = 101; - $category = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $category->expects($this->any())->method('getPath')->willReturn($categoryKey); $this->registry->expects($this->any())->method('registry')->with('current_category')->willReturn($category); @@ -80,7 +80,7 @@ public function testGetCurrentCategoryKey() public function testGetCurrentCategoryKeyFromRootCategory() { $categoryKey = 102; - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store->expects($this->any())->method('getRootCategoryId')->willReturn($categoryKey); $this->storeManager->expects($this->any())->method('getStore')->willReturn($store); @@ -90,13 +90,13 @@ public function testGetCurrentCategoryKeyFromRootCategory() public function testGetCacheKeyInfo() { - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store->expects($this->atLeastOnce())->method('getId')->willReturn(55); $store->expects($this->atLeastOnce())->method('getRootCategoryId')->willReturn(60); $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store); - $theme = $this->getMock('\Magento\Framework\View\Design\ThemeInterface'); + $theme = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->atLeastOnce())->method('getId')->willReturn(65); $this->design->expects($this->atLeastOnce())->method('getDesignTheme')->willReturn($theme); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php index 7131e8f77a801..548915160ded6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php @@ -45,16 +45,16 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->productContextMock = $this->getMock( - 'Magento\Catalog\Block\Product\Context', + \Magento\Catalog\Block\Product\Context::class, ['getLayout', 'getStockRegistry', 'getImageBuilder'], [], '', false ); - $arrayUtilsMock = $this->getMock('Magento\Framework\Stdlib\ArrayUtils', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false); + $arrayUtilsMock = $this->getMock(\Magento\Framework\Stdlib\ArrayUtils::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, ['getBlock'], [], '', false); $this->stockRegistryMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\StockRegistryInterface', + \Magento\CatalogInventory\Api\StockRegistryInterface::class, [], '', false, @@ -63,7 +63,7 @@ protected function setUp() ['getStockItem'] ); - $this->imageBuilder = $this->getMockBuilder('Magento\Catalog\Block\Product\ImageBuilder') + $this->imageBuilder = $this->getMockBuilder(\Magento\Catalog\Block\Product\ImageBuilder::class) ->disableOriginalConstructor() ->getMock(); @@ -92,8 +92,8 @@ protected function setUp() public function testGetProductPrice() { $expectedPriceHtml = 'Expected Price html with price $30'; - $priceRenderBlock = $this->getMock('Magento\Framework\Pricing\Render', ['render'], [], '', false); - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $priceRenderBlock = $this->getMock(\Magento\Framework\Pricing\Render::class, ['render'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->layoutMock->expects($this->once()) ->method('getBlock') @@ -112,8 +112,8 @@ public function testGetProductPrice() public function testGetProductPriceHtml() { $expectedPriceHtml = 'Expected Price html with price $30'; - $priceRenderBlock = $this->getMock('Magento\Framework\Pricing\Render', ['render'], [], '', false); - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $priceRenderBlock = $this->getMock(\Magento\Framework\Pricing\Render::class, ['render'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->layoutMock->expects($this->once()) ->method('getBlock') @@ -144,21 +144,21 @@ public function testGetMinimalQty($minSale, $result) $websiteId = 99; $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getId', 'getStore'], [], '', false ); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false ); $stockItemMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\Data\StockItemInterface', + \Magento\CatalogInventory\Api\Data\StockItemInterface::class, [], '', false, @@ -212,11 +212,11 @@ public function testGetImage() $imageId = 'test_image_id'; $attributes = []; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $imageMock = $this->getMockBuilder('Magento\Catalog\Block\Product\Image') + $imageMock = $this->getMockBuilder(\Magento\Catalog\Block\Product\Image::class) ->disableOriginalConstructor() ->getMock(); @@ -237,7 +237,7 @@ public function testGetImage() ->willReturn($imageMock); $this->assertInstanceOf( - 'Magento\Catalog\Block\Product\Image', + \Magento\Catalog\Block\Product\Image::class, $this->block->getImage($productMock, $imageId, $attributes) ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php index 1f0a4f3f24cb8..327f387f24a9a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php @@ -24,16 +24,16 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layout = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, ['getBlock'], [], '', false); - $context = $this->getMock('Magento\Catalog\Block\Product\Context', ['getLayout'], [], '', false); + $context = $this->getMock(\Magento\Catalog\Block\Product\Context::class, ['getLayout'], [], '', false); $context->expects($this->any()) ->method('getLayout') ->will($this->returnValue($this->layout)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $objectManager->getObject( - 'Magento\Catalog\Block\Product\Compare\ListCompare', + \Magento\Catalog\Block\Product\Compare\ListCompare::class, ['context' => $context] ); } @@ -51,12 +51,12 @@ public function testGetProductPrice() $productId = 1; //Verification - $product = $this->getMock('Magento\Catalog\Model\Product', ['getId', '__wakeup'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getId', '__wakeup'], [], '', false); $product->expects($this->once()) ->method('getId') ->will($this->returnValue($productId)); - $blockMock = $this->getMock('Magento\Framework\Pricing\Render', ['render'], [], '', false); + $blockMock = $this->getMock(\Magento\Framework\Pricing\Render::class, ['render'], [], '', false); $blockMock->expects($this->once()) ->method('render') ->with( diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php index 0a3fcc13893c3..26c89c1e0f3cb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php @@ -35,18 +35,18 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->stockRegistryMock = $this->getMockForAbstractClass( - 'Magento\CatalogInventory\Api\StockRegistryInterface', + \Magento\CatalogInventory\Api\StockRegistryInterface::class, [], '', false ); - $this->imageBuilder = $this->getMockBuilder('Magento\Catalog\Block\Product\ImageBuilder') + $this->imageBuilder = $this->getMockBuilder(\Magento\Catalog\Block\Product\ImageBuilder::class) ->disableOriginalConstructor() ->getMock(); $this->context = $objectManager->getObject( - 'Magento\Catalog\Block\Product\Context', + \Magento\Catalog\Block\Product\Context::class, [ 'stockRegistry' => $this->stockRegistryMock, 'imageBuilder' => $this->imageBuilder, @@ -66,6 +66,6 @@ public function testGetStockRegistry() public function testGetImageBuilder() { - $this->assertInstanceOf('Magento\Catalog\Block\Product\ImageBuilder', $this->context->getImageBuilder()); + $this->assertInstanceOf(\Magento\Catalog\Block\Product\ImageBuilder::class, $this->context->getImageBuilder()); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageBuilderTest.php index 0fc6ae73f3e36..df70cbfcea9d0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageBuilderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageBuilderTest.php @@ -24,12 +24,12 @@ class ImageBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->helperFactory = $this->getMockBuilder('Magento\Catalog\Helper\ImageFactory') + $this->helperFactory = $this->getMockBuilder(\Magento\Catalog\Helper\ImageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->imageFactory = $this->getMockBuilder('Magento\Catalog\Block\Product\ImageFactory') + $this->imageFactory = $this->getMockBuilder(\Magento\Catalog\Block\Product\ImageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -42,12 +42,12 @@ protected function setUp() public function testSetProduct() { - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); $this->assertInstanceOf( - 'Magento\Catalog\Block\Product\ImageBuilder', + \Magento\Catalog\Block\Product\ImageBuilder::class, $this->model->setProduct($productMock) ); } @@ -57,7 +57,7 @@ public function testSetImageId() $imageId = 'test_image_id'; $this->assertInstanceOf( - 'Magento\Catalog\Block\Product\ImageBuilder', + \Magento\Catalog\Block\Product\ImageBuilder::class, $this->model->setImageId($imageId) ); } @@ -68,7 +68,7 @@ public function testSetAttributes() 'name' => 'value', ]; $this->assertInstanceOf( - 'Magento\Catalog\Block\Product\ImageBuilder', + \Magento\Catalog\Block\Product\ImageBuilder::class, $this->model->setAttributes($attributes) ); } @@ -81,11 +81,11 @@ public function testCreate($data, $expected) { $imageId = 'test_image_id'; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $helperMock = $this->getMockBuilder('Magento\Catalog\Helper\Image') + $helperMock = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class) ->disableOriginalConstructor() ->getMock(); $helperMock->expects($this->once()) @@ -116,7 +116,7 @@ public function testCreate($data, $expected) ->method('create') ->willReturn($helperMock); - $imageMock = $this->getMockBuilder('Magento\Catalog\Block\Product\Image') + $imageMock = $this->getMockBuilder(\Magento\Catalog\Block\Product\Image::class) ->disableOriginalConstructor() ->getMock(); @@ -128,7 +128,7 @@ public function testCreate($data, $expected) $this->model->setProduct($productMock); $this->model->setImageId($imageId); $this->model->setAttributes($data['custom_attributes']); - $this->assertInstanceOf('Magento\Catalog\Block\Product\Image', $this->model->create()); + $this->assertInstanceOf(\Magento\Catalog\Block\Product\Image::class, $this->model->create()); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index 2a13107546600..38ef297e68426 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Catalog\Test\Unit\Block\Product; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ListProductTest extends \PHPUnit_Framework_TestCase { /** @@ -50,10 +53,10 @@ class ListProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->layerMock = $this->getMock('Magento\Catalog\Model\Layer', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->layerMock = $this->getMock(\Magento\Catalog\Model\Layer::class, [], [], '', false); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */ - $layerResolver = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Resolver') + $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class) ->disableOriginalConstructor() ->setMethods(['get', 'create']) ->getMock(); @@ -61,14 +64,14 @@ protected function setUp() ->method($this->anything()) ->will($this->returnValue($this->layerMock)); $this->postDataHelperMock = $this->getMock( - 'Magento\Framework\Data\Helper\PostHelper', + \Magento\Framework\Data\Helper\PostHelper::class, [], [], '', false ); $this->typeInstanceMock = $this->getMock( - 'Magento\Catalog\Model\Product\Type\Simple', + \Magento\Catalog\Model\Product\Type\Simple::class, [], [], '', @@ -76,24 +79,24 @@ protected function setUp() false ); $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', false ); $this->cartHelperMock = $this->getMock( - 'Magento\Checkout\Helper\Cart', + \Magento\Checkout\Helper\Cart::class, [], [], '', false ); - $this->urlHelperMock = $this->getMockBuilder('Magento\Framework\Url\Helper\Data') + $this->urlHelperMock = $this->getMockBuilder(\Magento\Framework\Url\Helper\Data::class) ->disableOriginalConstructor()->getMock(); $this->block = $objectManager->getObject( - 'Magento\Catalog\Block\Product\ListProduct', + \Magento\Catalog\Block\Product\ListProduct::class, [ 'registry' => $this->registryMock, 'layerResolver' => $layerResolver, @@ -118,11 +121,14 @@ public function testGetIdentities() ->method('getIdentities') ->will($this->returnValue([$productTag])); - $itemsCollection = new \ReflectionProperty('Magento\Catalog\Block\Product\ListProduct', '_productCollection'); + $itemsCollection = new \ReflectionProperty( + \Magento\Catalog\Block\Product\ListProduct::class, + '_productCollection' + ); $itemsCollection->setAccessible(true); $itemsCollection->setValue($this->block, [$this->productMock]); - $currentCategory = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $currentCategory = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $currentCategory->expects($this->once()) ->method('getId') ->will($this->returnValue('1')); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php index d3cfccdfb3fe2..786185e60e9db 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php @@ -12,7 +12,7 @@ public function testGetMode() $childBlock = new \Magento\Framework\DataObject(); $block = $this->getMock( - 'Magento\Catalog\Block\Product\ListProduct', + \Magento\Catalog\Block\Product\ListProduct::class, ['getChildBlock'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php index 1a9abab5ee420..7a5c1726d168e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php @@ -15,7 +15,7 @@ class NewProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\NewProduct'); + $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\NewProduct::class); } protected function tearDown() diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php index f92b3059c3be9..5c8c3eef33ed2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php @@ -15,7 +15,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\Price'); + $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\Price::class); } protected function tearDown() @@ -26,7 +26,7 @@ protected function tearDown() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); $this->block->setProduct($product); $this->assertEquals($productTags, $this->block->getIdentities()); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php index 4277918e5c6f7..441daed2ee759 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php @@ -15,7 +15,7 @@ class RelatedTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\ProductList\Related'); + $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\ProductList\Related::class); } protected function tearDown() @@ -26,11 +26,11 @@ protected function tearDown() public function testGetIdentities() { $productTag = ['compare_item_1']; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTag)); $itemsCollection = new \ReflectionProperty( - 'Magento\Catalog\Block\Product\ProductList\Related', + \Magento\Catalog\Block\Product\ProductList\Related::class, '_itemCollection' ); $itemsCollection->setAccessible(true); @@ -52,7 +52,7 @@ public function testGetIdentities() public function testCanItemsAddToCart($isComposite, $isSaleable, $hasRequiredOptions, $canItemsAddToCart) { $product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['isComposite', 'isSaleable', 'getRequiredOptions'], [], '', @@ -63,7 +63,7 @@ public function testCanItemsAddToCart($isComposite, $isSaleable, $hasRequiredOpt $product->expects($this->any())->method('getRequiredOptions')->willReturn($hasRequiredOptions); $itemsCollection = new \ReflectionProperty( - 'Magento\Catalog\Block\Product\ProductList\Related', + \Magento\Catalog\Block\Product\ProductList\Related::class, '_itemCollection' ); $itemsCollection->setAccessible(true); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php index 0a6174b82fddc..4e17fb15e2dec 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php @@ -32,6 +32,7 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase * @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject */ protected $scopeConfig; + /** * @var \Magento\Catalog\Model\Config | \PHPUnit_Framework_MockObject_MockObject */ @@ -55,7 +56,7 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->model = $this->getMock( - 'Magento\Catalog\Model\Product\ProductList\Toolbar', + \Magento\Catalog\Model\Product\ProductList\Toolbar::class, [ 'getDirection', 'getOrder', @@ -67,9 +68,15 @@ protected function setUp() '', false ); - $this->layout = $this->getMock('Magento\Framework\View\Layout', ['getChildName', 'getBlock'], [], '', false); + $this->layout = $this->getMock( + \Magento\Framework\View\Layout::class, + ['getChildName', 'getBlock'], + [], + '', + false + ); $this->pagerBlock = $this->getMock( - 'Magento\Theme\Block\Html\Pager', + \Magento\Theme\Block\Html\Pager::class, [ 'setUseContainer', 'setShowPerPage', @@ -84,8 +91,8 @@ protected function setUp() '', false ); - $this->urlBuilder = $this->getMock('Magento\Framework\Url', ['getUrl'], [], '', false); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->urlBuilder = $this->getMock(\Magento\Framework\Url::class, ['getUrl'], [], '', false); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $scopeConfig = [ [\Magento\Catalog\Model\Config::XML_PATH_LIST_DEFAULT_SORT_BY, null, 'name'], @@ -100,7 +107,7 @@ protected function setUp() ->will($this->returnValueMap($scopeConfig)); $this->catalogConfig = $this->getMock( - 'Magento\Catalog\Model\Config', + \Magento\Catalog\Model\Config::class, ['getAttributeUsedForSortByArray'], [], '', @@ -108,7 +115,7 @@ protected function setUp() ); $context = $this->getMock( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, ['getUrlBuilder', 'getScopeConfig', 'getLayout'], [], '', @@ -124,17 +131,17 @@ protected function setUp() ->method('getlayout') ->will($this->returnValue($this->layout)); $this->productListHelper = $this->getMock( - 'Magento\Catalog\Helper\Product\ProductList', + \Magento\Catalog\Helper\Product\ProductList::class, [], [], '', false ); - $this->urlEncoder = $this->getMock('Magento\Framework\Url\EncoderInterface', ['encode'], [], '', false); + $this->urlEncoder = $this->getMock(\Magento\Framework\Url\EncoderInterface::class, ['encode'], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $objectManager->getObject( - 'Magento\Catalog\Block\Product\ProductList\Toolbar', + \Magento\Catalog\Block\Product\ProductList\Toolbar::class, [ 'context' => $context, 'catalogConfig' => $this->catalogConfig, diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php index d4e20ffb3e5e6..8f40db9bd73b8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php @@ -15,7 +15,7 @@ class UpsellTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\ProductList\Upsell'); + $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\ProductList\Upsell::class); } protected function tearDown() @@ -26,10 +26,10 @@ protected function tearDown() public function testGetIdentities() { $productTag = ['compare_item_1']; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTag)); - $itemsCollection = new \ReflectionProperty('Magento\Catalog\Block\Product\ProductList\Upsell', '_items'); + $itemsCollection = new \ReflectionProperty(\Magento\Catalog\Block\Product\ProductList\Upsell::class, '_items'); $itemsCollection->setAccessible(true); $itemsCollection->setValue($this->block, [$product]); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php index 2d3d5dd045ec7..2e3a896d956d9 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php @@ -41,11 +41,11 @@ protected function setUp() { $this->mockContext(); - $this->arrayUtils = $this->getMockBuilder('Magento\Framework\Stdlib\ArrayUtils') + $this->arrayUtils = $this->getMockBuilder(\Magento\Framework\Stdlib\ArrayUtils::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoderMock = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -58,18 +58,18 @@ protected function setUp() protected function mockContext() { - $this->context = $this->getMockBuilder('Magento\Catalog\Block\Product\Context') + $this->context = $this->getMockBuilder(\Magento\Catalog\Block\Product\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->imageHelper = $this->getMockBuilder('Magento\Catalog\Helper\Image') + $this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any()) ->method('getImageHelper') ->willReturn($this->imageHelper); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->any()) @@ -79,15 +79,15 @@ protected function mockContext() public function testGetGalleryImages() { - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $productTypeMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\AbstractType') + $productTypeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class) ->disableOriginalConstructor() ->getMock(); $productTypeMock->expects($this->once()) @@ -143,7 +143,7 @@ public function testGetGalleryImages() ->willReturnSelf(); $images = $this->model->getGalleryImages(); - $this->assertInstanceOf('Magento\Framework\Data\Collection', $images); + $this->assertInstanceOf(\Magento\Framework\Data\Collection::class, $images); } /** @@ -151,7 +151,7 @@ public function testGetGalleryImages() */ private function getImagesCollection() { - $collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php index 8c4b257ae2b43..0e8d55232221a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php @@ -9,6 +9,7 @@ * Test class for \Magento\Catalog\Block\Product\View\Options * * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OptionsTest extends \PHPUnit_Framework_TestCase { @@ -31,7 +32,7 @@ protected function setUp() { $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_optionResource = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Option', + \Magento\Catalog\Model\ResourceModel\Product\Option::class, [], [], '', @@ -46,30 +47,30 @@ protected function setUp() public function testGetOptionHtml() { $layout = $this->getMock( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', 'renderElement'], [], '', false ); $context = $this->_objectHelper->getObject( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, ['layout' => $layout] ); $optValFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Option\ValueFactory', + \Magento\Catalog\Model\Product\Option\ValueFactory::class, ['create'], [], '', false ); $option = $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product\Option', + \Magento\Catalog\Model\Product\Option::class, ['resource' => $this->_optionResource, 'optionValueFactory' => $optValFactoryMock] ); $dateBlock = $this->getMock( - 'Magento\Backend\Block\Catalog\Product\Composite\Fieldset\Options', + \Magento\Backend\Block\Catalog\Product\Composite\Fieldset\Options::class, ['setProduct', 'setOption'], ['context' => $context, 'option' => $option], '', @@ -82,33 +83,33 @@ public function testGetOptionHtml() $layout->expects($this->any())->method('renderElement')->with('date', false)->will($this->returnValue('html')); $this->_optionsBlock = $this->_objectHelper->getObject( - 'Magento\Catalog\Block\Product\View\Options', + \Magento\Catalog\Block\Product\View\Options::class, ['context' => $context, 'option' => $option] ); $itemOptFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Configuration\Item\OptionFactory', + \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory::class, ['create'], [], '', false ); $stockItemFactoryMock = $this->getMock( - 'Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory', + \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class, ['create'], [], '', false ); $productFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ProductFactory', + \Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false ); $categoryFactoryMock = $this->getMock( - 'Magento\Catalog\Model\CategoryFactory', + \Magento\Catalog\Model\CategoryFactory::class, ['create'], [], '', @@ -116,10 +117,10 @@ public function testGetOptionHtml() ); $this->_optionsBlock->setProduct( $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'collectionFactory' => $this->getMock( - 'Magento\Framework\Data\CollectionFactory', + \Magento\Framework\Data\CollectionFactory::class, [], [], '', @@ -134,7 +135,7 @@ public function testGetOptionHtml() ); $option = $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product\Option', + \Magento\Catalog\Model\Product\Option::class, ['resource' => $this->_optionResource] ); $option->setType('date'); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php index e7f8e7ac6c6b4..dffdce644d8f7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php @@ -9,14 +9,14 @@ class TabsTest extends \PHPUnit_Framework_TestCase { public function testAddTab() { - $tabBlock = $this->getMock('Magento\Framework\View\Element\Template', [], [], '', false); + $tabBlock = $this->getMock(\Magento\Framework\View\Element\Template::class, [], [], '', false); $tabBlock->expects($this->once())->method('setTemplate')->with('template')->will($this->returnSelf()); - $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $layout->expects($this->once())->method('createBlock')->with('block')->will($this->returnValue($tabBlock)); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $block = $helper->getObject('Magento\Catalog\Block\Product\View\Tabs', ['layout' => $layout]); + $block = $helper->getObject(\Magento\Catalog\Block\Product\View\Tabs::class, ['layout' => $layout]); $block->addTab('alias', 'title', 'block', 'template', 'header'); $expectedTabs = [['alias' => 'alias', 'title' => 'title', 'header' => 'header']]; diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php index 95b546c012856..faa76a9bdb9ac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php @@ -30,17 +30,17 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->productTypeConfig = $this->getMock('Magento\Catalog\Model\ProductTypes\ConfigInterface'); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->view = $helper->getObject( - 'Magento\Catalog\Block\Product\View', + $this->productTypeConfig = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->view = $helper->getObject( + \Magento\Catalog\Block\Product\View::class, ['productTypeConfig' => $this->productTypeConfig, 'registry' => $this->registryMock] ); } public function testShouldRenderQuantity() { - $productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->registryMock->expects( $this->any() )->method( @@ -66,8 +66,8 @@ public function testShouldRenderQuantity() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $category = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $product->expects($this->once()) ->method('getIdentities') diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php index 2323ae8280a98..cfd009787158a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php @@ -55,20 +55,34 @@ class NewWidgetTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManagerHelper($this); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', ['dispatch'], [], '', false, false); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config', ['getValue'], [], '', false, false); - $this->cacheState = $this->getMock('Magento\Framework\App\Cache\State', ['isEnabled'], [], '', false, false); - $this->localDate = $this->getMock('Magento\Framework\Stdlib\DateTime\Timezone', [], [], '', false, false); - $this->catalogConfig = $this->getMockBuilder('Magento\Catalog\Model\Config') + $this->eventManager = $this->getMock( + \Magento\Framework\Event\Manager::class, + ['dispatch'], + [], + '', + false, + false + ); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, ['getValue'], [], '', false, false); + $this->cacheState = $this->getMock( + \Magento\Framework\App\Cache\State::class, + ['isEnabled'], + [], + '', + false, + false + ); + $this->localDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, [], [], '', false, false); + $this->catalogConfig = $this->getMockBuilder(\Magento\Catalog\Model\Config::class) ->setMethods(['getProductAttributes']) ->disableOriginalConstructor() ->getMock(); - $this->layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Catalog\Block\Product\Context') + $this->context = $this->getMockBuilder(\Magento\Catalog\Block\Product\Context::class) ->setMethods( [ 'getEventManager', 'getScopeConfig', 'getLayout', @@ -88,7 +102,7 @@ protected function setUp() ->willReturn($this->requestMock); $this->block = $this->objectManager->getObject( - 'Magento\Catalog\Block\Product\Widget\NewWidget', + \Magento\Catalog\Block\Product\Widget\NewWidget::class, [ 'context' => $this->context ] @@ -110,7 +124,7 @@ public function testGetProductPriceHtml() '; $type = 'widget-new-list'; - $productMock = $this->getMock('Magento\Catalog\Model\Product', ['getId'], [], '', false, false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, ['getId'], [], '', false, false); $productMock->expects($this->once()) ->method('getId') ->willReturn($id); @@ -121,7 +135,7 @@ public function testGetProductPriceHtml() 'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ]; - $priceBoxMock = $this->getMock('Magento\Framework\Pricing\Render', ['render'], [], '', false, false); + $priceBoxMock = $this->getMock(\Magento\Framework\Pricing\Render::class, ['render'], [], '', false, false); $this->layout->expects($this->once()) ->method('getBlock') @@ -189,7 +203,7 @@ protected function generalGetProductCollection() $this->context->expects($this->once())->method('getCatalogConfig')->willReturn($this->catalogConfig); $this->context->expects($this->once())->method('getLocaleDate')->willReturn($this->localDate); - $this->productCollection = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Collection') + $this->productCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class) ->setMethods( [ 'setVisibility', 'addMinimalPrice', 'addFinalPrice', @@ -231,7 +245,7 @@ protected function generalGetProductCollection() protected function startTestGetProductCollection($displayType, $pagerEnable, $productsCount, $productsPerPage) { $productCollectionFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, ['create'], [], '', @@ -242,7 +256,7 @@ protected function startTestGetProductCollection($displayType, $pagerEnable, $pr ->willReturn($this->productCollection); $this->block = $this->objectManager->getObject( - 'Magento\Catalog\Block\Product\Widget\NewWidget', + \Magento\Catalog\Block\Product\Widget\NewWidget::class, [ 'context' => $this->context, 'productCollectionFactory' => $productCollectionFactory diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php index 729b032e6106f..e7e8171868f94 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php @@ -91,30 +91,36 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->request->expects($this->at(0))->method('getParam')->with('cid')->will($this->returnValue(1)); $this->request->expects($this->at(1))->method('getParam')->with('store_id')->will($this->returnValue(null)); - $this->httpContext = $this->getMock('Magento\Framework\App\Http\Context'); - $this->catalogHelper = $this->getMock('Magento\Catalog\Helper\Data', [], [], '', false); - $this->categoryFactory = $this->getMockBuilder('Magento\Catalog\Model\CategoryFactory') + $this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class); + $this->catalogHelper = $this->getMock(\Magento\Catalog\Helper\Data::class, [], [], '', false); + $this->categoryFactory = $this->getMockBuilder(\Magento\Catalog\Model\CategoryFactory::class) ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); - $this->rssModel = $this->getMock('Magento\Catalog\Model\Rss\Category', ['getProductCollection'], [], '', false); - $this->rssUrlBuilder = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); - $this->imageHelper = $this->getMock('Magento\Catalog\Helper\Image', [], [], '', false); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', ['getId'], [], '', false); + $this->rssModel = $this->getMock( + \Magento\Catalog\Model\Rss\Category::class, + ['getProductCollection'], + [], + '', + false + ); + $this->rssUrlBuilder = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); + $this->imageHelper = $this->getMock(\Magento\Catalog\Helper\Image::class, [], [], '', false); + $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, ['getId'], [], '', false); $this->customerSession->expects($this->any())->method('getId')->will($this->returnValue(1)); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $store = $this->getMockBuilder('\Magento\Store\Model\Store') + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getId', '__wakeup'])->disableOriginalConstructor()->getMock(); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); - $this->scopeConfig = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); - $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $objectManagerHelper = new ObjectManagerHelper($this); $this->block = $objectManagerHelper->getObject( - 'Magento\Catalog\Block\Rss\Category', + \Magento\Catalog\Block\Rss\Category::class, [ 'request' => $this->request, 'scopeConfig' => $this->scopeConfig, @@ -133,7 +139,7 @@ protected function setUp() public function testGetRssData() { - $category = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->setMethods(['__sleep', '__wakeup', 'load', 'getId', 'getUrl', 'getName']) ->disableOriginalConstructor()->getMock(); $category->expects($this->once())->method('getName')->will($this->returnValue('Category Name')); @@ -142,7 +148,7 @@ public function testGetRssData() $this->categoryRepository->expects($this->once())->method('get')->will($this->returnValue($category)); - $product = $this->getMockBuilder('\Magento\catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\catalog\Model\Product::class) ->setMethods([ '__sleep', '__wakeup', @@ -205,11 +211,11 @@ public function testGetFeeds() ->with('rss/catalog/category', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ->will($this->returnValue(true)); - $category = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->setMethods(['__sleep', '__wakeup', 'getTreeModel', 'getResourceCollection', 'getId', 'getName']) ->disableOriginalConstructor()->getMock(); - $collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Category\Collection') + $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class) ->setMethods([ 'addIdFilter', 'addAttributeToSelect', @@ -233,11 +239,11 @@ public function testGetFeeds() $this->categoryFactory->expects($this->once())->method('create')->will($this->returnValue($category)); $node = new \Magento\Framework\DataObject(['id' => 1]); - $nodes = $this->getMockBuilder('Magento\Framework\Data\Tree\Node') + $nodes = $this->getMockBuilder(\Magento\Framework\Data\Tree\Node::class) ->setMethods(['getChildren'])->disableOriginalConstructor()->getMock(); $nodes->expects($this->once())->method('getChildren')->will($this->returnValue([$node])); - $tree = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Category\Tree') + $tree = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Tree::class) ->setMethods(['loadChildren', 'loadNode'])->disableOriginalConstructor()->getMock(); $tree->expects($this->once())->method('loadNode')->will($this->returnSelf()); $tree->expects($this->once())->method('loadChildren')->will($this->returnValue($nodes)); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php index 244edb761a3de..83195fd0af280 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php @@ -10,6 +10,7 @@ /** * Class NewProductsTest * @package Magento\Catalog\Block\Rss\Product + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class NewProductsTest extends \PHPUnit_Framework_TestCase { @@ -60,17 +61,17 @@ class NewProductsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->request->expects($this->any())->method('getParam')->with('store_id')->will($this->returnValue(null)); - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->imageHelper = $this->getMock('Magento\Catalog\Helper\Image', [], [], '', false); - $this->newProducts = $this->getMock('Magento\Catalog\Model\Rss\Product\NewProducts', [], [], '', false); - $this->rssUrlBuilder = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); - $this->scopeConfig = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->imageHelper = $this->getMock(\Magento\Catalog\Helper\Image::class, [], [], '', false); + $this->newProducts = $this->getMock(\Magento\Catalog\Model\Rss\Product\NewProducts::class, [], [], '', false); + $this->rssUrlBuilder = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $store = $this->getMockBuilder('\Magento\Store\Model\Store') + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getId', 'getFrontendName', '__wakeup'])->disableOriginalConstructor()->getMock(); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); $store->expects($this->any())->method('getFrontendName')->will($this->returnValue('Store 1')); @@ -78,7 +79,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); $this->block = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Block\Rss\Product\NewProducts', + \Magento\Catalog\Block\Rss\Product\NewProducts::class, [ 'request' => $this->request, 'imageHelper' => $this->imageHelper, @@ -97,6 +98,7 @@ public function isAllowedDataProvider() [0, false] ]; } + /** * @dataProvider isAllowedDataProvider */ @@ -118,7 +120,7 @@ protected function getItemMock() 'getName', '__wakeup', ]; - $item = $this->getMock('\Magento\Catalog\Model\Product', $methods, [], '', false); + $item = $this->getMock(\Magento\Catalog\Model\Product::class, $methods, [], '', false); $item->expects($this->once())->method('setAllowedInRss')->with(true); $item->expects($this->once())->method('setAllowedPriceInRss')->with(true); $item->expects($this->once())->method('getAllowedPriceInRss')->will($this->returnValue(true)); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php index 97ed9ed4028ff..426a052dfbfcb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php @@ -75,36 +75,42 @@ class SpecialTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->request->expects($this->at(0))->method('getParam')->with('store_id')->will($this->returnValue(null)); $this->request->expects($this->at(1))->method('getParam')->with('cid')->will($this->returnValue(null)); - $this->httpContext = $this->getMockBuilder('Magento\Framework\App\Http\Context') + $this->httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->setMethods(['getValue'])->disableOriginalConstructor()->getMock(); $this->httpContext->expects($this->any())->method('getValue')->will($this->returnValue(1)); - $this->imageHelper = $this->getMock('Magento\Catalog\Helper\Image', [], [], '', false); - $this->outputHelper = $this->getMock('Magento\Catalog\Helper\Output', ['productAttribute'], [], '', false); - $this->msrpHelper = $this->getMock('Magento\Msrp\Helper\Data', ['canApplyMsrp'], [], '', false); - $this->priceCurrency = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); - $this->rssModel = $this->getMock('Magento\Catalog\Model\Rss\Product\Special', [], [], '', false); - $this->rssUrlBuilder = $this->getMock('Magento\Framework\App\Rss\UrlBuilderInterface'); + $this->imageHelper = $this->getMock(\Magento\Catalog\Helper\Image::class, [], [], '', false); + $this->outputHelper = $this->getMock( + \Magento\Catalog\Helper\Output::class, + ['productAttribute'], + [], + '', + false + ); + $this->msrpHelper = $this->getMock(\Magento\Msrp\Helper\Data::class, ['canApplyMsrp'], [], '', false); + $this->priceCurrency = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->rssModel = $this->getMock(\Magento\Catalog\Model\Rss\Product\Special::class, [], [], '', false); + $this->rssUrlBuilder = $this->getMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $store = $this->getMockBuilder('\Magento\Store\Model\Store') + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getId', 'getFrontendName', '__wakeup'])->disableOriginalConstructor()->getMock(); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); $store->expects($this->any())->method('getFrontendName')->will($this->returnValue('Store 1')); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); - $this->scopeConfig = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue('en_US')); - $this->localeDate = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $this->localeDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); $objectManagerHelper = new ObjectManagerHelper($this); $this->block = $objectManagerHelper->getObject( - 'Magento\Catalog\Block\Rss\Product\Special', + \Magento\Catalog\Block\Rss\Product\Special::class, [ 'request' => $this->request, 'httpContext' => $this->httpContext, @@ -169,7 +175,7 @@ public function testGetRssData() protected function getItemMock() { - $item = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $item = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods([ '__wakeup', '__sleep', diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php index 4ed788dce0a26..38ef73e42b056 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php @@ -33,18 +33,18 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->urlFinder = $this->getMock('Magento\UrlRewrite\Model\UrlFinderInterface'); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->urlFinder = $this->getMock(\Magento\UrlRewrite\Model\UrlFinderInterface::class); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any()) ->method('getStoreManager') ->will($this->returnValue($this->storeManager)); $this->entityResource = - $this->getMock('Magento\Catalog\Model\ResourceModel\AbstractResource', [], [], '', false); + $this->getMock(\Magento\Catalog\Model\ResourceModel\AbstractResource::class, [], [], '', false); - $this->block = (new ObjectManager($this))->getObject('Magento\Catalog\Block\Widget\Link', [ + $this->block = (new ObjectManager($this))->getObject(\Magento\Catalog\Block\Widget\Link::class, [ 'context' => $context, 'urlFinder' => $this->urlFinder, 'entityResource' => $this->entityResource @@ -90,7 +90,7 @@ public function testGetHrefIfRewriteIsNotFound() { $this->block->setData('id_path', 'entity_type/entity_id'); - $store = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeUp'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId', '__wakeUp'], [], '', false); $store->expects($this->any()) ->method('getId'); @@ -116,12 +116,18 @@ public function testGetHrefWithoutUrlStoreSuffix($url, $separator) $requestPath = 'request-path'; $this->block->setData('id_path', 'entity_type/entity_id'); - $rewrite = $this->getMock('Magento\UrlRewrite\Service\V1\Data\UrlRewrite', [], [], '', false); + $rewrite = $this->getMock(\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::class, [], [], '', false); $rewrite->expects($this->once()) ->method('getRequestPath') ->will($this->returnValue($requestPath)); - $store = $this->getMock('Magento\Store\Model\Store', ['getId', 'getUrl', 'getCode', '__wakeUp'], [], '', false); + $store = $this->getMock( + \Magento\Store\Model\Store::class, + ['getId', 'getUrl', 'getCode', '__wakeUp'], + [], + '', + false + ); $store->expects($this->once()) ->method('getId') ->will($this->returnValue($storeId)); @@ -185,7 +191,7 @@ public function testGetHrefWithForProductWithCategoryIdParameter() $storeId = 15; $this->block->setData('id_path', ProductUrlRewriteGenerator::ENTITY_TYPE . '/entity_id/category_id'); - $store = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeUp'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId', '__wakeUp'], [], '', false); $store->expects($this->any()) ->method('getId') ->will($this->returnValue($storeId)); diff --git a/app/code/Magento/Catalog/Test/Unit/Console/Command/ImagesResizeCommandTest.php b/app/code/Magento/Catalog/Test/Unit/Console/Command/ImagesResizeCommandTest.php index 2da4752d058c4..cd350316c1046 100644 --- a/app/code/Magento/Catalog/Test/Unit/Console/Command/ImagesResizeCommandTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Console/Command/ImagesResizeCommandTest.php @@ -15,6 +15,9 @@ use Magento\Framework\Exception\NoSuchEntityException; use Symfony\Component\Console\Tester\CommandTester; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ImagesResizeCommandTest extends \PHPUnit_Framework_TestCase { /** @@ -54,11 +57,11 @@ class ImagesResizeCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->appState = $this->getMockBuilder('Magento\Framework\App\State') + $this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->productRepository = $this->getMockBuilder('Magento\Catalog\Api\ProductRepositoryInterface') + $this->productRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class) ->getMockForAbstractClass(); $this->prepareProductCollection(); @@ -105,7 +108,7 @@ public function testExecute() ->method('getAllIds') ->willReturn($productsIds); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -146,7 +149,7 @@ public function testExecuteWithException() ->method('getAllIds') ->willReturn($productsIds); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -172,14 +175,14 @@ public function testExecuteWithException() protected function prepareProductCollection() { $this->productCollectionFactory = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory' + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->productCollection = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Collection::class ) ->disableOriginalConstructor() ->getMock(); @@ -191,12 +194,12 @@ protected function prepareProductCollection() protected function prepareImageCache() { - $this->imageCacheFactory = $this->getMockBuilder('Magento\Catalog\Model\Product\Image\CacheFactory') + $this->imageCacheFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image\CacheFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->imageCache = $this->getMockBuilder('Magento\Catalog\Model\Product\Image\Cache') + $this->imageCache = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image\Cache::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php index 90508bd2962db..4a4c68b642669 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php @@ -8,6 +8,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DeleteTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Catalog\Controller\Adminhtml\Category\Delete */ @@ -27,16 +30,16 @@ class DeleteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->request = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -45,21 +48,21 @@ protected function setUp() ['getParam', 'getPost'] ); $auth = $this->getMock( - 'Magento\Backend\Model\Auth', + \Magento\Backend\Model\Auth::class, ['getAuthStorage'], [], '', false ); $this->authStorage = $this->getMock( - 'Magento\Backend\Model\Auth\StorageInterface', + \Magento\Backend\Model\Auth\StorageInterface::class, ['processLogin', 'processLogout', 'isLoggedIn', 'prolong', 'setDeletedPath'], [], '', false ); $eventManager = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -68,13 +71,13 @@ protected function setUp() ['dispatch'] ); $response = $this->getMockForAbstractClass( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, [], '', false ); $messageManager = $this->getMockForAbstractClass( - 'Magento\Framework\Message\ManagerInterface', + \Magento\Framework\Message\ManagerInterface::class, [], '', false, @@ -82,7 +85,7 @@ protected function setUp() true, ['addSuccess'] ); - $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); + $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $context->expects($this->any()) ->method('getRequest') ->will($this->returnValue($this->request)); @@ -103,11 +106,11 @@ protected function setUp() ->method('getAuthStorage') ->will($this->returnValue($this->authStorage)); - $this->resultRedirect = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->unit = (new ObjectManagerHelper($this))->getObject( - 'Magento\Catalog\Controller\Adminhtml\Category\Delete', + \Magento\Catalog\Controller\Adminhtml\Category\Delete::class, [ 'context' => $context, 'categoryRepository' => $this->categoryRepository @@ -130,7 +133,7 @@ public function testDelete() $categoryId = 5; $parentId = 7; $this->request->expects($this->any())->method('getParam')->with('id')->willReturn($categoryId); - $category = $this->getMock('Magento\Catalog\Model\Category', ['getParentId', 'getPath'], [], '', false); + $category = $this->getMock(\Magento\Catalog\Model\Category::class, ['getParentId', 'getPath'], [], '', false); $category->expects($this->once())->method('getParentId')->willReturn($parentId); $category->expects($this->once())->method('getPath')->willReturn('category-path'); $this->categoryRepository->expects($this->once())->method('get')->with($categoryId)->willReturn($category); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php index c15d4999dbbe2..12869f7c6f42d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php @@ -97,7 +97,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->categoryMock = $this->getMock( - 'Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'getPath', 'addData', @@ -113,7 +113,7 @@ protected function setUp() ); $this->contextMock = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getTitle', 'getRequest', @@ -129,7 +129,7 @@ protected function setUp() false ); $this->resultRedirectFactoryMock = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', @@ -137,7 +137,7 @@ protected function setUp() ); $this->resultPageMock = $this->getMock( - 'Magento\Framework\View\Result\Page', + \Magento\Framework\View\Result\Page::class, ['setActiveMenu', 'getConfig', 'addBreadcrumb', 'getLayout', 'getBlock', 'getTitle', 'prepend'], [], '', @@ -151,7 +151,7 @@ protected function setUp() ->will($this->returnSelf()); $this->resultPageFactoryMock = $this->getMock( - 'Magento\Framework\View\Result\PageFactory', + \Magento\Framework\View\Result\PageFactory::class, ['create'], [], '', @@ -162,14 +162,14 @@ protected function setUp() ->willReturn($this->resultPageMock); $this->resultJsonFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\JsonFactory', + \Magento\Framework\Controller\Result\JsonFactory::class, ['create'], [], '', false ); $this->storeManagerInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -178,7 +178,7 @@ protected function setUp() ['getStore', 'getDefaultStoreView', 'getRootCategoryId', 'getCode'] ); $this->requestMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -186,11 +186,11 @@ protected function setUp() true, ['getParam', 'getPost', 'getPostValue', 'getQuery', 'setParam'] ); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -199,7 +199,7 @@ protected function setUp() ['dispatch'] ); $this->sessionMock = $this->getMock( - 'Magento\Backend\Model\Session', + \Magento\Backend\Model\Session::class, ['__call'], [], '', @@ -217,7 +217,7 @@ protected function setUp() ->willReturn($this->resultRedirectFactoryMock); $this->edit = $this->objectManager->getObject( - 'Magento\Catalog\Controller\Adminhtml\Category\Edit', + \Magento\Catalog\Controller\Adminhtml\Category\Edit::class, [ 'context' => $this->contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, @@ -293,7 +293,7 @@ public function testExecute($categoryId, $storeId) * |\PHPUnit_Framework_MockObject_MockObject $blockMock */ $blockMock = $this->getMock( - 'Magento\Framework\View\Element\Template', + \Magento\Framework\View\Element\Template::class, ['setStoreId'], [], '', @@ -343,7 +343,7 @@ private function mockInitCategoryCall() * |\PHPUnit_Framework_MockObject_MockObject $registryMock */ $registryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, ['register'], [], '', @@ -354,7 +354,7 @@ private function mockInitCategoryCall() * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock */ $wysiwygConfigMock = $this->getMock( - 'Magento\Cms\Model\Wysiwyg\Config', + \Magento\Cms\Model\Wysiwyg\Config::class, ['setStoreId'], [], '', @@ -365,7 +365,7 @@ private function mockInitCategoryCall() * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock */ $storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -383,9 +383,9 @@ private function mockInitCategoryCall() ->will( $this->returnValueMap( [ - ['Magento\Framework\Registry', $registryMock], - ['Magento\Cms\Model\Wysiwyg\Config', $wysiwygConfigMock], - ['Magento\Store\Model\StoreManagerInterface', $storeManagerMock], + [\Magento\Framework\Registry::class, $registryMock], + [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfigMock], + [\Magento\Store\Model\StoreManagerInterface::class, $storeManagerMock], ] ) ); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php index 28eeaf4f639dd..de874df1c9319 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php @@ -88,7 +88,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->contextMock = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getTitle', 'getRequest', @@ -103,35 +103,35 @@ protected function setUp() false ); $this->resultRedirectFactoryMock = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->resultRawFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\RawFactory', + \Magento\Framework\Controller\Result\RawFactory::class, [], [], '', false ); $this->resultJsonFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\JsonFactory', + \Magento\Framework\Controller\Result\JsonFactory::class, ['create'], [], '', false ); $this->layoutFactoryMock = $this->getMock( - 'Magento\Framework\View\LayoutFactory', + \Magento\Framework\View\LayoutFactory::class, ['create'], [], '', false ); $this->requestMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [], '', false, @@ -139,11 +139,11 @@ protected function setUp() true, ['getParam', 'getPost', 'getPostValue'] ); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -152,13 +152,13 @@ protected function setUp() ['dispatch'] ); $this->responseMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, [], '', false ); $this->messageManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Message\ManagerInterface', + \Magento\Framework\Message\ManagerInterface::class, [], '', false, @@ -178,7 +178,7 @@ protected function setUp() ->willReturn($this->resultRedirectFactoryMock); $this->save = $this->objectManager->getObject( - 'Magento\Catalog\Controller\Adminhtml\Category\Save', + \Magento\Catalog\Controller\Adminhtml\Category\Save::class, [ 'context' => $this->contextMock, 'resultRawFactory' => $this->resultRawFactoryMock, @@ -217,7 +217,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock */ $resultRedirectMock = $this->getMock( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, [], [], '', @@ -228,7 +228,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $blockMock */ $blockMock = $this->getMock( - 'Magento\Framework\View\Element\Messages', + \Magento\Framework\View\Element\Messages::class, ['setMessages', 'getGroupedHtml'], [], '', @@ -239,7 +239,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $categoryMock */ $categoryMock = $this->getMock( - 'Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'setStoreId', 'load', @@ -268,7 +268,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $parentCategoryMock */ $parentCategoryMock = $this->getMock( - 'Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'setStoreId', 'load', @@ -292,7 +292,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $sessionMock */ $sessionMock = $this->getMock( - 'Magento\Backend\Model\Auth\Session', + \Magento\Backend\Model\Auth\Session::class, [], [], '', @@ -303,7 +303,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $registryMock */ $registryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, ['register'], [], '', @@ -314,7 +314,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock */ $wysiwygConfigMock = $this->getMock( - 'Magento\Cms\Model\Wysiwyg\Config', + \Magento\Cms\Model\Wysiwyg\Config::class, ['setStoreId'], [], '', @@ -325,7 +325,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock */ $storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -338,7 +338,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $layoutMock */ $layoutMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, [], '', false, @@ -351,7 +351,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock */ $resultJsonMock = $this->getMock( - 'Magento\Cms\Model\Wysiwyg\Config', + \Magento\Cms\Model\Wysiwyg\Config::class, ['setData'], [], '', @@ -362,7 +362,7 @@ public function testExecute($categoryId, $storeId, $parentId) * |\PHPUnit_Framework_MockObject_MockObject $messagesMock */ $messagesMock = $this->getMock( - 'Magento\Framework\Message\Collection', + \Magento\Framework\Message\Collection::class, [], [], '', @@ -395,10 +395,10 @@ public function testExecute($categoryId, $storeId, $parentId) ->will( $this->returnValueMap( [ - ['Magento\Backend\Model\Auth\Session', $sessionMock], - ['Magento\Framework\Registry', $registryMock], - ['Magento\Cms\Model\Wysiwyg\Config', $wysiwygConfigMock], - ['Magento\Store\Model\StoreManagerInterface', $storeManagerMock], + [\Magento\Backend\Model\Auth\Session::class, $sessionMock], + [\Magento\Framework\Registry::class, $registryMock], + [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfigMock], + [\Magento\Store\Model\StoreManagerInterface::class, $storeManagerMock], ] ) ); @@ -499,7 +499,7 @@ public function testExecute($categoryId, $storeId, $parentId) ); $categoryResource = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Category', + \Magento\Catalog\Model\ResourceModel\Category::class, [], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php index 10c0a9c53c25d..824d1c7bf23f2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php @@ -9,6 +9,9 @@ namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category\Widget; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CategoriesJsonTest extends \PHPUnit_Framework_TestCase { /** @@ -58,11 +61,11 @@ class CategoriesJsonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\View', ['getLayout'], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\View::class, ['getLayout'], [], '', false); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', @@ -71,10 +74,10 @@ protected function setUp() $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, ['getRequest', 'getResponse', 'getMessageManager', 'getSession'], $helper->getConstructArguments( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'response' => $this->responseMock, 'request' => $this->requestMock, @@ -84,10 +87,10 @@ protected function setUp() ) ); - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $this->resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); - $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -95,9 +98,9 @@ protected function setUp() ->method('create') ->willReturn($this->resultJson); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', ['createBlock'], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, ['createBlock'], [], '', false); - $layoutFactory = $this->getMockBuilder('Magento\Framework\View\LayoutFactory') + $layoutFactory = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -107,7 +110,7 @@ protected function setUp() $context->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock)); $context->expects($this->once())->method('getResponse')->will($this->returnValue($this->responseMock)); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->controller = new \Magento\Catalog\Controller\Adminhtml\Category\Widget\CategoriesJson( $context, $layoutFactory, $resultJsonFactory, $this->registryMock ); @@ -116,7 +119,7 @@ protected function setUp() protected function _getTreeBlock() { $this->chooserBlockMock = $this->getMock( - 'Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser', [], [], '', false + \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser::class, [], [], '', false ); $this->layoutMock->expects($this->once())->method('createBlock')->will( $this->returnValue($this->chooserBlockMock) @@ -129,11 +132,11 @@ public function testExecute() $testCategoryId = 1; $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue($testCategoryId)); - $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once())->method('load')->will($this->returnValue($categoryMock)); $categoryMock->expects($this->once())->method('getId')->will($this->returnValue($testCategoryId)); $this->objectManagerMock->expects($this->once())->method('create') - ->with($this->equalTo('Magento\Catalog\Model\Category'))->will($this->returnValue($categoryMock)); + ->with($this->equalTo(\Magento\Catalog\Model\Category::class))->will($this->returnValue($categoryMock)); $this->chooserBlockMock->expects($this->once())->method('setSelectedCategories')->will( $this->returnValue($this->chooserBlockMock) diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php index 7c81b8cb18ead..6872c8a0193ac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php @@ -9,6 +9,9 @@ namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category\Widget; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ChooserTest extends \PHPUnit_Framework_TestCase { /** @@ -53,11 +56,11 @@ class ChooserTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\View', ['getLayout'], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\View::class, ['getLayout'], [], '', false); $this->objectManagerMock = $this->getMock( - 'Magento\Framework\ObjectManager\ObjectManager', + \Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', @@ -66,10 +69,10 @@ protected function setUp() $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, ['getRequest', 'getResponse', 'getMessageManager', 'getSession'], $helper->getConstructArguments( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'response' => $this->responseMock, 'request' => $this->requestMock, @@ -79,10 +82,10 @@ protected function setUp() ) ); - $this->resultRaw = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') + $this->resultRaw = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class) ->disableOriginalConstructor() ->getMock(); - $resultRawFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') + $resultRawFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -90,8 +93,8 @@ protected function setUp() ->method('create') ->willReturn($this->resultRaw); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', ['createBlock'], [], '', false); - $layoutFactory = $this->getMockBuilder('Magento\Framework\View\LayoutFactory') + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, ['createBlock'], [], '', false); + $layoutFactory = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -109,7 +112,7 @@ protected function setUp() protected function _getTreeBlock() { $this->chooserBlockMock = $this->getMock( - 'Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser', [], [], '', false + \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser::class, [], [], '', false ); $this->layoutMock->expects($this->once())->method('createBlock')->will( diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php index 9ce9d43db7b60..9b8a85eee6e85 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php @@ -6,6 +6,9 @@ */ namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Action\Attribute; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EditTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save */ @@ -34,33 +37,33 @@ class EditTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeHelper = $this->getMockBuilder('Magento\Catalog\Helper\Product\Edit\Action\Attribute') + $this->attributeHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Product\Edit\Action\Attribute::class) ->setMethods(['getProductIds', 'setProductIds']) ->disableOriginalConstructor()->getMock(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->filter = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter') + $this->filter = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class) ->setMethods(['getCollection'])->disableOriginalConstructor()->getMock(); $this->collectionFactory = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory' + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class )->setMethods(['create'])->disableOriginalConstructor()->getMock(); - $this->resultPage = $this->getMockBuilder('Magento\Framework\View\Result\Page') + $this->resultPage = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->setMethods(['getConfig'])->disableOriginalConstructor()->getMock(); - $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->setMethods(['create'])->disableOriginalConstructor()->getMock(); $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage); $this->prepareContext(); $this->object = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Edit', + \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Edit::class, [ 'context' => $this->context, 'attributeHelper' => $this->attributeHelper, @@ -73,25 +76,26 @@ protected function setUp() private function prepareContext() { - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->setMethods(['getParam', 'getParams', 'setParams']) ->disableOriginalConstructor()->getMock(); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['isProductsHasSku']) ->disableOriginalConstructor()->getMock(); $product->expects($this->any())->method('isProductsHasSku') ->with([1, 2, 3]) ->willReturn(true); - $objectManager->expects($this->any())->method('create') - ->with('Magento\Catalog\Model\Product') + $objectManager->expects($this->any()) + ->method('create') + ->with(\Magento\Catalog\Model\Product::class) ->willReturn($product); - $messageManager = $this->getMockBuilder('\Magento\Framework\Message\ManagerInterface') + $messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->setMethods([]) ->disableOriginalConstructor()->getMock(); $messageManager->expects($this->any())->method('addError')->willReturn(true); - $this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->setMethods(['getRequest', 'getObjectManager', 'getMessageManager', 'getResultRedirectFactory']) ->disableOriginalConstructor()->getMock(); $this->context->expects($this->any())->method('getRequest')->willReturn($this->request); @@ -115,17 +119,17 @@ public function testExecutePageRequested() $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]); $this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]); - $collection = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Collection') + $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class) ->setMethods(['getAllIds']) ->disableOriginalConstructor()->getMock(); $collection->expects($this->any())->method('getAllIds')->willReturn([1, 2, 3]); $this->filter->expects($this->any())->method('getCollection')->with($collection)->willReturn($collection); $this->collectionFactory->expects($this->any())->method('create')->willReturn($collection); - $title = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $title = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->setMethods(['prepend']) ->disableOriginalConstructor()->getMock(); - $config = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $config = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->setMethods(['getTitle']) ->disableOriginalConstructor()->getMock(); $config->expects($this->any())->method('getTitle')->willReturn($title); @@ -142,10 +146,10 @@ public function testExecutePageReload() $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]); $this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]); - $title = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $title = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->setMethods(['prepend']) ->disableOriginalConstructor()->getMock(); - $config = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $config = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->setMethods(['getTitle']) ->disableOriginalConstructor()->getMock(); $config->expects($this->any())->method('getTitle')->willReturn($title); @@ -160,7 +164,7 @@ public function testExecutePageDirectAccess() $this->request->expects($this->any())->method('getParams')->willReturn([]); $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn(null); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->setMethods(['setPath']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php index 5489564a29257..4e3ace63e9d40 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php @@ -72,9 +72,6 @@ class SaveTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Data\Form\FormKey\Validator|\PHPUnit_Framework_MockObject_MockObject */ protected $formKeyValidator; - /** @var \Magento\Framework\App\Action\Title|\PHPUnit_Framework_MockObject_MockObject */ - protected $title; - /** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $localeResolver; @@ -101,30 +98,30 @@ class SaveTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->attributeHelper = $this->getMock( - 'Magento\Catalog\Helper\Product\Edit\Action\Attribute', + \Magento\Catalog\Helper\Product\Edit\Action\Attribute::class, ['getProductIds', 'getSelectedStoreId', 'getStoreWebsiteId'], [], '', false ); - $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); $this->stockIndexerProcessor = $this->getMock( - 'Magento\CatalogInventory\Model\Indexer\Stock\Processor', + \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, ['reindexList'], [], '', false ); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory') + $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -135,7 +132,7 @@ protected function setUp() $this->prepareContext(); $this->object = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save', + \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save::class, [ 'context' => $this->context, 'attributeHelper' => $this->attributeHelper, @@ -150,31 +147,36 @@ protected function setUp() */ protected function prepareContext() { - $this->stockItemRepository = $this->getMockBuilder('Magento\CatalogInventory\Api\StockItemRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); + $this->stockItemRepository = $this->getMockBuilder( + \Magento\CatalogInventory\Api\StockItemRepositoryInterface::class + )->disableOriginalConstructor()->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $this->url = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); - $this->redirect = $this->getMock('Magento\Framework\App\Response\RedirectInterface', [], [], '', false); - $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); - $this->view = $this->getMock('Magento\Framework\App\ViewInterface', [], [], '', false); - $this->messageManager = $this->getMock('Magento\Framework\Message\ManagerInterface', [], [], '', false); - $this->session = $this->getMock('Magento\Backend\Model\Session', [], [], '', false); - $this->authorization = $this->getMock('Magento\Framework\AuthorizationInterface', [], [], '', false); - $this->auth = $this->getMock('Magento\Backend\Model\Auth', [], [], '', false); - $this->helper = $this->getMock('Magento\Backend\Helper\Data', [], [], '', false); - $this->backendUrl = $this->getMock('Magento\Backend\Model\UrlInterface', [], [], '', false); - $this->formKeyValidator = $this->getMock('Magento\Framework\Data\Form\FormKey\Validator', [], [], '', false); - $this->title = $this->getMock('Magento\Framework\App\Action\Title', [], [], '', false); - $this->localeResolver = $this->getMock('Magento\Framework\Locale\ResolverInterface', [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->url = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->redirect = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class, [], [], '', false); + $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); + $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class, [], [], '', false); + $this->messageManager = $this->getMock(\Magento\Framework\Message\ManagerInterface::class, [], [], '', false); + $this->session = $this->getMock(\Magento\Backend\Model\Session::class, [], [], '', false); + $this->authorization = $this->getMock(\Magento\Framework\AuthorizationInterface::class, [], [], '', false); + $this->auth = $this->getMock(\Magento\Backend\Model\Auth::class, [], [], '', false); + $this->helper = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->backendUrl = $this->getMock(\Magento\Backend\Model\UrlInterface::class, [], [], '', false); + $this->formKeyValidator = $this->getMock( + \Magento\Framework\Data\Form\FormKey\Validator::class, + [], + [], + '', + false + ); + $this->localeResolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class, [], [], '', false); $this->context = $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getRequest', 'getResponse', @@ -191,7 +193,6 @@ protected function prepareContext() 'getHelper', 'getBackendUrl', 'getFormKeyValidator', - 'getTitle', 'getLocaleResolver', 'getResultRedirectFactory' ], @@ -214,41 +215,40 @@ protected function prepareContext() $this->context->expects($this->any())->method('getHelper')->willReturn($this->helper); $this->context->expects($this->any())->method('getBackendUrl')->willReturn($this->backendUrl); $this->context->expects($this->any())->method('getFormKeyValidator')->willReturn($this->formKeyValidator); - $this->context->expects($this->any())->method('getTitle')->willReturn($this->title); $this->context->expects($this->any())->method('getLocaleResolver')->willReturn($this->localeResolver); $this->context->expects($this->any()) ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactory); $this->product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['isProductsHasSku', '__wakeup'], [], '', false ); - $this->stockItemService = $this->getMockBuilder('Magento\CatalogInventory\Api\StockRegistryInterface') + $this->stockItemService = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockRegistryInterface::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', 'saveStockItem']) ->getMockForAbstractClass(); - $this->stockItem = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockItemInterface') + $this->stockItem = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class) ->setMethods(['getId', 'getProductId']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->stockConfig = $this->getMockBuilder('Magento\CatalogInventory\Api\StockConfigurationInterface') + $this->stockConfig = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockConfigurationInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->objectManager->expects($this->any())->method('create')->will($this->returnValueMap([ - ['Magento\Catalog\Model\Product', [], $this->product], - ['Magento\CatalogInventory\Api\StockRegistryInterface', [], $this->stockItemService], - ['Magento\CatalogInventory\Api\StockItemRepositoryInterface', [], $this->stockItemRepository], + [\Magento\Catalog\Model\Product::class, [], $this->product], + [\Magento\CatalogInventory\Api\StockRegistryInterface::class, [], $this->stockItemService], + [\Magento\CatalogInventory\Api\StockItemRepositoryInterface::class, [], $this->stockItemRepository], ])); $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - ['Magento\CatalogInventory\Api\StockConfigurationInterface', $this->stockConfig], + [\Magento\CatalogInventory\Api\StockConfigurationInterface::class, $this->stockConfig], ])); } @@ -260,7 +260,7 @@ public function testExecuteThatProductIdsAreObtainedFromAttributeHelper() $this->stockConfig->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([])); $this->dataObjectHelperMock->expects($this->any()) ->method('populateWithArray') - ->with($this->stockItem, $this->anything(), '\Magento\CatalogInventory\Api\Data\StockItemInterface') + ->with($this->stockItem, $this->anything(), \Magento\CatalogInventory\Api\Data\StockItemInterface::class) ->willReturnSelf(); $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true)); $this->stockItemService->expects($this->any())->method('getStockItem')->with(5, 1) diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php index e2a72342376d4..be6cd55729922 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php @@ -89,53 +89,53 @@ class EditTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface')->getMock(); + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')->getMock(); + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)->getMock(); $this->eavAttribute = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['setEntityTypeId', 'load', 'getId', 'getEntityTypeId', 'addData', 'getName'], [], '', false ); - $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb', 'addHandle', 'getLayout']) ->getMock(); - $this->resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $this->resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultLayout = $this->getMockBuilder('Magento\Framework\View\Result\Layout') + $this->resultLayout = $this->getMockBuilder(\Magento\Framework\View\Result\Layout::class) ->disableOriginalConstructor() ->getMock(); - $this->pageConfig = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfig = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->pageTitle = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $this->pageTitle = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); - $this->layout = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, ['getBlock'], [], '', false); - $this->session = $this->getMockBuilder('Magento\Backend\Model\Session') + $this->session = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->blockTemplate = $this->getMockBuilder('Magento\Backend\Block\Template') + $this->blockTemplate = $this->getMockBuilder(\Magento\Backend\Block\Template::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->context->expects($this->any())->method('getRequest')->willReturn($this->request); $this->context->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); $this->context->expects($this->any())->method('getResultPageFactory')->willReturn($this->resultPageFactory); @@ -143,7 +143,7 @@ protected function setUp() $this->objectManager = new ObjectManager($this); $this->editController = $this->objectManager->getObject( - 'Magento\Catalog\Controller\Adminhtml\Product\Attribute\Edit', + \Magento\Catalog\Controller\Adminhtml\Product\Attribute\Edit::class, [ 'context' => $this->context, 'resultPageFactory' => $this->resultPageFactory @@ -165,10 +165,10 @@ public function testExecutePopup() ); $this->objectManagerMock->expects($this->any())->method('create') - ->with('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->willReturn($this->eavAttribute); $this->objectManagerMock->expects($this->any())->method('get') - ->with('Magento\Backend\Model\Session') + ->with(\Magento\Backend\Model\Session::class) ->willReturn($this->session); $this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf(); @@ -215,10 +215,10 @@ public function testExecuteNoPopup() ); $this->objectManagerMock->expects($this->any())->method('create') - ->with('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->willReturn($this->eavAttribute); $this->objectManagerMock->expects($this->any())->method('get') - ->with('Magento\Backend\Model\Session') + ->with(\Magento\Backend\Model\Session::class) ->willReturn($this->session); $this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php index 94ba7ee6e487f..64be6f6fcf8cb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php @@ -97,14 +97,17 @@ protected function setUp() */ protected function getModel() { - return $this->objectManager->getObject(Validate::class, [ - 'context' => $this->contextMock, - 'attributeLabelCache' => $this->attributeLabelCacheMock, - 'coreRegistry' => $this->coreRegistryMock, - 'resultPageFactory' => $this->resultPageFactoryMock, - 'resultJsonFactory' => $this->resultJsonFactoryMock, - 'layoutFactory' => $this->layoutFactoryMock, - ]); + return $this->objectManager->getObject( + Validate::class, + [ + 'context' => $this->contextMock, + 'attributeLabelCache' => $this->attributeLabelCacheMock, + 'coreRegistry' => $this->coreRegistryMock, + 'resultPageFactory' => $this->resultPageFactoryMock, + 'resultJsonFactory' => $this->resultJsonFactoryMock, + 'layoutFactory' => $this->layoutFactoryMock, + ] + ); } public function testExecute() @@ -119,8 +122,8 @@ public function testExecute() $this->objectManagerMock->expects($this->exactly(2)) ->method('create') ->willReturnMap([ - ['Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], $this->attributeMock], - ['Magento\Eav\Model\Entity\Attribute\Set', [], $this->attributeSetMock] + [\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], $this->attributeMock], + [\Magento\Eav\Model\Entity\Attribute\Set::class, [], $this->attributeSetMock] ]); $this->attributeMock->expects($this->once()) ->method('loadByCode') diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php index 3b7396c5dd9b7..fa2e0271d9ccf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php @@ -81,7 +81,7 @@ protected function setUp() $this->wysiwygConfigMock = $this->getMock(WysiwygConfig::class, ['setStoreId'], [], '', false); $this->requestMock = $this->getMock(Http::class, [], [], '', false); $methods = ['setStoreId', 'setData', 'load', '__wakeup', 'setAttributeSetId', 'setTypeId']; - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $methods, [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, $methods, [], '', false); $this->storeFactoryMock = $this->getMockBuilder(StoreFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() @@ -94,13 +94,16 @@ protected function setUp() ->method('create') ->willReturn($this->storeMock); - $this->builder = $this->objectManager->getObject(Builder::class, [ - 'productFactory' => $this->productFactoryMock, - 'logger' => $this->loggerMock, - 'registry' => $this->registryMock, - 'wysiwygConfig' => $this->wysiwygConfigMock, - 'storeFactory' => $this->storeFactoryMock, - ]); + $this->builder = $this->objectManager->getObject( + Builder::class, + [ + 'productFactory' => $this->productFactoryMock, + 'logger' => $this->loggerMock, + 'registry' => $this->registryMock, + 'wysiwygConfig' => $this->wysiwygConfigMock, + 'storeFactory' => $this->storeFactoryMock, + ] + ); } public function testBuildWhenProductExistAndPossibleToLoadProduct() diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php index f4c6b2def9277..f5a3bdbb27c0d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php @@ -21,7 +21,7 @@ class HandlerFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new HandlerFactory($this->_objectManagerMock); } @@ -29,11 +29,11 @@ public function testCreateWithInvalidType() { $this->setExpectedException( '\InvalidArgumentException', - 'Magento\Framework\DataObject does not implement ' . - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface' + \Magento\Framework\DataObject::class . ' does not implement ' . + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class ); $this->_objectManagerMock->expects($this->never())->method('create'); - $this->_model->create('Magento\Framework\DataObject'); + $this->_model->create(\Magento\Framework\DataObject::class); } public function testCreateWithValidType() @@ -43,14 +43,14 @@ public function testCreateWithValidType() )->method( 'create' )->with( - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite' + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite::class )->will( $this->returnValue('object') ); $this->assertEquals( 'object', $this->_model->create( - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite' + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite::class ) ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php index 42ff29ff51cfc..588c4c8c8607f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php @@ -12,7 +12,7 @@ class CompositeTest extends \PHPUnit_Framework_TestCase public function testHandle() { $factoryMock = $this->getMock( - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory', + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory::class, [], [], '', @@ -20,7 +20,7 @@ public function testHandle() ); $constructorMock = $this->getMock( - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface' + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class ); $factoryMock->expects( @@ -33,7 +33,7 @@ public function testHandle() $this->returnValue($constructorMock) ); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $constructorMock->expects($this->exactly(2))->method('handle')->with($productMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php index 9cd056c997b64..a226ce91b24d1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php @@ -32,12 +32,12 @@ class StockDataFilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(1)); $this->stockConfiguration = $this->getMock( - 'Magento\CatalogInventory\Model\Configuration', + \Magento\CatalogInventory\Model\Configuration::class, ['getManageStock'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php index 60bdb8c836583..0fff613c56e2e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php @@ -18,23 +18,23 @@ class MassStatusTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\Pro protected function setUp() { - $this->priceProcessor = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Price\Processor') + $this->priceProcessor = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Price\Processor::class) ->disableOriginalConstructor()->getMock(); - $productBuilder = $this->getMockBuilder('Magento\Catalog\Controller\Adminhtml\Product\Builder')->setMethods([ - 'build', - ])->disableOriginalConstructor()->getMock(); + $productBuilder = $this->getMockBuilder( + \Magento\Catalog\Controller\Adminhtml\Product\Builder::class + )->setMethods(['build'])->disableOriginalConstructor()->getMock(); - $product = $this->getMockBuilder('\Magento\Catalog\Model\Product')->disableOriginalConstructor() + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods(['getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock(); $product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); $product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); $productBuilder->expects($this->any())->method('build')->will($this->returnValue($product)); - $this->resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + $this->resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); - $resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -43,7 +43,7 @@ protected function setUp() ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($this->resultRedirect); - $abstractDbMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $abstractDbMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['getAllIds', 'getResource']) ->getMock(); @@ -51,7 +51,7 @@ protected function setUp() ->method('getAllIds') ->willReturn([]); - $filterMock = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter') + $filterMock = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class) ->disableOriginalConstructor() ->setMethods(['getCollection']) ->getMock(); @@ -59,7 +59,9 @@ protected function setUp() ->method('getCollection') ->willReturn($abstractDbMock); - $collectionFactoryMock = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory') + $collectionFactoryMock = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php index 440e01405eef8..c29abe2261fe1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php @@ -36,23 +36,23 @@ class NewActionTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\Prod protected function setUp() { $this->productBuilder = $this->getMock( - 'Magento\Catalog\Controller\Adminhtml\Product\Builder', + \Magento\Catalog\Controller\Adminhtml\Product\Builder::class, ['build'], [], '', false ); - $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods(['addData', 'getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock(); $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); - $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -60,10 +60,10 @@ protected function setUp() ->method('create') ->willReturn($this->resultPage); - $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php index 7e4666baa8ed0..a309a5b9029b9 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php @@ -8,6 +8,9 @@ use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest { /** @var \Magento\Catalog\Controller\Adminhtml\Product\Save */ @@ -40,32 +43,32 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe protected function setUp() { $this->productBuilder = $this->getMock( - 'Magento\Catalog\Controller\Adminhtml\Product\Builder', + \Magento\Catalog\Controller\Adminhtml\Product\Builder::class, ['build'], [], '', false ); - $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods(['addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock(); $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); - $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage); - $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -74,14 +77,14 @@ protected function setUp() ->willReturn($this->resultForward); $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout); $this->resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->resultRedirect = $this->getMock( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, [], [], '', @@ -90,7 +93,7 @@ protected function setUp() $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->initializationHelper = $this->getMock( - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class, [], [], '', @@ -100,7 +103,7 @@ protected function setUp() $additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory]; $storeManagerInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -114,7 +117,7 @@ protected function setUp() ->will($this->returnSelf()); $this->action = (new ObjectManagerHelper($this))->getObject( - 'Magento\Catalog\Controller\Adminhtml\Product\Save', + \Magento\Catalog\Controller\Adminhtml\Product\Save::class, [ 'context' => $this->initContext($additionalParams), 'productBuilder' => $this->productBuilder, @@ -151,6 +154,6 @@ public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnErro */ public function exceptionTypeDataProvider() { - return [['Magento\Framework\Exception\LocalizedException'], ['Exception']]; + return [[\Magento\Framework\Exception\LocalizedException::class], ['Exception']]; } } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php index a4604875c08f0..2d2c2f1ca2cd7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php @@ -7,6 +7,9 @@ use Magento\Catalog\Controller\Adminhtml\Product\ShowUpdateResult; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ShowUpdateResultTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ @@ -29,7 +32,7 @@ class ShowUpdateResultTest extends \PHPUnit_Framework_TestCase protected function getSession() { $session = $this->getMock( - 'Magento\Backend\Model\Session', + \Magento\Backend\Model\Session::class, ['hasCompositeProductResult', 'getCompositeProductResult', 'unsCompositeProductResult'], [], '', @@ -54,20 +57,25 @@ protected function getSession() */ protected function getContext() { - $productActionMock = $this->getMock('Magento\Catalog\Model\Product\Action', [], [], '', false); - $objectManagerMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $productActionMock = $this->getMock(\Magento\Catalog\Model\Product\Action::class, [], [], '', false); + $objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any()) ->method('get') ->willreturn($productActionMock); - $eventManager = $this->getMockForAbstractClass('Magento\Framework\Event\Manager', ['dispatch'], '', false); + $eventManager = $this->getMockForAbstractClass( + \Magento\Framework\Event\Manager::class, + ['dispatch'], + '', + false + ); $eventManager->expects($this->any()) ->method('dispatch') ->willReturnSelf(); $this->request = $this->getMock( - 'Magento\Framework\App\Request\Http', + \Magento\Framework\App\Request\Http::class, ['getParam', 'getPost', 'getFullActionName', 'getPostValue'], [], '', @@ -75,19 +83,19 @@ protected function getContext() ); $responseInterfaceMock = $this->getMock( - 'Magento\Framework\App\ResponseInterface', + \Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse'], [], '', false ); - $managerInterfaceMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); + $managerInterfaceMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); $this->session = $this->getSession(); - $actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); - $helperDataMock = $this->getMock('Magento\Backend\Helper\Data', [], [], '', false); + $actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); + $helperDataMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getRequest', 'getResponse', @@ -137,11 +145,17 @@ protected function getContext() public function testExecute() { - $productCompositeHelper = $this->getMock('Magento\Catalog\Helper\Product\Composite', [], [], '', false); + $productCompositeHelper = $this->getMock(\Magento\Catalog\Helper\Product\Composite::class, [], [], '', false); $productCompositeHelper->expects($this->once()) ->method('renderUpdateResult'); - $productBuilder = $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Builder', [], [], '', false); + $productBuilder = $this->getMock( + \Magento\Catalog\Controller\Adminhtml\Product\Builder::class, + [], + [], + '', + false + ); $context = $this->getContext(); /** @var \Magento\Catalog\Controller\Adminhtml\Product\ShowUpdateResult $controller */ diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php index ee772db126d33..cbd38352387b4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php @@ -8,6 +8,9 @@ use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ValidateTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest { /** @var \Magento\Catalog\Controller\Adminhtml\Product\Validate */ @@ -50,13 +53,13 @@ class ValidateTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\Produ protected function setUp() { $this->productBuilder = $this->getMock( - 'Magento\Catalog\Controller\Adminhtml\Product\Builder', + \Magento\Catalog\Controller\Adminhtml\Product\Builder::class, ['build'], [], '', false ); - $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods([ 'addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', 'setAttributeSetId', @@ -67,20 +70,20 @@ protected function setUp() $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([])); $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); - $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); - $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage); - $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) ->disableOriginalConstructor() ->getMock(); - $resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + $resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -89,14 +92,14 @@ protected function setUp() ->willReturn($this->resultForward); $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout); $this->resultRedirectFactory = $this->getMock( - 'Magento\Backend\Model\View\Result\RedirectFactory', + \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'], [], '', false ); $this->resultRedirect = $this->getMock( - 'Magento\Backend\Model\View\Result\Redirect', + \Magento\Backend\Model\View\Result\Redirect::class, [], [], '', @@ -105,28 +108,28 @@ protected function setUp() $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->initializationHelper = $this->getMock( - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class, [], [], '', false ); - $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + $this->productFactory = $this->getMockBuilder(\Magento\Catalog\Model\ProductFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->productFactory->expects($this->any())->method('create')->willReturn($this->product); - $this->resultJson = $this->getMock('Magento\Framework\Controller\Result\Json', [], [], '', false); - $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); + $this->resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson); $storeManagerInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -141,7 +144,7 @@ protected function setUp() $additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory]; $this->action = (new ObjectManagerHelper($this))->getObject( - 'Magento\Catalog\Controller\Adminhtml\Product\Validate', + \Magento\Catalog\Controller\Adminhtml\Product\Validate::class, [ 'context' => $this->initContext($additionalParams), 'productBuilder' => $this->productBuilder, diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php index 13c89a0d34151..9a21de70b4f11 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php @@ -5,16 +5,23 @@ */ namespace Magento\Catalog\Test\Unit\Controller\Adminhtml; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ abstract class ProductTest extends \PHPUnit_Framework_TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $context; + /** @var \Magento\Catalog\Controller\Product */ protected $action; + /** @var \Magento\Framework\View\Layout */ protected $layout; + /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ protected $session; + /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -26,43 +33,43 @@ abstract class ProductTest extends \PHPUnit_Framework_TestCase */ protected function initContext(array $additionalParams = []) { - $productActionMock = $this->getMock('Magento\Catalog\Model\Product\Action', [], [], '', false); - $objectManagerMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $productActionMock = $this->getMock(\Magento\Catalog\Model\Product\Action::class, [], [], '', false); + $objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($productActionMock)); - $block = $this->getMockBuilder('\Magento\Framework\View\Element\AbstractBlock') + $block = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->disableOriginalConstructor()->getMockForAbstractClass(); - $this->layout = $this->getMockBuilder('Magento\Framework\View\Layout') + $this->layout = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->setMethods(['getBlock'])->disableOriginalConstructor() ->getMock(); $this->layout->expects($this->any())->method('getBlock')->will($this->returnValue($block)); - $eventManager = $this->getMockBuilder('Magento\Framework\Event\Manager') + $eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->setMethods(['dispatch'])->disableOriginalConstructor()->getMock(); $eventManager->expects($this->any())->method('dispatch')->will($this->returnSelf()); - $title = $this->getMockBuilder('\Magento\Framework\App\Action\Title') + $title = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) ->setMethods(['add'])->disableOriginalConstructor()->getMock(); $title->expects($this->any())->method('prepend')->withAnyParameters()->will($this->returnSelf()); - $requestInterfaceMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')->setMethods( + $requestInterfaceMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)->setMethods( ['getParam', 'getPost', 'getFullActionName', 'getPostValue'] )->disableOriginalConstructor()->getMock(); - $responseInterfaceMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')->setMethods( + $responseInterfaceMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class)->setMethods( ['setRedirect', 'sendResponse'] )->getMock(); - $managerInterfaceMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); + $managerInterfaceMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); $sessionMock = $this->getMock( - 'Magento\Backend\Model\Session', + \Magento\Backend\Model\Session::class, ['getProductData', 'setProductData'], [], '', false ); - $actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); - $helperDataMock = $this->getMock('Magento\Backend\Helper\Data', [], [], '', false); + $actionFlagMock = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); + $helperDataMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); $this->context = $this->getMock( - 'Magento\Backend\App\Action\Context', + \Magento\Backend\App\Action\Context::class, [ 'getRequest', 'getResponse', diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php index 99ca227c898c2..d8c18300a31f2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php @@ -109,22 +109,22 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->request = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface'); + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class); - $this->categoryHelper = $this->getMock('Magento\Catalog\Helper\Category', [], [], '', false); - $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->categoryHelper = $this->getMock(\Magento\Catalog\Helper\Category::class, [], [], '', false); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $this->update = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface'); - $this->layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $this->update = $this->getMock(\Magento\Framework\View\Layout\ProcessorInterface::class); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->update)); - $this->pageConfig = $this->getMockBuilder('Magento\Framework\View\Page\Config') + $this->pageConfig = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class) ->disableOriginalConstructor()->getMock(); $this->pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf()); - $this->page = $this->getMockBuilder('Magento\Framework\View\Page') + $this->page = $this->getMockBuilder(\Magento\Framework\View\Page::class) ->setMethods(['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout', 'addUpdate']) ->disableOriginalConstructor()->getMock(); $this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->pageConfig)); @@ -132,13 +132,13 @@ protected function setUp() $this->page->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout)); $this->page->expects($this->any())->method('addUpdate')->willReturnSelf(); - $this->view = $this->getMock('Magento\Framework\App\ViewInterface'); + $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class); $this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout)); - $this->resultFactory = $this->getMock('Magento\Framework\Controller\ResultFactory', [], [], '', false); + $this->resultFactory = $this->getMock(\Magento\Framework\Controller\ResultFactory::class, [], [], '', false); $this->resultFactory->expects($this->any())->method('create')->will($this->returnValue($this->page)); - $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response)); $this->context->expects($this->any())->method('getObjectManager') @@ -148,16 +148,16 @@ protected function setUp() $this->context->expects($this->any())->method('getResultFactory') ->will($this->returnValue($this->resultFactory)); - $this->category = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); - $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); + $this->category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); + $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); - $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); - $this->catalogDesign = $this->getMock('Magento\Catalog\Model\Design', [], [], '', false); + $this->catalogDesign = $this->getMock(\Magento\Catalog\Model\Design::class, [], [], '', false); - $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -165,7 +165,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->page)); - $this->action = (new ObjectManager($this))->getObject('Magento\Catalog\Controller\Category\View', [ + $this->action = (new ObjectManager($this))->getObject(\Magento\Catalog\Controller\Category\View::class, [ 'context' => $this->context, 'catalogDesign' => $this->catalogDesign, 'categoryRepository' => $this->categoryRepository, @@ -180,7 +180,7 @@ public function testApplyCustomLayoutUpdate() $pageLayout = 'page_layout'; $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - ['Magento\Catalog\Helper\Category', $this->categoryHelper], + [\Magento\Catalog\Helper\Category::class, $this->categoryHelper], ])); $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([ @@ -194,7 +194,7 @@ public function testApplyCustomLayoutUpdate() $this->categoryHelper->expects($this->any())->method('canShow')->will($this->returnValue(true)); $settings = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getPageLayout', 'getLayoutUpdates'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php index ae52427cfbd7e..30939e7c51983 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php @@ -69,17 +69,17 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock( - 'Magento\Framework\App\Action\Context', + $this->contextMock = $this->getMock( + \Magento\Framework\App\Action\Context::class, ['getRequest', 'getResponse', 'getResultRedirectFactory'], [], '', false ); - $this->request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); - $this->redirectFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\RedirectFactory', + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->redirectFactoryMock = $this->getMock( + \Magento\Framework\Controller\Result\RedirectFactory::class, ['create'], [], '', @@ -91,31 +91,43 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->redirectFactoryMock); - $this->itemFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Compare\ItemFactory', + $this->itemFactoryMock = $this->getMock( + \Magento\Catalog\Model\Product\Compare\ItemFactory::class, ['create'], [], '', false ); - $this->collectionFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory', + $this->collectionFactoryMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory::class, ['create'], [], '', false ); - $this->sessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->visitorMock = $this->getMock('Magento\Customer\Model\Visitor', [], [], '', false); - $this->listCompareMock = $this->getMock('Magento\Catalog\Model\Product\Compare\ListCompare', [], [], '', false); - $this->catalogSession = $this->getMock('Magento\Catalog\Model\Session', ['setBeforeCompareUrl'], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->formKeyValidatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->sessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->visitorMock = $this->getMock(\Magento\Customer\Model\Visitor::class, [], [], '', false); + $this->listCompareMock = $this->getMock( + \Magento\Catalog\Model\Product\Compare\ListCompare::class, + [], + [], + '', + false + ); + $this->catalogSession = $this->getMock( + \Magento\Catalog\Model\Session::class, + ['setBeforeCompareUrl'], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->formKeyValidatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $this->pageFactoryMock = $this->getMock('Magento\Framework\View\Result\PageFactory', [], [], '', false); - $this->productRepositoryMock = $this->getMock('Magento\Catalog\Api\ProductRepositoryInterface'); - $this->decoderMock = $this->getMock('Magento\Framework\Url\DecoderInterface'); + $this->pageFactoryMock = $this->getMock(\Magento\Framework\View\Result\PageFactory::class, [], [], '', false); + $this->productRepositoryMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->decoderMock = $this->getMock(\Magento\Framework\Url\DecoderInterface::class); $this->index = new Index( $this->contextMock, @@ -173,7 +185,7 @@ public function testExecuteWithItems() $this->listCompareMock->expects($this->once()) ->method('addProducts') ->with([1, 2, 3]); - $redirect = $this->getMock('Magento\Framework\Controller\Result\Redirect', ['setPath'], [], '', false); + $redirect = $this->getMock(\Magento\Framework\Controller\Result\Redirect::class, ['setPath'], [], '', false); $redirect->expects($this->once()) ->method('setPath') ->with('*/*/*'); diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php index 672f8f2b39e9d..60f1be4213193 100644 --- a/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php @@ -7,6 +7,9 @@ use Magento\Framework\App\ResourceConnection; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RefreshSpecialPricesTest extends \PHPUnit_Framework_TestCase { /** @@ -54,18 +57,18 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], [], '', false ); - $this->_resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->_dateTimeMock = $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false); - $this->_localeDateMock = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); - $this->_eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->_resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->_dateTimeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime::class, [], [], '', false); + $this->_localeDateMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->_eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); $this->_priceProcessorMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Price\Processor', + \Magento\Catalog\Model\Indexer\Product\Price\Processor::class, [], [], '', @@ -73,7 +76,7 @@ protected function setUp() ); $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Cron\RefreshSpecialPrices', + \Magento\Catalog\Cron\RefreshSpecialPrices::class, [ 'storeManager' => $this->_storeManagerMock, 'resource' => $this->_resourceMock, @@ -89,11 +92,11 @@ public function testRefreshSpecialPrices() { $idsToProcess = [1, 2, 3]; - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $selectMock->expects($this->any())->method('where')->will($this->returnSelf()); - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); $connectionMock->expects( $this->any() @@ -113,7 +116,7 @@ public function testRefreshSpecialPrices() $this->returnValue($connectionMock) ); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->_storeManagerMock->expects( @@ -136,7 +139,7 @@ public function testRefreshSpecialPrices() $this->returnValue(32000) ); - $indexerMock = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerMock = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $indexerMock->expects($this->exactly(2))->method('reindexList'); $this->_priceProcessorMock->expects( @@ -148,7 +151,7 @@ public function testRefreshSpecialPrices() ); $attributeMock = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [], '', false, diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php index bb7e2e7d09791..206f20bc98179 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php @@ -47,11 +47,11 @@ protected function setUp() $this->mockContext(); $this->mockImage(); - $this->assetRepository = $this->getMockBuilder('Magento\Framework\View\Asset\Repository') + $this->assetRepository = $this->getMockBuilder(\Magento\Framework\View\Asset\Repository::class) ->disableOriginalConstructor() ->getMock(); - $this->viewConfig = $this->getMockBuilder('Magento\Framework\View\ConfigInterface') + $this->viewConfig = $this->getMockBuilder(\Magento\Framework\View\ConfigInterface::class) ->getMockForAbstractClass(); $this->helper = new \Magento\Catalog\Helper\Image( @@ -64,11 +64,11 @@ protected function setUp() protected function mockContext() { - $this->context = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); $this->context->expects($this->any()) ->method('getScopeConfig') @@ -77,12 +77,12 @@ protected function mockContext() protected function mockImage() { - $this->imageFactory = $this->getMockBuilder('Magento\Catalog\Model\Product\ImageFactory') + $this->imageFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\ImageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->image = $this->getMockBuilder('Magento\Catalog\Model\Product\Image') + $this->image = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image::class) ->disableOriginalConstructor() ->getMock(); $this->imageFactory->expects($this->any()) @@ -99,7 +99,7 @@ public function testInit($data) $imageId = 'test_image_id'; $attributes = []; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -108,7 +108,7 @@ public function testInit($data) $this->prepareWatermarkProperties($data); $this->assertInstanceOf( - 'Magento\Catalog\Helper\Image', + \Magento\Catalog\Helper\Image::class, $this->helper->init($productMock, $imageId, $attributes) ); } @@ -145,7 +145,7 @@ public function initDataProvider() */ protected function prepareAttributes($data, $imageId) { - $configViewMock = $this->getMockBuilder('Magento\Framework\Config\View') + $configViewMock = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->disableOriginalConstructor() ->getMock(); $configViewMock->expects($this->once()) @@ -262,7 +262,7 @@ public function testGetType() 'type' => 'image', ]; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -281,7 +281,7 @@ public function testGetWidth() 'width' => 100, ]; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -300,7 +300,7 @@ public function testGetHeight($data) $imageId = 'test_image_id'; $attributes = []; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -342,7 +342,7 @@ public function testGetFrame($data) $imageId = 'test_image_id'; $attributes = []; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -379,7 +379,7 @@ public function testGetLabel($data, $expected) $imageId = 'test_image_id'; $attributes = []; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); @@ -443,7 +443,7 @@ public function testGetResizedImageInfo( $isBaseFilePlaceholder, $resizedImageInfo ) { - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php index d025ebd2f038b..29786ecdce969 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php @@ -52,17 +52,23 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urlBuilder = $this->getMock('Magento\Framework\Url', ['getUrl'], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getServer', 'isSecure'], [], '', false); + $this->urlBuilder = $this->getMock(\Magento\Framework\Url::class, ['getUrl'], [], '', false); + $this->request = $this->getMock( + \Magento\Framework\App\Request\Http::class, + ['getServer', 'isSecure'], + [], + '', + false + ); /** @var \Magento\Framework\App\Helper\Context $context */ $this->context = $this->getMock( - 'Magento\Framework\App\Helper\Context', + \Magento\Framework\App\Helper\Context::class, ['getUrlBuilder', 'getRequest', 'getUrlEncoder'], [], '', false ); - $this->urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface')->getMock(); + $this->urlEncoder = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class)->getMock(); $this->urlEncoder->expects($this->any()) ->method('encode') ->willReturnCallback(function ($url) { @@ -78,14 +84,14 @@ protected function setUp() ->method('getUrlEncoder') ->will($this->returnValue($this->urlEncoder)); $this->postDataHelper = $this->getMock( - 'Magento\Framework\Data\Helper\PostHelper', + \Magento\Framework\Data\Helper\PostHelper::class, ['getPostData'], [], '', false ); $this->catalogSessionMock = $this->getMock( - '\Magento\Catalog\Model\Session', + \Magento\Catalog\Model\Session::class, ['getBeforeCompareUrl'], [], '', @@ -93,7 +99,7 @@ protected function setUp() ); $this->compareHelper = $objectManager->getObject( - 'Magento\Catalog\Helper\Product\Compare', + \Magento\Catalog\Helper\Product\Compare::class, [ 'context' => $this->context, 'postHelper' => $this->postDataHelper, @@ -128,7 +134,7 @@ public function testGetPostDataRemove() ->will($this->returnValue(true)); /** @var \Magento\Catalog\Model\Product | \PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMock('Magento\Catalog\Model\Product', ['getId', '__wakeup'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getId', '__wakeup'], [], '', false); $product->expects($this->once()) ->method('getId') ->will($this->returnValue($productId)); @@ -190,7 +196,7 @@ public function testGetAddToCartUrl() '_secure' => $isRequestSecure ]; - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->catalogSessionMock->expects($this->once())->method('getBeforeCompareUrl')->willReturn($beforeCompareUrl); $productMock->expects($this->once())->method('getId')->willReturn($productId); $this->urlEncoder->expects($this->once())->method('encode')->with($beforeCompareUrl) diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php index 26258cf6f3b11..f7ef5095529ec 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php @@ -21,7 +21,7 @@ protected function setUp() { $this->instancesType = ['simple' => 'simple', 'default' => 'default']; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Catalog\Helper\Product\ConfigurationPool($objectManagerMock, $this->instancesType); } diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php index 6bd60f3655e55..a6b11d7993950 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php @@ -30,14 +30,14 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false ); $this->attribute = $objectManager->getObject( - 'Magento\Catalog\Helper\Product\Edit\Action\Attribute', + \Magento\Catalog\Helper\Product\Edit\Action\Attribute::class, [ 'storeManager' => $this->storeManagerMock ] @@ -54,7 +54,7 @@ public function testGetStoreWebsiteId() $storeId = 20; $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php index 8109cb6732502..1e31d494fa422 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php @@ -7,6 +7,9 @@ use Magento\Framework\App\ResourceConnection; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class IndexerTest extends \PHPUnit_Framework_TestCase { /** @@ -41,10 +44,10 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $contextMock = $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false); $this->_resourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', @@ -53,7 +56,7 @@ protected function setUp() $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); $flatHelperMock = $this->getMock( - 'Magento\Catalog\Helper\Product\Flat\Indexer', + \Magento\Catalog\Helper\Product\Flat\Indexer::class, ['isAddChildData'], [], '', @@ -61,24 +64,24 @@ protected function setUp() ); $flatHelperMock->expects($this->any())->method('isAddChildData')->will($this->returnValue(true)); - $eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $attributeConfigMock = $this->getMock('Magento\Catalog\Model\Attribute\Config', [], [], '', false); + $attributeConfigMock = $this->getMock(\Magento\Catalog\Model\Attribute\Config::class, [], [], '', false); $resourceConfigFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\ConfigFactory', + \Magento\Catalog\Model\ResourceModel\ConfigFactory::class, ['create'], [], '', false ); - $eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', ['create'], [], '', false); + $eavFactoryMock = $this->getMock(\Magento\Eav\Model\Entity\AttributeFactory::class, ['create'], [], '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->_connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['getTables', 'dropTable'], [], '', @@ -86,7 +89,7 @@ protected function setUp() ); $this->_changelogMock = $this->getMock( - 'Magento\Framework\Mview\View\Changelog', + \Magento\Framework\Mview\View\Changelog::class, ['getName'], [], '', @@ -95,7 +98,7 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Helper\Product\Flat\Indexer', + \Magento\Catalog\Helper\Product\Flat\Indexer::class, [ 'context' => $contextMock, 'resource' => $this->_resourceMock, @@ -257,7 +260,7 @@ protected function _setStoreManagerExpectedStores(array $storeIds) $stores = []; foreach ($storeIds as $storeId) { $store = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getId', '__sleep', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php index 4b6226a1d24dc..53285abb5106b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php @@ -22,7 +22,7 @@ protected function setUp() ]; $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_productHelper = $objectManager->getObject('Magento\Catalog\Helper\Product', $arguments); + $this->_productHelper = $objectManager->getObject(\Magento\Catalog\Helper\Product::class, $arguments); } /** @@ -41,9 +41,14 @@ public function testIsDataForPriceIndexerWasChanged($data, $result) */ public function getData() { - $product1 = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $product1 = $this->getMockBuilder( + \Magento\Catalog\Model\Product::class + )->disableOriginalConstructor()->getMock(); + + $product2 = $this->getMockBuilder( + \Magento\Catalog\Model\Product::class + )->disableOriginalConstructor()->getMock(); - $product2 = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); $product2->expects( $this->once() )->method( @@ -54,7 +59,9 @@ public function getData() $this->returnValue(true) ); - $product3 = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $product3 = $this->getMockBuilder( + \Magento\Catalog\Model\Product::class + )->disableOriginalConstructor()->getMock(); $product3->expects( $this->once() )->method( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php index ee7584182a0ea..0f389224fef14 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php @@ -57,8 +57,8 @@ public function validateProvider() protected function setUp() { $helper = new ObjectManager($this); - $this->model = $helper->getObject( - '\Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate', + $this->model = $helper->getObject( + \Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate::class, [ 'layoutUpdateValidatorFactory' => $this->getMockedLayoutUpdateValidatorFactory() ] @@ -71,7 +71,7 @@ protected function setUp() */ private function getMockedLayoutUpdateValidatorFactory() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\View\Model\Layout\Update\ValidatorFactory'); + $mockBuilder = $this->getMockBuilder(\Magento\Framework\View\Model\Layout\Update\ValidatorFactory::class); $mockBuilder->disableOriginalConstructor(); $mockBuilder->setMethods(['create']); $mock = $mockBuilder->getMock(); @@ -88,7 +88,7 @@ private function getMockedLayoutUpdateValidatorFactory() */ private function getMockedValidator() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\View\Model\Layout\Update\Validator'); + $mockBuilder = $this->getMockBuilder(\Magento\Framework\View\Model\Layout\Update\Validator::class); $mockBuilder->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -122,7 +122,7 @@ function ($xml) { */ private function getMockedAttribute() { - $mockBuilder = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute'); + $mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class); $mockBuilder->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php index dff208aca8111..6a843c179107b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php @@ -34,7 +34,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); + $this->_fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); $this->_fileResolverMock->expects( $this->once() )->method( @@ -51,10 +51,10 @@ protected function setUp() ) ); - $this->_converter = $this->getMock('Magento\Catalog\Model\Attribute\Config\Converter', ['convert']); + $this->_converter = $this->getMock(\Magento\Catalog\Model\Attribute\Config\Converter::class, ['convert']); $moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['getModuleDir'], [], '', @@ -72,7 +72,7 @@ protected function setUp() ); $this->_schemaLocator = new \Magento\Catalog\Model\Attribute\Config\SchemaLocator($moduleReader); - $this->_validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->_validationState = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->_validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php index 2c0f641d24849..470faa23de58c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php @@ -20,7 +20,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', + \Magento\Framework\Module\Dir\Reader::class, ['getModuleDir'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php index dd2b229324958..bdc897ebc0047 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php @@ -30,7 +30,13 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock = $this->getMock( + \Magento\Framework\Config\ValidationStateInterface::class, + [], + [], + '', + false + ); $validationStateMock->method('isValidationRequired') ->willReturn(true); $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php index cce9169113d1c..358a5ed67e63d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php @@ -20,7 +20,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_dataStorage = $this->getMock( - 'Magento\Catalog\Model\Attribute\Config\Data', + \Magento\Catalog\Model\Attribute\Config\Data::class, ['get'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php index 791f1548ee5b1..7545fbd44d0fb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php @@ -20,7 +20,7 @@ class LockValidatorCompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); } /** @@ -28,7 +28,7 @@ protected function setUp() */ public function testCompositionsWithInvalidValidatorInstance() { - $validators = ['Magento\Catalog\Model']; + $validators = [\Magento\Catalog\Model\Attribute\Backend\Startdate::class]; $this->model = new \Magento\Catalog\Model\Attribute\LockValidatorComposite( $this->objectManagerMock, $validators @@ -37,14 +37,14 @@ public function testCompositionsWithInvalidValidatorInstance() public function testValidateWithValidValidatorInstance() { - $validators = ['Magento\Catalog\Model\Attribute\LockValidatorComposite']; - $lockValidatorMock = $this->getMock('Magento\Catalog\Model\Attribute\LockValidatorInterface'); + $validators = [\Magento\Catalog\Model\Attribute\LockValidatorComposite::class]; + $lockValidatorMock = $this->getMock(\Magento\Catalog\Model\Attribute\LockValidatorInterface::class); $this->objectManagerMock->expects( $this->any() )->method( 'get' )->with( - 'Magento\Catalog\Model\Attribute\LockValidatorComposite' + \Magento\Catalog\Model\Attribute\LockValidatorComposite::class )->will( $this->returnValue($lockValidatorMock) ); @@ -53,7 +53,7 @@ public function testValidateWithValidValidatorInstance() $this->objectManagerMock, $validators ); - $abstractModelHelper = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false, false); + $abstractModelHelper = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false, false); $lockValidatorMock->expects($this->once())->method('validate')->with($abstractModelHelper); $this->model->validate($abstractModelHelper); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php index c475ef788e229..b720856d8554d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php @@ -36,13 +36,13 @@ protected function setUp() { $this->markTestSkipped('Due to MAGETWO-48956'); $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->_model = $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Category\Attribute\Backend\Sortby', + $this->_scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_model = $this->_objectHelper->getObject( + \Magento\Catalog\Model\Category\Attribute\Backend\Sortby::class, ['scopeConfig' => $this->_scopeConfig] ); - $this->_attribute = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + $this->_attribute = $this->getMock( + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [ 'getName', '__call', @@ -196,8 +196,8 @@ public function testValidateUnique() $this->_attribute->expects($this->at(1))->method('getIsRequired'); $this->_attribute->expects($this->at(2))->method('getIsUnique')->will($this->returnValue(true)); - $entityMock = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\AbstractEntity', + $entityMock = $this->getMockForAbstractClass( + \Magento\Eav\Model\Entity\AbstractEntity::class, [], '', false, @@ -219,8 +219,8 @@ public function testValidateUniqueException() $this->_attribute->expects($this->at(1))->method('getIsRequired'); $this->_attribute->expects($this->at(2))->method('getIsUnique')->will($this->returnValue(true)); - $entityMock = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\AbstractEntity', + $entityMock = $this->getMockForAbstractClass( + \Magento\Eav\Model\Entity\AbstractEntity::class, [], '', false, @@ -228,8 +228,8 @@ public function testValidateUniqueException() true, ['checkAttributeUniqueValue'] ); - $frontMock = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend', + $frontMock = $this->getMockForAbstractClass( + \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class, [], '', false, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php index e25168688a1c9..7b2e1d8416dec 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php @@ -10,6 +10,7 @@ class LayoutTest extends \PHPUnit_Framework_TestCase { private $testArray = ['test1', ['test1']]; + /** * @var \Magento\Catalog\Model\Category\Attribute\Source\Layout */ @@ -26,7 +27,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Category\Attribute\Source\Layout', + \Magento\Catalog\Model\Category\Attribute\Source\Layout::class, [ 'pageLayoutBuilder' => $this->getMockedPageLayoutBuilder() ] @@ -38,7 +39,7 @@ protected function setUp() */ private function getMockedPageLayoutBuilder() { - $mockPageLayoutConfig = $this->getMockBuilder('Magento\Framework\View\PageLayout\Config') + $mockPageLayoutConfig = $this->getMockBuilder(\Magento\Framework\View\PageLayout\Config::class) ->disableOriginalConstructor() ->getMock(); $mockPageLayoutConfig->expects($this->any()) @@ -46,7 +47,7 @@ private function getMockedPageLayoutBuilder() ->will($this->returnValue($this->testArray)); $mockPageLayoutBuilder = $this->getMockBuilder( - 'Magento\Framework\View\Model\PageLayout\Config\BuilderInterface' + \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface::class )->disableOriginalConstructor()->getMock(); $mockPageLayoutBuilder->expects($this->once()) ->method('getPageLayoutsConfig') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php index 338fee0ebdb34..3da324850044c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php @@ -31,7 +31,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Category\Attribute\Source\Page', + \Magento\Catalog\Model\Category\Attribute\Source\Page::class, [ 'blockCollectionFactory' => $this->getMockedBlockCollectionFactory() ] @@ -45,7 +45,7 @@ private function getMockedBlockCollectionFactory() { $mockedCollection = $this->getMockedCollection(); - $mockBuilder = $this->getMockBuilder('Magento\Cms\Model\ResourceModel\Block\CollectionFactory'); + $mockBuilder = $this->getMockBuilder(\Magento\Cms\Model\ResourceModel\Block\CollectionFactory::class); $mock = $mockBuilder->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -62,7 +62,7 @@ private function getMockedBlockCollectionFactory() */ private function getMockedCollection() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\Data\Collection'); + $mockBuilder = $this->getMockBuilder(\Magento\Framework\Data\Collection::class); $mock = $mockBuilder->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php index 329da9fed4ae6..9769c20686ea7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php @@ -24,7 +24,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Category\Attribute\Source\Sortby', + \Magento\Catalog\Model\Category\Attribute\Source\Sortby::class, [ 'catalogConfig' => $this->getMockedConfig() ] @@ -36,7 +36,7 @@ protected function setUp() */ private function getMockedConfig() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Config'); + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Config::class); $mockBuilder->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php index ac70256b841f1..c7805f0fa8d28 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php @@ -12,6 +12,9 @@ use Magento\Catalog\Model\Category\AttributeRepository; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -47,14 +50,14 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->searchBuilderMock = - $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); + $this->getMock(\Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false); $this->filterBuilderMock = - $this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false); + $this->getMock(\Magento\Framework\Api\FilterBuilder::class, [], [], '', false); $this->attributeRepositoryMock = - $this->getMock('Magento\Eav\Api\AttributeRepositoryInterface', [], [], '', false); + $this->getMock(\Magento\Eav\Api\AttributeRepositoryInterface::class, [], [], '', false); $this->searchResultMock = $this->getMock( - 'Magento\Framework\Api\SearchResultsInterface', + \Magento\Framework\Api\SearchResultsInterface::class, [ 'getItems', 'getSearchCriteria', @@ -67,11 +70,11 @@ protected function setUp() [], '', false); - $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); $this->eavConfigMock->expects($this->any())->method('getEntityType') ->willReturn(new \Magento\Framework\DataObject(['default_attribute_set_id' => 3])); $this->model = (new ObjectManager($this))->getObject( - 'Magento\Catalog\Model\Category\AttributeRepository', + \Magento\Catalog\Model\Category\AttributeRepository::class, [ 'searchCriteriaBuilder' => $this->searchBuilderMock, 'filterBuilder' => $this->filterBuilderMock, @@ -83,7 +86,7 @@ protected function setUp() public function testGetList() { - $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $this->attributeRepositoryMock->expects($this->once()) ->method('getList') ->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE, $searchCriteriaMock) @@ -96,7 +99,7 @@ public function testGet() { $attributeCode = 'some Attribute Code'; $dataInterfaceMock = - $this->getMock('Magento\Catalog\Api\Data\CategoryAttributeInterface', [], [], '', false); + $this->getMock(\Magento\Catalog\Api\Data\CategoryAttributeInterface::class, [], [], '', false); $this->attributeRepositoryMock->expects($this->once()) ->method('get') ->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE, $attributeCode) @@ -107,7 +110,7 @@ public function testGet() public function testGetCustomAttributesMetadata() { - $filterMock = $this->getMock('Magento\Framework\Service\V1\Data\Filter', [], [], '', false); + $filterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); $this->filterBuilderMock->expects($this->once())->method('setField') ->with('attribute_set_id')->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setValue')->with( @@ -115,9 +118,9 @@ public function testGetCustomAttributesMetadata() )->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock])->willReturnSelf(); - $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $this->searchBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); - $itemMock = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $itemMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->attributeRepositoryMock->expects($this->once())->method('getList')->with( \Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE, $searchCriteriaMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php index b0105f44f8420..adf78761d5e2e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php @@ -49,28 +49,28 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->categoryTreeMock = $this->getMockBuilder( - '\Magento\Catalog\Model\ResourceModel\Category\Tree' + $this->categoryTreeMock = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Category\Tree::class )->disableOriginalConstructor() ->getMock(); - $this->categoryCollection = $this->getMockBuilder( - '\Magento\Catalog\Model\ResourceModel\Category\Collection' + $this->categoryCollection = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Category\Collection::class )->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + $this->storeManagerMock = $this->getMockBuilder( + \Magento\Store\Model\StoreManagerInterface::class )->disableOriginalConstructor() ->getMock(); $methods = ['create']; $this->treeFactoryMock = - $this->getMock('\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory', $methods, [], '', false); + $this->getMock(\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory::class, $methods, [], '', false); $this->tree = $this->objectManager - ->getObject( - 'Magento\Catalog\Model\Category\Tree', + ->getObject( + \Magento\Catalog\Model\Category\Tree::class, [ 'categoryCollection' => $this->categoryCollection, 'categoryTree' => $this->categoryTreeMock, @@ -82,14 +82,14 @@ protected function setUp() public function testGetNode() { - $category = $this->getMockBuilder( - '\Magento\Catalog\Model\Category' + $category = $this->getMockBuilder( + \Magento\Catalog\Model\Category::class )->disableOriginalConstructor() ->getMock(); $category->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); - $node = $this->getMockBuilder( - '\Magento\Framework\Data\Tree\Node' + $node = $this->getMockBuilder( + \Magento\Framework\Data\Tree\Node::class )->disableOriginalConstructor() ->getMock(); $node->expects($this->once())->method('loadChildren'); @@ -97,7 +97,7 @@ public function testGetNode() ->with($this->equalTo(1)) ->will($this->returnValue($node)); - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($store)); @@ -113,7 +113,7 @@ public function testGetNode() public function testGetRootNode() { - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->once())->method('getRootCategoryId')->will($this->returnValue(2)); $store->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); @@ -123,8 +123,8 @@ public function testGetRootNode() $this->categoryCollection->expects($this->once())->method('setLoadProductCount')->will($this->returnSelf()); $this->categoryCollection->expects($this->once())->method('setStoreId')->will($this->returnSelf()); - $node = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Category\Tree' + $node = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Category\Tree::class )->disableOriginalConstructor() ->getMock(); $node->expects($this->once())->method('addCollectionData') @@ -141,7 +141,7 @@ public function testGetTree() $depth = 2; $currentLevel = 1; - $treeNodeMock1 = $this->getMock('\Magento\Catalog\Api\Data\CategoryTreeInterface'); + $treeNodeMock1 = $this->getMock(\Magento\Catalog\Api\Data\CategoryTreeInterface::class); $treeNodeMock1->expects($this->once())->method('setId')->with($this->equalTo($currentLevel)) ->will($this->returnSelf()); $treeNodeMock1->expects($this->once())->method('setParentId')->with($this->equalTo($currentLevel - 1)) @@ -158,7 +158,7 @@ public function testGetTree() ->will($this->returnSelf()); $treeNodeMock1->expects($this->once())->method('setChildrenData')->will($this->returnSelf()); - $treeNodeMock2 = $this->getMock('\Magento\Catalog\Api\Data\CategoryTreeInterface'); + $treeNodeMock2 = $this->getMock(\Magento\Catalog\Api\Data\CategoryTreeInterface::class); $treeNodeMock2->expects($this->once())->method('setId')->with($this->equalTo($currentLevel)) ->will($this->returnSelf()); $treeNodeMock2->expects($this->once())->method('setParentId')->with($this->equalTo($currentLevel - 1)) @@ -178,7 +178,7 @@ public function testGetTree() $this->treeFactoryMock->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($treeNodeMock1, $treeNodeMock2)); - $node = $this->getMockBuilder('Magento\Framework\Data\Tree\Node')->disableOriginalConstructor() + $node = $this->getMockBuilder(\Magento\Framework\Data\Tree\Node::class)->disableOriginalConstructor() ->setMethods( [ 'hasChildren', @@ -209,7 +209,7 @@ public function testGetTree() public function testGetTreeWhenChildrenAreNotExist() { $currentLevel = 1; - $treeNodeMock = $this->getMock('\Magento\Catalog\Api\Data\CategoryTreeInterface'); + $treeNodeMock = $this->getMock(\Magento\Catalog\Api\Data\CategoryTreeInterface::class); $this->treeFactoryMock->expects($this->any())->method('create')->will($this->returnValue($treeNodeMock)); $treeNodeMock->expects($this->once())->method('setId')->with($this->equalTo($currentLevel)) ->will($this->returnSelf()); @@ -227,7 +227,7 @@ public function testGetTreeWhenChildrenAreNotExist() ->will($this->returnSelf()); $treeNodeMock->expects($this->once())->method('setChildrenData')->will($this->returnSelf()); - $node = $this->getMockBuilder('Magento\Framework\Data\Tree\Node')->disableOriginalConstructor() + $node = $this->getMockBuilder(\Magento\Framework\Data\Tree\Node::class)->disableOriginalConstructor() ->setMethods( [ 'hasChildren', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php index 38061c6fc2f65..75fce8983889b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php @@ -26,16 +26,22 @@ class CategoryLinkManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->categoryRepositoryMock = $this->getMock('\Magento\Catalog\Model\CategoryRepository', [], [], '', false); - $productResource = $this->getMock('Magento\Catalog\Model\ResourceModel\Product', [], [], '', false); - $categoryLinkRepository = $this->getMockBuilder('Magento\Catalog\Api\CategoryLinkRepositoryInterface') + $this->categoryRepositoryMock = $this->getMock( + \Magento\Catalog\Model\CategoryRepository::class, + [], + [], + '', + false + ); + $productResource = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); + $categoryLinkRepository = $this->getMockBuilder(\Magento\Catalog\Api\CategoryLinkRepositoryInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $indexerRegistry = $this->getMockBuilder('Magento\Framework\Indexer\IndexerRegistry') + $indexerRegistry = $this->getMockBuilder(\Magento\Framework\Indexer\IndexerRegistry::class) ->disableOriginalConstructor() ->getMock(); $this->productLinkFactoryMock = $this->getMock( - '\Magento\Catalog\Api\Data\CategoryProductLinkInterfaceFactory', + \Magento\Catalog\Api\Data\CategoryProductLinkInterfaceFactory::class, ['create'], [], '', @@ -61,19 +67,25 @@ public function testGetAssignedProducts() $productId = 55; $position = 25; $productSku = 'testSku'; - $categoryProductLinkMock = $this->getMock('\Magento\Catalog\Api\Data\CategoryProductLinkInterface'); + $categoryProductLinkMock = $this->getMock(\Magento\Catalog\Api\Data\CategoryProductLinkInterface::class); $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [], [], '', false ); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $productMock->expects($this->once())->method('getSku')->willReturn($productSku); $productMock->expects($this->once())->method('getData')->with('cat_index_position')->willReturn($position); $items = [$productId => $productMock]; - $productsMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $productsMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, + [], + [], + '', + false + ); $this->categoryRepositoryMock->expects($this->once())->method('get')->with($categoryId) ->willReturn($categoryMock); $categoryMock->expects($this->once())->method('getProductCollection')->willReturn($productsMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php index 4c6d7c5a97aba..d0c0e2ff2fa52 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php @@ -30,9 +30,9 @@ class CategoryLinkRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->categoryRepositoryMock = $this->getMock('\Magento\Catalog\Api\CategoryRepositoryInterface'); - $this->productRepositoryMock = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface'); - $this->productLinkMock = $this->getMock('\Magento\Catalog\Api\Data\CategoryProductLinkInterface'); + $this->categoryRepositoryMock = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $this->productRepositoryMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->productLinkMock = $this->getMock(\Magento\Catalog\Api\Data\CategoryProductLinkInterface::class); $this->model = new \Magento\Catalog\Model\CategoryLinkRepository( $this->categoryRepositoryMock, $this->productRepositoryMock @@ -47,14 +47,14 @@ public function testSave() $sku = 'testSku'; $productPositions = [$productId => $productPosition]; $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getPostedProducts', 'getProductsPosition', 'setPostedProducts', 'save'], [], '', false ); $productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', @@ -85,14 +85,14 @@ public function testSaveWithCouldNotSaveException() $sku = 'testSku'; $productPositions = [$productId => $productPosition]; $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getProductsPosition', 'setPostedProducts', 'save', 'getId'], [], '', false ); $productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', @@ -119,14 +119,14 @@ public function testDeleteByIds() $productId = 55; $productPositions = [55 => 1]; $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getProductsPosition', 'setPostedProducts', 'save', 'getId'], [], '', false ); $productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', @@ -154,14 +154,14 @@ public function testDeleteByIdsWithCouldNotSaveException() $productId = 55; $productPositions = [55 => 1]; $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getProductsPosition', 'setPostedProducts', 'save', 'getId'], [], '', false ); $productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', @@ -192,14 +192,14 @@ public function testDeleteWithInputException() $this->productLinkMock->expects($this->once())->method('getCategoryId')->willReturn($categoryId); $this->productLinkMock->expects($this->once())->method('getSku')->willReturn($productSku); $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getProductsPosition', 'setPostedProducts', 'save', 'getId'], [], '', false ); $productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', @@ -225,14 +225,14 @@ public function testDelete() $this->productLinkMock->expects($this->once())->method('getCategoryId')->willReturn($categoryId); $this->productLinkMock->expects($this->once())->method('getSku')->willReturn($productSku); $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getProductsPosition', 'setPostedProducts', 'save', 'getId'], [], '', false ); $productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php index 14c8088e70c46..64efa50c31331 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php @@ -29,10 +29,10 @@ class CategoryManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->categoryRepositoryMock = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); - $this->categoryTreeMock = $this->getMock('Magento\Catalog\Model\Category\Tree', [], [], '', false); + $this->categoryRepositoryMock = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $this->categoryTreeMock = $this->getMock(\Magento\Catalog\Model\Category\Tree::class, [], [], '', false); $this->categoriesFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Category\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class, ['create'], [], '', @@ -49,8 +49,8 @@ public function testGetTree() { $rootCategoryId = 1; $depth = 2; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); - $nodeMock = $this->getMock('\Magento\Framework\Data\Tree\Node', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); + $nodeMock = $this->getMock(\Magento\Framework\Data\Tree\Node::class, [], [], '', false); $this->categoryRepositoryMock ->expects($this->once()) @@ -93,9 +93,9 @@ public function testMove() $categoryId = 2; $parentId = 1; $afterId = null; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], 'categoryMock', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], 'categoryMock', false); $parentCategoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [], [], 'parentCategoryMock', @@ -128,9 +128,9 @@ public function testMoveWithException() $categoryId = 2; $parentId = 1; $afterId = null; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], 'categoryMock', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], 'categoryMock', false); $parentCategoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [], [], 'parentCategoryMock', @@ -160,9 +160,9 @@ public function testMoveWithCouldNotMoveException() $categoryId = 2; $parentId = 1; $afterId = null; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], 'categoryMock', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], 'categoryMock', false); $parentCategoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [], [], 'parentCategoryMock', @@ -187,7 +187,13 @@ public function testMoveWithCouldNotMoveException() public function testGetCount() { - $categoriesMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Category\Collection', [], [], '', false); + $categoriesMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category\Collection::class, + [], + [], + '', + false + ); $this->categoriesFactoryMock ->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php index 04b6d809f7f44..8f39dafbd73cf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Catalog\Test\Unit\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CategoryRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -45,28 +48,28 @@ class CategoryRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->categoryFactoryMock = $this->getMock( - '\Magento\Catalog\Model\CategoryFactory', + \Magento\Catalog\Model\CategoryFactory::class, ['create'], [], '', false ); $this->categoryResourceMock = - $this->getMock('\Magento\Catalog\Model\ResourceModel\Category', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->storeMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface') + $this->getMock(\Magento\Catalog\Model\ResourceModel\Category::class, [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMockForAbstractClass(); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->extensibleDataObjectConverterMock = $this - ->getMockBuilder('\Magento\Framework\Api\ExtensibleDataObjectConverter') + ->getMockBuilder(\Magento\Framework\Api\ExtensibleDataObjectConverter::class) ->setMethods(['toNestedArray']) ->disableOriginalConstructor() ->getMock(); $metadataMock = $this->getMock( - 'Magento\Framework\EntityManager\EntityMetadata', + \Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', @@ -77,7 +80,7 @@ protected function setUp() ->willReturn('entity_id'); $this->metadataPoolMock = $this->getMock( - 'Magento\Framework\EntityManager\MetadataPool', + \Magento\Framework\EntityManager\MetadataPool::class, [], [], '', @@ -108,7 +111,7 @@ protected function setUp() public function testGet() { $categoryId = 5; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects( $this->once() )->method('getId')->willReturn( @@ -135,7 +138,7 @@ public function testGet() public function testGetWhenCategoryDoesNotExist() { $categoryId = 5; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects( $this->once() )->method('getId')->willReturn(null); @@ -190,7 +193,7 @@ public function filterExtraFieldsOnUpdateCategoryDataProvider() public function testFilterExtraFieldsOnUpdateCategory($categoryId, $categoryData, $dataForSave) { $this->storeMock->expects($this->any())->method('getId')->willReturn(1); - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false, true, true); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false, true, true); $categoryMock->expects( $this->atLeastOnce() )->method('getId')->willReturn($categoryId); @@ -207,7 +210,7 @@ public function testFilterExtraFieldsOnUpdateCategory($categoryId, $categoryData $categoryMock->expects($this->once())->method('addData')->with($dataForSave); $this->categoryResourceMock->expects($this->once()) ->method('save') - ->willReturn('\Magento\Framework\DataObject'); + ->willReturn(\Magento\Framework\DataObject::class); $this->assertEquals($categoryMock, $this->model->save($categoryMock)); } @@ -223,8 +226,8 @@ public function testCreateNewCategory() ->expects($this->once()) ->method('toNestedArray') ->will($this->returnValue($categoryData)); - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false, true, true); - $parentCategoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false, true, true); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false, true, true); + $parentCategoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false, true, true); $categoryMock->expects($this->any())->method('getId') ->will($this->onConsecutiveCalls($categoryId, $newCategoryId)); $this->categoryFactoryMock->expects($this->exactly(2))->method('create')->willReturn($parentCategoryMock); @@ -236,7 +239,7 @@ public function testCreateNewCategory() $categoryMock->expects($this->once())->method('validate')->willReturn(true); $this->categoryResourceMock->expects($this->once()) ->method('save') - ->willReturn('\Magento\Framework\DataObject'); + ->willReturn(\Magento\Framework\DataObject::class); $this->assertEquals($categoryMock, $this->model->save($categoryMock)); } @@ -247,7 +250,7 @@ public function testCreateNewCategory() public function testSaveWithException() { $categoryId = 5; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false, true, true); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false, true, true); $this->extensibleDataObjectConverterMock ->expects($this->once()) ->method('toNestedArray') @@ -271,12 +274,12 @@ public function testSaveWithValidateCategoryException($error, $expectedException { $this->setExpectedException($expectedException, $expectedExceptionMessage); $categoryId = 5; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $this->extensibleDataObjectConverterMock ->expects($this->once()) ->method('toNestedArray') ->will($this->returnValue([])); - $objectMock = $this->getMock('\Magento\Framework\DataObject', ['getFrontend', 'getLabel'], [], '', false); + $objectMock = $this->getMock(\Magento\Framework\DataObject::class, ['getFrontend', 'getLabel'], [], '', false); $categoryMock->expects( $this->atLeastOnce() )->method('getId')->willReturn($categoryId); @@ -297,12 +300,10 @@ public function saveWithValidateCategoryExceptionDataProvider() { return [ [ - true, - '\Magento\Framework\Exception\CouldNotSaveException', + true, \Magento\Framework\Exception\CouldNotSaveException::class, 'Could not save category: Attribute "ValidateCategoryTest" is required.', ], [ - 'Something went wrong', - '\magento\Framework\Exception\CouldNotSaveException', + 'Something went wrong', \Magento\Framework\Exception\CouldNotSaveException::class, 'Could not save category: Something went wrong' ] ]; @@ -310,7 +311,7 @@ public function saveWithValidateCategoryExceptionDataProvider() public function testDelete() { - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false, true, true); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false, true, true); $this->assertTrue($this->model->delete($categoryMock)); } @@ -321,7 +322,7 @@ public function testDelete() */ public function testDeleteWithException() { - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false, true, true); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false, true, true); $this->categoryResourceMock->expects($this->once())->method('delete')->willThrowException(new \Exception()); $this->model->delete($categoryMock); } @@ -329,7 +330,7 @@ public function testDeleteWithException() public function testDeleteByIdentifier() { $categoryId = 5; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects( $this->any() )->method('getId')->willReturn( @@ -355,7 +356,7 @@ public function testDeleteByIdentifier() public function testDeleteByIdentifierWithException() { $categoryId = 5; - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects( $this->once() )->method('getId')->willReturn(null); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php index 34acce7844723..471037f1d3f45 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php @@ -91,76 +91,88 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock( - 'Magento\Framework\Model\Context', + $this->context = $this->getMock( + \Magento\Framework\Model\Context::class, ['getEventDispatcher', 'getCacheManager'], [], '', false ); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $this->context->expects($this->any())->method('getEventDispatcher') ->will($this->returnValue($this->eventManager)); - $this->cacheManager = $this->getMock('Magento\Framework\App\CacheInterface'); + $this->cacheManager = $this->getMock(\Magento\Framework\App\CacheInterface::class); $this->context->expects($this->any())->method('getCacheManager') ->will($this->returnValue($this->cacheManager)); - $this->registry = $this->getMock('Magento\Framework\Registry'); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->categoryTreeResource = $this->getMock('Magento\Catalog\Model\ResourceModel\Category\Tree', [], [], '', false); - $this->categoryTreeFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Category\TreeFactory', + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->categoryTreeResource = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category\Tree::class, + [], + [], + '', + false + ); + $this->categoryTreeFactory = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class, ['create'], [], '', false); - $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); - $this->storeCollectionFactory = $this->getMock( - 'Magento\Store\Model\ResourceModel\Store\CollectionFactory', + $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $this->storeCollectionFactory = $this->getMock( + \Magento\Store\Model\ResourceModel\Store\CollectionFactory::class, ['create'], [], '', false ); - $this->url = $this->getMock('Magento\Framework\UrlInterface'); - $this->productCollectionFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory', + $this->url = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->productCollectionFactory = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, ['create'], [], '', false ); - $this->catalogConfig = $this->getMock('Magento\Catalog\Model\Config', [], [], '', false); - $this->filterManager = $this->getMock( - 'Magento\Framework\Filter\FilterManager', + $this->catalogConfig = $this->getMock(\Magento\Catalog\Model\Config::class, [], [], '', false); + $this->filterManager = $this->getMock( + \Magento\Framework\Filter\FilterManager::class, ['translitUrl'], [], '', false ); - $this->flatState = $this->getMock('Magento\Catalog\Model\Indexer\Category\Flat\State', [], [], '', false); - $this->flatIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); - $this->productIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); - $this->categoryUrlPathGenerator = $this->getMock( - 'Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator', + $this->flatState = $this->getMock(\Magento\Catalog\Model\Indexer\Category\Flat\State::class, [], [], '', false); + $this->flatIndexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); + $this->productIndexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); + $this->categoryUrlPathGenerator = $this->getMock( + \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class, [], [], '', false ); - $this->urlFinder = $this->getMock('Magento\UrlRewrite\Model\UrlFinderInterface'); - $this->resource = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Category', + $this->urlFinder = $this->getMock(\Magento\UrlRewrite\Model\UrlFinderInterface::class); + $this->resource = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category::class, [], [], '', false ); - $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistry = $this->getMock( + \Magento\Framework\Indexer\IndexerRegistry::class, + ['get'], + [], + '', + false + ); - $this->metadataServiceMock = $this->getMock('\Magento\Catalog\Api\CategoryAttributeRepositoryInterface'); - $this->attributeValueFactory = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->metadataServiceMock = $this->getMock(\Magento\Catalog\Api\CategoryAttributeRepositoryInterface::class); + $this->attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor()->getMock(); $this->category = $this->getCategoryModel(); @@ -186,8 +198,8 @@ public function testFormatUrlKey() public function testMoveWhenCannotFindParentCategory() { $this->markTestIncomplete('MAGETWO-31165'); - $parentCategory = $this->getMock( - 'Magento\Catalog\Model\Category', + $parentCategory = $this->getMock( + \Magento\Catalog\Model\Category::class, ['getId', 'setStoreId', 'load'], [], '', @@ -197,7 +209,7 @@ public function testMoveWhenCannotFindParentCategory() $parentCategory->expects($this->any())->method('load')->will($this->returnSelf()); $this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory)); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->category->move(1, 2); @@ -211,8 +223,8 @@ public function testMoveWhenCannotFindParentCategory() */ public function testMoveWhenCannotFindNewCategory() { - $parentCategory = $this->getMock( - 'Magento\Catalog\Model\Category', + $parentCategory = $this->getMock( + \Magento\Catalog\Model\Category::class, ['getId', 'setStoreId', 'load'], [], '', @@ -223,7 +235,7 @@ public function testMoveWhenCannotFindNewCategory() $parentCategory->expects($this->any())->method('load')->will($this->returnSelf()); $this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory)); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->category->move(1, 2); @@ -238,8 +250,8 @@ public function testMoveWhenCannotFindNewCategory() public function testMoveWhenParentCategoryIsSameAsChildCategory() { $this->markTestIncomplete('MAGETWO-31165'); - $parentCategory = $this->getMock( - 'Magento\Catalog\Model\Category', + $parentCategory = $this->getMock( + \Magento\Catalog\Model\Category::class, ['getId', 'setStoreId', 'load'], [], '', @@ -250,7 +262,7 @@ public function testMoveWhenParentCategoryIsSameAsChildCategory() $parentCategory->expects($this->any())->method('load')->will($this->returnSelf()); $this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory)); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->category->setId(5); @@ -259,14 +271,14 @@ public function testMoveWhenParentCategoryIsSameAsChildCategory() public function testMovePrimaryWorkflow() { - $indexer = $this->getMock('stdClass', ['isScheduled']); + $indexer = $this->getMock(\stdClass::class, ['isScheduled']); $indexer->expects($this->once())->method('isScheduled')->will($this->returnValue(true)); $this->indexerRegistry->expects($this->once()) ->method('get') ->with('catalog_category_product') ->will($this->returnValue($indexer)); - $parentCategory = $this->getMock( - 'Magento\Catalog\Model\Category', + $parentCategory = $this->getMock( + \Magento\Catalog\Model\Category::class, ['getId', 'setStoreId', 'load'], [], '', @@ -277,7 +289,7 @@ public function testMovePrimaryWorkflow() $parentCategory->expects($this->any())->method('load')->will($this->returnSelf()); $this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory)); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->category->setId(3); @@ -301,8 +313,8 @@ public function testGetUseFlatResourceTrue() protected function getCategoryModel() { - return (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Catalog\Model\Category', + return (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + \Magento\Catalog\Model\Category::class, [ 'context' => $this->context, 'registry' => $this->registry, @@ -438,11 +450,11 @@ public function testGetCustomAttributes() { $nameAttributeCode = 'name'; $descriptionAttributeCode = 'description'; - $interfaceAttribute = $this->getMock('\Magento\Framework\Api\MetadataObjectInterface'); + $interfaceAttribute = $this->getMock(\Magento\Framework\Api\MetadataObjectInterface::class); $interfaceAttribute->expects($this->once()) ->method('getAttributeCode') ->willReturn($nameAttributeCode); - $descriptionAttribute = $this->getMock('\Magento\Framework\Api\MetadataObjectInterface'); + $descriptionAttribute = $this->getMock(\Magento\Framework\Api\MetadataObjectInterface::class); $descriptionAttribute->expects($this->once()) ->method('getAttributeCode') ->willReturn($descriptionAttributeCode); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php index 6d9ed7334dbb7..6a0d695d71f39 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php @@ -38,18 +38,18 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eavConfig = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); $this->attributeCollection = $this->getMockBuilder( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class ) ->disableOriginalConstructor() ->getMock(); $this->attributeCollectionFactory = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory' + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class ) ->setMethods(['create']) ->disableOriginalConstructor() @@ -58,13 +58,13 @@ protected function setUp() $this->returnValue($this->attributeCollection) ); - $this->attribute = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute') + $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) ->disableOriginalConstructor() ->getMock(); $helper = new ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Config\CatalogClone\Media\Image', + \Magento\Catalog\Model\Config\CatalogClone\Media\Image::class, [ 'eavConfig' => $this->eavConfig, 'attributeCollectionFactory' => $this->attributeCollectionFactory @@ -76,13 +76,13 @@ public function testGetPrefixes() { $entityTypeId = 3; /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $entityType */ - $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $entityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); $entityType->expects($this->once())->method('getId')->will($this->returnValue($entityTypeId)); /** @var AbstractFrontend|\PHPUnit_Framework_MockObject_MockObject $frontend */ - $frontend = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend') + $frontend = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class) ->setMethods(['getLabel']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php index 13c13f9ed0c38..eec82c1b640e2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php @@ -27,11 +27,13 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->categoryCollection = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Category\Collection') + $this->categoryCollection = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Category\Collection::class + ) ->disableOriginalConstructor() ->getMock(); - $this->category = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Category') + $this->category = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category::class) ->setMethods(['getName', 'getId']) ->disableOriginalConstructor() ->getMock(); @@ -40,7 +42,7 @@ protected function setUp() * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|MockObject $categoryCollectionFactory */ $categoryCollectionFactory = - $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Category\CollectionFactory') + $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -49,9 +51,10 @@ protected function setUp() ); $helper = new ObjectManager($this); - $this->model = $helper->getObject('Magento\Catalog\Model\Config\Source\Category', [ - 'categoryCollectionFactory' => $categoryCollectionFactory - ]); + $this->model = $helper->getObject( + \Magento\Catalog\Model\Config\Source\Category::class, + ['categoryCollectionFactory' => $categoryCollectionFactory] + ); } public function testToOptionArray() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php index 0af5865ed3bff..c39b3a47cef06 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php @@ -18,7 +18,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Config\Source\GridPerPage', + \Magento\Catalog\Model\Config\Source\GridPerPage::class, ['perPageValues' => 'some,values'] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php index b75e9fa0421a8..1cbbe87613fbe 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php @@ -18,7 +18,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Config\Source\ListPerPage', + \Magento\Catalog\Model\Config\Source\ListPerPage::class, ['options' => 'some,test,options'] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php index dfa5e8a0cb365..e95a33c4ee248 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php @@ -21,13 +21,12 @@ class ListSortTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->catalogConfig = $this->getMockBuilder('Magento\Catalog\Model\Config')-> - disableOriginalConstructor()-> - getMock(); + $this->catalogConfig = $this->getMockBuilder(\Magento\Catalog\Model\Config::class) + ->disableOriginalConstructor()->getMock(); $helper = new ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Config\Source\ListSort', + \Magento\Catalog\Model\Config\Source\ListSort::class, ['catalogConfig' => $this->catalogConfig] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php index 731a310d710b8..a87b8df7c0b52 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php @@ -21,14 +21,14 @@ class TypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productOptionConfig = $this->getMockBuilder('Magento\Catalog\Model\ProductOptions\ConfigInterface') + $this->productOptionConfig = $this->getMockBuilder(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class) ->setMethods(['getAll']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $helper = new ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Config\Source\Product\Options\Type', + \Magento\Catalog\Model\Config\Source\Product\Options\Type::class, ['productOptionConfig' => $this->productOptionConfig] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php index a173b7218b344..1e1af69fceaa8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php @@ -6,6 +6,9 @@ */ namespace Magento\Catalog\Test\Unit\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ConfigTest extends \PHPUnit_Framework_TestCase { /** @@ -15,7 +18,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testLoadAttributeSets() { $setCollectionFactory = $this->getMock( - '\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory', + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, ['create'], [], '', @@ -23,11 +26,11 @@ public function testLoadAttributeSets() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $model = $objectManager->getObject( - 'Magento\Catalog\Model\Config', + \Magento\Catalog\Model\Config::class, ['setCollectionFactory' => $setCollectionFactory] ); $setItem = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\Set', + \Magento\Eav\Model\Entity\Attribute\Set::class, ['getEntityTypeId', 'getAttributeSetName', '__wakeup'], [], '', @@ -36,7 +39,7 @@ public function testLoadAttributeSets() $setItem->expects($this->once())->method('getEntityTypeId')->will($this->returnValue(1)); $setItem->expects($this->once())->method('getAttributeSetName')->will($this->returnValue('name')); $setCollection = $this->getMock( - '\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection', + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class, ['load'], [], '', @@ -57,6 +60,7 @@ public function testGetAttributeSetName($model) $this->assertEquals('name', $model->getAttributeSetName(1, 1)); $this->assertFalse($model->getAttributeSetName(2, 1)); } + /** * @depends testLoadAttributeSets * @covers \Magento\Catalog\Model\Config::getAttributeSetId @@ -74,7 +78,7 @@ public function testGetAttributeSetId($model) public function testLoadAttributeGroups() { $groupCollectionFactory = $this->getMock( - '\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory', + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory::class, ['create'], [], '', @@ -82,11 +86,11 @@ public function testLoadAttributeGroups() ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $model = $objectManager->getObject( - 'Magento\Catalog\Model\Config', + \Magento\Catalog\Model\Config::class, ['groupCollectionFactory' => $groupCollectionFactory] ); $setItem = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\Group', + \Magento\Eav\Model\Entity\Attribute\Group::class, ['getAttributeSetId', 'getAttributeGroupName', '__wakeup'], [], '', @@ -95,7 +99,7 @@ public function testLoadAttributeGroups() $setItem->expects($this->once())->method('getAttributeSetId')->will($this->returnValue(1)); $setItem->expects($this->once())->method('getAttributeGroupName')->will($this->returnValue('name')); $groupCollection = $this->getMock( - '\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection', + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection::class, ['load'], [], '', @@ -119,6 +123,7 @@ public function testGetAttributeGroupName($model) $this->assertEquals('name', $model->getAttributeGroupName(1, 1)); $this->assertFalse($model->getAttributeGroupName(2, 1)); } + /** * @depends testLoadAttributeGroups * @covers \Magento\Catalog\Model\Config::getAttributeGroupId @@ -135,13 +140,19 @@ public function testGetAttributeGroupId($model) */ public function testLoadProductTypes() { - $productTypeFactory = $this->getMock('\Magento\Catalog\Model\Product\TypeFactory', ['create'], [], '', false); + $productTypeFactory = $this->getMock( + \Magento\Catalog\Model\Product\TypeFactory::class, + ['create'], + [], + '', + false + ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $model = $objectManager->getObject( - 'Magento\Catalog\Model\Config', + \Magento\Catalog\Model\Config::class, ['productTypeFactory' => $productTypeFactory] ); - $typeCollection = $this->getMock('\Magento\Catalog\Model\Product\Type', ['getOptionArray'], [], '', false); + $typeCollection = $this->getMock(\Magento\Catalog\Model\Product\Type::class, ['getOptionArray'], [], '', false); $typeCollection->expects($this->once())->method('getOptionArray')->will($this->returnValue([1 => 'name'])); $productTypeFactory ->expects($this->any()) @@ -181,10 +192,10 @@ public function testGetProductTypeName($model) */ public function testGetSourceOptionId($expected, $data, $search) { - $object = $this->getMock('\Magento\Framework\DataObject', ['getAllOptions'], [], '', false); + $object = $this->getMock(\Magento\Framework\DataObject::class, ['getAllOptions'], [], '', false); $object->expects($this->once())->method('getAllOptions')->will($this->returnValue($data)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $model = $objectManager->getObject('Magento\Catalog\Model\Config'); + $model = $objectManager->getObject(\Magento\Catalog\Model\Config::class); $this->assertEquals($expected, $model->getSourceOptionId($object, $search)); } @@ -213,7 +224,7 @@ protected function prepareConfigModelForAttributes() $attributeCode = 'code'; $attribute = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getStoreLabel', 'getAttributeCode', '__wakeup'], [], '', @@ -222,13 +233,13 @@ protected function prepareConfigModelForAttributes() $attribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue($storeLabel)); $attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode)); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue($storeId)); $config = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Config', + \Magento\Catalog\Model\ResourceModel\Config::class, ['setStoreId', 'getAttributesUsedInListing', 'getAttributesUsedForSortBy', '__wakeup'], [], '', @@ -239,11 +250,11 @@ protected function prepareConfigModelForAttributes() $config->expects($this->any())->method('getAttributesUsedForSortBy')->will($this->returnValue($attributesData)); $configFactory = - $this->getMock('\Magento\Catalog\Model\ResourceModel\ConfigFactory', ['create'], [], '', false); + $this->getMock(\Magento\Catalog\Model\ResourceModel\ConfigFactory::class, ['create'], [], '', false); $configFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($config)); $eavConfig = $this->getMock( - '\Magento\Eav\Model\Config', + \Magento\Eav\Model\Config::class, ['getAttribute', 'importAttributesData'], [], '', @@ -256,7 +267,7 @@ protected function prepareConfigModelForAttributes() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $model = $objectManager->getObject( - 'Magento\Catalog\Model\Config', + \Magento\Catalog\Model\Config::class, ['configFactory' => $configFactory, 'storeManager' => $storeManager, 'eavConfig' => $eavConfig] ); @@ -307,7 +318,7 @@ public function testGetAttributeUsedForSortByArray() public function testGetProductListDefaultSortBy() { $scopeConfig = $this->getMock( - '\Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, ['getValue', 'isSetFlag'], [], '', @@ -316,7 +327,7 @@ public function testGetProductListDefaultSortBy() $scopeConfig->expects($this->once())->method('getValue') ->with('catalog/frontend/default_sort_by', 'store', null)->will($this->returnValue(1)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $model = $objectManager->getObject('Magento\Catalog\Model\Config', ['scopeConfig' => $scopeConfig]); + $model = $objectManager->getObject(\Magento\Catalog\Model\Config::class, ['scopeConfig' => $scopeConfig]); $this->assertEquals(1, $model->getProductListDefaultSortBy()); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php index 7acccfcc2a294..e3bdffbf5aefc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php @@ -7,6 +7,9 @@ use Magento\Catalog\Model\CustomOptions\CustomOptionProcessor; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CustomOptionProcessorTest extends \PHPUnit_Framework_TestCase { /** @@ -50,37 +53,41 @@ class CustomOptionProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectFactory = $this->getMockBuilder('Magento\Framework\DataObject\Factory') + $this->objectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->productOptionFactory = $this->getMockBuilder('Magento\Quote\Model\Quote\ProductOptionFactory') + $this->productOptionFactory = $this->getMockBuilder(\Magento\Quote\Model\Quote\ProductOptionFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->extensionFactory = $this->getMockBuilder('Magento\Quote\Api\Data\ProductOptionExtensionFactory') + $this->extensionFactory = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOptionExtensionFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->customOptionFactory = $this->getMockBuilder('Magento\Catalog\Model\CustomOptions\CustomOptionFactory') + $this->customOptionFactory = $this->getMockBuilder( + \Magento\Catalog\Model\CustomOptions\CustomOptionFactory::class + ) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->cartItem = $this->getMockBuilder('Magento\Quote\Api\Data\CartItemInterface') + $this->cartItem = $this->getMockBuilder(\Magento\Quote\Api\Data\CartItemInterface::class) ->disableOriginalConstructor() ->setMethods(['getOptionByCode', 'getProductOption', 'setProductOption']) ->getMockForAbstractClass(); - $this->extensibleAttribute = $this->getMockBuilder('Magento\Quote\Api\Data\ProductOptionExtensionInterface') + $this->extensibleAttribute = $this->getMockBuilder( + \Magento\Quote\Api\Data\ProductOptionExtensionInterface::class + ) ->disableOriginalConstructor() ->setMethods(['setCustomOptions', 'getCustomOptions']) ->getMockForAbstractClass(); - $this->productOption = $this->getMockBuilder('Magento\Quote\Model\Quote\ProductOption') + $this->productOption = $this->getMockBuilder(\Magento\Quote\Model\Quote\ProductOption::class) ->disableOriginalConstructor() ->getMock(); - $this->customOption = $this->getMockBuilder('Magento\Catalog\Api\Data\CustomOptionInterface') + $this->customOption = $this->getMockBuilder(\Magento\Catalog\Api\Data\CustomOptionInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->buyRequest = $this->getMockBuilder('Magento\Framework\DataObject') + $this->buyRequest = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); @@ -122,7 +129,7 @@ public function testConvertToBuyRequest() public function testProcessCustomOptions() { $optionId = 23; - $quoteItemOption = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $quoteItemOption = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->disableOriginalConstructor() ->getMock(); $this->cartItem->expects($this->atLeastOnce()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php index e41771ba62454..d7a0fdb778d4c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php @@ -22,31 +22,33 @@ class CustomOptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMockBuilder('Magento\Framework\Model\Context') + $context = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->getMock(); - $registry = $this->getMockBuilder('Magento\Framework\Registry') + $registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + $extensionAttributesFactory = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesFactory::class) ->disableOriginalConstructor() ->getMock(); - $attributeValueFactory = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->fileProcessor = $this->getMockBuilder('Magento\Catalog\Model\Webapi\Product\Option\Type\File\Processor') + $this->fileProcessor = $this->getMockBuilder( + \Magento\Catalog\Model\Webapi\Product\Option\Type\File\Processor::class + ) ->disableOriginalConstructor() ->getMock(); - $resource = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') + $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->disableOriginalConstructor() ->getMock(); - $collection = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMock(); @@ -82,11 +84,11 @@ public function testGetOptionValue() public function testGetOptionValueWithFileInfo() { - $customOption = $this->getMockBuilder('Magento\Catalog\Api\Data\CustomOptionExtensionInterface') + $customOption = $this->getMockBuilder(\Magento\Catalog\Api\Data\CustomOptionExtensionInterface::class) ->setMethods(['getFileInfo']) ->getMockForAbstractClass(); - $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->getMockForAbstractClass(); $customOption->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php index 447feb0bcc00b..ccd37ae9f3197 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php @@ -128,63 +128,65 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->setMethods(['getCacheManager', 'getEventDispatcher']) ->disableOriginalConstructor() ->getMock(); - $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->getMock(); - $this->metadataServiceMock = $this->getMockBuilder('Magento\Framework\Api\MetadataServiceInterface') + $this->metadataServiceMock = $this->getMockBuilder(\Magento\Framework\Api\MetadataServiceInterface::class) ->getMock(); - $this->extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + $this->extensionAttributesFactory = $this->getMockBuilder( + \Magento\Framework\Api\ExtensionAttributesFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->typeFactoryMock = $this->getMockBuilder('Magento\Eav\Model\Entity\TypeFactory') + $this->typeFactoryMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\TypeFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Eav\Model\ResourceModel\Helper') + $this->helperMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Helper::class) ->disableOriginalConstructor() ->getMock(); - $this->universalFactoryMock = $this->getMockBuilder('Magento\Framework\Validator\UniversalFactory') + $this->universalFactoryMock = $this->getMockBuilder(\Magento\Framework\Validator\UniversalFactory::class) ->disableOriginalConstructor() ->getMock(); $this->attributeOptionFactoryMock = - $this->getMockBuilder('Magento\Eav\Api\Data\AttributeOptionInterfaceFactory') + $this->getMockBuilder(\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $this->dataObjectProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); - $this->reservedAttributeListMock = $this->getMockBuilder('Magento\Catalog\Model\Product\ReservedAttributeList') + $this->reservedAttributeListMock = $this->getMockBuilder( + \Magento\Catalog\Model\Product\ReservedAttributeList::class) ->disableOriginalConstructor() ->getMock(); - $this->resolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->resolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); - $this->lockValidatorMock = $this->getMockBuilder('Magento\Catalog\Model\Attribute\LockValidatorInterface') + $this->lockValidatorMock = $this->getMockBuilder(\Magento\Catalog\Model\Attribute\LockValidatorInterface::class) ->getMock(); - $this->dateTimeFormatter = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface'); + $this->dateTimeFormatter = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->setMethods(['_construct', 'getConnection', 'getIdFieldName', 'saveInSetIncluding']) ->getMockForAbstractClass(); - $this->cacheManager = $this->getMockBuilder('Magento\Framework\App\CacheInterface') + $this->cacheManager = $this->getMockBuilder(\Magento\Framework\App\CacheInterface::class) ->getMock(); - $this->eventDispatcher = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->getMock(); $this->contextMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php index cec8a7ab9e6d3..531a67adb1684 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php @@ -26,7 +26,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase public function testCreate() { - $this->assertInstanceOf('\Magento\Catalog\Model\Product\Option', $this->factory->create('model', [])); + $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option::class, $this->factory->create('model', [])); } /** @@ -39,7 +39,7 @@ public function testExceptionCreate() protected function setUp() { - $this->model = $this->getMock('Magento\Catalog\Model\Product\Option', [], [], '', false); + $this->model = $this->getMock(\Magento\Catalog\Model\Product\Option::class, [], [], '', false); $this->setObjectManager(); @@ -48,7 +48,7 @@ protected function setUp() protected function setObjectManager() { - $this->objectManager = $this->getMock('\Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManager ->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php index 3c70e28f1803e..4cc35fd0cafb5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php @@ -25,14 +25,14 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->stateMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\State', + \Magento\Catalog\Model\Indexer\Category\Flat\State::class, ['isFlatEnabled'], [], '', false ); - $this->subjectMock = $this->getMock('Magento\Indexer\Model\Config\Data', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Indexer\Model\Config\Data::class, [], [], '', false); $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData($this->stateMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php index 0611a594f01b6..32d7e19e6d46e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php @@ -47,7 +47,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -56,16 +56,16 @@ protected function setUp() ['getId', 'getState', '__wakeup'] ); $this->stateMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\State', + \Magento\Catalog\Model\Indexer\Category\Flat\State::class, ['isFlatEnabled'], [], '', false ); - $this->subjectMock = $this->getMock('Magento\Store\Model\ResourceModel\Group', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Store\Model\ResourceModel\Group::class, [], [], '', false); $this->groupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['dataHasChangedFor', 'isObjectNew', '__wakeup'], [], '', @@ -76,7 +76,7 @@ protected function setUp() }; $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -111,7 +111,7 @@ public function testAroundSaveNotNew() { $this->stateMock->expects($this->never())->method('isFlatEnabled'); $this->groupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['dataHasChangedFor', 'isObjectNew', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php index d585d64159b7c..21d3403c775a5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php @@ -42,7 +42,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -51,7 +51,7 @@ protected function setUp() ['getId', 'getState', '__wakeup'] ); $this->stateMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\State', + \Magento\Catalog\Model\Indexer\Category\Flat\State::class, ['isFlatEnabled'], [], '', @@ -60,9 +60,9 @@ protected function setUp() $this->closureMock = function () { return false; }; - $this->subjectMock = $this->getMock('Magento\Store\Model\ResourceModel\Store', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Store\Model\ResourceModel\Store::class, [], [], '', false); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -76,7 +76,7 @@ public function testAroundSaveNewObject() $this->mockConfigFlatEnabled(); $this->mockIndexerMethods(); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['isObjectNew', 'dataHasChangedFor', '__wakeup'], [], '', @@ -89,7 +89,7 @@ public function testAroundSaveNewObject() public function testAroundSaveHasChanged() { $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['isObjectNew', 'dataHasChangedFor', '__wakeup'], [], '', @@ -102,7 +102,7 @@ public function testAroundSaveNoNeed() { $this->mockConfigFlatEnabledNeever(); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['isObjectNew', 'dataHasChangedFor', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php index cd885b87b84e8..a618ea9ea9730 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php @@ -29,10 +29,12 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfigMock = $this->getMockForAbstractClass( + \Magento\Framework\App\Config\ScopeConfigInterface::class + ); $this->flatIndexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -42,7 +44,7 @@ protected function setUp() ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php index 6a6d1259c8fdd..c8cde1d002515 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php @@ -34,21 +34,21 @@ class ModeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->indexerStateMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['loadByIndexer', 'setStatus', 'save', '__wakeup'], [], '', false ); - $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); + $this->indexerRegistry = $this->getMock(\Magento\Framework\Indexer\IndexerRegistry::class, [], [], '', false); - $this->flatIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); + $this->flatIndexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode', + \Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode::class, [ 'config' => $this->configMock, 'indexerState' => $this->indexerStateMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php index 0be219fdecd91..feda0d0cb9e95 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php @@ -40,7 +40,7 @@ class FlatTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fullMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory', + \Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory::class, ['create'], [], '', @@ -48,7 +48,7 @@ protected function setUp() ); $this->rowsMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory', + \Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory::class, ['create'], [], '', @@ -56,7 +56,7 @@ protected function setUp() ); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -66,7 +66,7 @@ protected function setUp() ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -108,7 +108,7 @@ public function testExecuteWithIndexerWorking() $this->prepareIndexer(); $rowMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows', + \Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows::class, ['reindex'], [], '', @@ -135,7 +135,7 @@ public function testExecuteWithIndexerNotWorking() $this->prepareIndexer(); $rowMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows', + \Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows::class, ['reindex'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php index 1097f763083c4..c57406df15e70 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php @@ -9,13 +9,13 @@ class ImportTest extends \PHPUnit_Framework_TestCase { public function testAfterImportSource() { - $processorMock = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Category\Product\Processor') + $processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\Processor::class) ->disableOriginalConstructor() ->getMock(); $processorMock->expects($this->once()) ->method('markIndexerAsInvalid'); - $subjectMock = $this->getMockBuilder('Magento\ImportExport\Model\Import') + $subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php index 1151d0fcae618..523b932e2d8a4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php @@ -27,7 +27,7 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus) $relatedVersion = 'related_version'; $state = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId)); @@ -35,7 +35,7 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus) $state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus)); $relatedViewState = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMock(); $relatedViewState->expects( @@ -75,7 +75,7 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus) ); $relatedViewChangelog = $this->getMockBuilder( - 'Magento\Framework\Mview\View\ChangelogInterface' + \Magento\Framework\Mview\View\ChangelogInterface::class )->disableOriginalConstructor()->getMock(); $relatedViewChangelog->expects( @@ -94,7 +94,7 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus) $relatedViewState, $relatedViewChangelog ); - $this->assertInstanceOf('\Magento\Framework\Mview\View\StateInterface', $model->afterSetStatus($state)); + $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state)); } /** @@ -116,7 +116,7 @@ public function testAfterSetStatusResume($stateStatus, $relatedStatus) $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID; $state = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId)); @@ -124,7 +124,7 @@ public function testAfterSetStatusResume($stateStatus, $relatedStatus) $state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus)); $relatedViewState = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMock(); $relatedViewState->expects( @@ -156,14 +156,14 @@ public function testAfterSetStatusResume($stateStatus, $relatedStatus) ); $relatedViewChangelog = $this->getMockBuilder( - 'Magento\Framework\Mview\View\ChangelogInterface' + \Magento\Framework\Mview\View\ChangelogInterface::class )->disableOriginalConstructor()->getMock(); $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState( $relatedViewState, $relatedViewChangelog ); - $this->assertInstanceOf('\Magento\Framework\Mview\View\StateInterface', $model->afterSetStatus($state)); + $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state)); } /** @@ -191,7 +191,7 @@ public function testAfterSetStatusSkip($stateStatus, $relatedStatus) $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID; $state = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId)); @@ -199,7 +199,7 @@ public function testAfterSetStatusSkip($stateStatus, $relatedStatus) $state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus)); $relatedViewState = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMock(); $relatedViewState->expects( @@ -223,14 +223,14 @@ public function testAfterSetStatusSkip($stateStatus, $relatedStatus) $relatedViewState->expects($this->never())->method('setStatus'); $relatedViewChangelog = $this->getMockBuilder( - 'Magento\Framework\Mview\View\ChangelogInterface' + \Magento\Framework\Mview\View\ChangelogInterface::class )->disableOriginalConstructor()->getMock(); $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState( $relatedViewState, $relatedViewChangelog ); - $this->assertInstanceOf('\Magento\Framework\Mview\View\StateInterface', $model->afterSetStatus($state)); + $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state)); } /** @@ -251,7 +251,7 @@ public function testAfterSetStatusDisabled($stateStatus) $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID; $state = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId)); @@ -259,7 +259,7 @@ public function testAfterSetStatusDisabled($stateStatus) $state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus)); $relatedViewState = $this->getMockBuilder( - 'Magento\Framework\Mview\View\StateInterface' + \Magento\Framework\Mview\View\StateInterface::class )->disableOriginalConstructor()->getMock(); $relatedViewState->expects( @@ -283,13 +283,13 @@ public function testAfterSetStatusDisabled($stateStatus) $relatedViewState->expects($this->never())->method('setStatus'); $relatedViewChangelog = $this->getMockBuilder( - 'Magento\Framework\Mview\View\ChangelogInterface' + \Magento\Framework\Mview\View\ChangelogInterface::class )->disableOriginalConstructor()->getMock(); $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState( $relatedViewState, $relatedViewChangelog ); - $this->assertInstanceOf('\Magento\Framework\Mview\View\StateInterface', $model->afterSetStatus($state)); + $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state)); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php index c6f9bd16c526e..58385e8d38d7a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php @@ -37,7 +37,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -45,9 +45,9 @@ protected function setUp() true, ['getId', 'getState', '__wakeup'] ); - $this->subject = $this->getMock('Magento\Store\Model\ResourceModel\Group', [], [], '', false); + $this->subject = $this->getMock(\Magento\Store\Model\ResourceModel\Group::class, [], [], '', false); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -65,7 +65,7 @@ public function testAroundSave($valueMap) { $this->mockIndexerMethods(); $groupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['dataHasChangedFor', 'isObjectNew', '__wakeup'], [], '', @@ -85,7 +85,7 @@ public function testAroundSave($valueMap) public function testAroundSaveNotNew($valueMap) { $groupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['dataHasChangedFor', 'isObjectNew', '__wakeup'], [], '', @@ -111,7 +111,7 @@ public function changedDataProvider() public function testAroundSaveWithoutChanges() { $groupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['dataHasChangedFor', 'isObjectNew', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php index 080a7ecaf93a0..26dcfd206b124 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php @@ -37,7 +37,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -45,9 +45,9 @@ protected function setUp() true, ['getId', 'getState', '__wakeup'] ); - $this->subject = $this->getMock('Magento\Store\Model\ResourceModel\Group', [], [], '', false); + $this->subject = $this->getMock(\Magento\Store\Model\ResourceModel\Group::class, [], [], '', false); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -61,7 +61,7 @@ public function testAroundSaveNewObject() { $this->mockIndexerMethods(); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['isObjectNew', 'dataHasChangedFor', '__wakeup'], [], '', @@ -76,7 +76,7 @@ public function testAroundSaveHasChanged() { $this->mockIndexerMethods(); $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['isObjectNew', 'dataHasChangedFor', '__wakeup'], [], '', @@ -98,7 +98,7 @@ public function testAroundSaveHasChanged() public function testAroundSaveNoNeed() { $storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['isObjectNew', 'dataHasChangedFor', '__wakeup'], [], '', @@ -123,7 +123,7 @@ public function testAroundSaveNoNeed() protected function getStateMock() { $stateMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['setStatus', 'save', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php index 2dd1d30500cd5..f748b48eba1bf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php @@ -40,7 +40,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fullMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory', + \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory::class, ['create'], [], '', @@ -48,7 +48,7 @@ protected function setUp() ); $this->rowsMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Product\Action\RowsFactory', + \Magento\Catalog\Model\Indexer\Category\Product\Action\RowsFactory::class, ['create'], [], '', @@ -56,7 +56,7 @@ protected function setUp() ); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -66,7 +66,7 @@ protected function setUp() ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -97,7 +97,7 @@ public function testExecuteWithIndexerWorking() $this->prepareIndexer(); $rowMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Product\Action\Rows', + \Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class, ['execute'], [], '', @@ -119,7 +119,7 @@ public function testExecuteWithIndexerNotWorking() $this->prepareIndexer(); $rowMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Product\Action\Rows', + \Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class, ['execute'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php index 6baafdee70d38..d1d47068b908c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php @@ -9,13 +9,13 @@ class ImportTest extends \PHPUnit_Framework_TestCase { public function testAfterImportSource() { - $processorMock = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Category\Processor') + $processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Category\Processor::class) ->disableOriginalConstructor() ->getMock(); $processorMock->expects($this->once()) ->method('markIndexerAsInvalid'); - $subjectMock = $this->getMockBuilder('Magento\ImportExport\Model\Import') + $subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php index 9910ca7f06ba6..3417f2588f45e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php @@ -40,7 +40,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fullMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory', + \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory::class, ['create'], [], '', @@ -48,7 +48,7 @@ protected function setUp() ); $this->rowsMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Category\Action\RowsFactory', + \Magento\Catalog\Model\Indexer\Product\Category\Action\RowsFactory::class, ['create'], [], '', @@ -56,7 +56,7 @@ protected function setUp() ); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, @@ -66,7 +66,7 @@ protected function setUp() ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -97,7 +97,7 @@ public function testExecuteWithIndexerWorking() $this->prepareIndexer(); $rowMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Category\Action\Rows', + \Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class, ['execute'], [], '', @@ -119,7 +119,7 @@ public function testExecuteWithIndexerNotWorking() $this->prepareIndexer(); $rowMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Category\Action\Rows', + \Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class, ['execute'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php index 2d2df1e148cb1..8705ba643bf58 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php @@ -25,14 +25,14 @@ class AbstractActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_eavDecimalFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory', + \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory::class, ['create'], [], '', false ); $this->_eavSourceFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory', + \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory::class, ['create'], [], '', @@ -40,7 +40,7 @@ protected function setUp() ); $this->_model = $this->getMockForAbstractClass( - 'Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction', + \Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction::class, [$this->_eavDecimalFactoryMock, $this->_eavSourceFactoryMock] ); } @@ -95,11 +95,11 @@ public function testGetIndexer() public function testReindexWithoutArgumentsExecutesReindexAll() { - $eavSource = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source') + $eavSource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source::class) ->disableOriginalConstructor() ->getMock(); - $eavDecimal = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal') + $eavDecimal = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal::class) ->disableOriginalConstructor() ->getMock(); @@ -124,11 +124,11 @@ public function testReindexWithNotNullArgumentExecutesReindexEntities() { $ids = [1, 2, 3]; - $eavSource = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source') + $eavSource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source::class) ->disableOriginalConstructor() ->getMock(); - $eavDecimal = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal') + $eavDecimal = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php index ea3ae63aba42a..13155413a2b1f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php @@ -10,14 +10,14 @@ class FullTest extends \PHPUnit_Framework_TestCase public function testExecuteWithAdapterErrorThrowsException() { $eavDecimalFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory', + \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory::class, ['create'], [], '', false ); $eavSourceFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory', + \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory::class, ['create'], [], '', @@ -36,7 +36,7 @@ public function testExecuteWithAdapterErrorThrowsException() $eavSourceFactory ); - $this->setExpectedException('Magento\Framework\Exception\LocalizedException', $exceptionMessage); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); $model->execute(); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php index 18e6977069975..ea2c35c161b1a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php @@ -17,7 +17,7 @@ class RowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Eav\Action\Row'); + $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Eav\Action\Row::class); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php index 872ae68d45f22..90a537fffc402 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php @@ -17,7 +17,7 @@ class RowsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows'); + $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows::class); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php index 61e9131f3bb41..7afe91d4f357b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php @@ -9,7 +9,7 @@ class IndexableAttributeFilterTest extends \PHPUnit_Framework_TestCase { public function testFilter() { - $catalogResourceMock = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + $catalogResourceMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->disableOriginalConstructor() ->setMethods(['load', 'isIndexable', '__wakeup']) ->getMock(); @@ -23,7 +23,9 @@ public function testFilter() ->method('isIndexable') ->will($this->returnValue(false)); - $eavAttributeFactoryMock = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory') + $eavAttributeFactoryMock = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -31,7 +33,7 @@ public function testFilter() ->method('create') ->will($this->returnValue($catalogResourceMock)); - $attributeMock1 = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute') + $attributeMock1 = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getAttributeId', 'getAttributeCode', 'load', '__wakeup']) ->getMock(); @@ -42,7 +44,7 @@ public function testFilter() ->method('load') ->will($this->returnSelf()); - $attributeMock2 = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute') + $attributeMock2 = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getAttributeId', 'getAttributeCode', 'load', '__wakeup']) ->getMock(); @@ -55,7 +57,7 @@ public function testFilter() $attributes = [$attributeMock1, $attributeMock2]; - $groupMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Group') + $groupMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Group::class) ->disableOriginalConstructor() ->setMethods(['getAttributes', '__wakeup']) ->getMock(); @@ -63,7 +65,7 @@ public function testFilter() ->method('getAttributes') ->will($this->returnValue($attributes)); - $attributeSetMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Set') + $attributeSetMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Set::class) ->disableOriginalConstructor() ->setMethods(['getGroups', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php index 031cf8f00005b..38f74d7c730c2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php @@ -9,14 +9,14 @@ class AttributeSetTest extends \PHPUnit_Framework_TestCase { public function testAroundSave() { - $eavProcessorMock = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Eav\Processor') + $eavProcessorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Eav\Processor::class) ->disableOriginalConstructor() ->getMock(); $eavProcessorMock->expects($this->once()) ->method('markIndexerAsInvalid'); $filter = $this->getMockBuilder( - 'Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet\IndexableAttributeFilter' + \Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet\IndexableAttributeFilter::class ) ->disableOriginalConstructor() ->getMock(); @@ -27,7 +27,7 @@ public function testAroundSave() ->method('filter') ->will($this->returnValue([1, 2])); - $subjectMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Set') + $subjectMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Set::class) ->disableOriginalConstructor() ->getMock(); $subjectMock->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php index 93cc84d523b3b..d7c845d6cdb8f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php @@ -9,13 +9,13 @@ class ImportTest extends \PHPUnit_Framework_TestCase { public function testAfterImportSource() { - $eavProcessorMock = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Eav\Processor') + $eavProcessorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Eav\Processor::class) ->disableOriginalConstructor() ->getMock(); $eavProcessorMock->expects($this->once()) ->method('markIndexerAsInvalid'); - $subjectMock = $this->getMockBuilder('Magento\ImportExport\Model\Import') + $subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class) ->disableOriginalConstructor() ->getMock(); $import = new \stdClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php index 5e553b8040332..a8ab5acb0c736 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php @@ -13,18 +13,18 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase */ public function testBeforeSave(array $data) { - $eavProcessorMock = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Eav\Processor') + $eavProcessorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Eav\Processor::class) ->disableOriginalConstructor() ->getMock(); $matcher = $data['matcher']; $eavProcessorMock->expects($this->$matcher()) ->method('markIndexerAsInvalid'); - $subjectMock = $this->getMockBuilder('Magento\Store\Model\ResourceModel\Store') + $subjectMock = $this->getMockBuilder(\Magento\Store\Model\ResourceModel\Store::class) ->disableOriginalConstructor() ->getMock(); - $objectMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + $objectMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods(['getId', 'dataHasChangedFor', 'getIsActive', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php index 446fde618b8c9..94c85aab09535 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php @@ -34,15 +34,21 @@ class EavTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_productEavIndexerRow = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Eav\Action\Row') + $this->_productEavIndexerRow = $this->getMockBuilder( + \Magento\Catalog\Model\Indexer\Product\Eav\Action\Row::class + ) ->disableOriginalConstructor() ->getMock(); - $this->_productEavIndexerRows = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows') + $this->_productEavIndexerRows = $this->getMockBuilder( + \Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows::class + ) ->disableOriginalConstructor() ->getMock(); - $this->_productEavIndexerFull = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Eav\Action\Full') + $this->_productEavIndexerFull = $this->getMockBuilder( + \Magento\Catalog\Model\Indexer\Product\Eav\Action\Full::class + ) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php index a54a1eb453212..57b33c9aed8ee 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php @@ -33,11 +33,11 @@ class EraserTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->connection = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection)); $this->indexerHelper = $this->getMock( - 'Magento\Catalog\Helper\Product\Flat\Indexer', + \Magento\Catalog\Helper\Product\Flat\Indexer::class, [], [], '', false ); @@ -47,7 +47,7 @@ protected function setUp() [2, 'store_2_flat'], ])); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser( $resource, $this->indexerHelper, @@ -58,12 +58,12 @@ protected function setUp() public function testRemoveDeletedProducts() { $productsToDeleteIds = [1, 2]; - $select = $this->getMock('\Magento\Framework\Db\Select', [], [], '', false); + $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $select->expects($this->once())->method('from')->with('catalog_product_entity')->will($this->returnSelf()); $select->expects($this->once())->method('where')->with('entity_id IN(?)', $productsToDeleteIds) ->will($this->returnSelf()); $products = [['entity_id' => 2]]; - $statement = $this->getMock('\Zend_Db_Statement_Interface'); + $statement = $this->getMock(\Zend_Db_Statement_Interface::class); $statement->expects($this->once())->method('fetchAll')->will($this->returnValue($products)); $this->connection->expects($this->once())->method('query')->with($select) ->will($this->returnValue($statement)); @@ -76,9 +76,9 @@ public function testRemoveDeletedProducts() public function testDeleteProductsFromStoreForAllStores() { - $store1 = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store1 = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store1->expects($this->any())->method('getId')->will($this->returnValue(1)); - $store2 = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store2 = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store2->expects($this->any())->method('getId')->will($this->returnValue(2)); $this->storeManager->expects($this->once())->method('getStores') ->will($this->returnValue([$store1, $store2])); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php index 8dc0004e5d1b5..f30ffbe6b2eac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php @@ -61,29 +61,30 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->connection = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'); - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->resource->expects($this->any())->method('getConnection') ->with('default') ->will($this->returnValue($this->connection)); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1')); $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$this->store])); - $this->productIndexerHelper = $this->getMock( - 'Magento\Catalog\Helper\Product\Flat\Indexer', [], [], '', false + $this->productIndexerHelper = $this->getMock( + \Magento\Catalog\Helper\Product\Flat\Indexer::class, [], [], '', false ); - $this->flatItemEraser = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser', [], [], '', false + $this->flatItemEraser = $this->getMock( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class, [], [], '', false ); - $this->flatItemWriter = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer', [], [], '', false + $this->flatItemWriter = $this->getMock( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class, [], [], '', false ); - $this->flatTableBuilder = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder', [], [], '', false + $this->flatTableBuilder = $this->getMock( + \Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class, [], [], '', false ); - $this->model = $objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Flat\Action\Row', [ + $this->model = $objectManager->getObject( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class, [ 'resource' => $this->resource, 'storeManager' => $this->storeManager, 'productHelper' => $this->productIndexerHelper, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php index 5c1ee2c438eb2..aa1543cf1eedd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php @@ -32,10 +32,10 @@ class TableDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); - $this->_resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->_connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->_resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->_productIndexerHelper = $this->getMock( - 'Magento\Catalog\Helper\Product\Flat\Indexer', + \Magento\Catalog\Helper\Product\Flat\Indexer::class, [], [], '', @@ -77,7 +77,7 @@ public function testMoveWithNonExistentFlatTable() ); $model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData', + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData::class, ['resource' => $this->_resourceMock, 'productIndexerHelper' => $this->_productIndexerHelper] ); @@ -102,7 +102,7 @@ public function testMoveWithExistentFlatTable() 'column_3' => 'column_definition', ]; - $selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $selectMock->expects( $this->once() )->method( @@ -172,7 +172,7 @@ public function testMoveWithExistentFlatTable() ); $model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData', + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData::class, ['resource' => $this->_resourceMock, 'productIndexerHelper' => $this->_productIndexerHelper] ); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php index e43f8ee575a68..bcfabfb9f7d0f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php @@ -61,31 +61,32 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->_connection = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'); - $this->_resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->_connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->_resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->_resource->expects($this->any())->method('getConnection') ->with('default') ->will($this->returnValue($this->_connection)); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->_store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->_storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->_store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->_store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1')); $this->_storeManager->expects($this->any())->method('getStores')->will( $this->returnValue([$this->_store]) ); - $this->_productIndexerHelper = $this->getMock( - 'Magento\Catalog\Helper\Product\Flat\Indexer', [], [], '', false + $this->_productIndexerHelper = $this->getMock( + \Magento\Catalog\Helper\Product\Flat\Indexer::class, [], [], '', false ); - $this->_flatItemEraser = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser', [], [], '', false + $this->_flatItemEraser = $this->getMock( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class, [], [], '', false ); - $this->_flatItemWriter = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer', [], [], '', false + $this->_flatItemWriter = $this->getMock( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class, [], [], '', false ); - $this->_flatTableBuilder = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder', [], [], '', false + $this->_flatTableBuilder = $this->getMock( + \Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class, [], [], '', false ); - $this->_model = $objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows', [ + $this->_model = $objectManager->getObject( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows::class, [ 'resource' => $this->_resource, 'storeManager' => $this->_storeManager, 'productHelper' => $this->_productIndexerHelper, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php index 77710f27d38ee..6624f2fa82609 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php @@ -25,13 +25,13 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_stateMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\State', + \Magento\Catalog\Model\Indexer\Product\Flat\State::class, ['isFlatEnabled'], [], '', false ); - $this->subjectMock = $this->getMock('Magento\Indexer\Model\Config\Data', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Indexer\Model\Config\Data::class, [], [], '', false); $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData($this->_stateMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php index b5322442eda89..3615fd25e2f0d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php @@ -25,16 +25,16 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->processorMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', + \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, ['markIndexerAsInvalid'], [], '', false ); - $this->subjectMock = $this->getMock('Magento\Store\Model\ResourceModel\Group', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Store\Model\ResourceModel\Group::class, [], [], '', false); $this->storeGroupMock = $this->getMock( - 'Magento\Store\Model\Group', + \Magento\Store\Model\Group::class, ['getId', '__wakeup', 'dataHasChangedFor'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php index bfb18310bd023..e207533a9a934 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php @@ -25,16 +25,16 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->processorMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', + \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, ['markIndexerAsInvalid'], [], '', false ); - $this->subjectMock = $this->getMock('\Magento\Store\Model\ResourceModel\Store', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Store\Model\ResourceModel\Store::class, [], [], '', false); $this->storeMock = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, ['getId', '__wakeup', 'dataHasChangedFor'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php index 5d4253a000223..bcb9854e8e634 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php @@ -37,7 +37,7 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_indexerMock = $this->getMock( - 'Magento\Indexer\Model\Indexer', + \Magento\Indexer\Model\Indexer::class, ['getId', 'invalidate'], [], '', @@ -46,23 +46,26 @@ protected function setUp() $this->_indexerMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->_stateMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\State', + \Magento\Catalog\Model\Indexer\Product\Flat\State::class, ['isFlatEnabled'], [], '', false ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', false ); - $this->_model = $this->_objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Flat\Processor', [ - 'indexerRegistry' => $this->indexerRegistryMock, - 'state' => $this->_stateMock - ]); + $this->_model = $this->_objectManager->getObject( + \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, + [ + 'indexerRegistry' => $this->indexerRegistryMock, + 'state' => $this->_stateMock + ] + ); } /** @@ -71,7 +74,7 @@ protected function setUp() public function testGetIndexer() { $this->prepareIndexer(); - $this->assertInstanceOf('\Magento\Indexer\Model\Indexer', $this->_model->getIndexer()); + $this->assertInstanceOf(\Magento\Indexer\Model\Indexer::class, $this->_model->getIndexer()); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php index e76ee94475d6f..31dde2ed819bd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php @@ -21,17 +21,17 @@ protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $indexerMock = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); + $indexerMock = $this->getMock(\Magento\Indexer\Model\Indexer::class, [], [], '', false); $flatIndexerHelperMock = $this->getMock( - 'Magento\Catalog\Helper\Product\Flat\Indexer', + \Magento\Catalog\Helper\Product\Flat\Indexer::class, [], [], '', false ); - $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat\State', + \Magento\Catalog\Model\Indexer\Product\Flat\State::class, [ 'scopeConfig' => $configMock, 'flatIndexer' => $indexerMock, @@ -43,6 +43,9 @@ protected function setUp() public function testGetIndexer() { - $this->assertInstanceOf('\Magento\Catalog\Helper\Product\Flat\Indexer', $this->_model->getFlatIndexerHelper()); + $this->assertInstanceOf( + \Magento\Catalog\Helper\Product\Flat\Indexer::class, + $this->_model->getFlatIndexerHelper() + ); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php index ea157c045e3f4..ed46d7e0528e1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php @@ -29,16 +29,16 @@ class ModeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->indexerStateMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', + \Magento\Indexer\Model\Indexer\State::class, ['loadByIndexer', 'setStatus', 'save', '__wakeup'], [], '', false ); $this->indexerProcessorMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', + \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, ['getIndexer'], [], '', @@ -47,7 +47,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat\System\Config\Mode', + \Magento\Catalog\Model\Indexer\Product\Flat\System\Config\Mode::class, [ 'config' => $this->configMock, 'indexerState' => $this->indexerStateMock, @@ -170,7 +170,7 @@ public function testProcessValueOff($oldValue, $value) $this->indexerStateMock->expects($this->never())->method('save'); $indexerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Indexer\IndexerInterface', + \Magento\Framework\Indexer\IndexerInterface::class, [], '', false, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php index abc8c10d51a0a..0f47a675c8265 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php @@ -27,8 +27,8 @@ class TableDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); - $this->_resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->_connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->_resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); } /** @@ -74,7 +74,7 @@ public function testMove( ); $model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat\TableData', + \Magento\Catalog\Model\Indexer\Product\Flat\TableData::class, ['resource' => $this->_resourceMock] ); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php index f9eb1b1d29099..186441dbd91a3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php @@ -36,21 +36,27 @@ class FlatTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productFlatIndexerRow = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Flat\Action\Row') + $this->productFlatIndexerRow = $this->getMockBuilder( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class + ) ->disableOriginalConstructor() ->getMock(); - $this->productFlatIndexerRows = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows') + $this->productFlatIndexerRows = $this->getMockBuilder( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows::class + ) ->disableOriginalConstructor() ->getMock(); - $this->productFlatIndexerFull = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Flat\Action\Full') + $this->productFlatIndexerFull = $this->getMockBuilder( + \Magento\Catalog\Model\Indexer\Product\Flat\Action\Full::class + ) ->disableOriginalConstructor() ->getMock(); $helper = new ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Indexer\Product\Flat', + \Magento\Catalog\Model\Indexer\Product\Flat::class, [ 'productFlatIndexerRow' => $this->productFlatIndexerRow, 'productFlatIndexerRows' => $this->productFlatIndexerRows, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php index 970bc2891d635..2c0304421a9eb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php @@ -17,7 +17,7 @@ class RowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Price\Action\Row'); + $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Price\Action\Row::class); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php index c52b50ba8f8dc..a9e37d97035db 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php @@ -17,7 +17,7 @@ class RowsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Price\Action\Rows'); + $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Price\Action\Rows::class); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php index a1a99ab7a584d..81110030ef6ea 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php @@ -34,26 +34,32 @@ protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_subjectMock = $this->getMock( - '\Magento\Customer\Api\GroupRepositoryInterface', [], [], '', false + $this->_subjectMock = $this->getMock( + \Magento\Customer\Api\GroupRepositoryInterface::class, [], [], '', false ); - $indexerMock = $this->getMock( - 'Magento\Indexer\Model\Indexer', + $indexerMock = $this->getMock( + \Magento\Indexer\Model\Indexer::class, ['getId', 'invalidate'], [], '', false ); $indexerMock->expects($this->once())->method('invalidate'); - $this->indexerRegistryMock = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + \Magento\Framework\Indexer\IndexerRegistry::class, + ['get'], + [], + '', + false + ); $this->indexerRegistryMock->expects($this->once()) ->method('get') ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) ->will($this->returnValue($indexerMock)); - $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Price\Plugin\CustomerGroup', + $this->_model = $this->_objectManager->getObject( + \Magento\Catalog\Model\Indexer\Product\Price\Plugin\CustomerGroup::class, ['indexerRegistry' => $this->indexerRegistryMock] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php index db48052fbd23c..f00ce8652a9db 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php @@ -27,7 +27,7 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_priceProcessorMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Price\Processor', + \Magento\Catalog\Model\Indexer\Product\Price\Processor::class, ['markIndexerAsInvalid'], [], '', @@ -35,7 +35,7 @@ protected function setUp() ); $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website', + \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website::class, ['processor' => $this->_priceProcessorMock] ); } @@ -44,7 +44,7 @@ public function testAfterDelete() { $this->_priceProcessorMock->expects($this->once())->method('markIndexerAsInvalid'); - $websiteMock = $this->getMock('Magento\Store\Model\ResourceModel\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\ResourceModel\Website::class, [], [], '', false); $this->assertEquals('return_value', $this->_model->afterDelete($websiteMock, 'return_value')); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php index cdec8d4b3a8f1..96277f32d82a7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php @@ -32,27 +32,27 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_indexerMock = $this->getMock( - 'Magento\Indexer\Model\Indexer', + \Magento\Indexer\Model\Indexer::class, ['load', 'invalidate'], [], '', false ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', false ); - $contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); - $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_model = $this->_objectManager->getObject( - 'Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope', + \Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope::class, [ 'context' => $contextMock, 'registry' => $registryMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php index 2dc48d82f5558..f97ff76f336bd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php @@ -40,11 +40,11 @@ class AvailabilityFlagTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->filterMock = $this->getMock( - '\Magento\Catalog\Model\Layer\Filter\AbstractFilter', [], [], '', false + \Magento\Catalog\Model\Layer\Filter\AbstractFilter::class, [], [], '', false ); $this->filters = [$this->filterMock]; - $this->layerMock = $this->getMock('\Magento\Catalog\Model\Layer', [], [], '', false); - $this->stateMock = $this->getMock('\Magento\Catalog\Model\Layer\State', [], [], '', false); + $this->layerMock = $this->getMock(\Magento\Catalog\Model\Layer::class, [], [], '', false); + $this->stateMock = $this->getMock(\Magento\Catalog\Model\Layer\State::class, [], [], '', false); $this->model = new AvailabilityFlag(); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php index 18447cd98fc56..4aada9146c471 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php @@ -29,10 +29,10 @@ class CollectionFilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->visibilityMock = $this->getMock( - '\Magento\Catalog\Model\Product\Visibility', [], [], '', false + $this->visibilityMock = $this->getMock( + \Magento\Catalog\Model\Product\Visibility::class, [], [], '', false ); - $this->catalogConfigMock = $this->getMock('\Magento\Catalog\Model\Config', [], [], '', false); + $this->catalogConfigMock = $this->getMock(\Magento\Catalog\Model\Config::class, [], [], '', false); $this->model = new CollectionFilter($this->visibilityMock, $this->catalogConfigMock); } @@ -42,11 +42,11 @@ protected function setUp() */ public function testFilter() { - $collectionMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false + $collectionMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], [], '', false ); - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once())->method('getId'); $this->catalogConfigMock->expects($this->once())->method('getProductAttributes'); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php index 09b227832ecf4..ff2be85e7705f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php @@ -28,10 +28,15 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->collectionFactoryMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory', ['create'], [], '', false); + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, + ['create'], + [], + '', + false + ); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', [], [], '', false + \Magento\Store\Model\StoreManagerInterface::class, [], [], '', false ); $this->model = new \Magento\Catalog\Model\Layer\Search\FilterableAttributeList( @@ -43,14 +48,14 @@ protected function setUp() public function testGetList() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeId = 4321; $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); $collectionMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection', [], [], '', false + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, [], [], '', false ); $this->collectionFactoryMock ->expects($this->once()) @@ -60,7 +65,7 @@ public function testGetList() $collectionMock ->expects($this->once()) ->method('setItemObjectClass') - ->with('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->will($this->returnSelf()); $collectionMock ->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php index 16aaa56ac4bbb..0889a13f1c4c1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php @@ -27,8 +27,8 @@ class StateKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->model = new StateKey($this->storeManagerMock, $this->customerSessionMock); } @@ -38,10 +38,10 @@ protected function setUp() */ public function testToString() { - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once())->method('getId')->will($this->returnValue('1')); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getId')->will($this->returnValue('2')); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php index d86543facfd92..ebfdd9a562c56 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php @@ -55,29 +55,30 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** @var \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory */ - $this->filterItemFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\ItemFactory') + $this->filterItemFactory = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\ItemFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $this->storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); /** @var \Magento\Catalog\Model\Layer $layer */ - $this->layer = $this->getMockBuilder('\Magento\Catalog\Model\Layer') + $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class) ->disableOriginalConstructor() ->setMethods(['getState']) ->getMock(); /** @var \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder */ - $this->itemDataBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder') + $this->itemDataBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class) ->disableOriginalConstructor() ->setMethods(['addItemData', 'build']) ->getMock(); - $this->filterAttribute = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute') - ->disableOriginalConstructor() + $this->filterAttribute = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute::class + )->disableOriginalConstructor() ->setMethods(['getCount', 'applyFilterToCollection']) ->getMock(); @@ -86,7 +87,7 @@ protected function setUp() ->will($this->returnSelf()); $this->filterAttributeFactory = $this->getMockBuilder( - '\Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory' + \Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory::class ) ->disableOriginalConstructor() ->setMethods(['create']) @@ -96,7 +97,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->filterAttribute)); - $this->state = $this->getMockBuilder('\Magento\Catalog\Model\Layer\State') + $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class) ->disableOriginalConstructor() ->setMethods(['addFilter']) ->getMock(); @@ -104,11 +105,11 @@ protected function setUp() ->method('getState') ->will($this->returnValue($this->state)); - $this->frontend = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend') + $this->frontend = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class) ->disableOriginalConstructor() ->setMethods(['getOption', 'getSelectOptions']) ->getMock(); - $this->attribute = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute') + $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) ->disableOriginalConstructor() ->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable']) ->getMock(); @@ -116,12 +117,12 @@ protected function setUp() ->method('getFrontend') ->will($this->returnValue($this->frontend)); - $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $stripTagsFilter = $this->getMockBuilder('\Magento\Framework\Filter\StripTags') + $stripTagsFilter = $this->getMockBuilder(\Magento\Framework\Filter\StripTags::class) ->disableOriginalConstructor() ->setMethods(['filter']) ->getMock(); @@ -129,7 +130,7 @@ protected function setUp() ->method('filter') ->will($this->returnArgument(0)); - $string = $this->getMockBuilder('\Magento\Framework\Stdlib\StringUtils') + $string = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class) ->disableOriginalConstructor() ->setMethods(['strlen']) ->getMock(); @@ -145,7 +146,7 @@ function ($value) { $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\Attribute', + \Magento\Catalog\Model\Layer\Filter\Attribute::class, [ 'filterItemFactory' => $this->filterItemFactory, 'storeManager' => $this->storeManager, @@ -257,7 +258,7 @@ public function testGetItems() */ private function createFilterItem($index, $label, $value, $count) { - $filterItem = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Item') + $filterItem = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item::class) ->disableOriginalConstructor() ->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php index 7499bc5dec3bd..15581b42320b7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php @@ -10,6 +10,8 @@ /** * Test for \Magento\Catalog\Model\Layer\Filter\Category + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CategoryTest extends \PHPUnit_Framework_TestCase { @@ -51,17 +53,16 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods(['getParam']) ->getMockForAbstractClass(); - $dataProviderFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); + $dataProviderFactory = $this->getMockBuilder( + \Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory::class + )->disableOriginalConstructor()->setMethods(['create'])->getMock(); - $this->dataProvider = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\Category') + $this->dataProvider = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\DataProvider\Category::class) ->disableOriginalConstructor() ->setMethods(['setCategoryId', 'getCategory']) ->getMock(); @@ -70,7 +71,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->dataProvider)); - $this->category = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getChildrenCategories', 'getIsActive']) ->getMock(); @@ -79,12 +80,12 @@ protected function setUp() ->method('getCategory', 'isValid') ->will($this->returnValue($this->category)); - $this->layer = $this->getMockBuilder('\Magento\Catalog\Model\Layer') + $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class) ->disableOriginalConstructor() ->setMethods(['getState', 'getProductCollection']) ->getMock(); - $this->state = $this->getMockBuilder('\Magento\Catalog\Model\Layer\State') + $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class) ->disableOriginalConstructor() ->setMethods(['addFilter']) ->getMock(); @@ -93,7 +94,7 @@ protected function setUp() ->will($this->returnValue($this->state)); $this->collection = $this->getMockBuilder( - '\Magento\Catalog\Model\ResourceModel\Product\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Collection::class ) ->disableOriginalConstructor() ->setMethods(['addCategoryFilter', 'getFacetedData', 'addCountToCategories']) @@ -103,22 +104,18 @@ protected function setUp() ->method('getProductCollection') ->will($this->returnValue($this->collection)); - $this->itemDataBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder') + $this->itemDataBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class) ->disableOriginalConstructor() ->setMethods(['addItemData', 'build']) ->getMock(); $this->filterItemFactory = $this->getMockBuilder( - '\Magento\Catalog\Model\Layer\Filter\ItemFactory' - ) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); + \Magento\Catalog\Model\Layer\Filter\ItemFactory::class + )->disableOriginalConstructor()->setMethods(['create'])->getMock(); $filterItem = $this->getMockBuilder( - '\Magento\Catalog\Model\Layer\Filter\Item' - ) - ->disableOriginalConstructor() + \Magento\Catalog\Model\Layer\Filter\Item::class + )->disableOriginalConstructor() ->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount']) ->getMock(); $filterItem->expects($this->any()) @@ -128,7 +125,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($filterItem)); - $escaper = $this->getMockBuilder('\Magento\Framework\Escaper') + $escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->setMethods(['escapeHtml']) ->getMock(); @@ -138,7 +135,7 @@ protected function setUp() $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\Category', + \Magento\Catalog\Model\Layer\Filter\Category::class, [ 'categoryDataProviderFactory' => $dataProviderFactory, 'layer' => $this->layer, @@ -247,7 +244,7 @@ public function testGetItems() ->method('getIsActive') ->will($this->returnValue(true)); - $category1 = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $category1 = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getName', 'getIsActive', 'getProductCount']) ->getMock(); @@ -264,7 +261,7 @@ public function testGetItems() ->method('getProductCount') ->will($this->returnValue(10)); - $category2 = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $category2 = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getName', 'getIsActive', 'getProductCount']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php index 60d3251286ba1..30a1d6c37b3f6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php @@ -40,26 +40,26 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** @var \Magento\Framework\Registry $var */ - $this->coreRegistry = $var = $this->getMockBuilder('\Magento\Framework\Registry') + $this->coreRegistry = $var = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->setMethods(['register']) ->getMock(); - $this->category = $this->getMockBuilder('Magento\Catalog\Model\Category') + $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->setMethods(['getId', 'setStoreId', 'load', 'getPathIds']) ->getMock(); - $this->categoryFactory = $this->getMockBuilder('Magento\Catalog\Model\CategoryFactory') + $this->categoryFactory = $this->getMockBuilder(\Magento\Catalog\Model\CategoryFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->categoryFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->category)); - $this->store = $this->getMockBuilder('\Magento\Store\Model\Store') + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); - $this->layer = $this->getMockBuilder('Magento\Catalog\Model\Layer') + $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class) ->disableOriginalConstructor() ->setMethods(['getCurrentStore', 'getCurrentCategory']) ->getMock(); @@ -68,7 +68,7 @@ protected function setUp() ->will($this->returnValue($this->store)); $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\DataProvider\Category', + \Magento\Catalog\Model\Layer\Filter\DataProvider\Category::class, [ 'coreRegistry' => $this->coreRegistry, 'categoryFactory' => $this->categoryFactory, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php index eb82402e3f426..80bf29832516e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php @@ -27,17 +27,17 @@ class DecimalTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filter = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\FilterInterface') + $this->filter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\FilterInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $this->resource = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal') + $this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal::class) ->disableOriginalConstructor() ->setMethods(['getMinMax', 'getCount']) ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\DataProvider\Decimal', + \Magento\Catalog\Model\Layer\Filter\DataProvider\Decimal::class, [ 'resource' => $this->resource, ] diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php index 8cac13fc75276..e27f6b29d8f3d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php @@ -38,32 +38,32 @@ class PriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productCollection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Collection') + $this->productCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class) ->disableOriginalConstructor() ->setMethods(['getMaxPrice']) ->getMock(); - $this->layer = $this->getMockBuilder('\Magento\Catalog\Model\Layer') + $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class) ->disableOriginalConstructor() ->setMethods(['getProductCollection']) ->getMock(); $this->layer->expects($this->any()) ->method('getProductCollection') ->will($this->returnValue($this->productCollection)); - $this->coreRegistry = $this->getMockBuilder('\Magento\Framework\Registry') + $this->coreRegistry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->setMethods(['registry']) ->getMock(); - $this->scopeConfig = $this->getMockBuilder('\Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMockForAbstractClass(); - $this->resource = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price') + $this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price::class) ->disableOriginalConstructor() ->setMethods(['getCount']) ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\DataProvider\Price', + \Magento\Catalog\Model\Layer\Filter\DataProvider\Price::class, [ 'layer' => $this->layer, 'coreRegistry' => $this->coreRegistry, @@ -109,7 +109,7 @@ function ($key, $scope) use ($map) { public function testGetPriceRangeWithRangeInFilter() { /** @var \Magento\Catalog\Model\Category|MockObject $category */ - $category = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->setMethods(['getFilterPriceRange']) ->getMock(); @@ -127,7 +127,7 @@ public function testGetPriceRangeWithRangeInFilter() public function testGetPriceRangeWithRangeCalculation() { /** @var \Magento\Catalog\Model\Category|MockObject $category */ - $category = $this->getMockBuilder('\Magento\Catalog\Model\Category') + $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->setMethods(['getFilterPriceRange']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php index cd42104fd9b6e..40bf8f17221ac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php @@ -10,7 +10,7 @@ class DecimalTest extends \PHPUnit_Framework_TestCase public function testConstructorRequestVarIsOverwrittenCorrectlyInParent() { $attributeModel = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['getAttributeCode', '__wakeup'], [], '', @@ -20,12 +20,14 @@ public function testConstructorRequestVarIsOverwrittenCorrectlyInParent() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $dataProviderFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\DecimalFactory') + $dataProviderFactory = $this->getMockBuilder( + \Magento\Catalog\Model\Layer\Filter\DataProvider\DecimalFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $instance = $objectManager->getObject( - 'Magento\Catalog\Model\Layer\Filter\Decimal', + \Magento\Catalog\Model\Layer\Filter\Decimal::class, [ 'data' => [ 'attribute_model' => $attributeModel, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php index 440935c9dc64b..f356b0176a521 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php @@ -19,18 +19,18 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_factory = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\Factory', + \Magento\Catalog\Model\Layer\Filter\Factory::class, ['objectManager' => $this->_objectManagerMock] ); } public function testCreate() { - $className = 'Magento\Catalog\Model\Layer\Filter\AbstractFilter'; + $className = \Magento\Catalog\Model\Layer\Filter\AbstractFilter::class; $filterMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects( @@ -49,7 +49,7 @@ public function testCreate() public function testCreateWithArguments() { - $className = 'Magento\Catalog\Model\Layer\Filter\AbstractFilter'; + $className = \Magento\Catalog\Model\Layer\Filter\AbstractFilter::class; $arguments = ['foo', 'bar']; $filterMock = $this->getMock($className, [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php index 21a22626f26f5..d556327378aaa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php @@ -19,7 +19,7 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); $this->dataBuilder = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\Item\DataBuilder', + \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class, [] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php index 1af8e8bd27202..2ebbbf9e465b2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php @@ -12,6 +12,7 @@ /** * Test for \Magento\Catalog\Model\Layer\Filter\Price * @SuppressWarnings(PHPMD.UnusedPrivateField) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PriceTest extends \PHPUnit_Framework_TestCase { @@ -56,21 +57,23 @@ class PriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods(['getParam']) ->getMockForAbstractClass(); - $dataProviderFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory') + $dataProviderFactory = $this->getMockBuilder( + \Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->dataProvider = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\DataProvider\Price') + $this->dataProvider = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\DataProvider\Price::class) ->disableOriginalConstructor() ->setMethods(['setPriceId', 'getPrice', 'getResource']) ->getMock(); - $this->resource = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price') + $this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price::class) ->disableOriginalConstructor() ->setMethods(['applyPriceRange']) ->getMock(); @@ -82,12 +85,12 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->dataProvider)); - $this->layer = $this->getMockBuilder('\Magento\Catalog\Model\Layer') + $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class) ->disableOriginalConstructor() ->setMethods(['getState']) ->getMock(); - $this->state = $this->getMockBuilder('\Magento\Catalog\Model\Layer\State') + $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class) ->disableOriginalConstructor() ->setMethods(['addFilter']) ->getMock(); @@ -95,20 +98,20 @@ protected function setUp() ->method('getState') ->will($this->returnValue($this->state)); - $this->itemDataBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder') + $this->itemDataBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class) ->disableOriginalConstructor() ->setMethods(['addItemData', 'build']) ->getMock(); $this->filterItemFactory = $this->getMockBuilder( - '\Magento\Catalog\Model\Layer\Filter\ItemFactory' + \Magento\Catalog\Model\Layer\Filter\ItemFactory::class ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $filterItem = $this->getMockBuilder( - '\Magento\Catalog\Model\Layer\Filter\Item' + \Magento\Catalog\Model\Layer\Filter\Item::class ) ->disableOriginalConstructor() ->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount']) @@ -120,7 +123,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($filterItem)); - $escaper = $this->getMockBuilder('\Magento\Framework\Escaper') + $escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->disableOriginalConstructor() ->setMethods(['escapeHtml']) ->getMock(); @@ -128,16 +131,16 @@ protected function setUp() ->method('escapeHtml') ->will($this->returnArgument(0)); - $this->attribute = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute') + $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) ->disableOriginalConstructor() ->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable']) ->getMock(); - $algorithmFactory = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory') + $algorithmFactory = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->algorithm = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Filter\Dynamic\Auto') + $this->algorithm = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Dynamic\Auto::class) ->disableOriginalConstructor() ->setMethods(['getItemsData']) ->getMock(); @@ -148,7 +151,7 @@ protected function setUp() $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Layer\Filter\Price', + \Magento\Catalog\Model\Layer\Filter\Price::class, [ 'dataProviderFactory' => $dataProviderFactory, 'layer' => $this->layer, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php index 044aecaddba0f..09ef52e74d74b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php @@ -39,12 +39,12 @@ class FilterListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface'); - $this->attributeListMock = $this->getMock( - 'Magento\Catalog\Model\Layer\Category\FilterableAttributeList', [], [], '', false + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->attributeListMock = $this->getMock( + \Magento\Catalog\Model\Layer\Category\FilterableAttributeList::class, [], [], '', false ); - $this->attributeMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false + $this->attributeMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false ); $filters = [ FilterList::CATEGORY_FILTER => 'CategoryFilterClass', @@ -53,7 +53,7 @@ protected function setUp() FilterList::ATTRIBUTE_FILTER => 'AttributeFilterClass', ]; - $this->layerMock = $this->getMock('\Magento\Catalog\Model\Layer', [], [], '', false); + $this->layerMock = $this->getMock(\Magento\Catalog\Model\Layer::class, [], [], '', false); $this->model = new FilterList($this->objectManagerMock, $this->attributeListMock, $filters); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php index 5114f7f57a182..2f65473a7cb38 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php @@ -33,13 +33,13 @@ class CollectionFilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->visibilityMock = $this->getMock('Magento\Catalog\Model\Product\Visibility', [], [], '', false); - $this->catalogConfigMock = $this->getMock('\Magento\Catalog\Model\Config', [], [], '', false); + $this->visibilityMock = $this->getMock(\Magento\Catalog\Model\Product\Visibility::class, [], [], '', false); + $this->catalogConfigMock = $this->getMock(\Magento\Catalog\Model\Config::class, [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Layer\Search\CollectionFilter', + \Magento\Catalog\Model\Layer\Search\CollectionFilter::class, [ 'catalogConfig' => $this->catalogConfigMock, 'storeManager' => $this->storeManagerMock, @@ -55,7 +55,7 @@ protected function setUp() public function testFilter() { $collectionMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, [ 'addAttributeToSelect', 'setStore', 'addMinimalPrice', 'addFinalPrice', 'addTaxPercents', 'addStoreFilter', 'addUrlRewrite', 'setVisibility' @@ -64,7 +64,7 @@ public function testFilter() '', false ); - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $this->catalogConfigMock->expects($this->once())->method('getProductAttributes'); $this->visibilityMock->expects($this->once())->method('getVisibleInSearchIds'); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php index 9f0cd80898d95..373ad5e3cc295 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php @@ -28,10 +28,15 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->collectionFactoryMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory', ['create'], [], '', false); + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, + ['create'], + [], + '', + false + ); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', [], [], '', false + \Magento\Store\Model\StoreManagerInterface::class, [], [], '', false ); $this->model = new \Magento\Catalog\Model\Layer\Search\FilterableAttributeList( @@ -46,14 +51,14 @@ protected function setUp() */ public function testGetList() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeId = 4321; $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); $collectionMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection', [], [], '', false + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, [], [], '', false ); $this->collectionFactoryMock ->expects($this->once()) @@ -63,7 +68,7 @@ public function testGetList() $collectionMock ->expects($this->once()) ->method('setItemObjectClass') - ->with('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->will($this->returnSelf()); $collectionMock ->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php index 12e8ebc210281..5dcc3ffdc8690 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php @@ -32,10 +32,10 @@ class StateKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->queryFactoryMock = $this->getMock( - '\Magento\Search\Model\QueryFactory', + \Magento\Search\Model\QueryFactory::class, [], [], '', @@ -51,16 +51,16 @@ protected function setUp() */ public function testToString() { - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once())->method('getId')->will($this->returnValue('1')); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getId')->will($this->returnValue('2')); $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('3')); - $queryMock = $this->getMock('\Magento\CatalogSearch\Helper\Query', ['getId'], [], '', false); + $queryMock = $this->getMock(\Magento\Search\Model\Query::class, ['getId'], [], '', false); $queryMock->expects($this->once())->method('getId')->will($this->returnValue('4')); $this->queryFactoryMock->expects($this->once())->method('get')->will($this->returnValue($queryMock)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php index 7389d4795c9d3..c0c4f5f572f3b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php @@ -21,12 +21,12 @@ class StateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->item = $this->getMockBuilder('Magento\Catalog\Model\Layer\Filter\Item') + $this->item = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item::class) ->disableOriginalConstructor() ->getMock(); $helper = new ObjectManager($this); - $this->model = $helper->getObject('Magento\Catalog\Model\Layer\State'); + $this->model = $helper->getObject(\Magento\Catalog\Model\Layer\State::class); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php index 4f6ba3b79fce3..aeac5187a7838 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php @@ -98,53 +98,53 @@ protected function setUp() { $helper = new ObjectManager($this); - $this->category = $this->getMockBuilder('Magento\Catalog\Model\Category') + $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->setMethods(['getId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->setMethods(['registry']) ->disableOriginalConstructor() ->getMock(); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getRootCategoryId', 'getFilters', '__wakeup']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->storeManager->expects($this->any())->method('getStore') ->will($this->returnValue($this->store)); - $this->stateKeyGenerator = $this->getMockBuilder('Magento\Catalog\Model\Layer\Category\StateKey') + $this->stateKeyGenerator = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Category\StateKey::class) ->setMethods(['toString']) ->disableOriginalConstructor() ->getMock(); - $this->collectionFilter = $this->getMockBuilder('Magento\Catalog\Model\Layer\Category\CollectionFilter') + $this->collectionFilter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Category\CollectionFilter::class) ->setMethods(['filter']) ->disableOriginalConstructor() ->getMock(); - $this->collectionProvider = $this->getMockBuilder('Magento\Catalog\Model\Layer\ItemCollectionProviderInterface') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); + $this->collectionProvider = $this->getMockBuilder( + \Magento\Catalog\Model\Layer\ItemCollectionProviderInterface::class + )->disableOriginalConstructor()->getMockForAbstractClass(); - $this->filter = $this->getMockBuilder('Magento\Catalog\Model\Layer\Filter\Item') + $this->filter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item::class) ->setMethods(['getFilter', 'getValueString']) ->disableOriginalConstructor() ->getMock(); - $this->abstractFilter = $this->getMockBuilder('Magento\Catalog\Model\Layer\Filter\AbstractFilter') + $this->abstractFilter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\AbstractFilter::class) ->setMethods(['getRequestVar']) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Catalog\Model\Layer\ContextInterface') + $this->context = $this->getMockBuilder(\Magento\Catalog\Model\Layer\ContextInterface::class) ->setMethods(['getStateKey', 'getCollectionFilter']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -155,25 +155,31 @@ protected function setUp() $this->context->expects($this->any())->method('getCollectionProvider') ->will($this->returnValue($this->collectionProvider)); - $this->state = $this->getMockBuilder('Magento\Catalog\Model\Layer\State') + $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class) ->disableOriginalConstructor() ->getMock(); - $this->stateFactory = $this->getMockBuilder('Magento\Catalog\Model\Layer\StateFactory') + $this->stateFactory = $this->getMockBuilder(\Magento\Catalog\Model\Layer\StateFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->stateFactory->expects($this->any())->method('create')->will($this->returnValue($this->state)); - $this->collection = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Collection') + $this->collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class) ->disableOriginalConstructor() ->getMock(); - $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); - $this->currentCategory = $this->getMock('Magento\Catalog\Model\Category', ['getId', '__wakeup'], [], '', false); + $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $this->currentCategory = $this->getMock( + \Magento\Catalog\Model\Category::class, + ['getId', '__wakeup'], + [], + '', + false + ); $this->model = $helper->getObject( - 'Magento\Catalog\Model\Layer', + \Magento\Catalog\Model\Layer::class, [ 'registry' => $this->registry, 'storeManager' => $this->storeManager, @@ -186,7 +192,7 @@ protected function setUp() public function testGetState() { - $this->assertInstanceOf('\Magento\Catalog\Model\Layer\State', $this->model->getState()); + $this->assertInstanceOf(\Magento\Catalog\Model\Layer\State::class, $this->model->getState()); } public function testGetStateKey() @@ -217,9 +223,9 @@ public function testGetProductCollection() ->will($this->returnValue($this->collection)); $result = $this->model->getProductCollection(); - $this->assertInstanceOf('\Magento\Catalog\Model\ResourceModel\Product\Collection', $result); + $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, $result); $result = $this->model->getProductCollection(); - $this->assertInstanceOf('\Magento\Catalog\Model\ResourceModel\Product\Collection', $result); + $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, $result); } public function testApply() @@ -240,7 +246,7 @@ public function testApply() $this->abstractFilter->expects($this->once())->method('getRequestVar')->will($this->returnValue('t')); $result = $this->model->apply(); - $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $result); + $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $result); } public function testPrepareProductCollection() @@ -252,12 +258,12 @@ public function testPrepareProductCollection() ->with($this->equalTo($this->collection), $this->equalTo($this->category)); $result = $this->model->prepareProductCollection($this->collection); - $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $result); + $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $result); } public function testGetCurrentStore() { - $this->assertInstanceOf('\Magento\Store\Model\Store', $this->model->getCurrentStore()); + $this->assertInstanceOf(\Magento\Store\Model\Store::class, $this->model->getCurrentStore()); } public function testSetNewCurrentCategoryIfCurrentCategoryIsAnother() @@ -273,7 +279,7 @@ public function testSetNewCurrentCategoryIfCurrentCategoryIsAnother() $this->registry->expects($this->once())->method('registry')->with('current_category') ->willReturn($this->currentCategory); - $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $this->model->setCurrentCategory($categoryId)); + $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $this->model->setCurrentCategory($categoryId)); $this->assertEquals($this->currentCategory, $this->model->getData('current_category')); } @@ -288,7 +294,7 @@ public function testSetNewCurrentCategoryIfCurrentCategoryIsSame() $this->registry->expects($this->once())->method('registry')->with('current_category') ->willReturn($this->category); - $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $this->model->setCurrentCategory($categoryId)); + $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $this->model->setCurrentCategory($categoryId)); $this->assertEquals($this->category, $this->model->getData('current_category')); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php index f6e1f97aadebc..9ebd5b9fa93df 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -34,24 +34,24 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->catalogSessionMock = $this->getMock('Magento\Catalog\Model\Session', + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->catalogSessionMock = $this->getMock( + \Magento\Catalog\Model\Session::class, ['clearStorage'], [], '', false ); - $this->resultLayout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->depersonalizeCheckerMock = $this->getMock( - 'Magento\PageCache\Model\DepersonalizeChecker', + $this->resultLayout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->depersonalizeCheckerMock = $this->getMock( + \Magento\PageCache\Model\DepersonalizeChecker::class, [], [], '', false ); - $this->plugin = (new ObjectManager($this))->getObject( - 'Magento\Catalog\Model\Layout\DepersonalizePlugin', + $this->plugin = (new ObjectManager($this))->getObject(\Magento\Catalog\Model\Layout\DepersonalizePlugin::class, ['catalogSession' => $this->catalogSessionMock, 'depersonalizeChecker' => $this->depersonalizeCheckerMock] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php index 8f631595bb07b..7fb5415385894 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php @@ -29,15 +29,21 @@ class LogTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->logResourceMock = $this->getMock('Magento\Customer\Model\ResourceModel\Visitor', [], [], '', false); + $this->logResourceMock = $this->getMock( + \Magento\Customer\Model\ResourceModel\Visitor::class, + [], + [], + '', + false + ); $this->compareItemMock = $this->getMock( - 'Magento\Catalog\Model\Product\Compare\Item', + \Magento\Catalog\Model\Product\Compare\Item::class, [], [], '', false ); - $this->subjectMock = $this->getMock('Magento\Customer\Model\ResourceModel\Visitor', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Customer\Model\ResourceModel\Visitor::class, [], [], '', false); $this->model = new \Magento\Catalog\Model\Plugin\Log($this->compareItemMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php index 5a88a48361c08..c3644c5460dc1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php @@ -46,9 +46,9 @@ class TransactionWrapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Product', [], [], '', false); - $this->subjectMock = $this->getMock('Magento\Catalog\Api\ProductRepositoryInterface', [], [], '', false); - $this->productMock = $this->getMock('Magento\Catalog\Api\Data\ProductInterface', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class, [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class, [], [], '', false); $productMock = $this->productMock; $this->closureMock = function () use ($productMock) { return $productMock; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php index ebf3ff2d6d6ff..6b6b0921e506a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php @@ -28,10 +28,10 @@ class QuoteItemProductOptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderItemMock = $this->getMock('Magento\Sales\Model\Order\Item', [], [], '', false); - $this->quoteItemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $this->orderItemMock = $this->getMock(\Magento\Sales\Model\Order\Item::class, [], [], '', false); + $this->quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $orderItem = $this->orderItemMock; - $this->subjectMock = $this->getMock('Magento\Quote\Model\Quote\Item\ToOrderItem', [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Quote\Model\Quote\Item\ToOrderItem::class, [], [], '', false); $this->closureMock = function () use ($orderItem) { return $orderItem; }; @@ -49,7 +49,7 @@ public function testAroundItemToOrderItemEmptyOptions() public function testAroundItemToOrderItemWithOptions() { $itemOption = $this->getMock( - 'Magento\Quote\Model\Quote\Item\Option', + \Magento\Quote\Model\Quote\Item\Option::class, ['getCode', '__wakeup'], [], '', @@ -66,8 +66,8 @@ public function testAroundItemToOrderItemWithOptions() $itemOption->expects($this->at(0))->method('getCode')->will($this->returnValue('someText_8')); $itemOption->expects($this->at(1))->method('getCode')->will($this->returnValue('not_int_text')); - $productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $optionMock = $this->getMock('stdClass', ['getType']); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $optionMock = $this->getMock(\stdClass::class, ['getType']); $optionMock->expects($this->once())->method('getType'); $productMock->expects($this->once())->method('getOptionById')->will($this->returnValue($optionMock)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php index e08d12b93c9c9..6058f382341e3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php @@ -49,16 +49,16 @@ class ActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $this->productWebsiteFactory = $this->getMock( - '\Magento\Catalog\Model\Product\WebsiteFactory', + \Magento\Catalog\Model\Product\WebsiteFactory::class, ['create'], [], '', false ); $this->resource = $this->getMock( - '\Magento\Framework\Model\ResourceModel\AbstractResource', + \Magento\Framework\Model\ResourceModel\AbstractResource::class, [ 'updateAttributes', 'getConnection', @@ -70,7 +70,7 @@ protected function setUp() false ); $this->productWebsite = $this->getMock( - '\Magento\Catalog\Model\Product\Website', + \Magento\Catalog\Model\Product\Website::class, ['addProducts', 'removeProducts', '__wakeup'], [], '', @@ -81,28 +81,28 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->productWebsite)); $this->categoryIndexer = $this->getMock( - '\Magento\Indexer\Model\Indexer', + \Magento\Indexer\Model\Indexer::class, ['getId', 'load', 'isScheduled', 'reindexList'], [], '', false ); $this->eavConfig = $this->getMock( - '\Magento\Eav\Model\Config', + \Magento\Eav\Model\Config::class, ['__wakeup', 'getAttribute'], [], '', false ); $this->eavAttribute = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['__wakeup', 'isIndexable'], [], '', false ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Framework\Indexer\IndexerRegistry', + \Magento\Framework\Indexer\IndexerRegistry::class, ['get'], [], '', @@ -111,7 +111,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Product\Action', + \Magento\Catalog\Model\Product\Action::class, [ 'eventDispatcher' => $eventManagerMock, 'resource' => $this->resource, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php index 64dcc9dbdec73..87d35586ae008 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php @@ -11,12 +11,12 @@ public function testAfterLoad() { $categoryIds = [1, 2, 3, 4, 5]; - $product = $this->getMock('Magento\Framework\DataObject', ['getCategoryIds', 'setData']); + $product = $this->getMock(\Magento\Framework\DataObject::class, ['getCategoryIds', 'setData']); $product->expects($this->once())->method('getCategoryIds')->will($this->returnValue($categoryIds)); $product->expects($this->once())->method('setData')->with('category_ids', $categoryIds); - $categoryAttribute = $this->getMock('Magento\Framework\DataObject', ['getAttributeCode']); + $categoryAttribute = $this->getMock(\Magento\Framework\DataObject::class, ['getAttributeCode']); $categoryAttribute->expects( $this->once() )->method( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php index 0f4af13a77771..19d5ac7d7f63c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend\GroupPrice; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractTest extends \PHPUnit_Framework_TestCase { /** @@ -21,18 +24,24 @@ class AbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_helper = $this->getMock('Magento\Catalog\Helper\Data', ['isPriceGlobal'], [], '', false); + $this->_helper = $this->getMock(\Magento\Catalog\Helper\Data::class, ['isPriceGlobal'], [], '', false); $this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true)); - $currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', ['create'], [], '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); - $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', [], [], '', false); - $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $localeFormatMock = $this->getMock('\Magento\Framework\Locale\FormatInterface', [], [], '', false); - $groupManagement = $this->getMock('Magento\Customer\Api\GroupManagementInterface', [], [], '', false); - $metadataPool = $this->getMock('Magento\Framework\EntityManager\MetadataPool', [], [], '', false); + $currencyFactoryMock = $this->getMock( + \Magento\Directory\Model\CurrencyFactory::class, + ['create'], + [], + '', + false + ); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $productTypeMock = $this->getMock(\Magento\Catalog\Model\Product\Type::class, [], [], '', false); + $configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $localeFormatMock = $this->getMock(\Magento\Framework\Locale\FormatInterface::class, [], [], '', false); + $groupManagement = $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class, [], [], '', false); + $metadataPool = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); $this->_model = $this->getMockForAbstractClass( - 'Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice', + \Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice::class, [ 'currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, @@ -44,7 +53,7 @@ protected function setUp() 'metadataPool' => $metadataPool ] ); - $resource = $this->getMock('StdClass', ['getMainTable']); + $resource = $this->getMock(\StdClass::class, ['getMainTable']); $resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table')); $this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource)); @@ -56,20 +65,16 @@ public function testGetAffectedFields() $attributeId = 42; $attribute = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getBackendTable', 'isStatic', 'getAttributeId', 'getName', '__wakeup'], [], '', false ); $attribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($attributeId)); - $attribute->expects($this->any())->method('isStatic')->will($this->returnValue(false)); - $attribute->expects($this->any())->method('getBackendTable')->will($this->returnValue('table')); - $attribute->expects($this->any())->method('getName')->will($this->returnValue('tear_price')); - $this->_model->setAttribute($attribute); $object = new \Magento\Framework\DataObject(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php index b5ff723a7ce86..07b4b10834c71 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php @@ -32,7 +32,7 @@ protected function setUp() { $this->imageMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::class, [], [], '', @@ -43,7 +43,7 @@ protected function setUp() $this->videoMock = $this->getMock( - '\Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter', + \Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter::class, [], [], '', @@ -52,7 +52,7 @@ protected function setUp() $this->videoMock->expects($this->any())->method('getMediaEntryType')->willReturn('external-video'); - $this->dataObjectMock = $this->getMock('\Magento\Framework\DataObject', [], [], '', false); + $this->dataObjectMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); } public function testGetConverterByMediaTypeImage() @@ -60,7 +60,7 @@ public function testGetConverterByMediaTypeImage() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $converterPool = $objectManager->getObject( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class, [ 'mediaGalleryEntryConvertersCollection' => [$this->imageMock, $this->videoMock] ] @@ -74,7 +74,7 @@ public function testGetConverterByMediaTypeVideo() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $converterPool = $objectManager->getObject( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class, [ 'mediaGalleryEntryConvertersCollection' => [$this->imageMock, $this->videoMock] ] @@ -90,7 +90,7 @@ public function testConstructException() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $converterPool = $objectManager->getObject( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class, [ 'mediaGalleryEntryConvertersCollection' => [$this->dataObjectMock] ] @@ -104,13 +104,13 @@ public function testGetConverterByMediaTypeImageException() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $converterPool = $objectManager->getObject( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class, [ 'mediaGalleryEntryConvertersCollection' => [$this->imageMock, $this->videoMock] ] ); - $this->setExpectedException('\Magento\Framework\Exception\LocalizedException'); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); $converterPool->getConverterByMediaType('something_wrong'); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php index 0e45b8a2d77b5..ecb87ec436ad4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php @@ -41,7 +41,7 @@ protected function setUp() { $this->mediaGalleryEntryFactoryMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory', + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class, ['create'], [], '', @@ -50,7 +50,7 @@ protected function setUp() $this->mediaGalleryEntryMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface', + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class, [ 'getId', 'setId', @@ -80,14 +80,14 @@ protected function setUp() $this->mediaGalleryEntryMock ); - $this->dataObjectHelperMock = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->dataObjectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); - $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->modelObject = $objectManager->getObject( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::class, [ 'mediaGalleryEntryFactory' => $this->mediaGalleryEntryFactoryMock, 'dataObjectHelper' => $this->dataObjectHelperMock @@ -173,7 +173,13 @@ public function testConvertFrom() 1 => 'swatch_image', ] ); - $imageContentInterface = $this->getMock('Magento\Framework\Api\Data\ImageContentInterface', [], [], '', false); + $imageContentInterface = $this->getMock( + \Magento\Framework\Api\Data\ImageContentInterface::class, + [], + [], + '', + false + ); $imageContentInterface->expects($this->once())->method('getBase64EncodedData')->willReturn( base64_encode('some_content') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php index 8dc8817786545..05a5b8ebe53a7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php @@ -17,11 +17,21 @@ protected function setUp() $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); // we want to use an actual implementation of \Magento\Framework\Locale\FormatInterface - $scopeResolver = $this->getMockForAbstractClass('\Magento\Framework\App\ScopeResolverInterface', [], '', false); - $localeResolver = $this->getMockForAbstractClass('\Magento\Framework\Locale\ResolverInterface', [], '', false); - $currencyFactory = $this->getMock('\Magento\Directory\Model\CurrencyFactory', [], [], '', false); + $scopeResolver = $this->getMockForAbstractClass( + \Magento\Framework\App\ScopeResolverInterface::class, + [], + '', + false + ); + $localeResolver = $this->getMockForAbstractClass( + \Magento\Framework\Locale\ResolverInterface::class, + [], + '', + false + ); + $currencyFactory = $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false); $localeFormat = $objectHelper->getObject( - 'Magento\Framework\Locale\Format', + \Magento\Framework\Locale\Format::class, [ 'scopeResolver' => $scopeResolver, 'localeResolver' => $localeResolver, @@ -31,12 +41,12 @@ protected function setUp() // the model we are testing $this->model = $objectHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Backend\Price', + \Magento\Catalog\Model\Product\Attribute\Backend\Price::class, ['localeFormat' => $localeFormat] ); $attribute = $this->getMockForAbstractClass( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [], '', false @@ -51,7 +61,7 @@ protected function setUp() */ public function testValidate($value) { - $object = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $object = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $object->expects($this->once())->method('getData')->willReturn($value); $this->assertTrue($this->model->validate($object)); @@ -81,7 +91,7 @@ public function dataProviderValidate() */ public function testValidateForFailure($value) { - $object = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $object = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $object->expects($this->once())->method('getData')->willReturn($value); $this->model->validate($object); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php index 3cd1922622f0e..ec9cb624db79a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php @@ -30,13 +30,13 @@ class StockTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getIsInStock', 'getQty', '__wakeup'], [], '', @@ -47,10 +47,10 @@ protected function setUp() ->method('getStockItem') ->will($this->returnValue($this->stockItemMock)); $this->model = $this->objectHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Backend\Stock', + \Magento\Catalog\Model\Product\Attribute\Backend\Stock::class, ['stockRegistry' => $this->stockRegistry] ); - $attribute = $this->getMock('Magento\Framework\DataObject', ['getAttributeCode']); + $attribute = $this->getMock(\Magento\Framework\DataObject::class, ['getAttributeCode']); $attribute->expects($this->atLeastOnce()) ->method('getAttributeCode') ->will($this->returnValue(self::ATTRIBUTE_NAME)); @@ -64,7 +64,7 @@ public function testAfterLoad() $this->stockItemMock->expects($this->once())->method('getIsInStock')->will($this->returnValue(1)); $this->stockItemMock->expects($this->once())->method('getQty')->will($this->returnValue(5)); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId', '__wakeup'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup'], [], '', false); $store->expects($this->once()) ->method('getWebsiteId') ->will($this->returnValue(10)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php index fd5ea0fbd3677..0ca0cdf7818b4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php @@ -17,11 +17,21 @@ protected function setUp() $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); // we want to use an actual implementation of \Magento\Framework\Locale\FormatInterface - $scopeResolver = $this->getMockForAbstractClass('\Magento\Framework\App\ScopeResolverInterface', [], '', false); - $localeResolver = $this->getMockForAbstractClass('\Magento\Framework\Locale\ResolverInterface', [], '', false); - $currencyFactory = $this->getMock('\Magento\Directory\Model\CurrencyFactory', [], [], '', false); + $scopeResolver = $this->getMockForAbstractClass( + \Magento\Framework\App\ScopeResolverInterface::class, + [], + '', + false + ); + $localeResolver = $this->getMockForAbstractClass( + \Magento\Framework\Locale\ResolverInterface::class, + [], + '', + false + ); + $currencyFactory = $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false); $localeFormat = $objectHelper->getObject( - 'Magento\Framework\Locale\Format', + \Magento\Framework\Locale\Format::class, [ 'scopeResolver' => $scopeResolver, 'localeResolver' => $localeResolver, @@ -31,12 +41,12 @@ protected function setUp() // the model we are testing $this->model = $objectHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Backend\Weight', + \Magento\Catalog\Model\Product\Attribute\Backend\Weight::class, ['localeFormat' => $localeFormat] ); $attribute = $this->getMockForAbstractClass( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [], '', false @@ -51,7 +61,7 @@ protected function setUp() */ public function testValidate($value) { - $object = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $object = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $object->expects($this->once())->method('getData')->willReturn($value); $this->assertTrue($this->model->validate($object)); @@ -81,7 +91,7 @@ public function dataProviderValidate() */ public function testValidateForFailure($value) { - $object = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $object = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $object->expects($this->once())->method('getData')->willReturn($value); $this->model->validate($object); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php index dfd9624ed1b9a..d5f52f95c67d7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php @@ -23,7 +23,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Product\Attribute\Frontend\Image', + \Magento\Catalog\Model\Product\Attribute\Frontend\Image::class, ['storeManager' => $this->getMockedStoreManager()] ); $this->model->setAttribute($this->getMockedAttribute()); @@ -34,7 +34,7 @@ protected function setUp() */ private function getMockedProduct() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product'); + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class); $mock = $mockBuilder->setMethods(['getData', 'getStore', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -56,7 +56,7 @@ private function getMockedStoreManager() { $mockedStore = $this->getMockedStore(); - $mockBuilder = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface'); + $mockBuilder = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class); $mock = $mockBuilder->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -73,7 +73,7 @@ private function getMockedStoreManager() */ private function getMockedStore() { - $mockBuilder = $this->getMockBuilder('\Magento\Store\Model\Store'); + $mockBuilder = $this->getMockBuilder(\Magento\Store\Model\Store::class); $mock = $mockBuilder->setMethods(['getBaseUrl', '__wakeup']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -90,7 +90,7 @@ private function getMockedStore() */ private function getMockedAttribute() { - $mockBuilder = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute'); + $mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class); $mockBuilder->setMethods(['getAttributeCode', '__wakeup']); $mockBuilder->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php index 18d3a48afd63b..4a10c3194a552 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php @@ -25,7 +25,7 @@ protected function setUp() { $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Product\Attribute\Group', + \Magento\Catalog\Model\Product\Attribute\Group::class, [ 'attributeCollectionFactory' => $this->getMockedCollectionFactory() ] @@ -40,7 +40,7 @@ private function getMockedCollectionFactory() $mockedCollection = $this->getMockedCollection(); $mockBuilder = $this->getMockBuilder( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory' + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class ); $mock = $mockBuilder->setMethods(['create']) ->disableOriginalConstructor() @@ -58,7 +58,7 @@ private function getMockedCollectionFactory() */ private function getMockedCollection() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection'); + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class); $mock = $mockBuilder->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php index d000e7b236d5b..7b51a2738eb03 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php @@ -23,7 +23,7 @@ class ManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attrManagementMock = $this->getMock('\Magento\Eav\Api\AttributeManagementInterface'); + $this->attrManagementMock = $this->getMock(\Magento\Eav\Api\AttributeManagementInterface::class); $this->model = new \Magento\Catalog\Model\Product\Attribute\Management($this->attrManagementMock); } @@ -62,7 +62,7 @@ public function testUnassign() public function testGetAttributes() { $attributeSetId = 1; - $attributeMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeInterface'); + $attributeMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeInterface::class); $this->attrManagementMock->expects($this->once()) ->method('getAttributes') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php index 11ba7f4985ca4..e6624c5a90d48 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php @@ -19,7 +19,7 @@ class OptionManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eavOptionManagementMock = $this->getMock('\Magento\Eav\Api\AttributeOptionManagementInterface'); + $this->eavOptionManagementMock = $this->getMock(\Magento\Eav\Api\AttributeOptionManagementInterface::class); $this->model = new \Magento\Catalog\Model\Product\Attribute\OptionManagement( $this->eavOptionManagementMock ); @@ -38,7 +38,7 @@ public function testGetItems() public function testAdd() { $attributeCode = 42; - $optionMock = $this->getMock('\Magento\Eav\Api\Data\AttributeOptionInterface'); + $optionMock = $this->getMock(\Magento\Eav\Api\Data\AttributeOptionInterface::class); $this->eavOptionManagementMock->expects($this->once())->method('add')->with( \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php index e124badb02f79..1b2648fb3254c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php @@ -11,6 +11,9 @@ use \Magento\Catalog\Model\Product\Attribute\Repository; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -71,27 +74,27 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->attributeResourceMock = - $this->getMock('Magento\Catalog\Model\ResourceModel\Attribute', [], [], '', false); + $this->getMock(\Magento\Catalog\Model\ResourceModel\Attribute::class, [], [], '', false); $this->productHelperMock = - $this->getMock('Magento\Catalog\Helper\Product', [], [], '', false); + $this->getMock(\Magento\Catalog\Helper\Product::class, [], [], '', false); $this->filterManagerMock = - $this->getMock('Magento\Framework\Filter\FilterManager', [], [], '', false); + $this->getMock(\Magento\Framework\Filter\FilterManager::class, [], [], '', false); $this->eavAttributeRepositoryMock = - $this->getMock('Magento\Eav\Api\AttributeRepositoryInterface', [], [], '', false); - $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->getMock(\Magento\Eav\Api\AttributeRepositoryInterface::class, [], [], '', false); + $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); $this->eavConfigMock->expects($this->any())->method('getEntityType') ->willReturn(new \Magento\Framework\DataObject(['default_attribute_set_id' => 4])); $this->validatorFactoryMock = $this->getMock( - 'Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory', + \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory::class, ['create'], [], '', false); $this->searchCriteriaBuilderMock = - $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); + $this->getMock(\Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false); $this->searchResultMock = $this->getMock( - '\Magento\Framework\Api\SearchResultsInterface', + \Magento\Framework\Api\SearchResultsInterface::class, [ 'getItems', 'getSearchCriteria', @@ -105,7 +108,7 @@ protected function setUp() '', false); $this->optionManagementMock = - $this->getMock('\Magento\Catalog\Api\ProductAttributeOptionManagementInterface', [], [], '', false); + $this->getMock(\Magento\Catalog\Api\ProductAttributeOptionManagementInterface::class, [], [], '', false); $this->model = new Repository( $this->attributeResourceMock, @@ -133,7 +136,7 @@ public function testGet() public function testGetList() { - $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $this->eavAttributeRepositoryMock->expects($this->once()) ->method('getList') ->with( @@ -146,7 +149,7 @@ public function testGetList() public function testDelete() { - $attributeMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); + $attributeMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); $this->attributeResourceMock->expects($this->once())->method('delete')->with($attributeMock); $this->assertEquals(true, $this->model->delete($attributeMock)); @@ -155,7 +158,7 @@ public function testDelete() public function testDeleteById() { $attributeCode = 'some attribute code'; - $attributeMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); + $attributeMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); $this->eavAttributeRepositoryMock->expects($this->once()) ->method('get') ->with( @@ -169,9 +172,9 @@ public function testDeleteById() public function testGetCustomAttributesMetadata() { - $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $this->searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); - $itemMock = $this->getMock('Magento\Catalog\Api\Data\ProductInterface'); + $itemMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); $this->eavAttributeRepositoryMock->expects($this->once()) ->method('getList') ->with( @@ -190,8 +193,14 @@ public function testGetCustomAttributesMetadata() */ public function testSaveNoSuchEntityException() { - $attributeMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); - $existingModelMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); + $attributeMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); + $existingModelMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, + [], + [], + '', + false + ); $attributeMock->expects($this->once())->method('getAttributeId')->willReturn('12'); $attributeCode = 'test attribute code'; $attributeMock->expects($this->once())->method('getAttributeCode')->willReturn($attributeCode); @@ -215,7 +224,7 @@ public function testSaveNoSuchEntityException() public function testSaveInputExceptionRequiredField() { $attributeMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['getFrontendLabels', 'getDefaultFrontendLabel', '__wakeup', 'getAttributeId', 'setAttributeId'], [], '', @@ -236,7 +245,7 @@ public function testSaveInputExceptionRequiredField() public function testSaveInputExceptionInvalidFieldValue() { $attributeMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['getFrontendLabels', 'getDefaultFrontendLabel', 'getAttributeId', '__wakeup', 'setAttributeId'], [], '', @@ -244,7 +253,7 @@ public function testSaveInputExceptionInvalidFieldValue() ); $attributeMock->expects($this->once())->method('getAttributeId')->willReturn(null); $attributeMock->expects($this->once())->method('setAttributeId')->with(null)->willReturnSelf(); - $labelMock = $this->getMock('Magento\Eav\Api\Data\AttributeFrontendLabelInterface', [], [], '', false); + $labelMock = $this->getMock(\Magento\Eav\Api\Data\AttributeFrontendLabelInterface::class, [], [], '', false); $attributeMock->expects($this->exactly(4))->method('getFrontendLabels')->willReturn([$labelMock]); $attributeMock->expects($this->exactly(2))->method('getDefaultFrontendLabel')->willReturn('test'); $labelMock->expects($this->once())->method('getStoreId')->willReturn(0); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php index 12d957cb1d219..25553562d2a0b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php @@ -30,9 +30,9 @@ class SetManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attrSetManagementMock = $this->getMock('\Magento\Eav\Api\AttributeSetManagementInterface'); - $this->attributeSetRepository = $this->getMock('\Magento\Eav\Api\AttributeSetRepositoryInterface'); - $this->eavConfig = $this->getMock('\Magento\Eav\Model\Config', [], [], '', false); + $this->attrSetManagementMock = $this->getMock(\Magento\Eav\Api\AttributeSetManagementInterface::class); + $this->attributeSetRepository = $this->getMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class); + $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); $this->model = new \Magento\Catalog\Model\Product\Attribute\SetManagement( $this->attrSetManagementMock, $this->attributeSetRepository, @@ -43,15 +43,15 @@ protected function setUp() public function testCreate() { $skeletonId = 1; - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); - $skeletonSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $skeletonSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->attributeSetRepository->expects($this->once()) ->method('get') ->with($skeletonId) ->willReturn($skeletonSetMock); - $typeMock = $this->getMock('\Magento\Eav\Model\Entity\Type', [], [], '', false); + $typeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); $typeMock->expects($this->once())->method('getId')->willReturn(4); $this->eavConfig->expects($this->once()) ->method('getEntityType') @@ -76,14 +76,14 @@ public function testCreate() public function testCreateNonProductAttributeSet() { $skeletonId = 1; - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); - $skeletonSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $skeletonSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->attributeSetRepository->expects($this->once()) ->method('get') ->with($skeletonId) ->willReturn($skeletonSetMock); - $typeMock = $this->getMock('\Magento\Eav\Model\Entity\Type', [], [], '', false); + $typeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); $typeMock->expects($this->once())->method('getId')->willReturn(4); $this->eavConfig->expects($this->once()) ->method('getEntityType') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php index 61487c081f334..c4cd38e4956eb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php @@ -6,6 +6,9 @@ */ namespace Magento\Catalog\Test\Unit\Model\Product\Attribute; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SetRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -35,22 +38,22 @@ class SetRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attrSetRepositoryMock = $this->getMock('\Magento\Eav\Api\AttributeSetRepositoryInterface'); + $this->attrSetRepositoryMock = $this->getMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class); $this->searchCriteriaBuilderMock = $this->getMock( - '\Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false ); $this->filterBuilderMock = $this->getMock( - '\Magento\Framework\Api\FilterBuilder', + \Magento\Framework\Api\FilterBuilder::class, [], [], '', false ); - $this->eavConfig = $this->getMock('\Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); $this->model = new \Magento\Catalog\Model\Product\Attribute\SetRepository( $this->attrSetRepositoryMock, @@ -62,7 +65,7 @@ protected function setUp() public function testSave() { - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 4); $this->attrSetRepositoryMock->expects($this->once()) @@ -78,7 +81,7 @@ public function testSave() */ public function testSaveNonProductAttributeSet() { - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 3); $this->attrSetRepositoryMock->expects($this->never())->method('save'); $this->model->save($attributeSetMock); @@ -87,7 +90,7 @@ public function testSaveNonProductAttributeSet() public function testGet() { $attributeSetId = 1; - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 4); $this->attrSetRepositoryMock->expects($this->once()) @@ -104,7 +107,7 @@ public function testGet() public function testGetNonProductAttributeSet() { $attributeSetId = 1; - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 3); $this->attrSetRepositoryMock->expects($this->once()) @@ -116,7 +119,7 @@ public function testGetNonProductAttributeSet() public function testDelete() { - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 4); $this->attrSetRepositoryMock->expects($this->once()) ->method('delete') @@ -131,7 +134,7 @@ public function testDelete() */ public function testDeleteNonProductAttributeSet() { - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 3); $this->attrSetRepositoryMock->expects($this->never()) ->method('delete'); @@ -141,7 +144,7 @@ public function testDeleteNonProductAttributeSet() public function testDeleteById() { $attributeSetId = 1; - $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface'); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setMockForValidation($attributeSetMock, 4); $this->attrSetRepositoryMock->expects($this->once()) @@ -158,13 +161,13 @@ public function testDeleteById() public function testGetList() { - $searchResultMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface'); + $searchResultMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface::class); - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface'); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->willReturn(1); $searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(2); - $filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); + $filterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); $this->filterBuilderMock->expects($this->once()) ->method('setField') @@ -194,7 +197,7 @@ public function testGetList() ->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->once()) ->method('create') - ->willReturn($this->getMock('\Magento\Framework\Api\SearchCriteriaInterface')); + ->willReturn($this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class)); $this->attrSetRepositoryMock->expects($this->once()) ->method('getList') @@ -213,7 +216,7 @@ protected function setMockForValidation( \PHPUnit_Framework_MockObject_MockObject $attributeSetMock, $setEntityTypeId ) { - $typeMock = $this->getMock('\Magento\Eav\Model\Entity\Type', [], [], '', false); + $typeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); $typeMock->expects($this->once())->method('getId')->willReturn(4); $this->eavConfig->expects($this->once()) ->method('getEntityType') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php index fa6b51c3afbd2..2888a0a84f230 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php @@ -29,9 +29,9 @@ class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->cacheConfig = $this->getMock('\Magento\Framework\App\Cache\Type\Config', [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->cacheConfig = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } @@ -53,7 +53,7 @@ public function testGetAllOptions($cachedDataSrl, $cachedDataUnsrl) ->will($this->returnValue($cachedDataSrl)); $countryOfManufacture = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture', + \Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture::class, [ 'storeManager' => $this->storeManagerMock, 'configCacheType' => $this->cacheConfig, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php index 744105b75c65c..8362fc8a76180 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php @@ -21,11 +21,11 @@ class InputtypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->inputtypeModel = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Source\Inputtype', + \Magento\Catalog\Model\Product\Attribute\Source\Inputtype::class, [ 'coreRegistry' => $this->registry ] diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php index 2bc256e985117..a6b1b2740701d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php @@ -23,12 +23,12 @@ class LayoutTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->pageLayoutBuilder = $this->getMockBuilder( - 'Magento\Framework\View\Model\PageLayout\Config\BuilderInterface' + \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface::class )->disableOriginalConstructor()->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->layoutModel = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Source\Layout', + \Magento\Catalog\Model\Product\Attribute\Source\Layout::class, [ 'pageLayoutBuilder' => $this->pageLayoutBuilder ] @@ -41,7 +41,7 @@ public function testGetAllOptions() '0' => ['value' => '', 'label' => 'No layout updates'], '1' => ['value' => 'option_value', 'label' => 'option_label'], ]; - $mockPageLayoutConfig = $this->getMockBuilder('Magento\Framework\View\PageLayout\Config') + $mockPageLayoutConfig = $this->getMockBuilder(\Magento\Framework\View\PageLayout\Config::class) ->disableOriginalConstructor() ->getMock(); $mockPageLayoutConfig->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php index 541f05b2a498e..0e08a18948420 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php @@ -31,7 +31,7 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->collection = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, [ '__wakeup', 'getSelect', @@ -46,7 +46,7 @@ protected function setUp() false ); $this->attributeModel = $this->getMock( - '\Magento\Catalog\Model\Entity\Attributee', + \Magento\Catalog\Model\Entity\Attributee::class, [ '__wakeup', 'getAttributeCode', @@ -59,9 +59,14 @@ protected function setUp() false ); $this->backendAttributeModel = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Backend\Sku', ['__wakeup', 'getTable'], [], '', false); + \Magento\Catalog\Model\Product\Attribute\Backend\Sku::class, + ['__wakeup', 'getTable'], + [], + '', + false + ); $this->status = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Attribute\Source\Status' + \Magento\Catalog\Model\Product\Attribute\Source\Status::class ); $this->attributeModel->expects($this->any())->method('getAttribute') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php index 9a0179870353d..fad630534ff42 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php @@ -35,15 +35,15 @@ class TypesListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->inputTypeFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory', + $this->inputTypeFactoryMock = $this->getMock( + \Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory::class, ['create', '__wakeup'], [], '', false); $this->attributeTypeFactoryMock = - $this->getMock( - 'Magento\Catalog\Api\Data\ProductAttributeTypeInterfaceFactory', + $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeTypeInterfaceFactory::class, [ 'create', ], @@ -51,7 +51,7 @@ protected function setUp() '', false); - $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); $this->model = new TypesList( @@ -63,13 +63,19 @@ protected function setUp() public function testGetItems() { - $inputTypeMock = $this->getMock('Magento\Catalog\Model\Product\Attribute\Source\Inputtype', [], [], '', false); + $inputTypeMock = $this->getMock( + \Magento\Catalog\Model\Product\Attribute\Source\Inputtype::class, + [], + [], + '', + false + ); $this->inputTypeFactoryMock->expects($this->once())->method('create')->willReturn($inputTypeMock); $inputTypeMock->expects($this->once())->method('toOptionArray')->willReturn(['option' => ['value']]); - $attributeTypeMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeTypeInterface'); + $attributeTypeMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeTypeInterface::class); $this->dataObjectHelperMock->expects($this->once()) ->method('populateWithArray') - ->with($attributeTypeMock, ['value'], '\Magento\Catalog\Api\Data\ProductAttributeTypeInterface') + ->with($attributeTypeMock, ['value'], \Magento\Catalog\Api\Data\ProductAttributeTypeInterface::class) ->willReturnSelf(); $this->attributeTypeFactoryMock->expects($this->once())->method('create')->willReturn($attributeTypeMock); $this->assertEquals([$attributeTypeMock], $this->model->getItems()); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php index f1411842f29ba..1208065acad0a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php @@ -16,7 +16,7 @@ class CartConfigurationTest extends \PHPUnit_Framework_TestCase public function testIsProductConfigured($productType, $config, $expected) { $cartConfiguration = new \Magento\Catalog\Model\Product\CartConfiguration(); - $productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($productType)); $this->assertEquals($expected, $cartConfiguration->isProductConfigured($productMock, $config)); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php index 6358d800bdefd..0725045c68fd1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php @@ -30,14 +30,14 @@ class CatalogPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->priceFactoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\CatalogPriceFactory', + \Magento\Catalog\Model\Product\CatalogPriceFactory::class, [], [], '', false ); - $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $this->catalogPriceInterfaceMock = $this->getMock('Magento\Catalog\Model\Product\CatalogPriceInterface'); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->catalogPriceInterfaceMock = $this->getMock(\Magento\Catalog\Model\Product\CatalogPriceInterface::class); $this->model = new \Magento\Catalog\Model\Product\CatalogPrice( $this->priceFactoryMock, ['custom_product_type' => 'CustomProduct/Model/CatalogPrice'] diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php index bdde9cf5c5dae..631100656ec99 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php @@ -15,7 +15,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Catalog\Model\Product\Compare\Item'); + $this->model = $objectManager->getObject(\Magento\Catalog\Model\Product\Compare\Item::class); } protected function tearDown() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php index bc7bdf54c9a2f..c292cd99c486f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php @@ -21,7 +21,7 @@ public function testApplyToCollection() { $collection = $this->getMockedAbstractCollection(); $this->assertInstanceOf( - '\Magento\Catalog\Model\Product\Condition', + \Magento\Catalog\Model\Product\Condition::class, $this->model->applyToCollection($collection) ); } @@ -29,7 +29,7 @@ public function testApplyToCollection() public function testGetIdsSelect() { $connection = $this->getMockedAdapterInterface(); - $this->assertInstanceOf('\Magento\Framework\DB\Select', $this->model->getIdsSelect($connection)); + $this->assertInstanceOf(\Magento\Framework\DB\Select::class, $this->model->getIdsSelect($connection)); $this->model->setTable(null); $this->assertEmpty($this->model->getIdsSelect($connection)); } @@ -37,7 +37,7 @@ public function testGetIdsSelect() protected function setUp() { $helper = new ObjectManager($this); - $this->model = $helper->getObject('Magento\Catalog\Model\Product\Condition'); + $this->model = $helper->getObject(\Magento\Catalog\Model\Product\Condition::class); $this->model->setTable('testTable') ->setPkFieldName('testFieldName'); } @@ -47,7 +47,7 @@ protected function setUp() */ private function getMockedAbstractCollection() { - $mockBuilder = $this->getMockBuilder('\Magento\Eav\Model\Entity\Collection\AbstractCollection') + $mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class) ->setMethods(['joinTable']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); @@ -65,7 +65,7 @@ private function getMockedAdapterInterface() { $mockedDbSelect = $this->getMockedDbSelect(); - $mockBuilder = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->setMethods(['select']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); @@ -82,7 +82,7 @@ private function getMockedAdapterInterface() */ private function getMockedDbSelect() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\DB\Select') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods(['from']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php index 3ce525c20c649..cca3c7dd7a1ba 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php @@ -36,23 +36,23 @@ class CopierTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->copyConstructorMock = $this->getMock('\Magento\Catalog\Model\Product\CopyConstructorInterface'); + $this->copyConstructorMock = $this->getMock(\Magento\Catalog\Model\Product\CopyConstructorInterface::class); $this->productFactoryMock = $this->getMock( - '\Magento\Catalog\Model\ProductFactory', + \Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false ); $this->optionRepositoryMock = $this->getMock( - 'Magento\Catalog\Model\Product\Option\Repository', + \Magento\Catalog\Model\Product\Option\Repository::class, [], [], '', false ); $this->optionRepositoryMock; - $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->productMock->expects($this->any())->method('getEntityId')->willReturn(1); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue('product data')); @@ -71,11 +71,11 @@ public function testCopy() $this->productMock->expects($this->atLeastOnce())->method('getWebsiteIds'); $this->productMock->expects($this->atLeastOnce())->method('getCategoryIds'); - $resourceMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Product', [], [], '', false); + $resourceMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); $this->productMock->expects($this->once())->method('getResource')->will($this->returnValue($resourceMock)); $duplicateMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ '__wakeup', 'setData', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php index c5df76016c6a9..7d39f9e8e63fd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php @@ -10,14 +10,14 @@ class CompositeTest extends \PHPUnit_Framework_TestCase public function testBuild() { $factoryMock = $this->getMock( - '\Magento\Catalog\Model\Product\CopyConstructorFactory', + \Magento\Catalog\Model\Product\CopyConstructorFactory::class, [], [], '', false ); - $constructorMock = $this->getMock('\Magento\Catalog\Model\Product\CopyConstructorInterface'); + $constructorMock = $this->getMock(\Magento\Catalog\Model\Product\CopyConstructorInterface::class); $factoryMock->expects( $this->exactly(2) @@ -29,8 +29,8 @@ public function testBuild() $this->returnValue($constructorMock) ); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $duplicateMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $duplicateMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $constructorMock->expects($this->exactly(2))->method('build')->with($productMock, $duplicateMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php index 15b01aa21f601..8dd12a93c04b1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php @@ -36,10 +36,10 @@ protected function setUp() { $this->_model = new \Magento\Catalog\Model\Product\CopyConstructor\CrossSell(); - $this->_productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->_productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->_duplicateMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['setCrossSellLinkData', '__wakeup'], [], '', @@ -47,7 +47,7 @@ protected function setUp() ); $this->_linkMock = $this->getMock( - '\Magento\Catalog\Model\Product\Link', + \Magento\Catalog\Model\Product\Link::class, ['__wakeup', 'getAttributes', 'getCrossSellLinkCollection', 'useCrossSellLinks'], [], '', @@ -75,7 +75,7 @@ public function testBuild() $this->_linkMock->expects($this->once())->method('getAttributes')->will($this->returnValue($attributes)); $productLinkMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Link', + \Magento\Catalog\Model\ResourceModel\Product\Link::class, ['__wakeup', 'getLinkedProductId', 'toArray'], [], '', @@ -94,7 +94,7 @@ public function testBuild() ); $collectionMock = $helper->getCollectionMock( - '\Magento\Catalog\Model\ResourceModel\Product\Link\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class, [$productLinkMock] ); $this->_productMock->expects( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php index 878c6e5c35a4f..b76cc977ca741 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php @@ -36,10 +36,10 @@ protected function setUp() { $this->_model = new \Magento\Catalog\Model\Product\CopyConstructor\Related(); - $this->_productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->_productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->_duplicateMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['setRelatedLinkData', '__wakeup'], [], '', @@ -47,7 +47,7 @@ protected function setUp() ); $this->_linkMock = $this->getMock( - '\Magento\Catalog\Model\Product\Link', + \Magento\Catalog\Model\Product\Link::class, ['__wakeup', 'getAttributes', 'getRelatedLinkCollection', 'useRelatedLinks'], [], '', @@ -75,7 +75,7 @@ public function testBuild() $this->_linkMock->expects($this->once())->method('getAttributes')->will($this->returnValue($attributes)); $productLinkMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Link', + \Magento\Catalog\Model\ResourceModel\Product\Link::class, ['__wakeup', 'getLinkedProductId', 'toArray'], [], '', @@ -94,7 +94,7 @@ public function testBuild() ); $collectionMock = $helper->getCollectionMock( - '\Magento\Catalog\Model\ResourceModel\Product\Link\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class, [$productLinkMock] ); $this->_productMock->expects( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php index 86cd326cc8e0a..640d36c28e4b1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php @@ -36,10 +36,10 @@ protected function setUp() { $this->_model = new \Magento\Catalog\Model\Product\CopyConstructor\UpSell(); - $this->_productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->_productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->_duplicateMock = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['setUpSellLinkData', '__wakeup'], [], '', @@ -47,7 +47,7 @@ protected function setUp() ); $this->_linkMock = $this->getMock( - '\Magento\Catalog\Model\Product\Link', + \Magento\Catalog\Model\Product\Link::class, ['__wakeup', 'getAttributes', 'getUpSellLinkCollection', 'useUpSellLinks'], [], '', @@ -75,7 +75,7 @@ public function testBuild() $this->_linkMock->expects($this->once())->method('getAttributes')->will($this->returnValue($attributes)); $productLinkMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Link', + \Magento\Catalog\Model\ResourceModel\Product\Link::class, ['__wakeup', 'getLinkedProductId', 'toArray'], [], '', @@ -94,7 +94,7 @@ public function testBuild() ); $collectionMock = $helper->getCollectionMock( - '\Magento\Catalog\Model\ResourceModel\Product\Link\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class, [$productLinkMock] ); $this->_productMock->expects( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php index 8f655d9c77912..e55286af1fb06 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php @@ -21,7 +21,7 @@ class CopyConstructorFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new CopyConstructorFactory($this->_objectManagerMock); } @@ -32,7 +32,7 @@ public function testCreateWithInvalidType() 'Magento\Framework\DataObject does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface' ); $this->_objectManagerMock->expects($this->never())->method('create'); - $this->_model->create('Magento\Framework\DataObject'); + $this->_model->create(\Magento\Framework\DataObject::class); } public function testCreateWithValidType() @@ -42,13 +42,13 @@ public function testCreateWithValidType() )->method( 'create' )->with( - 'Magento\Catalog\Model\Product\CopyConstructor\Composite' + \Magento\Catalog\Model\Product\CopyConstructor\Composite::class )->will( $this->returnValue('object') ); $this->assertEquals( 'object', - $this->_model->create('Magento\Catalog\Model\Product\CopyConstructor\Composite') + $this->_model->create(\Magento\Catalog\Model\Product\CopyConstructor\Composite::class) ); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php index 0e4d357164481..17dceef6c11c8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php @@ -43,10 +43,10 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productRepositoryMock = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface'); - $this->contentValidatorMock = $this->getMock('\Magento\Framework\Api\ImageContentValidatorInterface'); - $this->productMock = $this->getMock( - '\Magento\Catalog\Model\Product', + $this->productRepositoryMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->contentValidatorMock = $this->getMock(\Magento\Framework\Api\ImageContentValidatorInterface::class); + $this->productMock = $this->getMock( + \Magento\Catalog\Model\Product::class, [ 'setStoreId', 'getData', @@ -61,12 +61,12 @@ protected function setUp() false ); $this->mediaGalleryEntryMock = - $this->getMock('Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class); $this->model = new \Magento\Catalog\Model\Product\Gallery\GalleryManagement( $this->productRepositoryMock, $this->contentValidatorMock ); - $this->attributeValueMock = $this->getMockBuilder('\Magento\Framework\Api\AttributeValue') + $this->attributeValueMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class) ->disableOriginalConstructor() ->getMock(); } @@ -77,7 +77,7 @@ protected function setUp() */ public function testCreateWithInvalidImageException() { - $entryContentMock = $this->getMockBuilder('\Magento\Framework\Api\Data\ImageContentInterface') + $entryContentMock = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); @@ -95,7 +95,7 @@ public function testCreateWithInvalidImageException() public function testCreateWithCannotSaveException() { $productSku = 'mediaProduct'; - $entryContentMock = $this->getMockBuilder('\Magento\Framework\Api\Data\ImageContentInterface') + $entryContentMock = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class) ->disableOriginalConstructor() ->getMock(); $this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); @@ -115,8 +115,8 @@ public function testCreateWithCannotSaveException() public function testCreate() { $productSku = 'mediaProduct'; - $entryContentMock = $this->getMock( - 'Magento\Framework\Api\Data\ImageContentInterface' + $entryContentMock = $this->getMock( + \Magento\Framework\Api\Data\ImageContentInterface::class ); $this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); @@ -132,7 +132,7 @@ public function testCreate() $this->contentValidatorMock->expects($this->once())->method('isValid')->with($entryContentMock) ->willReturn(true); - $newEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $newEntryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class); $newEntryMock->expects($this->exactly(2))->method('getId')->willReturn(42); $this->productMock->expects($this->at(2))->method('getMediaGalleryEntries') ->willReturn([$newEntryMock]); @@ -149,11 +149,13 @@ public function testCreate() public function testUpdateWithNonExistingImage() { $productSku = 'testProduct'; - $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $entryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class); $entryId = 42; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn(43); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -168,11 +170,13 @@ public function testUpdateWithNonExistingImage() public function testUpdateWithCannotSaveException() { $productSku = 'testProduct'; - $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $entryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class); $entryId = 42; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -185,11 +189,13 @@ public function testUpdateWithCannotSaveException() public function testUpdate() { $productSku = 'testProduct'; - $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $entryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class); $entryId = 42; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -211,7 +217,9 @@ public function testRemoveWithNonExistingImage() $entryId = 42; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn(43); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -224,7 +232,9 @@ public function testRemove() $entryId = 42; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn(42); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -257,7 +267,9 @@ public function testGetWithNonExistingImage() $imageId = 43; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn(44); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -270,7 +282,9 @@ public function testGet() $imageId = 42; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $existingEntryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $existingEntryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class + ); $existingEntryMock->expects($this->once())->method('getId')->willReturn(42); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$existingEntryMock]); @@ -282,7 +296,7 @@ public function testGetList() $productSku = 'testProductSku'; $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); + $entryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class); $this->productMock->expects($this->once())->method('getMediaGalleryEntries') ->willReturn([$entryMock]); $this->assertEquals([$entryMock], $this->model->getList($productSku)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php index a86142740b024..61d4e3a5c76d5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php @@ -45,7 +45,7 @@ protected function setUp() $this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->attributeRepository = $this->getMock( - 'Magento\Catalog\Model\Product\Attribute\Repository', + \Magento\Catalog\Model\Product\Attribute\Repository::class, ['get'], [], '', @@ -53,7 +53,7 @@ protected function setUp() ); $fileStorageDb = $this->getMock( - 'Magento\MediaStorage\Helper\File\Storage\Database', + \Magento\MediaStorage\Helper\File\Storage\Database::class, [], [], '', @@ -61,7 +61,7 @@ protected function setUp() ); $this->mediaConfig = $this->getMock( - 'Magento\Catalog\Model\Product\Media\Config', + \Magento\Catalog\Model\Product\Media\Config::class, [], [], '', @@ -69,7 +69,7 @@ protected function setUp() ); $this->mediaDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, [], [], '', @@ -77,7 +77,7 @@ protected function setUp() ); $filesystem = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, [], [], '', @@ -88,7 +88,7 @@ protected function setUp() ->willReturn($this->mediaDirectory); $resourceModel = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Gallery', + \Magento\Catalog\Model\ResourceModel\Product\Gallery::class, ['getMainTable'], [], '', @@ -101,7 +101,7 @@ protected function setUp() ); $this->dataObject = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getIsDuplicate', 'isLockedAttribute', 'getMediaAttributes'], [], '', @@ -109,7 +109,7 @@ protected function setUp() ); $this->model = $this->objectHelper->getObject( - 'Magento\Catalog\Model\Product\Gallery\Processor', + \Magento\Catalog\Model\Product\Gallery\Processor::class, [ 'attributeRepository' => $this->attributeRepository, 'fileStorageDb' => $fileStorageDb, @@ -126,7 +126,7 @@ public function testGetAffectedFields() $attributeId = 345345; $attribute = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute', + \Magento\Eav\Model\Entity\Attribute::class, ['getBackendTable', 'isStatic', 'getAttributeId', 'getName', '__wakeup'], [], '', @@ -164,14 +164,14 @@ public function testValidate($value) { $attributeCode = 'attr_code'; $attribute = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute', + \Magento\Eav\Model\Entity\Attribute::class, ['getAttributeCode', 'getIsRequired', 'isValueEmpty', 'getIsUnique', 'getEntityType', '__wakeup'], [], '', false ); $attributeEntity = $this->getMock( - '\Magento\Framework\Model\ResourceModel\AbstractResourceAbstractEntity', + \Magento\Framework\Model\ResourceModel\AbstractResourceAbstractEntity::class, ['checkAttributeUniqueValue'] ); $attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php index 3d6608d595121..de60264c33163 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php @@ -8,6 +8,9 @@ use Magento\Framework\App\Area; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CacheTest extends \PHPUnit_Framework_TestCase { /** @@ -52,32 +55,32 @@ class CacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $this->viewConfig = $this->getMockBuilder('Magento\Framework\View\ConfigInterface') + $this->viewConfig = $this->getMockBuilder(\Magento\Framework\View\ConfigInterface::class) ->getMockForAbstractClass(); - $this->config = $this->getMockBuilder('Magento\Framework\Config\View') + $this->config = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->disableOriginalConstructor() ->getMock(); - $this->themeCollection = $this->getMockBuilder('Magento\Theme\Model\ResourceModel\Theme\Collection') + $this->themeCollection = $this->getMockBuilder(\Magento\Theme\Model\ResourceModel\Theme\Collection::class) ->disableOriginalConstructor() ->getMock(); - $this->imageHelper = $this->getMockBuilder('Magento\Catalog\Helper\Image') + $this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class) ->disableOriginalConstructor() ->getMock(); - $this->mediaGalleryCollection = $this->getMockBuilder('Magento\Framework\Data\Collection') + $this->mediaGalleryCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->objectManager = new ObjectManager($this); $this->model = $this->objectManager->getObject( - 'Magento\Catalog\Model\Product\Image\Cache', + \Magento\Catalog\Model\Product\Image\Cache::class, [ 'viewConfig' => $this->viewConfig, 'themeCollection' => $this->themeCollection, @@ -93,7 +96,7 @@ public function testGenerate() { $imageFile = 'image.jpg'; $imageItem = $this->objectManager->getObject( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, [ 'data' => ['file' => $imageFile] ] @@ -112,7 +115,7 @@ public function testGenerate() ->with('Magento_Catalog') ->willReturn($data); - $themeMock = $this->getMockBuilder('Magento\Theme\Model\Theme') + $themeMock = $this->getMockBuilder(\Magento\Theme\Model\Theme::class) ->disableOriginalConstructor() ->getMock(); $themeMock->expects($this->exactly(3)) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php index f4a791622f5d8..a032ffa33b375 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php @@ -77,42 +77,42 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->context = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManager') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class) ->disableOriginalConstructor() ->setMethods(['getStore', 'getWebsite'])->getMock(); - $store = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor() + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor() ->setMethods(['getId', '__sleep', '__wakeup', 'getBaseUrl'])->getMock(); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); $store->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://magento.com/media/')); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); - $this->config = $this->getMockBuilder('Magento\Catalog\Model\Product\Media\Config') + $this->config = $this->getMockBuilder(\Magento\Catalog\Model\Product\Media\Config::class) ->setMethods(['getBaseMediaPath'])->disableOriginalConstructor()->getMock(); $this->config->expects($this->any())->method('getBaseMediaPath')->will($this->returnValue('catalog/product')); - $this->coreFileHelper = $this->getMockBuilder('Magento\MediaStorage\Helper\File\Storage\Database') + $this->coreFileHelper = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class) ->setMethods(['saveFile', 'deleteFolder'])->disableOriginalConstructor()->getMock(); - $this->mediaDirectory = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\Write') + $this->mediaDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Write::class) ->disableOriginalConstructor() ->setMethods(['create', 'isFile', 'isExist', 'getAbsolutePath']) ->getMock(); $this->mediaDirectory->expects($this->once())->method('create')->will($this->returnValue(true)); - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->filesystem->expects($this->once())->method('getDirectoryWrite') ->with(DirectoryList::MEDIA) ->will($this->returnValue($this->mediaDirectory)); - $this->factory = $this->getMock('Magento\Framework\Image\Factory', [], [], '', false); - $this->repository = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->fileSystem = $this->getMock('Magento\Framework\View\FileSystem', [], [], '', false); - $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->factory = $this->getMock(\Magento\Framework\Image\Factory::class, [], [], '', false); + $this->repository = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->fileSystem = $this->getMock(\Magento\Framework\View\FileSystem::class, [], [], '', false); + $this->scopeConfigInterface = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $objectManagerHelper = new ObjectManagerHelper($this); $this->image = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Image', + \Magento\Catalog\Model\Product\Image::class, [ 'registry' => $this->registry, 'storeManager' => $this->storeManager, @@ -193,7 +193,7 @@ public function testSetBaseNoSelectionFile() public function testSetGetImageProcessor() { - $imageProcessor = $this->getMockBuilder('Magento\Framework\Image')->disableOriginalConstructor() + $imageProcessor = $this->getMockBuilder(\Magento\Framework\Image::class)->disableOriginalConstructor() ->getMock(); $result = $this->image->setImageProcessor($imageProcessor); $this->assertSame($this->image, $result); @@ -204,7 +204,7 @@ public function testResize() { $this->image->setWidth(100); $this->image->setHeight(100); - $imageProcessor = $this->getMockBuilder('Magento\Framework\Image')->disableOriginalConstructor() + $imageProcessor = $this->getMockBuilder(\Magento\Framework\Image::class)->disableOriginalConstructor() ->getMock(); $imageProcessor->expects($this->once())->method('resize') ->with($this->image->getWidth(), $this->image->getHeight())->will($this->returnValue(true)); @@ -215,7 +215,7 @@ public function testResize() public function testRotate() { - $imageProcessor = $this->getMockBuilder('Magento\Framework\Image')->disableOriginalConstructor() + $imageProcessor = $this->getMockBuilder(\Magento\Framework\Image::class)->disableOriginalConstructor() ->getMock(); $imageProcessor->expects($this->once())->method('rotate')->with(90)->will($this->returnValue(true)); $this->image->setImageProcessor($imageProcessor); @@ -231,7 +231,7 @@ public function testSetAngle() public function testSetWatermark() { - $website = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor() + $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor() ->setMethods(['getId', '__sleep', '__wakeup'])->getMock(); $website->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website)); @@ -242,7 +242,7 @@ public function testSetWatermark() ->with('catalog/product/watermark//somefile.png') ->will($this->returnValue($absolutePath)); - $imageProcessor = $this->getMockBuilder('Magento\Framework\Image')->disableOriginalConstructor() + $imageProcessor = $this->getMockBuilder(\Magento\Framework\Image::class)->disableOriginalConstructor() ->setMethods([ 'keepAspectRatio', 'keepFrame', @@ -279,7 +279,9 @@ public function testSetWatermark() public function testSaveFile() { - $imageProcessor = $this->getMockBuilder('Magento\Framework\Image')->disableOriginalConstructor()->getMock(); + $imageProcessor = $this->getMockBuilder( + \Magento\Framework\Image::class + )->disableOriginalConstructor()->getMock(); $this->image->setImageProcessor($imageProcessor); $this->coreFileHelper->expects($this->once())->method('saveFile')->will($this->returnValue(true)); $absolutePath = dirname(dirname(__DIR__)) . '/_files/catalog/product/somefile.png'; @@ -339,7 +341,9 @@ public function testResizeWithoutSize() public function testGetImageProcessor() { - $imageProcessor = $this->getMockBuilder('\Magento\Framework\Image')->disableOriginalConstructor()->getMock(); + $imageProcessor = $this->getMockBuilder( + \Magento\Framework\Image::class + )->disableOriginalConstructor()->getMock(); $this->factory->expects($this->once())->method('create')->will($this->returnValue($imageProcessor)); $this->assertSame($imageProcessor, $this->image->getImageProcessor()); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php index c5f35d7dc8960..34cb5c81a1291 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php @@ -19,7 +19,7 @@ public function testInitializeLinks() { $links = ['related' => ['data'], 'upsell' => ['data'], 'crosssell' => ['data']]; $this->assertInstanceOf( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, $this->model->initializeLinks($this->getMockedProduct(), $links) ); } @@ -27,7 +27,7 @@ public function testInitializeLinks() protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $helper->getObject('Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks'); + $this->model = $helper->getObject(\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks::class); } /** @@ -35,7 +35,7 @@ protected function setUp() */ private function getMockedProduct() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods( [ 'getRelatedReadonly', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php index 7990f4c110955..0e02fa327a22b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php @@ -32,13 +32,13 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $linkCollection = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\Link\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class )->disableOriginalConstructor()->setMethods( ['setLinkModel'] )->getMock(); $linkCollection->expects($this->any())->method('setLinkModel')->will($this->returnSelf()); $linkCollectionFactory = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\Link\CollectionFactory' + \Magento\Catalog\Model\ResourceModel\Product\Link\CollectionFactory::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); @@ -46,13 +46,13 @@ protected function setUp() ->method('create') ->will($this->returnValue($linkCollection)); $this->productCollection = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class )->disableOriginalConstructor()->setMethods( ['setLinkModel'] )->getMock(); $this->productCollection->expects($this->any())->method('setLinkModel')->will($this->returnSelf()); $productCollectionFactory = $this->getMockBuilder( - 'Magento\Catalog\Model\ResourceModel\Product\Link\Product\CollectionFactory' + \Magento\Catalog\Model\ResourceModel\Product\Link\Product\CollectionFactory::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); @@ -61,7 +61,7 @@ protected function setUp() ->will($this->returnValue($this->productCollection)); $this->resource = $this->getMock( - 'Magento\Framework\Model\ResourceModel\AbstractResource', + \Magento\Framework\Model\ResourceModel\AbstractResource::class, [ 'saveProductLinks', 'getAttributeTypeTable', @@ -73,13 +73,13 @@ protected function setUp() ] ); - $this->saveProductLinksMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Link\SaveHandler') + $this->saveProductLinksMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Link\SaveHandler::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Product\Link', + \Magento\Catalog\Model\Product\Link::class, [ 'linkCollectionFactory' => $linkCollectionFactory, 'productCollectionFactory' => $productCollectionFactory, @@ -128,7 +128,7 @@ public function testGetAttributeTypeTable() public function testGetProductCollection() { $this->assertInstanceOf( - 'Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class, $this->model->getProductCollection() ); } @@ -136,7 +136,7 @@ public function testGetProductCollection() public function testGetLinkCollection() { $this->assertInstanceOf( - 'Magento\Catalog\Model\ResourceModel\Product\Link\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class, $this->model->getLinkCollection() ); } @@ -155,7 +155,7 @@ public function testGetAttributes() public function testSaveProductRelations() { - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); $this->saveProductLinksMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php index 26433b7ae9949..13a2f578c1213 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php @@ -37,19 +37,19 @@ class LinkTypeProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->linkTypeFactoryMock = $this->getMock( - 'Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory', + $this->linkTypeFactoryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory::class, ['create'], [], '', false ); - $this->linkAttributeFactoryMock = $this->getMock( - 'Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory', + $this->linkAttributeFactoryMock = $this->getMock( + \Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory::class, ['create'], [], '', false, false ); - $this->linkFactoryMock = $this->getMock( - '\Magento\Catalog\Model\Product\LinkFactory', + $this->linkFactoryMock = $this->getMock( + \Magento\Catalog\Model\Product\LinkFactory::class, ['create'], [], '', false, false ); $this->linkTypes = [ @@ -58,8 +58,8 @@ protected function setUp() 'test_product_link_3' => 'test_code_3', ]; $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Product\LinkTypeProvider', + $this->model = $objectManager->getObject( + \Magento\Catalog\Model\Product\LinkTypeProvider::class, [ 'linkTypeFactory' => $this->linkTypeFactoryMock, 'linkAttributeFactory' => $this->linkAttributeFactoryMock, @@ -78,7 +78,7 @@ public function testGetItems() $linkTypeMocks = []; foreach ($this->linkTypes as $type => $typeCode) { $value = ['name' => $type, 'code' => $typeCode]; - $linkTypeMock = $this->getMock('\Magento\Catalog\Api\Data\ProductLinkTypeInterface'); + $linkTypeMock = $this->getMock(\Magento\Catalog\Api\Data\ProductLinkTypeInterface::class); $linkTypeMock->expects($this->once()) ->method('setName') ->with($type) @@ -104,7 +104,7 @@ public function testGetItemAttributes($type, $typeId) $attributes = [ ['code' => 'test_code_1', 'type' => 'test_type_1'], ]; - $linkAttributeMock = $this->getMock('\Magento\Catalog\Api\Data\ProductLinkAttributeInterface'); + $linkAttributeMock = $this->getMock(\Magento\Catalog\Api\Data\ProductLinkAttributeInterface::class); $linkAttributeMock->expects($this->once()) ->method('setCode') ->with($attributes[0]['code']) @@ -116,7 +116,7 @@ public function testGetItemAttributes($type, $typeId) $expectedResult = [ $linkAttributeMock, ]; - $linkMock = $this->getMock('\Magento\Catalog\Model\Product\Link', ['getAttributes'], [], '', false); + $linkMock = $this->getMock(\Magento\Catalog\Model\Product\Link::class, ['getAttributes'], [], '', false); $linkMock->expects($this->once())->method('getAttributes')->willReturn($attributes); $this->linkFactoryMock->expects($this->once())->method('create')->with($typeId)->willReturn($linkMock); $this->linkAttributeFactoryMock->expects($this->once())->method('create')->willReturn($linkAttributeMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php index 007d49173599b..8ea2a8262c714 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php @@ -34,15 +34,15 @@ class AttributeManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->factoryMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, ['create'], [], '', false ); $this->storeId = 1; - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->any()) ->method('getId') ->will($this->returnValue($this->storeId)); @@ -60,10 +60,10 @@ public function testGetList() { $attributeSetName = 'Default Attribute Set'; $expectedResult = [ - $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeInterface'), + $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeInterface::class), ]; $collectionMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, [], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php index edb5e6b1309bf..c461e7a616d81 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php @@ -9,6 +9,9 @@ use \Magento\Catalog\Model\Product\Option\Repository; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -38,35 +41,47 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productRepositoryMock = $this->getMock('Magento\Catalog\Model\ProductRepository', [], [], '', false); + $this->productRepositoryMock = $this->getMock( + \Magento\Catalog\Model\ProductRepository::class, + [], + [], + '', + false + ); $this->optionResourceMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Option', + \Magento\Catalog\Model\ResourceModel\Product\Option::class, + [], + [], + '', + false + ); + $this->converterMock = $this->getMock( + \Magento\Catalog\Model\Product\Option\Converter::class, [], [], '', false ); - $this->converterMock = $this->getMock('\Magento\Catalog\Model\Product\Option\Converter', [], [], '', false); - $this->optionMock = $this->getMock('\Magento\Catalog\Model\Product\Option', [], [], '', false); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $this->optionMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $optionFactory = $this->getMock( - 'Magento\Catalog\Model\Product\OptionFactory', + \Magento\Catalog\Model\Product\OptionFactory::class, ['create'], [], '', false ); $optionCollectionFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class, ['create'], [], '', false ); - $metadataPool = $this->getMockBuilder('Magento\Framework\EntityManager\MetadataPool') + $metadataPool = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); - $metadata = $this->getMockBuilder('Magento\Framework\EntityManager\EntityMetadata') + $metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class) ->disableOriginalConstructor() ->getMock(); $metadataPool->expects($this->any())->method('getMetadata')->willReturn($metadata); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php index 6cbec67d6143b..1b66800ca8c01 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php @@ -19,18 +19,18 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_factory = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Option\Type\Factory', + \Magento\Catalog\Model\Product\Option\Type\Factory::class, ['objectManager' => $this->_objectManagerMock] ); } public function testCreate() { - $className = 'Magento\Catalog\Model\Product\Option\Type\DefaultType'; + $className = \Magento\Catalog\Model\Product\Option\Type\DefaultType::class; $filterMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects( @@ -49,7 +49,7 @@ public function testCreate() public function testCreateWithArguments() { - $className = 'Magento\Catalog\Model\Product\Option\Type\DefaultType'; + $className = \Magento\Catalog\Model\Product\Option\Type\DefaultType::class; $arguments = ['foo', 'bar']; $filterMock = $this->getMock($className, [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php index 7a385fd1fc172..9b41651863fdb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php @@ -26,13 +26,13 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->rootDirectory = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $this->rootDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->setMethods(['isFile', 'isReadable', 'getAbsolutePath']) ->getMockForAbstractClass(); $this->coreFileStorageDatabase = $this->getMock( - 'Magento\MediaStorage\Helper\File\Storage\Database', + \Magento\MediaStorage\Helper\File\Storage\Database::class, ['copyFile'], [], '', @@ -46,7 +46,7 @@ protected function setUp() protected function getFileObject() { return $this->objectManager->getObject( - 'Magento\Catalog\Model\Product\Option\Type\File', + \Magento\Catalog\Model\Product\Option\Type\File::class, [ 'saleableItem' => $this->rootDirectory, 'priceCurrency' => $this->coreFileStorageDatabase @@ -57,7 +57,7 @@ protected function getFileObject() public function testCopyQuoteToOrder() { $optionMock = $this->getMockBuilder( - 'Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface' + \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class )->disableOriginalConstructor()->setMethods(['getValue'])->getMockForAbstractClass(); $quotePath = '/quote/path/path/uploaded.file'; @@ -89,7 +89,7 @@ public function testCopyQuoteToOrder() $fileObject->setData('configuration_item_option', $optionMock); $this->assertInstanceOf( - 'Magento\Catalog\Model\Product\Option\Type\File', + \Magento\Catalog\Model\Product\Option\Type\File::class, $fileObject->copyQuoteToOrder() ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php index fa295d795417c..9b0e1e1627454 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php @@ -24,7 +24,7 @@ protected function setUp() $mockedFrontendUrlBuilder = $this->getMockedFrontendUrlBuilder(); $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Product\Option\UrlBuilder', + \Magento\Catalog\Model\Product\Option\UrlBuilder::class, ['frontendUrlBuilder' => $mockedFrontendUrlBuilder] ); } @@ -34,7 +34,7 @@ protected function setUp() */ private function getMockedFrontendUrlBuilder() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\UrlInterface') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php index 042f4a94bb836..686bee92bc9d5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php @@ -20,7 +20,7 @@ class DefaultValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $configMock = $this->getMock('Magento\Catalog\Model\ProductOptions\ConfigInterface'); + $configMock = $this->getMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class); $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price(); $config = [ [ @@ -79,7 +79,7 @@ public function isValidTitleDataProvider() public function testIsValidTitle($title, $type, $priceType, $price, $product, $messages, $result) { $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; - $valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $valueMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, $methods, [], '', false); $valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title)); $valueMock->expects($this->any())->method('getType')->will($this->returnValue($type)); $valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType)); @@ -109,7 +109,7 @@ public function isValidFailDataProvider() public function testIsValidFail($product) { $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; - $valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $valueMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, $methods, [], '', false); $valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product)); $valueMock->expects($this->once())->method('getTitle'); $valueMock->expects($this->any())->method('getType'); @@ -147,7 +147,7 @@ public function validationNegativePriceDataProvider() public function testValidationNegativePrice($title, $type, $priceType, $price, $product) { $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; - $valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $valueMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, $methods, [], '', false); $valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title)); $valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue($type)); $valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType)); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php index 185b7cc89e265..27ee4d09e7173 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php @@ -20,7 +20,7 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $configMock = $this->getMock('Magento\Catalog\Model\ProductOptions\ConfigInterface'); + $configMock = $this->getMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class); $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price(); $config = [ [ @@ -46,7 +46,7 @@ protected function setUp() ]; $configMock->expects($this->once())->method('getAll')->will($this->returnValue($config)); $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', 'getImageSizeX', 'getImageSizeY','__wakeup']; - $this->valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $this->valueMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, $methods, [], '', false); $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\File( $configMock, $priceConfigMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php index 3eb0cfd981f02..b2243e213c85d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php @@ -28,10 +28,10 @@ class PoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->defaultValidatorMock = $this->getMock( - 'Magento\Catalog\Model\Product\Option\Validator\DefaultValidator', [], [], '', false + \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator::class, [], [], '', false ); $this->selectValidatorMock = $this->getMock( - 'Magento\Catalog\Model\Product\Option\Validator\Select', [], [], '', false + \Magento\Catalog\Model\Product\Option\Validator\Select::class, [], [], '', false ); $this->pool = new \Magento\Catalog\Model\Product\Option\Validator\Pool( ['default' => $this->defaultValidatorMock, 'select' => $this->selectValidatorMock] diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php index 4e2988d212e0a..4d26d2ce914c8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php @@ -20,7 +20,7 @@ class SelectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $configMock = $this->getMock('Magento\Catalog\Model\ProductOptions\ConfigInterface'); + $configMock = $this->getMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class); $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price(); $config = [ [ @@ -46,7 +46,7 @@ protected function setUp() ]; $configMock->expects($this->once())->method('getAll')->will($this->returnValue($config)); $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getData']; - $this->valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $this->valueMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, $methods, [], '', false); $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\Select( $configMock, $priceConfigMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php index 86abe87053a33..769ad05837b37 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php @@ -20,7 +20,7 @@ class TextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $configMock = $this->getMock('Magento\Catalog\Model\ProductOptions\ConfigInterface'); + $configMock = $this->getMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class); $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price(); $config = [ [ @@ -46,7 +46,7 @@ protected function setUp() ]; $configMock->expects($this->once())->method('getAll')->will($this->returnValue($config)); $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getMaxCharacters']; - $this->valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $this->valueMock = $this->getMock(\Magento\Catalog\Model\Product\Option::class, $methods, [], '', false); $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\Text( $configMock, $priceConfigMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php index d17d430b2f0fb..960dda45e2ca0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php @@ -25,12 +25,12 @@ public function testSaveProduct() ->setData('option_type_id', -1) ->setDataChanges(false) ->isDeleted(false); - $this->assertInstanceOf('\Magento\Catalog\Model\Product\Option\Value', $this->model->saveValues()); + $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->saveValues()); $this->model->setData('is_delete', 1) ->setData('option_type_id', 1) ->setValues([100]); - $this->assertInstanceOf('\Magento\Catalog\Model\Product\Option\Value', $this->model->saveValues()); + $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->saveValues()); } public function testGetPrice() @@ -45,7 +45,7 @@ public function testGetPrice() public function testGetValuesCollection() { $this->assertInstanceOf( - '\Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class, $this->model->getValuesCollection($this->getMockedOption()) ); } @@ -53,29 +53,29 @@ public function testGetValuesCollection() public function testGetValuesByOption() { $this->assertInstanceOf( - '\Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class, $this->model->getValuesByOption([1], 1, 1) ); } public function testGetProduct() { - $this->assertInstanceOf('\Magento\Catalog\Model\Product', $this->model->getProduct()); + $this->assertInstanceOf(\Magento\Catalog\Model\Product::class, $this->model->getProduct()); } public function testDuplicate() { - $this->assertInstanceOf('\Magento\Catalog\Model\Product\Option\Value', $this->model->duplicate(1, 1)); + $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->duplicate(1, 1)); } public function testDeleteValues() { - $this->assertInstanceOf('\Magento\Catalog\Model\Product\Option\Value', $this->model->deleteValues(1)); + $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->deleteValues(1)); } public function testDeleteValue() { - $this->assertInstanceOf('\Magento\Catalog\Model\Product\Option\Value', $this->model->deleteValue(1)); + $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->deleteValue(1)); } protected function setUp() @@ -85,7 +85,7 @@ protected function setUp() $mockedContext = $this->getMockedContext(); $helper = new ObjectManager($this); $this->model = $helper->getObject( - '\Magento\Catalog\Model\Product\Option\Value', + \Magento\Catalog\Model\Product\Option\Value::class, [ 'resource' => $mockedResource, 'valueCollectionFactory' => $mockedCollectionFactory, @@ -103,7 +103,7 @@ private function getMockedValueCollectionFactory() $mockedCollection = $this->getMockedValueCollection(); $mockBuilder = - $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory') + $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class) ->setMethods(['create']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -120,9 +120,9 @@ private function getMockedValueCollectionFactory() */ private function getMockedValueCollection() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection') - ->setMethods(['addFieldToFilter', 'getValuesByOption', 'getValues']) - ->disableOriginalConstructor(); + $mockBuilder = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class + )->setMethods(['addFieldToFilter', 'getValuesByOption', 'getValues'])->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); $mock->expects($this->any()) @@ -147,7 +147,7 @@ private function getMockedOption() { $mockedProduct = $this->getMockedProduct(); - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -163,7 +163,7 @@ private function getMockedOption() */ private function getMockedProduct() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getFinalPrice', '__wakeup']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -180,7 +180,7 @@ private function getMockedProduct() */ private function getMockedResource() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Option\Value') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Option\Value::class) ->setMethods( [ 'duplicate', @@ -238,7 +238,7 @@ private function getMockedContext() $mockedRemoveAction = $this->getMockedRemoveAction(); $mockEventManager = $this->getMockedEventManager(); - $mockBuilder = $this->getMockBuilder('\Magento\Framework\Model\Context') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->setMethods(['getActionValidator', 'getEventDispatcher']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -259,7 +259,7 @@ private function getMockedContext() */ private function getMockedRemoveAction() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\Model\Context') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->setMethods(['isAllowed']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -276,7 +276,7 @@ private function getMockedRemoveAction() */ private function getMockedEventManager() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->setMethods(['dispatch']) ->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php index ea01f87a1ad6c..50ab88f7df462 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php @@ -22,9 +22,9 @@ class OptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $objectManager = new ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Catalog\Model\Product\Option'); + $this->model = $objectManager->getObject(\Magento\Catalog\Model\Product\Option::class); $this->model->setProduct($this->productMock); } @@ -38,7 +38,7 @@ public function testGetProductSku() public function testGetRegularPrice() { $priceInfoMock = $this->getMockForAbstractClass( - 'Magento\Framework\Pricing\PriceInfoInterface', + \Magento\Framework\Pricing\PriceInfoInterface::class, [], '', false, @@ -47,7 +47,7 @@ public function testGetRegularPrice() ['getAmount', 'getPrice'] ); $priceInfoMock->expects($this->once())->method('getPrice')->willReturnSelf(); - $amountMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); + $amountMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); $priceInfoMock->expects($this->once())->method('getAmount')->willReturn($amountMock); $this->productMock->expects($this->once())->method('getPriceInfo')->willReturn($priceInfoMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php index a6437a047aac0..35aad84447526 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php @@ -29,9 +29,9 @@ class CompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->priceModifierMock = $this->getMock('Magento\Catalog\Model\Product\PriceModifierInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->priceModifierMock = $this->getMock(\Magento\Catalog\Model\Product\PriceModifierInterface::class); } public function testModifyPriceIfModifierExists() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php index f6fa55930993a..371ecc61033ca 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php @@ -33,10 +33,11 @@ class PriceModifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->productMock = - $this->getMock('Magento\Catalog\Model\Product', + $this->getMock( + \Magento\Catalog\Model\Product::class, ['getData', 'setData', '__wakeup'], [], '', false); - $this->productRepositoryMock = $this->getMock( - '\Magento\Catalog\Model\ProductRepository', + $this->productRepositoryMock = $this->getMock( + \Magento\Catalog\Model\ProductRepository::class, [], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php index 063f85ae4f360..7bafd7a5b5686 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php @@ -27,11 +27,11 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() ->getMock(); $this->toolbarModel = (new ObjectManager($this))->getObject( - 'Magento\Catalog\Model\Product\ProductList\Toolbar', + \Magento\Catalog\Model\Product\ProductList\Toolbar::class, [ 'request' => $this->requestMock, ] diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php index 0821c9c257646..5661b828865b3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php @@ -16,7 +16,11 @@ class ReservedAttributeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->model = new ReservedAttributeList('Magento\Catalog\Model\Product', ['some_value'], ['some_attribute']); + $this->model = new ReservedAttributeList( + \Magento\Catalog\Model\Product::class, + ['some_value'], + ['some_attribute'] + ); } /** @@ -26,7 +30,7 @@ protected function setUp() public function testIsReservedAttribute($isUserDefined, $attributeCode, $expected) { $attribute = $this->getMock( - '\Magento\Catalog\Model\Entity\Attribute', + \Magento\Catalog\Model\Entity\Attribute::class, ['getIsUserDefined', 'getAttributeCode', '__sleep', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php index 2cfbca60d736a..85efdbd0ce06d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php @@ -13,6 +13,9 @@ use Magento\Customer\Model\GroupManagement; use Magento\Framework\Exception\NoSuchEntityException; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class TierPriceManagementTest extends \PHPUnit_Framework_TestCase { /** @@ -68,38 +71,38 @@ class TierPriceManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->repositoryMock = $this->getMock( - '\Magento\Catalog\Model\ProductRepository', + \Magento\Catalog\Model\ProductRepository::class, [], [], '', false ); $this->priceFactoryMock = $this->getMock( - 'Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory', + \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class, ['create'], [], '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->websiteMock = - $this->getMock('Magento\Store\Model\Website', ['getId', '__wakeup'], [], '', false); + $this->getMock(\Magento\Store\Model\Website::class, ['getId', '__wakeup'], [], '', false); $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getData', 'getIdBySku', 'load', '__wakeup', 'save', 'validate', 'setData'], [], '', false ); - $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->priceModifierMock = - $this->getMock('Magento\Catalog\Model\Product\PriceModifier', [], [], '', false); + $this->getMock(\Magento\Catalog\Model\Product\PriceModifier::class, [], [], '', false); $this->repositoryMock->expects($this->any())->method('get')->with('product_sku') ->will($this->returnValue($this->productMock)); $this->groupManagementMock = - $this->getMock('Magento\Customer\Api\GroupManagementInterface', [], [], '', false); + $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class, [], [], '', false); $this->groupRepositoryMock = - $this->getMock('Magento\Customer\Api\GroupRepositoryInterface', [], [], '', false); + $this->getMock(\Magento\Customer\Api\GroupRepositoryInterface::class, [], [], '', false); $this->service = new TierPriceManagement( $this->repositoryMock, @@ -121,7 +124,8 @@ protected function setUp() */ public function testGetList($configValue, $customerGroupId, $groupData, $expected) { - $group = $this->getMock('\Magento\Customer\Model\Data\Group', + $group = $this->getMock( + \Magento\Customer\Model\Data\Group::class, [], [], '', @@ -143,7 +147,7 @@ public function testGetList($configValue, $customerGroupId, $groupData, $expecte ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE) ->will($this->returnValue($configValue)); if ($expected) { - $priceMock = $this->getMock('\Magento\Catalog\Api\Data\ProductTierPriceInterface'); + $priceMock = $this->getMock(\Magento\Catalog\Api\Data\ProductTierPriceInterface::class); $priceMock->expects($this->once()) ->method('setValue') ->with($expected['value']) @@ -239,7 +243,7 @@ public function testSuccessDeleteTierPriceFromWebsiteLevel() public function testSetNewPriceWithGlobalPriceScopeAll() { - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->setMethods(['getId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -276,7 +280,8 @@ public function testSetNewPriceWithGlobalPriceScopeAll() ] ); $this->repositoryMock->expects($this->once())->method('save')->with($this->productMock); - $group = $this->getMock('\Magento\Customer\Model\Data\Group', + $group = $this->getMock( + \Magento\Customer\Model\Data\Group::class, [], [], '', @@ -290,7 +295,7 @@ public function testSetNewPriceWithGlobalPriceScopeAll() public function testSetNewPriceWithGlobalPriceScope() { - $group = $this->getMock('\Magento\Customer\Model\Data\Group', [], [], '', false); + $group = $this->getMock(\Magento\Customer\Model\Data\Group::class, [], [], '', false); $group->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->groupRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($group)); $this->productMock @@ -352,7 +357,7 @@ public function testSetUpdatedPriceWithGlobalPriceScope() */ public function testSetThrowsExceptionIfDoesntValidate() { - $group = $this->getMock('\Magento\Customer\Model\Data\Group', [], [], '', false); + $group = $this->getMock(\Magento\Customer\Model\Data\Group::class, [], [], '', false); $group->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->productMock ->expects($this->once()) @@ -375,7 +380,7 @@ public function testSetThrowsExceptionIfDoesntValidate() */ public function testSetThrowsExceptionIfCantSave() { - $group = $this->getMock('\Magento\Customer\Model\Data\Group', [], [], '', false); + $group = $this->getMock(\Magento\Customer\Model\Data\Group::class, [], [], '', false); $group->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->productMock ->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php index 7ba304b058a40..6b66704fcdcae 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php @@ -38,20 +38,20 @@ class AbstractTypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManager($this); - $this->model = $this->objectManagerHelper->getObject('Magento\Catalog\Model\Product\Type\Simple'); + $this->model = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\Type\Simple::class); - $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getHasOptions', '__wakeup', '__sleep', 'getResource']) ->disableOriginalConstructor() ->getMock(); - $this->productResource = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product') + $this->productResource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product::class) ->setMethods(['getSortedAttributes', 'loadAllAttributes']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->product->expects($this->any())->method('getResource')->will($this->returnValue($this->productResource)); - $this->attribute = $this->getMockBuilder('Magento\Catalog\Model\Entity\Attribute') + $this->attribute = $this->getMockBuilder(\Magento\Catalog\Model\Entity\Attribute::class) ->setMethods(['getGroupSortPath', 'getSortPath', '__wakeup']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php index 3f55218f0a6cd..c51f9486c2ecb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php @@ -58,10 +58,10 @@ class PriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->product = $this->objectManagerHelper->getObject('Magento\Catalog\Model\Product'); + $this->product = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product::class); - $this->tpFactory = $this->getMockForAbstractClass( - 'Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory', + $this->tpFactory = $this->getMockForAbstractClass( + \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class, [], '', false, @@ -70,9 +70,9 @@ protected function setUp() ['create'] ); - $this->websiteMock = $this->getMock('Magento\Store\Model\Website', ['getId'], [], '', false); - $storeMangerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + $this->websiteMock = $this->getMock(\Magento\Store\Model\Website::class, ['getId'], [], '', false); + $storeMangerMock = $this->getMockForAbstractClass( + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -84,8 +84,8 @@ protected function setUp() ->method('getWebsite') ->will($this->returnValue($this->websiteMock)); - $this->scopeConfigMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\Config\ScopeConfigInterface', + $this->scopeConfigMock = $this->getMockForAbstractClass( + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false, @@ -94,7 +94,8 @@ protected function setUp() ['getValue'] ); - $group = $this->getMock('\Magento\Customer\Model\Data\Group', + $group = $this->getMock( + \Magento\Customer\Model\Data\Group::class, [], [], '', @@ -102,12 +103,12 @@ protected function setUp() ); $group->expects($this->any())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL); $this->groupManagementMock = - $this->getMock('Magento\Customer\Api\GroupManagementInterface', [], [], '', false); + $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class, [], [], '', false); $this->groupManagementMock->expects($this->any())->method('getAllCustomersGroup') ->will($this->returnValue($group)); - $this->model = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product\Type\Price', + $this->model = $this->objectManagerHelper->getObject( + \Magento\Catalog\Model\Product\Type\Price::class, [ 'tierPriceFactory' => $this->tpFactory, 'config' => $this->scopeConfigMock, @@ -172,15 +173,15 @@ public function testTierPrices($priceScope, $expectedWebsiteId) $this->tpFactory->expects($this->any()) ->method('create') ->will($this->returnCallback(function () { - return $this->objectManagerHelper->getObject('Magento\Catalog\Model\Product\TierPrice'); + return $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class); })); // create sample TierPrice objects that would be coming from a REST call - $tp1 = $this->objectManagerHelper->getObject('Magento\Catalog\Model\Product\TierPrice'); + $tp1 = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class); $tp1->setValue(10); $tp1->setCustomerGroupId(1); $tp1->setQty(11); - $tp2 = $this->objectManagerHelper->getObject('Magento\Catalog\Model\Product\TierPrice'); + $tp2 = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class); $tp2->setValue(20); $tp2->setCustomerGroupId(2); $tp2->setQty(22); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php index 0e7e8f5a48198..01f33a5d5e9b1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php @@ -15,16 +15,22 @@ class SimpleTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $fileStorageDbMock = $this->getMock('Magento\MediaStorage\Helper\File\Storage\Database', [], [], '', false); - $filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $fileStorageDbMock = $this->getMock( + \Magento\MediaStorage\Helper\File\Storage\Database::class, + [], + [], + '', + false + ); + $filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $coreRegistry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $productFactoryMock = $this->getMock('Magento\Catalog\Model\ProductFactory', [], [], '', false); + $coreRegistry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $productFactoryMock = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false); $this->_model = $objectHelper->getObject( - 'Magento\Catalog\Model\Product\Type\Simple', + \Magento\Catalog\Model\Product\Type\Simple::class, [ 'productFactory' => $productFactoryMock, 'eventManager' => $eventManager, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php index 1254acba5b4c3..da4547ad77e13 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php @@ -15,16 +15,22 @@ class VirtualTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $coreRegistryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $fileStorageDbMock = $this->getMock('Magento\MediaStorage\Helper\File\Storage\Database', [], [], '', false); - $filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $fileStorageDbMock = $this->getMock( + \Magento\MediaStorage\Helper\File\Storage\Database::class, + [], + [], + '', + false + ); + $filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $productFactoryMock = $this->getMock('Magento\Catalog\Model\ProductFactory', [], [], '', false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $productFactoryMock = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false); $this->_model = $objectHelper->getObject( - 'Magento\Catalog\Model\Product\Type\Virtual', + \Magento\Catalog\Model\Product\Type\Virtual::class, [ 'eventManager' => $eventManager, 'fileStorageDb' => $fileStorageDbMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php index 4c18551173263..b04c718f57e84 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php @@ -115,7 +115,7 @@ public function testGetTypesByPriority() public function testGetPriceInfo() { $mockedProduct = $this->getMockedProduct(); - $expectedResult = '\Magento\Framework\Pricing\PriceInfoInterface'; + $expectedResult = \Magento\Framework\Pricing\PriceInfoInterface::class; $this->assertInstanceOf($expectedResult, $this->_model->getPriceInfo($mockedProduct)); } @@ -131,11 +131,11 @@ public function testFactory() ->will($this->returnValue('type_id_3')); $this->assertInstanceOf( - '\Magento\Catalog\Model\Product\Type\Simple', + \Magento\Catalog\Model\Product\Type\Simple::class, $this->_model->factory($mockedProduct) ); $this->assertInstanceOf( - '\Magento\Catalog\Model\Product\Type\Virtual', + \Magento\Catalog\Model\Product\Type\Virtual::class, $this->_model->factory($mockedProduct) ); } @@ -143,7 +143,7 @@ public function testFactory() public function testPriceFactory() { $this->assertInstanceOf( - '\Magento\Catalog\Model\Product\Type\Price', + \Magento\Catalog\Model\Product\Type\Price::class, $this->_model->priceFactory('type_id_1') ); } @@ -157,7 +157,7 @@ protected function setUp() $mockedTypePriceFactory = $this->getMockedTypePriceFactory(); $this->_model = $this->_objectHelper->getObject( - 'Magento\Catalog\Model\Product\Type', + \Magento\Catalog\Model\Product\Type::class, [ 'config' => $mockedConfig, 'priceInfoFactory' => $mockedPriceInfoFactory, @@ -184,7 +184,7 @@ protected function getOptionArray() */ private function getMockedProduct() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor(); $mock = $mockBuilder->getMock(); @@ -198,7 +198,7 @@ private function getMockedPriceInfoFactory() { $mockedPriceInfoInterface = $this->getMockedPriceInfoInterface(); - $mockBuilder = $this->getMockBuilder('\Magento\Framework\Pricing\PriceInfo\Factory') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']); $mock = $mockBuilder->getMock(); @@ -215,7 +215,7 @@ private function getMockedPriceInfoFactory() */ private function getMockedPriceInfoInterface() { - $mockBuilder = $this->getMockBuilder('\Magento\Framework\Pricing\PriceInfoInterface') + $mockBuilder = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfoInterface::class) ->disableOriginalConstructor(); $mock = $mockBuilder->getMockForAbstractClass(); @@ -227,7 +227,7 @@ private function getMockedPriceInfoInterface() */ private function getMockedProductTypePool() { - $mockBuild = $this->getMockBuilder('\Magento\Catalog\Model\Product\Type\Pool') + $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Pool::class) ->disableOriginalConstructor() ->setMethods(['get']); $mock = $mockBuild->getMock(); @@ -238,7 +238,7 @@ private function getMockedProductTypePool() $this->returnValueMap( [ ['some_model', [], $this->getMockedProductTypeVirtual()], - ['Magento\Catalog\Model\Product\Type\Simple', [], $this->getMockedProductTypeSimple()], + [\Magento\Catalog\Model\Product\Type\Simple::class, [], $this->getMockedProductTypeSimple()], ] ) ); @@ -251,7 +251,7 @@ private function getMockedProductTypePool() */ private function getMockedProductTypeVirtual() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product\Type\Virtual') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Virtual::class) ->disableOriginalConstructor() ->setMethods(['setConfig']); $mock = $mockBuilder->getMock(); @@ -267,7 +267,7 @@ private function getMockedProductTypeVirtual() */ private function getMockedProductTypeSimple() { - $mockBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product\Type\Simple') + $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Simple::class) ->disableOriginalConstructor() ->setMethods(['setConfig']); $mock = $mockBuilder->getMock(); @@ -283,7 +283,7 @@ private function getMockedProductTypeSimple() */ private function getMockedConfig() { - $mockBuild = $this->getMockBuilder('\Magento\Catalog\Model\ProductTypes\ConfigInterface') + $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class) ->disableOriginalConstructor() ->setMethods(['getAll']); $mock = $mockBuild->getMockForAbstractClass(); @@ -300,7 +300,7 @@ private function getMockedConfig() */ private function getMockedTypePriceFactory() { - $mockBuild = $this->getMockBuilder('\Magento\Catalog\Model\Product\Type\Price\Factory') + $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Price\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']); $mock = $mockBuild->getMockForAbstractClass(); @@ -311,7 +311,7 @@ private function getMockedTypePriceFactory() $this->returnValueMap( [ ['some_model', [], $this->getMockedProductTypePrice()], - ['Magento\Catalog\Model\Product\Type\Price', [], $this->getMockedProductTypePrice()], + [\Magento\Catalog\Model\Product\Type\Price::class, [], $this->getMockedProductTypePrice()], ] ) ); @@ -324,7 +324,7 @@ private function getMockedTypePriceFactory() */ private function getMockedProductTypePrice() { - $mockBuild = $this->getMockBuilder('\Magento\Catalog\Model\Product\Type\Price') + $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Price::class) ->disableOriginalConstructor(); $mock = $mockBuild->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php index d793a479aa8b6..77fad64675e44 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php @@ -28,16 +28,16 @@ protected function setUp() $this->markTestSkipped('MAGETWO-43290: This test fails with Segmentation fault on PHP 5.5.28'); } $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getTypeId', 'setTypeId', 'setTypeInstance'], [], '', false ); - $this->weightResolver = $this->getMock('Magento\Catalog\Model\Product\Edit\WeightResolver'); + $this->weightResolver = $this->getMock(\Magento\Catalog\Model\Product\Edit\WeightResolver::class); $this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject( - 'Magento\Catalog\Model\Product\TypeTransitionManager', + \Magento\Catalog\Model\Product\TypeTransitionManager::class, [ 'weightResolver' => $this->weightResolver, 'compatibleTypes' => [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php index abe42c1e43c41..6d106b478fb70 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php @@ -42,29 +42,29 @@ class UrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->filter = $this->getMockBuilder( - 'Magento\Framework\Filter\FilterManager' + \Magento\Framework\Filter\FilterManager::class )->disableOriginalConstructor()->setMethods( ['translitUrl'] )->getMock(); $this->urlFinder = $this->getMockBuilder( - 'Magento\UrlRewrite\Model\UrlFinderInterface' + \Magento\UrlRewrite\Model\UrlFinderInterface::class )->disableOriginalConstructor()->getMock(); $this->url = $this->getMockBuilder( - 'Magento\Framework\Url' + \Magento\Framework\Url::class )->disableOriginalConstructor()->setMethods( ['setScope', 'getUrl'] )->getMock(); - $this->sidResolver = $this->getMock('Magento\Framework\Session\SidResolverInterface'); + $this->sidResolver = $this->getMock(\Magento\Framework\Session\SidResolverInterface::class); - $store = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup'], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); - $urlFactory = $this->getMockBuilder('\Magento\Framework\UrlFactory') + $urlFactory = $this->getMockBuilder(\Magento\Framework\UrlFactory::class) ->disableOriginalConstructor() ->getMock(); $urlFactory->method('create') @@ -72,7 +72,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\Product\Url', + \Magento\Catalog\Model\Product\Url::class, [ 'filter' => $this->filter, 'catalogCategory' => $this->catalogCategory, @@ -130,7 +130,7 @@ public function testGetUrl( $productUrlKey ) { $product = $this->getMockBuilder( - 'Magento\Catalog\Model\Product' + \Magento\Catalog\Model\Product::class )->disableOriginalConstructor()->setMethods( ['getStoreId', 'getEntityId', 'getId', 'getUrlKey', 'setRequestPath', 'hasUrlDataObject', 'getRequestPath', 'getCategoryId', 'getDoNotUseCategoryId', '__wakeup', ] diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php index a5bd4cef7fe35..97245c0696581 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php @@ -10,9 +10,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testValidator() { $validator = new \Magento\Catalog\Model\Product\Validator(); - $productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $responseMock = $this->getMock('Magento\Framework\DataObject'); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $responseMock = $this->getMock(\Magento\Framework\DataObject::class); $productMock->expects($this->once())->method('validate')->will($this->returnValue(true)); $this->assertEquals(true, $validator->validate($productMock, $requestMock, $responseMock)); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php index d4f731a0cf286..eb4d746a454cd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php @@ -17,13 +17,13 @@ class VisibilityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_model = $objectManager->getObject('Magento\Catalog\Model\Product\Visibility'); + $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Product\Visibility::class); } public function testGetFlatColumns() { $abstractAttributeMock = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getAttributeCode', '__wakeup'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php index d640b8e98de97..4209871ffb8b1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php @@ -29,16 +29,16 @@ class ProductAttributeGroupRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupRepositoryMock = $this->getMock('\Magento\Eav\Api\AttributeGroupRepositoryInterface'); + $this->groupRepositoryMock = $this->getMock(\Magento\Eav\Api\AttributeGroupRepositoryInterface::class); $this->groupFactoryMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\GroupFactory', + \Magento\Catalog\Model\Product\Attribute\GroupFactory::class, ['create'], [], '', false ); $this->groupResourceMock = $this->getMock( - '\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group', + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class, ['load', '__wakeup'], [], '', @@ -47,7 +47,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\ProductAttributeGroupRepository', + \Magento\Catalog\Model\ProductAttributeGroupRepository::class, [ 'groupRepository' => $this->groupRepositoryMock, 'groupResource' => $this->groupResourceMock, @@ -58,8 +58,8 @@ protected function setUp() public function testSave() { - $groupMock = $this->getMock('\Magento\Eav\Api\Data\AttributeGroupInterface'); - $expectedResult = $this->getMock('\Magento\Eav\Api\Data\AttributeGroupInterface'); + $groupMock = $this->getMock(\Magento\Eav\Api\Data\AttributeGroupInterface::class); + $expectedResult = $this->getMock(\Magento\Eav\Api\Data\AttributeGroupInterface::class); $this->groupRepositoryMock->expects($this->once())->method('save')->with($groupMock) ->willReturn($expectedResult); $this->assertEquals($expectedResult, $this->model->save($groupMock)); @@ -67,8 +67,8 @@ public function testSave() public function testGetList() { - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface'); - $expectedResult = $this->getMock('\Magento\Eav\Api\Data\AttributeGroupInterface'); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); + $expectedResult = $this->getMock(\Magento\Eav\Api\Data\AttributeGroupInterface::class); $this->groupRepositoryMock->expects($this->once())->method('getList')->with($searchCriteriaMock) ->willReturn($expectedResult); $this->assertEquals($expectedResult, $this->model->getList($searchCriteriaMock)); @@ -77,7 +77,7 @@ public function testGetList() public function testGet() { $groupId = 42; - $groupMock = $this->getMock('\Magento\Catalog\Model\Product\Attribute\Group', [], [], '', false); + $groupMock = $this->getMock(\Magento\Catalog\Model\Product\Attribute\Group::class, [], [], '', false); $this->groupFactoryMock->expects($this->once())->method('create')->willReturn($groupMock); $this->groupResourceMock->expects($this->once())->method('load')->with($groupMock, $groupId)->willReturnSelf(); $groupMock->expects($this->once())->method('getId')->willReturn($groupId); @@ -90,7 +90,7 @@ public function testGet() public function testGetThrowsExceptionIfGroupDoesNotExist() { $groupId = 42; - $groupMock = $this->getMock('\Magento\Catalog\Model\Product\Attribute\Group', [], [], '', false); + $groupMock = $this->getMock(\Magento\Catalog\Model\Product\Attribute\Group::class, [], [], '', false); $this->groupFactoryMock->expects($this->once())->method('create')->willReturn($groupMock); $this->groupResourceMock->expects($this->once())->method('load')->with($groupMock, $groupId)->willReturnSelf(); $groupMock->expects($this->once())->method('getId')->willReturn(null); @@ -101,7 +101,7 @@ public function testDeleteById() { $groupId = 42; $groupMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Group', + \Magento\Catalog\Model\Product\Attribute\Group::class, ['hasSystemAttributes', 'getId'], [], '', @@ -120,7 +120,7 @@ public function testDeleteById() public function testDelete() { $groupMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Group', + \Magento\Catalog\Model\Product\Attribute\Group::class, ['hasSystemAttributes'], [], '', @@ -138,7 +138,7 @@ public function testDelete() public function testDeleteThrowsExceptionIfGroupHasSystemAttributes() { $groupMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Group', + \Magento\Catalog\Model\Product\Attribute\Group::class, ['hasSystemAttributes'], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php index 765ba24f5cd24..d5ff3f580b457 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php @@ -34,17 +34,23 @@ class ManagementTest extends \PHPUnit_Framework_TestCase protected $linkTypeProviderMock; /** - * @var \Magento\Framework\ObjectManager + * @var \Magento\Framework\ObjectManagerInterface */ protected $objectManager; protected function setUp() { - $this->productRepositoryMock = $this->getMock('\Magento\Catalog\Model\ProductRepository', [], [], '', false); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $this->productRepositoryMock = $this->getMock( + \Magento\Catalog\Model\ProductRepository::class, + [], + [], + '', + false + ); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->linkTypeProviderMock = $this->getMock( - '\Magento\Catalog\Model\Product\LinkTypeProvider', + \Magento\Catalog\Model\Product\LinkTypeProvider::class, [], [], '', @@ -53,7 +59,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $this->objectManager->getObject( - 'Magento\Catalog\Model\ProductLink\Management', + \Magento\Catalog\Model\ProductLink\Management::class, [ 'productRepository' => $this->productRepositoryMock, 'linkTypeProvider' => $this->linkTypeProviderMock @@ -68,7 +74,7 @@ public function testGetLinkedItemsByType() $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setLinkType($linkType); $inputRelatedLink->setData("sku", "Simple Product 2"); @@ -96,7 +102,7 @@ public function testGetLinkedItemsByTypeWithWrongType() $this->productRepositoryMock->expects($this->never())->method('get')->with($productSku) ->willReturn($this->productMock); - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setLinkType($linkType); $inputRelatedLink->setData("sku", "Simple Product 2"); @@ -120,7 +126,7 @@ public function testSetProductLinks() $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setLinkType($linkType); $inputRelatedLink->setData("sku", "Simple Product 1"); @@ -146,7 +152,7 @@ public function testSetProductLinksWithoutLinkTypeInLink() { $productSku = 'Simple Product 1'; - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setData("sku", "Simple Product 1"); $inputRelatedLink->setPosition(0); @@ -171,7 +177,7 @@ public function testSetProductLinksThrowExceptionIfProductLinkTypeDoesNotExist() $this->productRepositoryMock->expects($this->never())->method('get')->with($productSku) ->willReturn($this->productMock); - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setLinkType($linkType); $inputRelatedLink->setData("sku", "Simple Product 2"); @@ -196,7 +202,7 @@ public function testSetProductLinksNoProductException() $productSku = 'Simple Product 1'; $linkType = 'related'; - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setLinkType($linkType); $inputRelatedLink->setData("sku", "Simple Product 2"); @@ -227,7 +233,7 @@ public function testSetProductLinksInvalidDataException() $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku) ->willReturn($this->productMock); - $inputRelatedLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputRelatedLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputRelatedLink->setProductSku($productSku); $inputRelatedLink->setLinkType($linkType); $inputRelatedLink->setData("sku", "bad sku"); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php index 079a6ad8f9f92..913b47ce0b73f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php @@ -8,6 +8,9 @@ namespace Magento\Catalog\Test\Unit\Model\ProductLink; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -66,59 +69,65 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $linkManagementMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Management', [], [], '', false); - $this->productRepositoryMock = $this->getMock('\Magento\Catalog\Model\ProductRepository', [], [], '', false); + $linkManagementMock = $this->getMock(\Magento\Catalog\Model\ProductLink\Management::class, [], [], '', false); + $this->productRepositoryMock = $this->getMock( + \Magento\Catalog\Model\ProductRepository::class, + [], + [], + '', + false + ); $this->entityCollectionProviderMock = $this->getMock( - 'Magento\Catalog\Model\ProductLink\CollectionProvider', + \Magento\Catalog\Model\ProductLink\CollectionProvider::class, [], [], '', false ); $this->linkInitializerMock = $this->getMock( - 'Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks', + \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks::class, [], [], '', false ); $this->metadataPoolMock = $this->getMock( - 'Magento\Framework\EntityManager\MetadataPool', + \Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false ); $this->hydratorPoolMock = $this->getMock( - 'Magento\Framework\EntityManager\HydratorPool', + \Magento\Framework\EntityManager\HydratorPool::class, [], [], '', false ); $this->hydratorMock = $this->getMock( - 'Magento\Framework\Model\Entity\Hydrator', + \Magento\Framework\Model\Entity\Hydrator::class, ['extract'], [], '', false ); $this->metadataMock = $this->getMock( - 'Magento\Framework\EntityManager\EntityMetadata', + \Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false ); $this->linkTypeProvider = $this->getMock( - 'Magento\Catalog\Model\Product\LinkTypeProvider', + \Magento\Catalog\Model\Product\LinkTypeProvider::class, [], [], '', false ); $this->linkResourceMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Link', + \Magento\Catalog\Model\ResourceModel\Product\Link::class, [], [], '', @@ -128,7 +137,7 @@ protected function setUp() $this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($this->metadataMock); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\ProductLink\Repository', + \Magento\Catalog\Model\ProductLink\Repository::class, [ 'productRepository' => $this->productRepositoryMock, 'entityCollectionProvider' => $this->entityCollectionProviderMock, @@ -147,10 +156,10 @@ protected function setUp() */ public function testSave() { - $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $entityMock = $this->getMock(\Magento\Catalog\Model\ProductLink\Link::class, [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $linkedProductMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $parentId = 42; $linkedProductId = 37; $typeId = 4; @@ -184,9 +193,9 @@ public function testSave() */ public function testSaveWithException() { - $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $linkedProductMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $entityMock = $this->getMock(\Magento\Catalog\Model\ProductLink\Link::class, [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $parentId = 42; $linkedProductId = 37; $typeId = 4; @@ -218,9 +227,9 @@ public function testSaveWithException() */ public function testDelete() { - $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $linkedProductMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $entityMock = $this->getMock(\Magento\Catalog\Model\ProductLink\Link::class, [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $parentId = 42; $linkedProductId = 37; $typeId = 4; @@ -255,9 +264,9 @@ public function testDelete() */ public function testDeleteWithInvalidDataException() { - $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $linkedProductMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $entityMock = $this->getMock(\Magento\Catalog\Model\ProductLink\Link::class, [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $parentId = 42; $linkedProductId = 37; $typeId = 4; @@ -293,9 +302,9 @@ public function testDeleteWithInvalidDataException() */ public function testDeleteWithNoSuchEntityException() { - $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $linkedProductMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $entityMock = $this->getMock(\Magento\Catalog\Model\ProductLink\Link::class, [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->productRepositoryMock->expects($this->exactly(2))->method('get')->will($this->returnValueMap( [ ['product', false, null, false, $productMock], diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php index 834df27e27d97..6da34786a4550 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php @@ -20,7 +20,7 @@ class ProductManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->productsFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, ['create'], [], '', @@ -34,7 +34,13 @@ protected function setUp() public function testGetEnabledCount() { $statusEnabled = 1; - $productsMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $productsMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, + [], + [], + '', + false + ); $this->productsFactoryMock ->expects($this->once()) @@ -59,7 +65,13 @@ public function testGetEnabledCount() public function testGetDisabledCount() { $statusDisabled = 2; - $productsMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $productsMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, + [], + [], + '', + false + ); $this->productsFactoryMock ->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php index 64f5de19e4cc8..eacda7a435d6e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php @@ -12,6 +12,9 @@ use Magento\Framework\DataObject\Factory as DataObjectFactory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ProductOptionProcessorTest extends \PHPUnit_Framework_TestCase { /** @@ -41,14 +44,14 @@ class ProductOptionProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataObject = $this->getMockBuilder('Magento\Framework\DataObject') + $this->dataObject = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods([ 'getOptions', ]) ->disableOriginalConstructor() ->getMock(); - $this->dataObjectFactory = $this->getMockBuilder('Magento\Framework\DataObject\Factory') + $this->dataObjectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -57,7 +60,7 @@ protected function setUp() ->willReturn($this->dataObject); $this->customOption = $this->getMockBuilder( - 'Magento\Catalog\Api\Data\CustomOptionInterface' + \Magento\Catalog\Api\Data\CustomOptionInterface::class ) ->setMethods([ 'getDownloadableLinks', @@ -65,7 +68,7 @@ protected function setUp() ->getMockForAbstractClass(); $this->customOptionFactory = $this->getMockBuilder( - 'Magento\Catalog\Model\CustomOptions\CustomOptionFactory' + \Magento\Catalog\Model\CustomOptions\CustomOptionFactory::class ) ->setMethods(['create']) ->disableOriginalConstructor() @@ -89,10 +92,12 @@ public function testConvertToBuyRequest( $options, $requestData ) { - $productOptionMock = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductOptionInterface') + $productOptionMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductOptionInterface::class) ->getMockForAbstractClass(); - $productOptionExtensionMock = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductOptionExtensionInterface') + $productOptionExtensionMock = $this->getMockBuilder( + \Magento\Catalog\Api\Data\ProductOptionExtensionInterface::class + ) ->setMethods([ 'getCustomOptions', ]) @@ -122,7 +127,7 @@ public function dataProviderConvertToBuyRequest() $objectManager = new ObjectManager($this); /** @var \Magento\Catalog\Model\CustomOptions\CustomOption $option */ - $option = $objectManager->getObject('Magento\Catalog\Model\CustomOptions\CustomOption'); + $option = $objectManager->getObject(\Magento\Catalog\Model\CustomOptions\CustomOption::class); $option->setOptionId(1); $option->setOptionValue(1); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index f2be2fc92b835..5ed94c4a0a500 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -147,10 +147,16 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->markTestSkipped('11111111111111111111111'); - $this->productFactoryMock = $this->getMock('Magento\Catalog\Model\ProductFactory', ['create'], [], '', false); + $this->productFactoryMock = $this->getMock( + \Magento\Catalog\Model\ProductFactory::class, + ['create'], + [], + '', + false + ); $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'getId', 'getSku', @@ -165,7 +171,7 @@ protected function setUp() ); $this->initializedProductMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'getWebsiteIds', 'setProductOptions', @@ -188,72 +194,86 @@ protected function setUp() $this->initializedProductMock->expects($this->any()) ->method('hasGalleryAttribute') ->willReturn(true); - $this->filterBuilderMock = $this->getMock('\Magento\Framework\Api\FilterBuilder', [], [], '', false); + $this->filterBuilderMock = $this->getMock(\Magento\Framework\Api\FilterBuilder::class, [], [], '', false); $this->initializationHelperMock = $this->getMock( - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class, [], [], '', false ); $this->collectionFactoryMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, ['create'], [], '', false ); $this->searchCriteriaBuilderMock = $this->getMock( - '\Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false ); $this->metadataServiceMock = $this->getMock( - '\Magento\Catalog\Api\ProductAttributeRepositoryInterface', + \Magento\Catalog\Api\ProductAttributeRepositoryInterface::class, [], [], '', false ); $this->searchResultsFactoryMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory', + \Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory::class, ['create'], [], '', false ); - $this->resourceModelMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Product', [], [], '', false); + $this->resourceModelMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product::class, + [], + [], + '', + false + ); $this->objectManager = new ObjectManager($this); $this->extensibleDataObjectConverterMock = $this - ->getMockBuilder('\Magento\Framework\Api\ExtensibleDataObjectConverter') + ->getMockBuilder(\Magento\Framework\Api\ExtensibleDataObjectConverter::class) ->setMethods(['toNestedArray']) ->disableOriginalConstructor() ->getMock(); - $this->fileSystemMock = $this->getMockBuilder('\Magento\Framework\Filesystem') + $this->fileSystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor()->getMock(); $this->mimeTypeExtensionMapMock = - $this->getMockBuilder('Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap')->getMock(); + $this->getMockBuilder(\Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap::class)->getMock(); $this->contentFactoryMock = $this->getMock( - 'Magento\Framework\Api\Data\ImageContentInterfaceFactory', + \Magento\Framework\Api\Data\ImageContentInterfaceFactory::class, ['create'], [], '', false ); - $this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface') + $this->contentValidatorMock = $this->getMockBuilder( + \Magento\Framework\Api\ImageContentValidatorInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->linkTypeProviderMock = $this->getMock('Magento\Catalog\Model\Product\LinkTypeProvider', + $this->linkTypeProviderMock = $this->getMock( + \Magento\Catalog\Model\Product\LinkTypeProvider::class, ['getLinkTypes'], [], '', false); - $this->imageProcessorMock = $this->getMock('Magento\Framework\Api\ImageProcessorInterface', [], [], '', false); + $this->imageProcessorMock = $this->getMock( + \Magento\Framework\Api\ImageProcessorInterface::class, + [], + [], + '', + false + ); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $storeMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface') + $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); @@ -263,7 +283,7 @@ protected function setUp() $this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']); $this->mediaGalleryProcessor = $this->getMock( - 'Magento\Catalog\Model\Product\Gallery\Processor', + \Magento\Catalog\Model\Product\Gallery\Processor::class, [], [], '', @@ -271,7 +291,7 @@ protected function setUp() ); $this->model = $this->objectManager->getObject( - 'Magento\Catalog\Model\ProductRepository', + \Magento\Catalog\Model\ProductRepository::class, [ 'productFactory' => $this->productFactoryMock, 'initializationHelper' => $this->initializationHelperMock, @@ -614,12 +634,18 @@ public function testDeleteById() */ public function testGetList($fieldName) { - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class, [], [], '', false); $attributeCode = 'attribute_code'; - $collectionMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); - $extendedSearchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); + $collectionMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, + [], + [], + '', + false + ); + $extendedSearchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $productAttributeSearchResultsMock = $this->getMockForAbstractClass( - '\Magento\Catalog\Api\Data\ProductAttributeInterface', + \Magento\Catalog\Api\Data\ProductAttributeInterface::class, [], '', false, @@ -628,16 +654,16 @@ public function testGetList($fieldName) ['getItems'] ); $productAttributeMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductAttributeInterface', + \Magento\Catalog\Api\Data\ProductAttributeInterface::class, [], [], '', false ); - $filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false); - $filterGroupFilterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); - $sortOrderMock = $this->getMock('\Magento\Framework\Api\SortOrder', [], [], '', false); - $itemsMock = $this->getMock('\Magento\Framework\DataObject', [], [], '', false); + $filterGroupMock = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); + $filterGroupFilterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $sortOrderMock = $this->getMock(\Magento\Framework\Api\SortOrder::class, [], [], '', false); + $itemsMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock); $this->searchCriteriaBuilderMock->expects($this->once())->method('create') @@ -671,7 +697,7 @@ public function testGetList($fieldName) $collectionMock->expects($this->once())->method('getItems')->willReturn([$itemsMock]); $collectionMock->expects($this->once())->method('getSize')->willReturn(128); $searchResultsMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductSearchResultsInterface', + \Magento\Catalog\Api\Data\ProductSearchResultsInterface::class, [], [], '', @@ -691,7 +717,7 @@ public function testGetList($fieldName) public function cacheKeyDataProvider() { $anyObject = $this->getMock( - 'stdClass', + \stdClass::class, ['getId'], [], '', @@ -814,7 +840,7 @@ public function saveExistingWithOptionsDataProvider() ]; /** @var \Magento\Catalog\Model\Product\Option|\PHPUnit_Framework_MockObject_MockObject $existingOption1 */ - $existingOption1 = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option') + $existingOption1 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); @@ -825,7 +851,7 @@ public function saveExistingWithOptionsDataProvider() ] ); /** @var \Magento\Catalog\Model\Product\Option\Value $existingOptionValue1 */ - $existingOptionValue1 = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option\Value') + $existingOptionValue1 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Value::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); @@ -836,7 +862,7 @@ public function saveExistingWithOptionsDataProvider() "price" => 5, ] ); - $existingOptionValue2 = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option\Value') + $existingOptionValue2 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Value::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); @@ -853,7 +879,7 @@ public function saveExistingWithOptionsDataProvider() "9" => $existingOptionValue2, ] ); - $existingOption2 = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $existingOption2 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); @@ -946,7 +972,7 @@ public function testSaveWithLinks(array $newLinks, array $existingLinks, array $ ->expects($this->any())->method('getProductsIdsBySkus') ->willReturn([$newLinks['linked_product_sku'] => $newLinks['linked_product_sku']]); - $inputLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $inputLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $inputLink->setProductSku($newLinks['product_sku']); $inputLink->setLinkType($newLinks['link_type']); $inputLink->setLinkedProductSku($newLinks['linked_product_sku']); @@ -990,7 +1016,7 @@ public function testSaveWithLinks(array $newLinks, array $existingLinks, array $ $outputLinks = []; if (!empty($expectedData)) { foreach ($expectedData as $link) { - $outputLink = $this->objectManager->getObject('Magento\Catalog\Model\ProductLink\Link'); + $outputLink = $this->objectManager->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $outputLink->setProductSku($link['product_sku']); $outputLink->setLinkType($link['link_type']); $outputLink->setLinkedProductSku($link['linked_product_sku']); @@ -1137,7 +1163,7 @@ public function testSaveExistingWithNewMediaGalleryEntries() $this->mediaGalleryProcessor->expects($this->once())->method('clearMediaAttribute') ->with($this->initializedProductMock, ['image', 'small_image']); - $mediaConfigMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Media\Config') + $mediaConfigMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Media\Config::class) ->disableOriginalConstructor() ->getMock(); $mediaConfigMock->expects($this->once()) @@ -1149,7 +1175,7 @@ public function testSaveExistingWithNewMediaGalleryEntries() ->willReturn($mediaConfigMock); //verify new entries - $contentDataObject = $this->getMockBuilder('Magento\Framework\Api\ImageContent') + $contentDataObject = $this->getMockBuilder(\Magento\Framework\Api\ImageContent::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index 999009fbb9697..4aa6d420eb481 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -176,61 +176,61 @@ class ProductTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->categoryIndexerMock = $this->getMockForAbstractClass('\Magento\Framework\Indexer\IndexerInterface'); + $this->categoryIndexerMock = $this->getMockForAbstractClass(\Magento\Framework\Indexer\IndexerInterface::class); $this->moduleManager = $this->getMock( - 'Magento\Framework\Module\Manager', + \Magento\Framework\Module\Manager::class, ['isEnabled'], [], '', false ); $this->stockItemFactoryMock = $this->getMock( - 'Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory', + \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class, ['create'], [], '', false ); - $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); $this->productFlatProcessor = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', + \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, [], [], '', false ); - $this->_priceInfoMock = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); - $this->productTypeInstanceMock = $this->getMock('Magento\Catalog\Model\Product\Type', [], [], '', false); + $this->_priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->productTypeInstanceMock = $this->getMock(\Magento\Catalog\Model\Product\Type::class, [], [], '', false); $this->productPriceProcessor = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Price\Processor', + \Magento\Catalog\Model\Indexer\Product\Price\Processor::class, [], [], '', false ); - $stateMock = $this->getMock('Magento\FrameworkApp\State', ['getAreaCode'], [], '', false); + $stateMock = $this->getMock(\Magento\Framework\App\State::class, ['getAreaCode'], [], '', false); $stateMock->expects($this->any()) ->method('getAreaCode') ->will($this->returnValue(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $actionValidatorMock = $this->getMock( - '\Magento\Framework\Model\ActionValidator\RemoveAction', + \Magento\Framework\Model\ActionValidator\RemoveAction::class, [], [], '', false ); $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); - $cacheInterfaceMock = $this->getMock('Magento\Framework\App\CacheInterface'); + $cacheInterfaceMock = $this->getMock(\Magento\Framework\App\CacheInterface::class); $contextMock = $this->getMock( - '\Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, ['getEventDispatcher', 'getCacheManager', 'getAppState', 'getActionValidator'], [], '', false ); $contextMock->expects($this->any())->method('getAppState')->will($this->returnValue($stateMock)); @@ -244,12 +244,12 @@ protected function setUp() ->method('getActionValidator') ->will($this->returnValue($actionValidatorMock)); - $this->optionInstanceMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $this->optionInstanceMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->setMethods(['setProduct', 'saveOptions', '__wakeup', '__sleep']) ->disableOriginalConstructor()->getMock(); $optionFactory = $this->getMock( - 'Magento\Catalog\Model\Product\OptionFactory', + \Magento\Catalog\Model\Product\OptionFactory::class, ['create'], [], '', @@ -257,27 +257,27 @@ protected function setUp() ); $optionFactory->expects($this->any())->method('create')->willReturn($this->optionInstanceMock); - $this->resource = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product') + $this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product::class) ->disableOriginalConstructor() ->getMock(); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->category = $this->getMockBuilder('Magento\Catalog\Model\Category') + $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->getMock(); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $this->website = $this->getMockBuilder('\Magento\Store\Model\Website') + $this->website = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->disableOriginalConstructor() ->getMock(); - $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $storeManager->expects($this->any()) @@ -286,38 +286,44 @@ protected function setUp() $storeManager->expects($this->any()) ->method('getWebsite') ->will($this->returnValue($this->website)); - $this->indexerRegistryMock = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); - $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); + $this->indexerRegistryMock = $this->getMock( + \Magento\Framework\Indexer\IndexerRegistry::class, + ['get'], + [], + '', + false + ); + $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $this->_catalogProduct = $this->getMock( - 'Magento\Catalog\Helper\Product', + \Magento\Catalog\Helper\Product::class, ['isDataForProductCategoryIndexerWasChanged'], [], '', false ); - $this->imageCache = $this->getMockBuilder('Magento\Catalog\Model\Product\Image\Cache') + $this->imageCache = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image\Cache::class) ->disableOriginalConstructor() ->getMock(); - $this->imageCacheFactory = $this->getMockBuilder('Magento\Catalog\Model\Product\Image\CacheFactory') + $this->imageCacheFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image\CacheFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->mediaGalleryEntryFactoryMock = - $this->getMockBuilder('Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory') + $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->metadataServiceMock = $this->getMock('\Magento\Catalog\Api\ProductAttributeRepositoryInterface'); - $this->attributeValueFactory = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->metadataServiceMock = $this->getMock(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class); + $this->attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor()->getMock(); $this->mediaGalleryEntryConverterPoolMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class, ['getConverterByMediaType'], [], '', @@ -326,7 +332,7 @@ protected function setUp() $this->converterMock = $this->getMock( - '\Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter', + \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::class, [], [], '', @@ -336,15 +342,16 @@ protected function setUp() $this->mediaGalleryEntryConverterPoolMock->expects($this->any())->method('getConverterByMediaType')->willReturn( $this->converterMock ); - $this->productLinkRepositoryMock = $this->getMockBuilder('Magento\Catalog\Api\ProductLinkRepositoryInterface') + $this->productLinkRepositoryMock = $this->getMockBuilder( + \Magento\Catalog\Api\ProductLinkRepositoryInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->mediaConfig = $this->getMock('Magento\Catalog\Model\Product\Media\Config', [], [], '', false); + $this->mediaConfig = $this->getMock(\Magento\Catalog\Model\Product\Media\Config::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'context' => $contextMock, 'catalogProductType' => $this->productTypeInstanceMock, @@ -383,14 +390,14 @@ protected function setUp() public function testGetAttributes() { - $productType = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\AbstractType') + $productType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class) ->setMethods(['getSetAttributes']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->productTypeInstanceMock->expects($this->any())->method('factory')->will( $this->returnValue($productType) ); - $attribute = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['__wakeup', 'isInGroup']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -430,11 +437,11 @@ public function testGetWebsiteIds() public function testGetCategoryCollection() { - $collection = $this->getMockBuilder('\Magento\Framework\Data\Collection') + $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->once())->method('getCategoryCollection')->will($this->returnValue($collection)); - $this->assertInstanceOf('\Magento\Framework\Data\Collection', $this->model->getCategoryCollection()); + $this->assertInstanceOf(\Magento\Framework\Data\Collection::class, $this->model->getCategoryCollection()); } /** @@ -443,7 +450,7 @@ public function testGetCategoryCollection() public function testGetCategoryCollectionCollectionNull($initCategoryCollection, $getIdResult, $productIdCached) { $product = $this->getMock( - '\Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ '_getResource', 'setCategoryCollection', @@ -454,14 +461,14 @@ public function testGetCategoryCollectionCollectionNull($initCategoryCollection, false ); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $abstractDbMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods([ 'getCategoryCollection', ]) ->getMockForAbstractClass(); $getCategoryCollectionMock = $this->getMock( - '\Magento\Framework\Data\Collection', + \Magento\Framework\Data\Collection::class, [], [], '', @@ -513,7 +520,7 @@ public function getCategoryCollectionCollectionNullDataProvider() public function testSetCategoryCollection() { - $collection = $this->getMockBuilder('\Magento\Framework\Data\Collection') + $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->once())->method('getCategoryCollection')->will($this->returnValue($collection)); @@ -525,7 +532,7 @@ public function testGetCategory() $this->category->expects($this->any())->method('getId')->will($this->returnValue(10)); $this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category)); $this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($this->category)); - $this->assertInstanceOf('\Magento\Catalog\Model\Category', $this->model->getCategory()); + $this->assertInstanceOf(\Magento\Catalog\Model\Category::class, $this->model->getCategory()); } public function testGetCategoryId() @@ -617,7 +624,7 @@ public function getProductReindexProvider() public function testPriceReindexCallback() { $this->model = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'catalogProductType' => $this->productTypeInstanceMock, 'categoryIndexer' => $this->categoryIndexerMock, @@ -821,7 +828,7 @@ public function testSaveAndDuplicate() public function testGetIsSalableSimple() { $typeInstanceMock = - $this->getMock('Magento\Catalog\Model\Product\Type\Simple', ['isSalable'], [], '', false); + $this->getMock(\Magento\Catalog\Model\Product\Type\Simple::class, ['isSalable'], [], '', false); $typeInstanceMock ->expects($this->atLeastOnce()) ->method('isSalable') @@ -834,7 +841,7 @@ public function testGetIsSalableSimple() public function testGetIsSalableHasDataIsSaleable() { - $typeInstanceMock = $this->getMock('Magento\Catalog\Model\Product\Type\Simple', [], [], '', false); + $typeInstanceMock = $this->getMock(\Magento\Catalog\Model\Product\Type\Simple::class, [], [], '', false); $this->model->setTypeInstance($typeInstanceMock); $this->model->setData('is_saleable', true); @@ -850,7 +857,7 @@ public function testGetIsSalableHasDataIsSaleable() */ protected function configureSaveTest() { - $productTypeMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\Simple') + $productTypeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Simple::class) ->disableOriginalConstructor()->setMethods(['beforeSave', 'save'])->getMock(); $productTypeMock->expects($this->once())->method('beforeSave')->will($this->returnSelf()); $productTypeMock->expects($this->once())->method('save')->will($this->returnSelf()); @@ -874,7 +881,7 @@ public function testFromArray() ]; $stockItemMock = $this->getMockForAbstractClass( - 'Magento\Framework\Api\AbstractSimpleObject', + \Magento\Framework\Api\AbstractSimpleObject::class, [], '', false, @@ -889,7 +896,7 @@ public function testFromArray() ->will($this->returnValue(true)); $this->dataObjectHelperMock->expects($this->once()) ->method('populateWithArray') - ->with($stockItemMock, $data['stock_item'], '\Magento\CatalogInventory\Api\Data\StockItemInterface') + ->with($stockItemMock, $data['stock_item'], \Magento\CatalogInventory\Api\Data\StockItemInterface::class) ->will($this->returnSelf()); $this->stockItemFactoryMock->expects($this->once()) ->method('create') @@ -912,7 +919,7 @@ protected function prepareCategoryIndexer() */ public function testGetProductLinks() { - $outputRelatedLink = $this->objectManagerHelper->getObject('Magento\Catalog\Model\ProductLink\Link'); + $outputRelatedLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $outputRelatedLink->setSku("Simple Product 1"); $outputRelatedLink->setLinkType("related"); $outputRelatedLink->setLinkedProductSku("Simple Product 2"); @@ -929,7 +936,7 @@ public function testGetProductLinks() */ public function testSetProductLinks() { - $link = $this->objectManagerHelper->getObject('Magento\Catalog\Model\ProductLink\Link'); + $link = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $link->setSku("Simple Product 1"); $link->setLinkType("upsell"); $link->setLinkedProductSku("Simple Product 2"); @@ -945,7 +952,7 @@ public function testSetProductLinks() */ protected function setupMediaAttributes() { - $productType = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\AbstractType') + $productType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class) ->setMethods(['getSetAttributes']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -953,12 +960,12 @@ protected function setupMediaAttributes() $this->returnValue($productType) ); - $frontendMock = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend') + $frontendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class) ->disableOriginalConstructor() ->setMethods(['getInputType']) ->getMockForAbstractClass(); $frontendMock->expects($this->any())->method('getInputType')->willReturn('media_image'); - $attributeImage = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeImage = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['__wakeup', 'getFrontend', 'getAttributeCode']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -966,7 +973,7 @@ protected function setupMediaAttributes() ->method('getFrontend') ->willReturn($frontendMock); $attributeImage->expects($this->any())->method('getAttributeCode')->willReturn('image'); - $attributeSmallImage = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeSmallImage = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods(['__wakeup', 'getFrontend', 'getAttributeCode']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -1034,9 +1041,21 @@ public function testGetMediaGalleryEntries() $this->model->setData('media_gallery', $mediaEntries); $entry1 = - $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface', [], [], '', false); + $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class, + [], + [], + '', + false + ); $entry2 = - $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface', [], [], '', false); + $this->getMock( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class, + [], + [], + '', + false + ); $this->converterMock->expects($this->exactly(2))->method('convertTo')->willReturnOnConsecutiveCalls( $entry1, @@ -1069,7 +1088,7 @@ public function testSetMediaGalleryEntries() ], ]; - $entryMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface') + $entryMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class) ->setMethods( [ 'getId', @@ -1111,11 +1130,11 @@ public function testGetCustomAttributes() { $priceCode = 'price'; $colorAttributeCode = 'color'; - $interfaceAttribute = $this->getMock('\Magento\Framework\Api\MetadataObjectInterface'); + $interfaceAttribute = $this->getMock(\Magento\Framework\Api\MetadataObjectInterface::class); $interfaceAttribute->expects($this->once()) ->method('getAttributeCode') ->willReturn($priceCode); - $colorAttribute = $this->getMock('\Magento\Framework\Api\MetadataObjectInterface'); + $colorAttribute = $this->getMock(\Magento\Framework\Api\MetadataObjectInterface::class); $colorAttribute->expects($this->once()) ->method('getAttributeCode') ->willReturn($colorAttributeCode); @@ -1161,12 +1180,12 @@ public function priceDataProvider() public function testGetOptions() { $option1Id = 2; - $optionMock1 = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option') + $optionMock1 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(['getId', 'setProduct']) ->getMock(); $option2Id = 3; - $optionMock2 = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option') + $optionMock2 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(['getId', 'setProduct']) ->getMock(); @@ -1215,7 +1234,7 @@ public function testGetFinalPrice() $qty = 1; $this->model->setQty($qty); $productTypePriceMock = $this->getMock( - 'Magento\Catalog\Model\Product\Type\Price', + \Magento\Catalog\Model\Product\Type\Price::class, ['getFinalPrice'], [], '', @@ -1248,7 +1267,7 @@ public function testGetFinalPricePreset() public function testGetTypeId() { - $productType = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\Virtual') + $productType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Virtual::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php index a8aab0838ffc5..63254a653ab35 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php @@ -26,9 +26,9 @@ class ProductTypeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->typeConfigMock = $this->getMock('Magento\Catalog\Model\ProductTypes\ConfigInterface'); + $this->typeConfigMock = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); $this->factoryMock = $this->getMock( - 'Magento\Catalog\Api\Data\ProductTypeInterfaceFactory', + \Magento\Catalog\Api\Data\ProductTypeInterfaceFactory::class, ['create'], [], '', @@ -49,7 +49,7 @@ public function testGetProductTypes() $productTypeData = [ 'simple' => $simpleProductType, ]; - $productTypeMock = $this->getMock('Magento\Catalog\Api\Data\ProductTypeInterface'); + $productTypeMock = $this->getMock(\Magento\Catalog\Api\Data\ProductTypeInterface::class); $this->typeConfigMock->expects($this->any())->method('getAll')->will($this->returnValue($productTypeData)); $this->factoryMock->expects($this->once())->method('create')->willReturn($productTypeMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php index aeef07b0344b3..e5e7c01c3602c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleReaderMock = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->_moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->_moduleReaderMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php index d22f4dc10923d..af0c1625f9cb6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php @@ -25,13 +25,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->readerMock = $this->getMock( - 'Magento\Catalog\Model\ProductTypes\Config\Reader', + \Magento\Catalog\Model\ProductTypes\Config\Reader::class, [], [], '', false ); - $this->cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php index 3270c210a267f..044bb6cfc9033 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php @@ -24,7 +24,7 @@ protected function _getAttributes() $codes = ['entity_type_id', 'attribute_set_id', 'created_at', 'updated_at', 'parent_id', 'increment_id']; foreach ($codes as $code) { $mock = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['isInSet', 'getBackend', '__wakeup'], [], '', @@ -48,7 +48,7 @@ public function testWalkAttributes() $code = 'test_attr'; $set = 10; - $object = $this->getMock('Magento\Catalog\Model\Product', ['__wakeup'], [], '', false); + $object = $this->getMock(\Magento\Catalog\Model\Product::class, ['__wakeup'], [], '', false); $object->setData('test_attr', 'test_attr'); $object->setData('attribute_set_id', $set); @@ -61,7 +61,7 @@ public function testWalkAttributes() $attributes = $this->_getAttributes(); $attribute = $this->getMock( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['isInSet', 'getBackend', '__wakeup'], [], '', @@ -83,9 +83,11 @@ public function testWalkAttributes() $attributes[$code] = $attribute; /** @var $model \Magento\Catalog\Model\ResourceModel\AbstractResource */ - $arguments = $objectManager->getConstructArguments('Magento\Catalog\Model\ResourceModel\AbstractResource'); + $arguments = $objectManager->getConstructArguments( + \Magento\Catalog\Model\ResourceModel\AbstractResource::class + ); $model = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\AbstractResource', + \Magento\Catalog\Model\ResourceModel\AbstractResource::class, ['getAttributesByCode'], $arguments ); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php index ec95f93495991..4d641aebd789f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php @@ -19,20 +19,20 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Catalog\Model\ResourceModel\Category\Collection\Factory($this->_objectManager); } public function testCreate() { - $objectOne = $this->getMock('Magento\Catalog\Model\ResourceModel\Category\Collection', [], [], '', false); - $objectTwo = $this->getMock('Magento\Catalog\Model\ResourceModel\Category\Collection', [], [], '', false); + $objectOne = $this->getMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class, [], [], '', false); + $objectTwo = $this->getMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class, [], [], '', false); $this->_objectManager->expects( $this->exactly(2) )->method( 'create' )->with( - 'Magento\Catalog\Model\ResourceModel\Category\Collection', + \Magento\Catalog\Model\ResourceModel\Category\Collection::class, [] )->will( $this->onConsecutiveCalls($objectOne, $objectTwo) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php index ef43e7c6db7f6..a1bcb88669eaf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php @@ -12,6 +12,9 @@ use Magento\Framework\EntityManager\EntityMetadata; use Magento\Framework\EntityManager\MetadataPool; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class TreeTest extends \PHPUnit_Framework_TestCase { /** @@ -45,11 +48,11 @@ class TreeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $select->expects($this->once())->method('from')->with('catalog_category_entity'); - $connection = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $connection = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $connection->expects($this->once())->method('select')->will($this->returnValue($select)); - $this->_resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->_resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->_resource->expects( $this->once() )->method( @@ -68,16 +71,16 @@ protected function setUp() )->will( $this->returnArgument(0) ); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $this->_attributeConfig = $this->getMock( - 'Magento\Catalog\Model\Attribute\Config', + \Magento\Catalog\Model\Attribute\Config::class, [], [], '', false ); $this->_collectionFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Category\Collection\Factory', + \Magento\Catalog\Model\ResourceModel\Category\Collection\Factory::class, [], [], '', @@ -89,7 +92,7 @@ protected function setUp() ->getMock(); $this->_model = $objectHelper->getObject( - 'Magento\Catalog\Model\ResourceModel\Category\Tree', + \Magento\Catalog\Model\ResourceModel\Category\Tree::class, [ 'resource' => $this->_resource, 'eventManager' => $eventManager, @@ -125,7 +128,7 @@ public function testGetCollection() */ protected function getCollectionMock() { - return $this->getMock('Magento\Catalog\Model\ResourceModel\Category\Collection', [], [], '', false); + return $this->getMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class, [], [], '', false); } public function testSetCollection() @@ -139,7 +142,7 @@ public function testSetCollection() public function testCallCleaningDuringSetCollection() { /** @var \Magento\Catalog\Model\ResourceModel\Category\Tree $model */ - $model = $this->getMock('Magento\Catalog\Model\ResourceModel\Category\Tree', ['_clean'], [], '', false); + $model = $this->getMock(\Magento\Catalog\Model\ResourceModel\Category\Tree::class, ['_clean'], [], '', false); $model->expects($this->once())->method('_clean')->will($this->returnSelf()); $this->assertEquals($model, $model->setCollection($this->getCollectionMock())); @@ -149,24 +152,24 @@ public function testCallCleaningDuringSetCollection() public function testAddCollectionData() { $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $select->expects($this->any())->method('from')->will($this->returnSelf()); $select->expects($this->any())->method('join')->will($this->returnSelf()); $select->expects($this->any())->method('joinInner')->will($this->returnSelf()); $select->expects($this->any())->method('joinLeft')->will($this->returnSelf()); $select->expects($this->any())->method('where')->will($this->returnSelf()); - $connection = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); + $connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $connection->expects($this->any())->method('select')->will($this->returnValue($select)); $connection->expects($this->any())->method('fetchCol')->will($this->returnValue([])); - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); $resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $attributeConfig = $this->getMock( - 'Magento\Catalog\Model\Attribute\Config', + \Magento\Catalog\Model\Attribute\Config::class, [], [], '', @@ -184,11 +187,17 @@ public function testAddCollectionData() $this->returnValue($attributes) ); - $collection = $this->getMock('Magento\Catalog\Model\ResourceModel\Category\Collection', [], [], '', false); + $collection = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category\Collection::class, + [], + [], + '', + false + ); $collection->expects($this->never())->method('getAllIds')->will($this->returnValue([])); $collection->expects($this->once())->method('getAllIdsSql')->will($this->returnValue($select)); $collectionFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Category\Collection\Factory', + \Magento\Catalog\Model\ResourceModel\Category\Collection\Factory::class, [], [], '', @@ -196,10 +205,10 @@ public function testAddCollectionData() ); $collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection)); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $categoryMetadataMock = $this->getMockBuilder(EntityMetadata::class) @@ -216,7 +225,7 @@ public function testAddCollectionData() $model = $objectHelper->getObject( - 'Magento\Catalog\Model\ResourceModel\Category\Tree', + \Magento\Catalog\Model\ResourceModel\Category\Tree::class, [ 'storeManager' => $storeManager, 'resource' => $resource, @@ -227,7 +236,7 @@ public function testAddCollectionData() ] ); - $nodeMock = $this->getMock('\Magento\Framework\Data\Tree\Node', ['getId', 'getPath'], [], '', false); + $nodeMock = $this->getMock(\Magento\Framework\Data\Tree\Node::class, ['getId', 'getPath'], [], '', false); $nodeMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $nodeMock->expects($this->once())->method('getPath')->will($this->returnValue([])); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php index fa59fd635adaa..9d93c185aa9e5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php @@ -8,6 +8,9 @@ namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Eav; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AttributeTest extends \PHPUnit_Framework_TestCase { /** @@ -43,7 +46,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_processor = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', + \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, [], [], '', @@ -51,24 +54,24 @@ protected function setUp() ); $this->_eavProcessor = $this->getMock( - '\Magento\Catalog\Model\Indexer\Product\Eav\Processor', + \Magento\Catalog\Model\Indexer\Product\Eav\Processor::class, [], [], '', false ); - $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); - $cacheInterfaceMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); + $cacheInterfaceMock = $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false); $actionValidatorMock = $this->getMock( - '\Magento\Framework\Model\ActionValidator\RemoveAction', [], [], '', false + \Magento\Framework\Model\ActionValidator\RemoveAction::class, [], [], '', false ); $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $this->contextMock = $this->getMock( - '\Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, ['getEventDispatcher', 'getCacheManager', 'getActionValidator'], [], '', false ); @@ -81,18 +84,27 @@ protected function setUp() $this->contextMock->expects($this->any())->method('getActionValidator') ->will($this->returnValue($actionValidatorMock)); - $dbAdapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $dbAdapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(1)); $this->resourceMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\AbstractResource', - ['_construct', 'getConnection', 'getIdFieldName', - 'save', 'saveInSetIncluding', 'isUsedBySuperProducts', 'delete'], - [], '', false + \Magento\Framework\Model\ResourceModel\AbstractResource::class, + [ + '_construct', + 'getConnection', + 'getIdFieldName', + 'save', + 'saveInSetIncluding', + 'isUsedBySuperProducts', + 'delete' + ], + [], + '', + false ); - $this->eavConfigMock = $this->getMockBuilder('Magento\Eav\Model\Config') + $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->setMethods(['clear']) ->disableOriginalConstructor() ->getMock(); @@ -103,7 +115,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManager->getObject( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [ 'context' => $this->contextMock, 'productFlatIndexerProcessor' => $this->_processor, @@ -163,7 +175,7 @@ public function testGetScopeGlobal() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManagerHelper->getObject( - '\Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [ 'context' => $this->contextMock, 'productFlatIndexerProcessor' => $this->_processor, @@ -181,7 +193,7 @@ public function testGetScopeWebiste() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManagerHelper->getObject( - '\Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [ 'context' => $this->contextMock, 'productFlatIndexerProcessor' => $this->_processor, @@ -199,7 +211,7 @@ public function testGetScopeStore() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManagerHelper->getObject( - '\Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [ 'context' => $this->contextMock, 'productFlatIndexerProcessor' => $this->_processor, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php index f61888f8df93f..332e775b019b2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php @@ -10,6 +10,8 @@ /** * Class CollectionTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CollectionTest extends \PHPUnit_Framework_TestCase { @@ -33,72 +35,72 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $entityFactory = $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface') + $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $fetchStrategy = $this->getMockBuilder('Magento\Framework\Data\Collection\Db\FetchStrategyInterface') + $fetchStrategy = $this->getMockBuilder(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $eventManager = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $eavConfig = $this->getMockBuilder('Magento\Eav\Model\Config') + $eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $resource = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); - $eavEntityFactory = $this->getMockBuilder('Magento\Eav\Model\EntityFactory') + $eavEntityFactory = $this->getMockBuilder(\Magento\Eav\Model\EntityFactory::class) ->disableOriginalConstructor() ->getMock(); - $resourceHelper = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Helper') + $resourceHelper = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Helper::class) ->disableOriginalConstructor() ->getMock(); - $universalFactory = $this->getMockBuilder('Magento\Framework\Validator\UniversalFactory') + $universalFactory = $this->getMockBuilder(\Magento\Framework\Validator\UniversalFactory::class) ->disableOriginalConstructor() ->getMock(); - $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->setMethods(['getStore', 'getId']) ->getMockForAbstractClass(); - $moduleManager = $this->getMockBuilder('Magento\Framework\Module\Manager') + $moduleManager = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); - $catalogProductFlatState = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Product\Flat\State') + $catalogProductFlatState = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\State::class) ->disableOriginalConstructor() ->getMock(); - $scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $productOptionFactory = $this->getMockBuilder('Magento\Catalog\Model\Product\OptionFactory') + $productOptionFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\OptionFactory::class) ->disableOriginalConstructor() ->getMock(); - $catalogUrl = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Url') + $catalogUrl = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Url::class) ->disableOriginalConstructor() ->getMock(); - $localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $localeDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $dateTime = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime') + $dateTime = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class) ->disableOriginalConstructor() ->getMock(); - $groupManagement = $this->getMockBuilder('Magento\Customer\Api\GroupManagementInterface') + $groupManagement = $this->getMockBuilder(\Magento\Customer\Api\GroupManagementInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $entityMock = $this->getMockBuilder('Magento\Eav\Model\Entity\AbstractEntity') + $entityMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\AbstractEntity::class) ->disableOriginalConstructor() ->getMock(); @@ -114,13 +116,12 @@ protected function setUp() $helper = new ObjectManager($this); $this->prepareObjectManager([ - [ - 'Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation', - $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation') + [\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class, + $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class) ] ]); $this->collection = $helper->getObject( - 'Magento\Catalog\Model\ResourceModel\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, [ 'entityFactory' => $entityFactory, 'logger' => $logger, @@ -178,12 +179,12 @@ public function testAddProductCategoriesFilter() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php index 28c7f8002e5f5..a05a627693260 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php @@ -24,9 +24,9 @@ class FlatTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->_store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->_storeManagerInterface = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerInterface = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->_storeManagerInterface->expects( $this->any() @@ -45,10 +45,10 @@ protected function setUp() ); $this->_model = new \Magento\Catalog\Model\ResourceModel\Product\Flat( - $this->getMock('Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false), + $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false), $this->_storeManagerInterface, - $this->getMock('Magento\Catalog\Model\Config', [], [], '', false), - $this->getMock('Magento\Catalog\Model\Product\Attribute\DefaultAttributes') + $this->getMock(\Magento\Catalog\Model\Config::class, [], [], '', false), + $this->getMock(\Magento\Catalog\Model\Product\Attribute\DefaultAttributes::class) ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php index b42c9c8027de3..d77ecc1f3dc8b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php @@ -53,7 +53,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', @@ -63,7 +63,7 @@ protected function setUp() ->method('setCacheAdapter'); $metadata = $this->getMock( - 'Magento\Framework\EntityManager\EntityMetadata', + \Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', @@ -77,7 +77,7 @@ protected function setUp() ->willReturn($this->connection); $metadataPool = $this->getMock( - 'Magento\Framework\EntityManager\MetadataPool', + \Magento\Framework\EntityManager\MetadataPool::class, [], [], '', @@ -85,21 +85,27 @@ protected function setUp() ); $metadataPool->expects($this->once()) ->method('getMetadata') - ->with('Magento\Catalog\Api\Data\ProductInterface') + ->with(\Magento\Catalog\Api\Data\ProductInterface::class) ->willReturn($metadata); - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $resource->expects($this->any())->method('getTableName')->willReturn('table'); $this->resource = $objectManager->getObject( - 'Magento\Catalog\Model\ResourceModel\Product\Gallery', + \Magento\Catalog\Model\ResourceModel\Product\Gallery::class, [ 'metadataPool' => $metadataPool, 'resource' => $resource ] ); - $this->product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); - $this->attribute = $this->getMock('Magento\Eav\Model\Entity\Attribute\AbstractAttribute', [], [], '', false); + $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $this->attribute = $this->getMock( + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, + [], + [], + '', + false + ); } public function testLoadDataFromTableByValueId() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php index 429440a2a1983..3c92cde30012d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php @@ -76,19 +76,25 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $this->fetchStrategyMock = $this->getMock('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $this->managerInterfaceMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->configMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->entityFactoryMock2 = $this->getMock('Magento\Eav\Model\EntityFactory', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Helper', [], [], '', false); - $entity = $this->getMock('Magento\Eav\Model\Entity\AbstractEntity', [], [], '', false); - $select = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->entityFactoryMock = $this->getMock( + \Magento\Framework\Data\Collection\EntityFactory::class, + [], + [], + '', + false + ); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->fetchStrategyMock = $this->getMock(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class); + $this->managerInterfaceMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->configMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->entityFactoryMock2 = $this->getMock(\Magento\Eav\Model\EntityFactory::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Helper::class, [], [], '', false); + $entity = $this->getMock(\Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', false); + $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); $connection->expects($this->any()) @@ -96,9 +102,15 @@ protected function setUp() ->willReturn($select); $entity->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); $entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([])); - $this->universalFactoryMock = $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false); + $this->universalFactoryMock = $this->getMock( + \Magento\Framework\Validator\UniversalFactory::class, + [], + [], + '', + false + ); $this->universalFactoryMock->expects($this->any())->method('create')->will($this->returnValue($entity)); - $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $this->storeManagerMock ->expects($this->any()) ->method('getStore') @@ -107,24 +119,29 @@ function ($store) { return is_object($store) ? $store : new \Magento\Framework\DataObject(['id' => 42]); } )); - $this->catalogHelperMock = $this->getMock('Magento\Catalog\Helper\Data', [], [], '', false); - $this->stateMock = $this->getMock('Magento\Catalog\Model\Indexer\Product\Flat\State', [], [], '', false); - $this->scopeConfigInterfaceMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->optionFactoryMock = $this->getMock('Magento\Catalog\Model\Product\OptionFactory', [], [], '', false); - $this->urlMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Url', [], [], '', false); - $this->timezoneInterfaceMock = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); - $this->sessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->dateTimeMock = $this->getMock('Magento\Framework\Stdlib\DateTime'); + $this->catalogHelperMock = $this->getMock(\Magento\Catalog\Helper\Data::class, [], [], '', false); + $this->stateMock = $this->getMock(\Magento\Catalog\Model\Indexer\Product\Flat\State::class, [], [], '', false); + $this->scopeConfigInterfaceMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->optionFactoryMock = $this->getMock( + \Magento\Catalog\Model\Product\OptionFactory::class, + [], + [], + '', + false + ); + $this->urlMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Url::class, [], [], '', false); + $this->timezoneInterfaceMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->sessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->dateTimeMock = $this->getMock(\Magento\Framework\Stdlib\DateTime::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->prepareObjectManager([ - [ - 'Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation', - $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation') + [\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class, + $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class) ] ]); $this->collection = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class, [ 'entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, @@ -151,7 +168,7 @@ function ($store) { public function testSetProduct() { /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $product->expects($this->any())->method('getId')->will($this->returnValue('5')); $productStore = new \Magento\Framework\DataObject(['id' => 33]); $product->expects($this->any())->method('getStore')->will($this->returnValue($productStore)); @@ -164,12 +181,12 @@ public function testSetProduct() */ public function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php index 4ca9840ce1ba0..50f14246ed9ee 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php @@ -30,19 +30,19 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->connection = - $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\ResourceModel\Product\Link', + \Magento\Catalog\Model\ResourceModel\Product\Link::class, ['resource' => $this->resource] ); } protected function prepareAdapter() { - $this->dbSelect = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->dbSelect = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); // method flow $this->resource->expects( @@ -52,7 +52,6 @@ protected function prepareAdapter() )->will( $this->returnValue($this->connection) ); - $this->connection->expects($this->once())->method('select')->will($this->returnValue($this->dbSelect)); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php index 72d879c8e7369..decf8e66f6738 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php @@ -80,34 +80,41 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->entityFactoryMock = $this->getMock( - 'Magento\Framework\Data\Collection\EntityFactory', ['create'], [], '', false + \Magento\Framework\Data\Collection\EntityFactory::class, ['create'], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->fetchStrategyMock = $this->getMock( - 'Magento\Framework\Data\Collection\Db\FetchStrategy\Query', ['fetchAll'], [], '', false + \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, ['fetchAll'], [], '', false ); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); $this->optionsFactoryMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class, ['create'], [], '', false ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $this->joinProcessor = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface') + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->joinProcessor = $this->getMockBuilder( + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->resourceMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Option', + \Magento\Catalog\Model\ResourceModel\Product\Option::class, ['getConnection', '__wakeup', 'getMainTable', 'getTable'], [], '', false ); - $this->selectMock = $this->getMock('Magento\Framework\DB\Select', ['from', 'reset', 'join'], [], '', false); + $this->selectMock = $this->getMock( + \Magento\Framework\DB\Select::class, + ['from', 'reset', 'join'], + [], + '', + false + ); $this->connection = - $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', ['select'], [], '', false); + $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select'], [], '', false); $this->connection->expects($this->once()) ->method('select') ->will($this->returnValue($this->selectMock)); @@ -128,15 +135,21 @@ protected function setUp() 'catalog_product_entity', 'catalog_product_entity' ); - $this->metadataPoolMock = $this->getMock('Magento\Framework\EntityManager\MetadataPool', [], [], '', false); - $metadata = $this->getMock('Magento\Framework\EntityManager\EntityMetadata', [], [], '', false); + $this->metadataPoolMock = $this->getMock( + \Magento\Framework\EntityManager\MetadataPool::class, + [], + [], + '', + false + ); + $metadata = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); $metadata->expects($this->any())->method('getLinkField')->willReturn('id'); $this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($metadata); $this->selectMock->expects($this->exactly(2))->method('join'); $this->prepareObjectManager([ - ['Magento\Framework\EntityManager\MetadataPool', $this->metadataPoolMock], - ['Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', $this->joinProcessor] + [\Magento\Framework\EntityManager\MetadataPool::class, $this->metadataPoolMock], + [\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, $this->joinProcessor] ]); $this->collection = new Collection( @@ -161,12 +174,12 @@ public function testReset() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php index f52394070659c..8a75e27bcac59 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php @@ -30,14 +30,14 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->setFactoryMock = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\SetFactory', + \Magento\Eav\Model\Entity\Attribute\SetFactory::class, ['create', '__wakeup'], [], '', false ); $this->typeFactoryMock = $this->getMock( - '\Magento\Eav\Model\Entity\TypeFactory', + \Magento\Eav\Model\Entity\TypeFactory::class, ['create', '__wakeup'], [], '', @@ -45,7 +45,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Catalog\Model\ResourceModel\Product', + \Magento\Catalog\Model\ResourceModel\Product::class, [ 'setFactory' => $this->setFactoryMock, 'typeFactory' => $this->typeFactoryMock, @@ -59,20 +59,20 @@ public function testValidateWrongAttributeSet() $expectedErrorMessage = ['attribute_set' => 'Invalid attribute set entity type']; $productMock = $this->getMock( - '\Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getAttributeSetId', '__wakeup'], [], '', false ); $attributeSetMock = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\Set', + \Magento\Eav\Model\Entity\Attribute\Set::class, ['load', 'getEntityTypeId', '__wakeup'], [], '', false ); - $entityTypeMock = $this->getMock('\Magento\Eav\Model\Entity\Type', [], [], '', false); + $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); $this->typeFactoryMock->expects($this->once())->method('create')->will($this->returnValue($entityTypeMock)); $entityTypeMock->expects($this->once())->method('loadByCode')->with('catalog_product')->willReturnSelf(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php index ae76205d1e870..9350c695a9afa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php @@ -42,21 +42,21 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->categoryLayer = $this->getMock( - 'Magento\Catalog\Model\Layer\Category', + \Magento\Catalog\Model\Layer\Category::class, ['setStore', '__wakeup'], [], '', false ); $this->collectionFactory = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory', + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, ['create'], [], '', false ); $this->visibility = $this->getMock( - 'Magento\Catalog\Model\Product\Visibility', + \Magento\Catalog\Model\Product\Visibility::class, [ 'getVisibleInCatalogIds', '__wakeup' @@ -67,7 +67,7 @@ protected function setUp() ); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */ - $layerResolver = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Resolver') + $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class) ->disableOriginalConstructor() ->setMethods(['get', 'create']) ->getMock(); @@ -78,7 +78,7 @@ protected function setUp() $this->objectManagerHelper = new ObjectManagerHelper($this); /** @var \Magento\Catalog\Model\Rss\Category model */ $this->model = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Rss\Category', + \Magento\Catalog\Model\Rss\Category::class, [ 'layerResolver' => $layerResolver, 'collectionFactory' => $this->collectionFactory, @@ -101,7 +101,7 @@ public function testGetProductCollection() ->method('getVisibleInCatalogIds') ->will($this->returnValue($visibleInCatalogIds)); $products = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, [ 'setStoreId', 'addAttributeToSort', @@ -115,7 +115,7 @@ public function testGetProductCollection() false ); $resourceCollection = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection', + \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection::class, [ 'addAttributeToSelect', 'addAttributeToFilter', @@ -165,7 +165,7 @@ public function testGetProductCollection() ->method('create') ->will($this->returnValue($products)); $category = $this->getMock( - 'Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'getResourceCollection', 'getChildren', @@ -186,7 +186,7 @@ public function testGetProductCollection() ->method('getProductCollection') ->will($this->returnValue($products)); $layer = $this->getMock( - 'Magento\Catalog\Model\Layer', + \Magento\Catalog\Model\Layer::class, [ 'setCurrentCategory', 'prepareProductCollection', @@ -206,7 +206,7 @@ public function testGetProductCollection() ->will($this->returnValue($products)); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */ - $layerResolver = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Resolver') + $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class) ->disableOriginalConstructor() ->setMethods(['get', 'create']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php index ff0df49c17795..874fe018ae2e0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php @@ -45,15 +45,15 @@ class NewProductsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory', ['create'], [], '', false); + $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); $this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product)); - $this->visibility = $this->getMock('Magento\Catalog\Model\Product\Visibility', [], [], '', false); - $this->timezone = $this->getMock('Magento\Framework\Stdlib\DateTime\Timezone', [], [], '', false); + $this->visibility = $this->getMock(\Magento\Catalog\Model\Product\Visibility::class, [], [], '', false); + $this->timezone = $this->getMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->newProducts = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Rss\Product\NewProducts', + \Magento\Catalog\Model\Rss\Product\NewProducts::class, [ 'productFactory' => $this->productFactory, 'visibility' => $this->visibility, @@ -65,7 +65,7 @@ protected function setUp() public function testGetProductsCollection() { /** @var \DateTime|\PHPUnit_Framework_MockObject_MockObject $dateObject */ - $dateObject = $this->getMock('DateTime'); + $dateObject = $this->getMock(\DateTime::class); $dateObject->expects($this->any()) ->method('setTime') ->will($this->returnSelf()); @@ -79,7 +79,7 @@ public function testGetProductsCollection() /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */ $productCollection = - $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], [], '', false); $this->product->expects($this->once())->method('getResourceCollection')->will( $this->returnValue($productCollection) ); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php index 0f0297587b118..52f276b914717 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php @@ -28,6 +28,7 @@ class NotifyStockTest extends \PHPUnit_Framework_TestCase */ protected $productFactory; + /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product */ @@ -55,13 +56,13 @@ class NotifyStockTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory', ['create'], [], '', false); + $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); $this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product)); - $this->stock = $this->getMock('Magento\CatalogInventory\Model\ResourceModel\Stock', [], [], '', false); + $this->stock = $this->getMock(\Magento\CatalogInventory\Model\ResourceModel\Stock::class, [], [], '', false); $this->stockFactory = $this->getMock( - 'Magento\CatalogInventory\Model\ResourceModel\StockFactory', + \Magento\CatalogInventory\Model\ResourceModel\StockFactory::class, ['create'], [], '', @@ -69,12 +70,12 @@ protected function setUp() ); $this->stockFactory->expects($this->any())->method('create')->will($this->returnValue($this->stock)); - $this->status = $this->getMock('Magento\Catalog\Model\Product\Attribute\Source\Status'); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->status = $this->getMock(\Magento\Catalog\Model\Product\Attribute\Source\Status::class); + $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->notifyStock = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Rss\Product\NotifyStock', + \Magento\Catalog\Model\Rss\Product\NotifyStock::class, [ 'productFactory' => $this->productFactory, 'stockFactory' => $this->stockFactory, @@ -88,7 +89,7 @@ public function testGetProductsCollection() { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */ $productCollection = - $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], [], '', false); $this->product->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection)); $productCollection->expects($this->once())->method('addAttributeToSelect')->will($this->returnSelf()); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php index db57c07b904b4..235829d69e7e0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php @@ -40,14 +40,14 @@ class SpecialTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory', ['create'], [], '', false); + $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); $this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product)); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->special = $this->objectManagerHelper->getObject( - 'Magento\Catalog\Model\Rss\Product\Special', + \Magento\Catalog\Model\Rss\Product\Special::class, [ 'productFactory' => $this->productFactory, 'storeManager' => $this->storeManager @@ -58,7 +58,7 @@ protected function setUp() public function testGetProductsCollection() { $storeId = 1; - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManager->expects($this->once())->method('getStore')->with($storeId)->will( $this->returnValue($store) ); @@ -67,7 +67,7 @@ public function testGetProductsCollection() /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */ $productCollection = - $this->getMock('Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], [], '', false); $this->product->expects($this->once())->method('getResourceCollection')->will( $this->returnValue($productCollection) ); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php index 52c1969aa1942..70ac3e0807267 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php @@ -20,7 +20,7 @@ class InputtypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_model = $this->_helper->getObject('Magento\Catalog\Model\System\Config\Source\Inputtype'); + $this->_model = $this->_helper->getObject(\Magento\Catalog\Model\System\Config\Source\Inputtype::class); } public function testToOptionArrayIsArray() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php index d3c7c9631d2a8..44c1d3159be0c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php @@ -24,11 +24,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_factory = $objectManagerHelper->getObject( - 'Magento\Catalog\Model\Template\Filter\Factory', + \Magento\Catalog\Model\Template\Filter\Factory::class, ['objectManager' => $this->_objectManagerMock] ); } @@ -40,7 +40,7 @@ protected function setUp() */ public function testCreate() { - $className = 'Magento\Framework\Filter\Template'; + $className = \Magento\Framework\Filter\Template::class; $filterMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects( @@ -64,7 +64,7 @@ public function testCreate() */ public function testCreateWithArguments() { - $className = 'Magento\Framework\Filter\Template'; + $className = \Magento\Framework\Filter\Template::class; $arguments = ['foo', 'bar']; $filterMock = $this->getMock($className, [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php b/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php index 44a9a00716fad..fde1c74bc5ae5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php @@ -39,29 +39,28 @@ class MenuCategoryDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_catalogCategory = $this->getMock( - '\Magento\Catalog\Helper\Category', + $this->_catalogCategory = $this->getMock( + \Magento\Catalog\Helper\Category::class, ['getStoreCategories', 'getCategoryUrl'], [], '', false ); - $layerResolver = $this->getMock('Magento\Catalog\Model\Layer\Resolver', [], [], '', false); + $layerResolver = $this->getMock(\Magento\Catalog\Model\Layer\Resolver::class, [], [], '', false); $layerResolver->expects($this->once())->method('get')->willReturn(null); - $this->_observer = (new ObjectManager($this))->getObject( - 'Magento\Catalog\Observer\MenuCategoryData', + $this->_observer = (new ObjectManager($this))->getObject(\Magento\Catalog\Observer\MenuCategoryData::class, [ 'layerResolver' => $layerResolver, 'catalogCategory' => $this->_catalogCategory, - 'catalogData' => $this->getMock('\Magento\Catalog\Helper\Data', [], [], '', false), + 'catalogData' => $this->getMock(\Magento\Catalog\Helper\Data::class, [], [], '', false), ] ); } public function testGetMenuCategoryData() { - $category = $this->getMock('Magento\Catalog\Model\Category', ['getId', 'getName'], [], '', false); + $category = $this->getMock(\Magento\Catalog\Model\Category::class, ['getId', 'getName'], [], '', false); $category->expects($this->once())->method('getId')->willReturn('id'); $category->expects($this->once())->method('getName')->willReturn('name'); $this->_catalogCategory->expects($this->once())->method('getCategoryUrl')->willReturn('url'); diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php index e0fe2deb232f6..93e9a6f49e9a0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php @@ -45,7 +45,7 @@ class TopmenuTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_catalogCategory = $this->getMock( - '\Magento\Catalog\Helper\Category', + \Magento\Catalog\Helper\Category::class, ['getStoreCategories', 'getCategoryUrl'], [], '', @@ -53,19 +53,19 @@ protected function setUp() ); $this->menuCategoryData = $this->getMock( - 'Magento\Catalog\Observer\MenuCategoryData', + \Magento\Catalog\Observer\MenuCategoryData::class, ['getMenuCategoryData'], [], '', false ); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getRootCategoryId', 'getFilters', '__wakeup']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -75,12 +75,13 @@ protected function setUp() $this->store->expects($this->any())->method('getRootCategoryId') ->will($this->returnValue(1)); - $collectionFactory = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory') + $collectionFactory = $this->getMockBuilder( + \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Category\Collection') + $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class) ->setMethods( [ 'addIsActiveFilter', @@ -125,7 +126,7 @@ protected function _getCleanMock($className) protected function _preparationData() { $this->_childrenCategory = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getIsActive', '__wakeup'], [], '', @@ -134,14 +135,14 @@ protected function _preparationData() $this->_category = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, ['getIsActive', '__wakeup', 'getName', 'getChildren', 'getUseFlatResource', 'getChildrenNodes'], [], '', false ); - $blockMock = $this->_getCleanMock('\Magento\Theme\Block\Html\Topmenu'); + $blockMock = $this->_getCleanMock(\Magento\Theme\Block\Html\Topmenu::class); return $blockMock; } diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php index e67e50d0aa1ef..9d72efbc15b5a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php @@ -21,11 +21,11 @@ class ExecuteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMockBuilder('Magento\PageCache\Model\Config') + $this->config = $this->getMockBuilder(\Magento\PageCache\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isEnabled']) ->getMock(); - $this->typeList = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + $this->typeList = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeListInterface::class) ->disableOriginalConstructor() ->setMethods(['invalidate']) ->getMockForAbstractClass(); @@ -35,11 +35,11 @@ protected function setUp() public function testAfterExecute() { - $subject = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Category\Product\AbstractAction') + $subject = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $result = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Category\Product\AbstractAction') + $result = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -57,11 +57,11 @@ public function testAfterExecute() public function testAfterExecuteInvalidate() { - $subject = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Category\Product\AbstractAction') + $subject = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $result = $this->getMockBuilder('Magento\Catalog\Model\Indexer\Category\Product\AbstractAction') + $result = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php index 3515addebdcaa..52e6d09d24430 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php @@ -15,22 +15,21 @@ public function testAroundUpdateAttributes() $attrData = []; $storeId = 1; - $productActionMock = $this->getMock('Magento\Catalog\Model\Product\Action', [], [], '', false); + $productActionMock = $this->getMock(\Magento\Catalog\Model\Product\Action::class, [], [], '', false); - $cacheContextMock = $this->getMock('Magento\Framework\Indexer\CacheContext', [], [], '', false); + $cacheContextMock = $this->getMock(\Magento\Framework\Indexer\CacheContext::class, [], [], '', false); $cacheContextMock->expects($this->once()) ->method('registerEntities') ->with(Product::CACHE_TAG, $productIds); - - $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $eventManagerMock->expects($this->once()) ->method('dispatch') ->with('clean_cache_by_tags', ['object' => $cacheContextMock]); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $model = $objectManager->getObject( - 'Magento\Catalog\Plugin\Model\Product\Action\UpdateAttributesFlushCache', + \Magento\Catalog\Plugin\Model\Product\Action\UpdateAttributesFlushCache::class, [ 'cacheContext' => $cacheContextMock, 'eventManager' => $eventManagerMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php index a85041087a218..cb01f50605f66 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php @@ -21,11 +21,11 @@ class SaveTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMockBuilder('Magento\PageCache\Model\Config') + $this->config = $this->getMockBuilder(\Magento\PageCache\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isEnabled']) ->getMock(); - $this->typeList = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + $this->typeList = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeListInterface::class) ->disableOriginalConstructor() ->setMethods(['invalidate']) ->getMockForAbstractClass(); @@ -35,10 +35,10 @@ protected function setUp() public function testAroundSaveWithoutInvalidate() { - $subject = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Attribute') + $subject = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Attribute::class) ->disableOriginalConstructor() ->getMock(); - $attribute = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + $attribute = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->disableOriginalConstructor() ->getMock(); $self = $this; @@ -58,10 +58,10 @@ public function testAroundSaveWithoutInvalidate() public function testAroundSave() { - $subject = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Attribute') + $subject = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Attribute::class) ->disableOriginalConstructor() ->getMock(); - $attribute = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Eav\Attribute') + $attribute = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php index 273c993f858ee..01f9964f2d83e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php @@ -24,9 +24,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cache = $this->getMock('Magento\Framework\App\CacheInterface'); - $this->cacheState = $this->getMock('Magento\Framework\App\Cache\StateInterface'); - $this->subject = $this->getMock('Magento\Catalog\Model\ResourceModel\Config', [], [], '', false); + $this->cache = $this->getMock(\Magento\Framework\App\CacheInterface::class); + $this->cacheState = $this->getMock(\Magento\Framework\App\Cache\StateInterface::class); + $this->subject = $this->getMock(\Magento\Catalog\Model\ResourceModel\Config::class, [], [], '', false); } public function testGetAttributesUsedInListingOnCacheDisabled() @@ -162,7 +162,7 @@ protected function getConfig($cacheEnabledFlag) $this->cacheState->expects($this->any())->method('isEnabled') ->with(\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER)->willReturn($cacheEnabledFlag); return (new ObjectManager($this))->getObject( - 'Magento\Catalog\Plugin\Model\ResourceModel\Config', + \Magento\Catalog\Plugin\Model\ResourceModel\Config::class, [ 'cache' => $this->cache, 'cacheState' => $this->cacheState diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php index cb72efc1d75ea..2d32d0ba00444 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php @@ -59,12 +59,18 @@ class BasePriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $qty = 1; - $this->saleableItemMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->priceInfoMock = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); - $this->regularPriceMock = $this->getMock('Magento\Catalog\Pricing\Price\RegularPrice', [], [], '', false); - $this->tearPriceMock = $this->getMock('Magento\Catalog\Pricing\Price\TierPrice', [], [], '', false); - $this->specialPriceMock = $this->getMock('Magento\Catalog\Pricing\Price\SpecialPrice', [], [], '', false); - $this->calculatorMock = $this->getMock('Magento\Framework\Pricing\Adjustment\Calculator', [], [], '', false); + $this->saleableItemMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->regularPriceMock = $this->getMock(\Magento\Catalog\Pricing\Price\RegularPrice::class, [], [], '', false); + $this->tearPriceMock = $this->getMock(\Magento\Catalog\Pricing\Price\TierPrice::class, [], [], '', false); + $this->specialPriceMock = $this->getMock(\Magento\Catalog\Pricing\Price\SpecialPrice::class, [], [], '', false); + $this->calculatorMock = $this->getMock( + \Magento\Framework\Pricing\Adjustment\Calculator::class, + [], + [], + '', + false + ); $this->saleableItemMock->expects($this->once()) ->method('getPriceInfo') @@ -76,7 +82,8 @@ protected function setUp() ]; $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->basePrice = $helper->getObject('Magento\Catalog\Pricing\Price\BasePrice', + $this->basePrice = $helper->getObject( + \Magento\Catalog\Pricing\Price\BasePrice::class, [ 'saleableItem' => $this->saleableItemMock, 'quantity' => $qty, diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php index acc42c91596ca..9f28d07cfdc8c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php @@ -53,25 +53,25 @@ class ConfiguredPriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $basePrice = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface', [], [], '', false); + $basePrice = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class, [], [], '', false); $basePrice->expects($this->any())->method('getValue')->will($this->returnValue($this->basePriceValue)); - $this->priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); + $this->priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); $this->priceInfo->expects($this->any())->method('getPrice')->will($this->returnValue($basePrice)); - $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getPriceInfo', 'getOptionById', 'getResource', '__wakeup']) ->disableOriginalConstructor() ->getMock(); $this->product->expects($this->once())->method('getPriceInfo')->will($this->returnValue($this->priceInfo)); - $this->item = $this->getMockBuilder('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface') + $this->item = $this->getMockBuilder(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class) ->getMock(); $this->item->expects($this->any())->method('getProduct')->will($this->returnValue($this->product)); - $this->calculator = $this->getMock('Magento\Framework\Pricing\Adjustment\Calculator', [], [], '', false); + $this->calculator = $this->getMock(\Magento\Framework\Pricing\Adjustment\Calculator::class, [], [], '', false); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->model = new ConfiguredPrice($this->product, 1, $this->calculator, $this->priceCurrencyMock); $this->model->setItem($this->item); @@ -82,7 +82,9 @@ protected function setUp() */ public function testOptionsValueGetter() { - $optionCollection = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface'); + $optionCollection = $this->getMock( + \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class + ); $optionCollection->expects($this->any())->method('getValue')->will($this->returnValue('1,2,3')); $optionCallback = $this->returnCallback(function ($optionId) { @@ -90,7 +92,7 @@ public function testOptionsValueGetter() }); $this->product->expects($this->any())->method('getOptionById')->will($optionCallback); - $itemOption = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface'); + $itemOption = $this->getMock(\Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class); $optionsList = [ 'option_1' => $itemOption, 'option_2' => $itemOption, @@ -111,7 +113,7 @@ public function testOptionsValueGetter() */ protected function createProductOptionStub($optionId) { - $option = $this->getMock('Magento\Catalog\Model\Product\Option', [], [], '', false); + $option = $this->getMock(\Magento\Catalog\Model\Product\Option::class, [], [], '', false); $option->expects($this->any())->method('getId')->will($this->returnValue($optionId)); $option->expects($this->atLeastOnce())->method('groupFactory')->will( $this->returnValue($this->createOptionTypeStub($option)) @@ -125,7 +127,7 @@ protected function createProductOptionStub($optionId) */ protected function createOptionTypeStub(\Magento\Catalog\Model\Product\Option $option) { - $optionType = $this->getMockBuilder('Magento\Catalog\Model\Product\Option\Type\DefaultType') + $optionType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Type\DefaultType::class) ->setMethods(['setOption', 'setConfigurationItem', 'setConfigurationItemOption', 'getOptionPrice']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php index 72529750e87a5..bd50f02ad82e1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php @@ -13,6 +13,8 @@ /** * Class OptionPriceTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CustomOptionPriceTest extends \PHPUnit_Framework_TestCase { @@ -52,7 +54,7 @@ class CustomOptionPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getOptionById', '__wakeup', 'getPriceInfo', 'getOptions'], [], '', @@ -60,7 +62,7 @@ protected function setUp() ); $this->priceInfo = $this->getMock( - 'Magento\Framework\Pricing\PriceInfo\Base', + \Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', @@ -72,7 +74,7 @@ protected function setUp() ->will($this->returnValue($this->priceInfo)); $this->calculator = $this->getMock( - 'Magento\Framework\Pricing\Adjustment\Calculator', + \Magento\Framework\Pricing\Adjustment\Calculator::class, [], [], '', @@ -80,14 +82,14 @@ protected function setUp() ); $this->amount = $this->getMock( - 'Magento\Framework\Pricing\Amount\Base', + \Magento\Framework\Pricing\Amount\Base::class, [], [], '', false ); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->object = new CustomOptionPrice( $this->product, @@ -104,7 +106,7 @@ protected function setupOptions(array $optionsData) $optionValueMax = $this->getOptionValueMock($optionData['max_option_price']); $optionValueMin = $this->getOptionValueMock($optionData['min_option_price']); - $optionItemMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $optionItemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(['getValues', '__wakeup', 'getIsRequire', 'getId', 'getType']) ->getMock(); @@ -129,7 +131,7 @@ protected function setupSingleValueOptions($optionsData) { $options = []; foreach ($optionsData as $optionData) { - $optionItemMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $optionItemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods([ 'getValues', @@ -297,7 +299,7 @@ public function testGetCustomOptionRange() */ protected function getOptionValueMock($price) { - $optionValueMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option\Value') + $optionValueMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Value::class) ->disableOriginalConstructor() ->setMethods(['getPriceType', 'getPrice', 'getId', '__wakeup']) ->getMock(); @@ -320,15 +322,15 @@ public function testGetSelectedOptions() $optionId2 = 2; $optionValue = 10; $optionType = 'select'; - $optionValueMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option\DefaultType') + $optionValueMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\DefaultType::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); - $optionMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $optionMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getType', 'groupFactory', '__wakeup']) ->getMock(); - $groupMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option\Type\Select') + $groupMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Type\Select::class) ->disableOriginalConstructor() ->setMethods(['setOption', 'setConfigurationItemOption', 'getOptionPrice']) ->getMock(); @@ -398,7 +400,7 @@ public function testGetOptions() $optionValueMock->expects($this->once()) ->method('getId') ->will($this->returnValue($id)); - $optionItemMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option') + $optionItemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) ->disableOriginalConstructor() ->setMethods(['getValues', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php index be1d6b3e2e11f..5ad3be93e5567 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php @@ -45,16 +45,16 @@ class FinalPriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->saleableMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $this->saleableMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->priceInfoMock = $this->basePriceMock = $this->getMock( - 'Magento\Framework\Pricing\PriceInfo\Base', + \Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false ); $this->basePriceMock = $this->getMock( - 'Magento\Catalog\Pricing\Price\BasePrice', + \Magento\Catalog\Pricing\Price\BasePrice::class, [], [], '', @@ -62,7 +62,7 @@ protected function setUp() ); $this->calculatorMock = $this->getMock( - 'Magento\Framework\Pricing\Adjustment\Calculator', + \Magento\Framework\Pricing\Adjustment\Calculator::class, [], [], '', @@ -76,7 +76,7 @@ protected function setUp() ->method('getPrice') ->with($this->equalTo(\Magento\Catalog\Pricing\Price\BasePrice::PRICE_CODE)) ->will($this->returnValue($this->basePriceMock)); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->model = new \Magento\Catalog\Pricing\Price\FinalPrice( $this->saleableMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php index c1fe48971689b..09988088c1632 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php @@ -44,16 +44,21 @@ class RegularPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $qty = 1; - $this->saleableItemMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $this->priceInfoMock = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); - $this->amountMock = $this->getMock('Magento\Framework\Pricing\Amount', [], [], '', false); - $this->calculatorMock = $this->getMock('Magento\Framework\Pricing\Adjustment\Calculator', [], [], '', false); + $this->saleableItemMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->calculatorMock = $this->getMock( + \Magento\Framework\Pricing\Adjustment\Calculator::class, + [], + [], + '', + false + ); $this->saleableItemMock->expects($this->once()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->regularPrice = new RegularPrice( $this->saleableItemMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php index 9f1425ff0781e..b46b589856e5a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php @@ -20,7 +20,7 @@ class SpecialPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } @@ -36,7 +36,7 @@ public function testGetValue($isValidInterval, $specialPrice, $specialPriceValue { $expected = 56.34; $specialPriceModel = $this->objectManager->getObject( - 'Magento\Catalog\Pricing\Price\SpecialPrice', + \Magento\Catalog\Pricing\Price\SpecialPrice::class, [ 'saleableItem' => $this->prepareSaleableItem($specialPrice), 'localeDate' => $this->prepareLocaleDate($isValidInterval), @@ -63,7 +63,7 @@ public function testGetValue($isValidInterval, $specialPrice, $specialPriceValue protected function prepareSaleableItem($specialPrice) { $saleableItemMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getSpecialPrice', 'getPriceInfo', 'getStore', '__wakeup'], [], '', @@ -75,7 +75,7 @@ protected function prepareSaleableItem($specialPrice) ->will($this->returnValue($specialPrice)); $priceInfo = $this->getMockBuilder( - 'Magento\Framework\Pricing\PriceInfoInterface' + \Magento\Framework\Pricing\PriceInfoInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $priceInfo->expects($this->any()) @@ -96,7 +96,7 @@ protected function prepareSaleableItem($specialPrice) protected function prepareLocaleDate($isValidInterval) { $localeDate = $this->getMockBuilder( - 'Magento\Framework\Stdlib\DateTime\TimezoneInterface' + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class )->disableOriginalConstructor()->getMockForAbstractClass(); $localeDate->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php index fce88c3a3fea7..27aa2d0e1615a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php @@ -15,6 +15,8 @@ /** * Test for \Magento\Catalog\Pricing\Price\TierPrice + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class TierPriceTest extends \PHPUnit_Framework_TestCase { @@ -70,10 +72,10 @@ class TierPriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); + $this->priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); $this->product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getPriceInfo', 'hasCustomerGroupId', 'getCustomerGroupId', 'getResource', '__wakeup'], [], '', @@ -81,20 +83,20 @@ protected function setUp() ); $this->product->expects($this->any())->method('getPriceInfo')->will($this->returnValue($this->priceInfo)); - $this->session = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->session = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->session->expects($this->any())->method('getCustomerGroupId') ->will($this->returnValue($this->customerGroup)); - $this->calculator = $this->getMock('Magento\Framework\Pricing\Adjustment\Calculator', [], [], '', false); + $this->calculator = $this->getMock(\Magento\Framework\Pricing\Adjustment\Calculator::class, [], [], '', false); $this->groupManagement = $this->getMock( - 'Magento\Customer\Api\GroupManagementInterface', + \Magento\Customer\Api\GroupManagementInterface::class, [], [], '', false ); - $this->priceCurrencyMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->model = new TierPrice( $this->product, @@ -128,7 +130,7 @@ function ($arg) { ); $this->product->setData(TierPrice::PRICE_CODE, $tierPrices); $group = $this->getMock( - '\Magento\Customer\Model\Data\Group', + \Magento\Customer\Model\Data\Group::class, [], [], '', @@ -217,12 +219,24 @@ public function testGetterStoredTierPrices() $this->product->expects($this->once())->method('getCustomerGroupId') ->will($this->returnValue($this->customerGroup)); - $backendMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', [], [], '', false); + $backendMock = $this->getMock( + \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, + [], + [], + '', + false + ); - $attributeMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\AbstractAttribute', [], [], '', false); + $attributeMock = $this->getMock( + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, + [], + [], + '', + false + ); $attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($backendMock)); - $productResource = $this->getMock('Magento\Catalog\Model\ResourceModel\Product', [], [], '', false); + $productResource = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); $productResource->expects($this->once())->method('getAttribute')->with(TierPrice::PRICE_CODE) ->will($this->returnValue($attributeMock)); @@ -237,7 +251,7 @@ public function testGetterStoredTierPrices() $this->groupManagement ); $group = $this->getMock( - '\Magento\Customer\Model\Data\Group', + \Magento\Customer\Model\Data\Group::class, [], [], '', @@ -264,7 +278,7 @@ public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult { $this->product->setData(TierPrice::PRICE_CODE, $tierPrices); - $price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface', [], [], '', false); + $price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class, [], [], '', false); $price->expects($this->any())->method('getValue')->will($this->returnValue($basePrice)); $this->calculator->expects($this->atLeastOnce())->method('getAmount') @@ -284,7 +298,7 @@ function ($arg) { ); $group = $this->getMock( - '\Magento\Customer\Model\Data\Group', + \Magento\Customer\Model\Data\Group::class, [], [], '', @@ -368,7 +382,7 @@ public function providerForGetterTierPriceList() */ public function testGetSavePercent($basePrice, $tierPrice, $savedPercent) { - $price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface'); + $price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); $this->priceInfo->expects(static::atLeastOnce()) ->method('getPrice') @@ -378,7 +392,7 @@ public function testGetSavePercent($basePrice, $tierPrice, $savedPercent) ->method('getValue') ->willReturn($basePrice); - $amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); + $amount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); $amount->expects($this->atLeastOnce()) ->method('getBaseAmount') ->will($this->returnValue($tierPrice)); diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index 859f510024b81..cffe17edb42b3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -8,6 +8,8 @@ /** * Class FinalPriceBoxTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase { @@ -59,23 +61,22 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->product = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getPriceInfo', '__wakeup', 'getCanShowPrice'], [], '', false ); - $this->priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo', ['getPrice'], [], '', false); + $this->priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfoInterface::class); $this->product->expects($this->any()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfo)); - $eventManager = $this->getMock('Magento\Framework\Event\Test\Unit\ManagerStub', [], [], '', false); - $config = $this->getMock('Magento\Store\Model\Store\Config', [], [], '', false); - $this->layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\Test\Unit\ManagerStub::class, [], [], '', false); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $this->priceBox = $this->getMock('Magento\Framework\Pricing\Render\PriceBox', [], [], '', false); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); + $this->priceBox = $this->getMock(\Magento\Framework\Pricing\Render\PriceBox::class, [], [], '', false); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); $this->layout->expects($this->any()) ->method('getBlock') @@ -84,14 +85,11 @@ protected function setUp() $cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class) ->getMockForAbstractClass(); - $scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any()) ->method('getEventManager') ->will($this->returnValue($eventManager)); - $context->expects($this->any()) - ->method('getStoreConfig') - ->will($this->returnValue($config)); $context->expects($this->any()) ->method('getLayout') ->will($this->returnValue($this->layout)); @@ -105,18 +103,18 @@ protected function setUp() ->method('getCacheState') ->will($this->returnValue($cacheState)); - $this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool') + $this->rendererPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class) ->disableOriginalConstructor() ->getMock(); - $this->price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface'); + $this->price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); $this->price->expects($this->any()) ->method('getPriceCode') ->will($this->returnValue(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->object = $objectManager->getObject( - 'Magento\Catalog\Pricing\Render\FinalPriceBox', + \Magento\Catalog\Pricing\Render\FinalPriceBox::class, [ 'context' => $context, 'saleableItem' => $this->product, @@ -129,7 +127,7 @@ protected function setUp() public function testRenderMsrpDisabled() { - $priceType = $this->getMock('Magento\Msrp\Pricing\Price\MsrpPrice', [], [], '', false); + $priceType = $this->getMock(\Magento\Msrp\Pricing\Price\MsrpPrice::class, [], [], '', false); $this->priceInfo->expects($this->once()) ->method('getPrice') ->with($this->equalTo('msrp_price')) @@ -150,7 +148,7 @@ public function testRenderMsrpDisabled() public function testRenderMsrpEnabled() { - $priceType = $this->getMock('Magento\Msrp\Pricing\Price\MsrpPrice', [], [], '', false); + $priceType = $this->getMock(\Magento\Msrp\Pricing\Price\MsrpPrice::class, [], [], '', false); $this->priceInfo->expects($this->once()) ->method('getPrice') ->with($this->equalTo('msrp_price')) @@ -166,7 +164,7 @@ public function testRenderMsrpEnabled() ->with($this->equalTo($this->product)) ->will($this->returnValue(true)); - $priceBoxRender = $this->getMockBuilder('Magento\Framework\Pricing\Render\PriceBox') + $priceBoxRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\PriceBox::class) ->disableOriginalConstructor() ->getMock(); $priceBoxRender->expects($this->once()) @@ -211,8 +209,8 @@ public function testRenderMsrpNotRegisteredException() public function testRenderAmountMinimal() { - $priceType = $this->getMock('Magento\Catalog\Pricing\Price\FinalPrice', [], [], '', false); - $amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); + $priceType = $this->getMock(\Magento\Catalog\Pricing\Price\FinalPrice::class, [], [], '', false); + $amount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); $priceId = 'price_id'; $html = 'html'; $this->object->setData('price_id', $priceId); @@ -225,7 +223,7 @@ public function testRenderAmountMinimal() 'skip_adjustments' => true, ]; - $amountRender = $this->getMock('Magento\Framework\Pricing\Render\Amount', ['toHtml'], [], '', false); + $amountRender = $this->getMock(\Magento\Framework\Pricing\Render\Amount::class, ['toHtml'], [], '', false); $amountRender->expects($this->once()) ->method('toHtml') ->will($this->returnValue($html)); @@ -255,10 +253,10 @@ public function testRenderAmountMinimal() */ public function testHasSpecialPrice($regularPrice, $finalPrice, $expectedResult) { - $regularPriceType = $this->getMock('Magento\Catalog\Pricing\Price\RegularPrice', [], [], '', false); - $finalPriceType = $this->getMock('Magento\Catalog\Pricing\Price\FinalPrice', [], [], '', false); - $regularPriceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); - $finalPriceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); + $regularPriceType = $this->getMock(\Magento\Catalog\Pricing\Price\RegularPrice::class, [], [], '', false); + $finalPriceType = $this->getMock(\Magento\Catalog\Pricing\Price\FinalPrice::class, [], [], '', false); + $regularPriceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); + $finalPriceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); $regularPriceAmount->expects($this->once()) ->method('getValue') @@ -303,10 +301,10 @@ public function testShowMinimalPrice() $this->object->setDisplayMinimalPrice($displayMininmalPrice); - $finalPriceType = $this->getMock('Magento\Catalog\Pricing\Price\FinalPrice', [], [], '', false); + $finalPriceType = $this->getMock(\Magento\Catalog\Pricing\Price\FinalPrice::class, [], [], '', false); - $finalPriceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); - $minimalPriceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface'); + $finalPriceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); + $minimalPriceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); $finalPriceAmount->expects($this->once()) ->method('getValue') diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php index 14dd4d8be0b5a..1e8b930a0c491 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php @@ -28,12 +28,18 @@ class PriceBoxTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->jsonHelperMock = $this->getMock('Magento\Framework\Json\Helper\Data', ['jsonEncode'], [], '', false); - $this->mathRandom = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); + $this->jsonHelperMock = $this->getMock( + \Magento\Framework\Json\Helper\Data::class, + ['jsonEncode'], + [], + '', + false + ); + $this->mathRandom = $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->object = $objectManager->getObject( - 'Magento\Catalog\Pricing\Render\PriceBox', + \Magento\Catalog\Pricing\Render\PriceBox::class, [ 'jsonHelper' => $this->jsonHelperMock, 'mathRandom' => $this->mathRandom, @@ -79,7 +85,7 @@ public function testGetRandomString() */ public function testGetCanDisplayQty($typeCode, $expected) { - $product = $this->getMock('Magento\Catalog\Model\Product', ['getTypeId', '__wakeup'], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getTypeId', '__wakeup'], [], '', false); $product->expects($this->once()) ->method('getTypeId') diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php index 5dcb411db93d4..3713bae7d3777 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php @@ -33,22 +33,18 @@ class RenderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registry = $this->getMock('Magento\Framework\Registry', ['registry'], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class, ['registry'], [], '', false); - $this->pricingRenderBlock = $this->getMock('Magento\Framework\Pricing\Render', [], [], '', false); + $this->pricingRenderBlock = $this->getMock(\Magento\Framework\Pricing\Render::class, [], [], '', false); - $this->layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Test\Unit\ManagerStub', [], [], '', false); - $config = $this->getMock('Magento\Store\Model\Store\Config', [], [], '', false); - $scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\Test\Unit\ManagerStub::class, [], [], '', false); + $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $context->expects($this->any()) ->method('getEventManager') ->will($this->returnValue($eventManager)); - $context->expects($this->any()) - ->method('getStoreConfig') - ->will($this->returnValue($config)); $context->expects($this->any()) ->method('getLayout') ->will($this->returnValue($this->layout)); @@ -58,7 +54,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->object = $objectManager->getObject( - 'Magento\Catalog\Pricing\Render', + \Magento\Catalog\Pricing\Render::class, [ 'context' => $context, 'registry' => $this->registry, @@ -75,7 +71,7 @@ public function testToHtmlProductFromRegistry() { $expectedValue = 'string'; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->layout->expects($this->any()) ->method('getBlock') @@ -104,12 +100,12 @@ public function testToHtmlProductFromParentBlock() { $expectedValue = 'string'; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->registry->expects($this->never()) ->method('registry'); - $block = $this->getMock('Magento\Framework\Pricing\Render', ['getProductItem', 'render'], [], '', false); + $block = $this->getMock(\Magento\Framework\Pricing\Render::class, ['getProductItem', 'render'], [], '', false); $arguments = $this->object->getData(); $arguments['render_block'] = $this->object; diff --git a/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php b/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php index 69d7ee6157ad5..7b72b391e765b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php @@ -13,7 +13,7 @@ class CategorySetupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->unit = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Catalog\Setup\CategorySetup' + \Magento\Catalog\Setup\CategorySetup::class ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index 51d3ec6009e51..ea575cf8ab48c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -301,7 +301,7 @@ public function testModifyData() $this->sortOrderBuilderMock->expects($this->once()) ->method('setAscendingDirection') ->willReturnSelf(); - $dataObjectMock = $this->getMock('\Magento\Framework\Api\AbstractSimpleObject', [], [], '', false); + $dataObjectMock = $this->getMock(\Magento\Framework\Api\AbstractSimpleObject::class, [], [], '', false); $this->sortOrderBuilderMock->expects($this->once()) ->method('create') ->willReturn($dataObjectMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php index e32c837c34c22..5ec8f0c1fcf7a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php @@ -44,9 +44,10 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->model = $this->objectManager->getObject(\Magento\Ui\DataProvider\Modifier\ModifierFactory::class, [ - 'objectManager' => $this->objectManagerMock, - ]); + $this->model = $this->objectManager->getObject( + \Magento\Ui\DataProvider\Modifier\ModifierFactory::class, + ['objectManager' => $this->objectManagerMock] + ); } public function testCreate() diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php index 130e64932f151..deaadb0f12f95 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php @@ -78,15 +78,15 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); $this->assignedWebsites = [self::SECOND_WEBSITE_ID]; - $this->websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $this->websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->setMethods(['getId', 'getName']) ->disableOriginalConstructor() ->getMock(); - $this->secondWebsiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $this->secondWebsiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->setMethods(['getId', 'getName']) ->disableOriginalConstructor() ->getMock(); - $this->websiteRepositoryMock = $this->getMockBuilder('Magento\Store\Api\WebsiteRepositoryInterface') + $this->websiteRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\WebsiteRepositoryInterface::class) ->setMethods(['getList', 'getDefault']) ->getMockForAbstractClass(); $this->websiteRepositoryMock->expects($this->any()) @@ -95,16 +95,16 @@ protected function setUp() $this->websiteRepositoryMock->expects($this->any()) ->method('getList') ->willReturn([$this->websiteMock, $this->secondWebsiteMock]); - $this->groupRepositoryMock = $this->getMockBuilder('Magento\Store\Api\GroupRepositoryInterface') + $this->groupRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\GroupRepositoryInterface::class) ->setMethods(['getList']) ->getMockForAbstractClass(); - $this->storeRepositoryMock = $this->getMockBuilder('Magento\Store\Api\StoreRepositoryInterface') + $this->storeRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class) ->setMethods(['getList']) ->getMockForAbstractClass(); - $this->locatorMock = $this->getMockBuilder('Magento\Catalog\Model\Locator\LocatorInterface') + $this->locatorMock = $this->getMockBuilder(\Magento\Catalog\Model\Locator\LocatorInterface::class) ->setMethods(['getProduct', 'getWebsiteIds']) ->getMockForAbstractClass(); - $this->productMock = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductInterface') + $this->productMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class) ->setMethods(['getId']) ->getMockForAbstractClass(); $this->locatorMock->expects($this->any()) @@ -113,13 +113,13 @@ protected function setUp() $this->locatorMock->expects($this->any()) ->method('getWebsiteIds') ->willReturn($this->assignedWebsites); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->setMethods(['isSingleStoreMode']) ->getMockForAbstractClass(); $this->storeManagerMock->expects($this->any()) ->method('isSingleStoreMode') ->willReturn(false); - $this->groupMock = $this->getMockBuilder('Magento\Store\Model\ResourceModel\Group\Collection') + $this->groupMock = $this->getMockBuilder(\Magento\Store\Model\ResourceModel\Group\Collection::class) ->setMethods(['getId', 'getName', 'getWebsiteId']) ->disableOriginalConstructor() ->getMock(); @@ -132,7 +132,7 @@ protected function setUp() $this->groupRepositoryMock->expects($this->any()) ->method('getList') ->willReturn([$this->groupMock]); - $this->storeViewMock = $this->getMockBuilder('Magento\Store\Model\Store') + $this->storeViewMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getName', 'getId', 'getStoreGroupId']) ->disableOriginalConstructor() ->getMock(); @@ -164,13 +164,16 @@ protected function setUp() */ protected function createModel() { - return $this->objectManager->getObject(Websites::class, [ - 'locator' => $this->locatorMock, - 'storeManager' => $this->storeManagerMock, - 'websiteRepository' => $this->websiteRepositoryMock, - 'groupRepository' => $this->groupRepositoryMock, - 'storeRepository' => $this->storeRepositoryMock, - ]); + return $this->objectManager->getObject( + Websites::class, + [ + 'locator' => $this->locatorMock, + 'storeManager' => $this->storeManagerMock, + 'websiteRepository' => $this->websiteRepositoryMock, + 'groupRepository' => $this->groupRepositoryMock, + 'storeRepository' => $this->storeRepositoryMock, + ] + ); } /** From 8e922431eb1520c8d1f3ae6bc67b3ade81429da9 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:29:08 +0300 Subject: [PATCH 17/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Test/Unit/Block/NavigationTest.php | 14 +- .../Unit/Model/Aggregation/StatusTest.php | 5 +- .../Controller/Adminhtml/Partners/Index.php | 2 +- .../Test/Unit/Block/PartnersTest.php | 4 +- .../Test/Unit/Controller/Index/IndexTest.php | 10 +- .../Unit/Controller/Partners/IndexTest.php | 12 +- .../Test/Unit/Helper/CacheTest.php | 4 +- .../Test/Unit/Model/PartnersTest.php | 8 +- .../NewRelicReporting/Model/Counts.php | 2 +- .../NewRelicReporting/Model/Module.php | 2 +- .../NewRelicReporting/Model/Orders.php | 2 +- .../Model/ResourceModel/Counts/Collection.php | 5 +- .../Model/ResourceModel/Module/Collection.php | 5 +- .../Model/ResourceModel/Orders/Collection.php | 5 +- .../Model/ResourceModel/System/Collection.php | 5 +- .../Model/ResourceModel/Users/Collection.php | 5 +- .../NewRelicReporting/Model/System.php | 2 +- .../Magento/NewRelicReporting/Model/Users.php | 2 +- .../Test/Unit/Model/Apm/DeploymentsTest.php | 16 +- .../Test/Unit/Model/CounterTest.php | 13 +- .../Test/Unit/Model/Cron/ReportCountsTest.php | 16 +- .../Unit/Model/Cron/ReportModulesInfoTest.php | 10 +- .../Model/Cron/ReportNewRelicCronTest.php | 19 +- .../Test/Unit/Model/CronEventTest.php | 18 +- .../Test/Unit/Model/CronTest.php | 16 +- .../Test/Unit/Model/Module/CollectTest.php | 33 ++-- .../Unit/Model/Observer/CheckConfigTest.php | 12 +- .../Observer/ReportConcurrentAdminsTest.php | 18 +- .../ReportConcurrentAdminsToNewRelicTest.php | 14 +- .../Observer/ReportConcurrentUsersTest.php | 30 ++-- .../ReportConcurrentUsersToNewRelicTest.php | 30 ++-- .../Model/Observer/ReportOrderPlacedTest.php | 14 +- .../ReportOrderPlacedToNewRelicTest.php | 12 +- .../Observer/ReportProductDeletedTest.php | 16 +- .../ReportProductDeletedToNewRelicTest.php | 8 +- .../Model/Observer/ReportProductSavedTest.php | 22 +-- .../ReportProductSavedToNewRelicTest.php | 18 +- .../Observer/ReportSystemCacheFlushTest.php | 12 +- .../ReportSystemCacheFlushToNewRelicTest.php | 17 +- .../OfflinePayments/Model/Banktransfer.php | 4 +- .../OfflinePayments/Model/Cashondelivery.php | 4 +- .../Magento/OfflinePayments/Model/Checkmo.php | 4 +- .../OfflinePayments/Model/Purchaseorder.php | 4 +- .../Block/Form/AbstractInstructionTest.php | 6 +- .../Test/Unit/Block/Info/CheckmoTest.php | 8 +- .../Test/Unit/Model/BanktransferTest.php | 16 +- .../Test/Unit/Model/CashondeliveryTest.php | 16 +- .../Unit/Model/CheckmoConfigProviderTest.php | 6 +- .../Test/Unit/Model/CheckmoTest.php | 8 +- .../Model/InstructionsConfigProviderTest.php | 8 +- .../Test/Unit/Model/PurchaseorderTest.php | 10 +- .../BeforeOrderPaymentSaveObserverTest.php | 24 +-- .../Block/Adminhtml/Form/Field/Export.php | 4 +- .../System/Config/ExportTablerates.php | 2 +- .../Carrier/Tablerate/Collection.php | 4 +- .../Adminhtml/Carrier/Tablerate/GridTest.php | 22 +-- .../Block/Adminhtml/Form/Field/ExportTest.php | 16 +- .../Block/Adminhtml/Form/Field/ImportTest.php | 4 +- .../Model/Config/Backend/TablerateTest.php | 11 +- .../Model/Config/Source/TablerateTest.php | 9 +- .../Checkout/Block/Cart/ShippingTest.php | 11 +- .../Unit/Model/SalesRule/CalculatorTest.php | 8 +- .../Block/System/Config/Form/Field/Export.php | 2 +- .../PageCache/Observer/FlushAllCache.php | 2 +- .../PageCache/Observer/FlushCacheByTags.php | 2 +- .../Unit/App/CacheIdentifierPluginTest.php | 8 +- .../Test/Unit/Block/JavascriptTest.php | 12 +- .../PageCache/ExportVarnishConfigTest.php | 18 +- .../Test/Unit/Controller/Block/EsiTest.php | 23 ++- .../Test/Unit/Controller/Block/RenderTest.php | 34 ++-- .../App/FrontController/BuiltinPluginTest.php | 16 +- .../App/FrontController/VarnishPluginTest.php | 16 +- .../Unit/Model/App/PageCachePluginTest.php | 4 +- .../Model/App/Response/HttpPluginTest.php | 4 +- .../Test/Unit/Model/Cache/ServerTest.php | 10 +- .../Test/Unit/Model/Cache/TypeTest.php | 8 +- .../PageCache/Test/Unit/Model/ConfigTest.php | 16 +- .../Controller/Result/BuiltinPluginTest.php | 22 +-- .../Controller/Result/VarnishPluginTest.php | 16 +- .../Unit/Model/DepersonalizeCheckerTest.php | 8 +- .../Model/Layout/DepersonalizePluginTest.php | 15 +- .../Unit/Model/Layout/LayoutPluginTest.php | 14 +- .../Test/Unit/Observer/FlushAllCacheTest.php | 10 +- .../Unit/Observer/FlushCacheByTagsTest.php | 20 +-- .../Observer/FlushFormKeyOnLogoutTest.php | 4 +- .../Unit/Observer/InvalidateCacheTest.php | 6 +- .../ProcessLayoutRenderElementTest.php | 20 +-- .../RegisterFormKeyFromCookieTest.php | 14 +- .../Payment/Block/Info/Substitution.php | 2 +- .../Gateway/Data/PaymentDataObjectFactory.php | 2 +- .../Payment/Model/Cart/SalesModel/Factory.php | 4 +- .../Payment/Model/Method/AbstractMethod.php | 4 +- app/code/Magento/Payment/Model/Method/Cc.php | 4 +- .../Payment/Model/Method/Substitution.php | 2 +- .../Block/Adminhtml/Transparent/FormTest.php | 16 +- .../Test/Unit/Block/Form/ContainerTest.php | 6 +- .../Payment/Test/Unit/Block/FormTest.php | 26 +-- .../Payment/Test/Unit/Block/Info/CcTest.php | 42 ++++- .../Unit/Block/Info/ContainerAbstractTest.php | 8 +- .../Test/Unit/Block/Info/InstructionsTest.php | 6 +- .../Test/Unit/Block/Info/SubstitutionTest.php | 21 ++- .../Payment/Test/Unit/Block/InfoTest.php | 22 ++- .../Test/Unit/Block/Transparent/FormTest.php | 27 +-- .../Unit/Gateway/Command/CommandPoolTest.php | 16 +- .../Gateway/Command/GatewayCommandTest.php | 13 +- .../Test/Unit/Gateway/Config/ConfigTest.php | 2 +- .../Gateway/Config/ConfigValueHandlerTest.php | 2 +- .../Gateway/Config/ValueHandlerPoolTest.php | 19 +- .../Gateway/Data/Order/AddressAdapterTest.php | 2 +- .../Gateway/Data/Order/OrderAdapterTest.php | 12 +- .../Data/PaymentDataObjectFactoryTest.php | 24 +-- .../Gateway/Data/PaymentDataObjectTest.php | 4 +- .../Gateway/Data/Quote/AddressAdapterTest.php | 2 +- .../Gateway/Data/Quote/QuoteAdapterTest.php | 20 ++- .../Unit/Gateway/Http/Client/SoapTest.php | 10 +- .../Unit/Gateway/Http/Client/ZendTest.php | 18 +- .../Gateway/Request/BuilderCompositeTest.php | 26 +-- .../Gateway/Response/HandlerChainTest.php | 16 +- .../Validator/CountryValidatorTest.php | 10 +- .../Unit/Gateway/Validator/ResultTest.php | 2 +- .../Validator/ValidatorCompositeTest.php | 25 ++- .../Gateway/Validator/ValidatorPoolTest.php | 16 +- .../Payment/Test/Unit/Helper/DataTest.php | 31 ++-- .../Model/Cart/SalesModel/FactoryTest.php | 6 +- .../Unit/Model/Cart/SalesModel/OrderTest.php | 2 +- .../Unit/Model/Cart/SalesModel/QuoteTest.php | 8 +- .../Payment/Test/Unit/Model/CartTest.php | 6 +- .../Test/Unit/Model/CcConfigProviderTest.php | 6 +- .../Payment/Test/Unit/Model/CcConfigTest.php | 10 +- .../Model/CcGenericConfigProviderTest.php | 4 +- .../Unit/Model/Checks/CanUseCheckoutTest.php | 4 +- .../CanUseForCountry/CountryProviderTest.php | 14 +- .../Model/Checks/CanUseForCountryTest.php | 6 +- .../Model/Checks/CanUseForCurrencyTest.php | 6 +- .../Unit/Model/Checks/CanUseInternalTest.php | 4 +- .../Test/Unit/Model/Checks/CompositeTest.php | 6 +- .../Model/Checks/SpecificationFactoryTest.php | 6 +- .../Unit/Model/Checks/TotalMinMaxTest.php | 4 +- .../Test/Unit/Model/Checks/ZeroTotalTest.php | 4 +- .../Unit/Model/Config/SchemaLocatorTest.php | 2 +- .../Model/Config/Source/AllmethodsTest.php | 2 +- .../Unit/Model/Config/Source/CctypeTest.php | 2 +- .../Payment/Test/Unit/Model/ConfigTest.php | 20 +-- .../Payment/Test/Unit/Model/InfoTest.php | 20 ++- .../Unit/Model/Method/AbstractMethodTest.php | 13 +- .../Test/Unit/Model/Method/AdapterTest.php | 25 +-- .../Test/Unit/Model/Method/FactoryTest.php | 8 +- .../Test/Unit/Model/Method/FreeTest.php | 39 ++-- .../Test/Unit/Model/Method/LoggerTest.php | 2 +- .../Method/Specification/CompositeTest.php | 8 +- .../Method/Specification/FactoryTest.php | 6 +- .../Unit/Model/Method/SubstitutionTest.php | 4 +- .../Test/Unit/Model/MethodListTest.php | 20 +-- .../ResourceModel/Grid/GroupListTest.php | 2 +- .../Model/ResourceModel/Grid/TypeListTest.php | 2 +- .../Test/Unit/Model/Source/CctypeTest.php | 2 +- .../SalesOrderBeforeSaveObserverTest.php | 12 +- ...derStatusForPaymentMethodsObserverTest.php | 22 ++- .../Block/Adminhtml/Settlement/Details.php | 2 +- .../Paypal/Block/Billing/Agreement/View.php | 2 +- .../Paypal/Block/Billing/Agreements.php | 2 +- .../Magento/Paypal/Block/Express/Form.php | 2 +- .../Paypal/Block/Express/Review/Billing.php | 2 +- .../Adminhtml/Billing/Agreement.php | 4 +- .../Adminhtml/Paypal/Reports/Details.php | 2 +- .../Paypal/Controller/Billing/Agreement.php | 4 +- .../Billing/Agreement/ReturnWizard.php | 4 +- .../Billing/Agreement/StartWizard.php | 8 +- .../ShippingOptionsCallback.php | 2 +- .../Paypal/Controller/Express/Cancel.php | 4 +- .../Paypal/Controller/Express/Edit.php | 4 +- .../Paypal/Controller/Express/GetToken.php | 4 +- .../Paypal/Controller/Express/PlaceOrder.php | 4 +- .../Controller/Express/ReturnAction.php | 4 +- .../Paypal/Controller/Express/Review.php | 4 +- .../Controller/Express/SaveShippingMethod.php | 4 +- .../Express/ShippingOptionsCallback.php | 4 +- .../Paypal/Controller/Express/Start.php | 4 +- .../Express/UpdateShippingMethods.php | 4 +- .../Controller/Hostedpro/ReturnAction.php | 2 +- .../Controller/Payflowexpress/Cancel.php | 4 +- .../Paypal/Controller/Payflowexpress/Edit.php | 4 +- .../Controller/Payflowexpress/PlaceOrder.php | 4 +- .../Payflowexpress/ReturnAction.php | 4 +- .../Controller/Payflowexpress/Review.php | 4 +- .../Payflowexpress/SaveShippingMethod.php | 4 +- .../ShippingOptionsCallback.php | 4 +- .../Controller/Payflowexpress/Start.php | 4 +- .../Payflowexpress/UpdateShippingMethods.php | 4 +- .../Paypal/Helper/Shortcut/Factory.php | 4 +- .../Paypal/Model/Billing/Agreement.php | 4 +- app/code/Magento/Paypal/Model/Bml.php | 2 +- app/code/Magento/Paypal/Model/Cert.php | 2 +- .../Paypal/Model/Config/Rules/Reader.php | 2 +- app/code/Magento/Paypal/Model/Direct.php | 2 +- app/code/Magento/Paypal/Model/Express.php | 4 +- .../Magento/Paypal/Model/Express/Checkout.php | 2 +- app/code/Magento/Paypal/Model/Hostedpro.php | 4 +- app/code/Magento/Paypal/Model/IpnFactory.php | 2 +- app/code/Magento/Paypal/Model/Payflow/Bml.php | 2 +- app/code/Magento/Paypal/Model/Payflow/Pro.php | 4 +- .../Paypal/Model/Payflow/Transparent.php | 5 +- .../Magento/Paypal/Model/PayflowExpress.php | 2 +- .../Paypal/Model/PayflowExpress/Checkout.php | 2 +- .../Magento/Paypal/Model/Payflowadvanced.php | 4 +- app/code/Magento/Paypal/Model/Payflowlink.php | 4 +- .../Method/Billing/AbstractAgreement.php | 4 +- app/code/Magento/Paypal/Model/Pro.php | 4 +- .../Paypal/Model/Report/Settlement.php | 2 +- .../Paypal/Model/Report/Settlement/Row.php | 2 +- .../Billing/Agreement/Collection.php | 5 +- .../Report/Settlement/Row/Collection.php | 4 +- .../Observer/AddPaypalShortcutsObserver.php | 15 +- .../Adminhtml/Store/SwitcherPluginTest.php | 4 +- .../System/Config/Field/CountryTest.php | 10 +- .../Field/Enable/AbstractEnableTest.php | 6 +- .../System/Config/Fieldset/GroupTest.php | 14 +- .../System/Config/Fieldset/PaymentTest.php | 8 +- .../Unit/Block/Billing/Agreement/ViewTest.php | 8 +- .../Unit/Block/Billing/AgreementsTest.php | 54 +++--- .../Test/Unit/Block/Bml/ShortcutTest.php | 12 +- .../Test/Unit/Block/Express/FormTest.php | 21 ++- .../Test/Unit/Block/Express/ReviewTest.php | 31 ++-- .../Unit/Block/Payflow/Link/IframeTest.php | 28 +-- .../Unit/Block/PayflowExpress/FormTest.php | 14 +- .../Billing/Agreement/CancelTest.php | 27 ++- .../Controller/Express/PlaceOrderTest.php | 4 +- .../Test/Unit/Controller/ExpressTest.php | 36 ++-- .../Test/Unit/Controller/Ipn/IndexTest.php | 8 +- .../Transparent/RequestSecureTokenTest.php | 26 +-- .../Controller/Transparent/ResponseTest.php | 34 ++-- .../Paypal/Test/Unit/Helper/BackendTest.php | 10 +- .../Paypal/Test/Unit/Helper/DataTest.php | 12 +- .../Helper/Shortcut/CheckoutValidatorTest.php | 28 +-- .../Test/Unit/Helper/Shortcut/FactoryTest.php | 14 +- .../Unit/Helper/Shortcut/ValidatorTest.php | 24 ++- .../Test/Unit/Model/AbstractConfigTest.php | 6 +- .../Paypal/Test/Unit/Model/Api/NvpTest.php | 52 +++--- .../Model/Billing/AbstractAgreementTest.php | 12 +- .../Billing/Agreement/OrdersUpdaterTest.php | 10 +- .../Test/Unit/Model/Billing/AgreementTest.php | 18 +- .../BillingAgreementConfigProviderTest.php | 6 +- .../Paypal/Test/Unit/Model/CartTest.php | 6 +- .../Model/Config/Rules/FileResolverTest.php | 2 +- .../Unit/Model/Config/Rules/ReaderTest.php | 10 +- .../Model/Config/Rules/SchemaLocatorTest.php | 2 +- .../Structure/Element/FieldPluginTest.php | 6 +- .../Unit/Model/Config/StructurePluginTest.php | 14 +- .../Paypal/Test/Unit/Model/ConfigTest.php | 11 +- .../Test/Unit/Model/Express/CheckoutTest.php | 24 +-- .../Unit/Model/ExpressConfigProviderTest.php | 16 +- .../Paypal/Test/Unit/Model/ExpressTest.php | 24 +-- .../Test/Unit/Model/Hostedpro/RequestTest.php | 20 +-- .../Unit/Model/IframeConfigProviderTest.php | 6 +- .../Paypal/Test/Unit/Model/InfoTest.php | 16 +- .../Paypal/Test/Unit/Model/IpnTest.php | 33 ++-- .../Test/Unit/Model/Method/AgreementTest.php | 20 +-- .../Method/Checks/SpecificationPluginTest.php | 14 +- .../Service/Request/SecureTokenTest.php | 10 +- .../CreditCardValidationHandlerTest.php | 7 +- .../Response/Handler/FraudHandlerTest.php | 6 +- .../Response/Handler/HandlerCompositeTest.php | 8 +- .../Service/Response/TransactionTest.php | 25 ++- .../Validator/ResponseValidatorTest.php | 2 +- .../Unit/Model/Payflow/TransparentTest.php | 22 +-- .../Test/Unit/Model/PayflowConfigTest.php | 6 +- .../Test/Unit/Model/PayflowExpressTest.php | 14 +- .../Test/Unit/Model/PayflowlinkTest.php | 25 +-- .../Paypal/Test/Unit/Model/PayflowproTest.php | 34 ++-- .../Method/Billing/AbstractAgreementTest.php | 6 +- .../Paypal/Test/Unit/Model/ProTest.php | 31 ++-- .../Unit/Model/Report/Settlement/RowTest.php | 2 +- .../ResourceModel/Billing/AgreementTest.php | 12 +- ...dBillingAgreementToSessionObserverTest.php | 16 +- .../AddPaypalShortcutsObserverTest.php | 29 +-- .../HtmlTransactionIdObserverTest.php | 14 +- ...AdminBillingAgreementUsageObserverTest.php | 10 +- .../SetResponseAfterSaveOrderObserverTest.php | 20 +-- .../Magento/Persistent/Model/Observer.php | 2 +- app/code/Magento/Persistent/Model/Session.php | 3 +- .../Test/Unit/Block/Header/AdditionalTest.php | 28 +-- .../Persistent/Test/Unit/Helper/DataTest.php | 4 +- .../Checkout/ConfigProviderPluginTest.php | 16 +- .../Test/Unit/Model/FactoryTest.php | 4 +- .../Model/Layout/DepersonalizePluginTest.php | 26 +-- .../Unit/Model/Plugin/CustomerDataTest.php | 9 +- .../Test/Unit/Model/QuoteManagerTest.php | 18 +- .../Test/Unit/Model/SessionTest.php | 20 +-- .../ApplyBlockPersistentDataObserverTest.php | 22 ++- .../ApplyPersistentDataObserverTest.php | 19 +- ...CheckExpirePersistentQuoteObserverTest.php | 21 ++- .../ClearExpiredCronJobObserverTest.php | 16 +- ...CustomerAuthenticatedEventObserverTest.php | 8 +- .../Observer/EmulateCustomerObserverTest.php | 20 +-- .../Observer/EmulateQuoteObserverTest.php | 25 +-- .../MakePersistentQuoteGuestObserverTest.php | 14 +- ...reventClearCheckoutSessionObserverTest.php | 12 +- .../PreventExpressCheckoutObserverTest.php | 17 +- .../RemovePersistentCookieObserverTest.php | 12 +- .../Unit/Observer/RenewCookieObserverTest.php | 17 +- .../SetLoadPersistentQuoteObserverTest.php | 10 +- .../SetQuotePersistentDataObserverTest.php | 14 +- ...SetRememberMeCheckedStatusObserverTest.php | 18 +- .../SynchronizePersistentInfoObserverTest.php | 15 +- ...chronizePersistentOnLogoutObserverTest.php | 11 +- .../UpdateCustomerCookiesObserverTest.php | 19 +- .../Quote/Model/Cart/CartTotalRepository.php | 2 +- .../Quote/Model/Cart/Totals/ItemConverter.php | 2 +- app/code/Magento/Quote/Model/Quote.php | 4 +- .../Magento/Quote/Model/Quote/Address.php | 6 +- .../Quote/Model/Quote/Address/Item.php | 2 +- .../Quote/Model/Quote/Address/Rate.php | 2 +- .../Address/RateCollectorInterfaceFactory.php | 2 +- .../Quote/Model/Quote/Address/ToOrder.php | 9 +- .../Model/Quote/Address/ToOrderAddress.php | 2 +- app/code/Magento/Quote/Model/Quote/Item.php | 2 +- .../Magento/Quote/Model/Quote/Item/Option.php | 2 +- .../Quote/Model/Quote/Item/ToOrderItem.php | 2 +- .../Magento/Quote/Model/Quote/Payment.php | 2 +- .../Model/Quote/Payment/ToOrderPayment.php | 2 +- .../Quote/Model/Quote/TotalsCollector.php | 4 +- .../Quote/Model/Quote/TotalsReader.php | 9 +- app/code/Magento/Quote/Model/QuoteIdMask.php | 2 +- .../Magento/Quote/Model/QuoteManagement.php | 4 +- .../Quote/Address/Collection.php | 5 +- .../Quote/Address/Item/Collection.php | 5 +- .../Quote/Address/Rate/Collection.php | 5 +- .../Model/ResourceModel/Quote/Collection.php | 2 +- .../ResourceModel/Quote/Item/Collection.php | 4 +- .../Quote/Item/Option/Collection.php | 5 +- .../Quote/Payment/Collection.php | 5 +- .../Model/BillingAddressManagementTest.php | 35 ++-- .../Model/Cart/CartTotalManagementTest.php | 24 ++- .../Model/Cart/CartTotalRepositoryTest.php | 31 ++-- .../Cart/ShippingMethodConverterTest.php | 26 +-- .../Model/Cart/Totals/ItemConverterTest.php | 22 ++- .../Test/Unit/Model/CouponManagementTest.php | 14 +- .../Unit/Model/CustomerManagementTest.php | 14 +- .../GuestBillingAddressManagementTest.php | 6 +- .../GuestCart/GuestCartItemRepositoryTest.php | 8 +- .../GuestCart/GuestCartManagementTest.php | 12 +- .../GuestCart/GuestCartRepositoryTest.php | 12 +- .../Model/GuestCart/GuestCartTestHelper.php | 4 +- .../GuestCartTotalRepositoryTest.php | 4 +- .../GuestCart/GuestCouponManagementTest.php | 10 +- .../GuestPaymentMethodManagementTest.php | 8 +- .../GuestShippingAddressManagementTest.php | 6 +- .../GuestShippingMethodManagementTest.php | 4 +- .../Plugin/AuthorizationTest.php | 4 +- .../Model/PaymentMethodManagementTest.php | 90 ++++++---- .../Test/Unit/Model/QueryResolverTest.php | 4 +- .../Unit/Model/Quote/Address/RelationTest.php | 8 +- .../Quote/Address/ToOrderAddressTest.php | 20 ++- .../Unit/Model/Quote/Address/ToOrderTest.php | 18 +- .../Model/Quote/Address/Total/GrandTest.php | 8 +- .../Quote/Address/Total/ShippingTest.php | 31 ++-- .../Quote/Address/Total/SubtotalTest.php | 39 ++-- .../Model/Quote/Address/ValidatorTest.php | 8 +- .../Test/Unit/Model/Quote/AddressTest.php | 14 +- .../Test/Unit/Model/Quote/ConfigTest.php | 2 +- .../Model/Quote/Item/AbstractItemTest.php | 6 +- .../Unit/Model/Quote/Item/CompareTest.php | 12 +- .../Unit/Model/Quote/Item/ProcessorTest.php | 16 +- .../Model/Quote/Item/RelatedProductsTest.php | 6 +- .../Unit/Model/Quote/Item/RepositoryTest.php | 41 +++-- .../Unit/Model/Quote/Item/ToOrderItemTest.php | 16 +- .../Unit/Model/Quote/Item/UpdaterTest.php | 14 +- .../Quote/Test/Unit/Model/Quote/ItemTest.php | 64 +++---- .../Quote/Payment/ToOrderPaymentTest.php | 24 +-- .../Test/Unit/Model/Quote/PaymentTest.php | 2 +- .../Test/Unit/Model/Quote/RelationTest.php | 13 +- .../Unit/Model/Quote/TotalsReaderTest.php | 25 +-- .../Unit/Model/QuoteAddressValidatorTest.php | 34 ++-- .../Quote/Test/Unit/Model/QuoteIdMaskTest.php | 2 +- .../Test/Unit/Model/QuoteManagementTest.php | 166 ++++++++++-------- .../Plugin/AuthorizationTest.php | 18 +- .../Test/Unit/Model/QuoteRepositoryTest.php | 35 ++-- .../Quote/Test/Unit/Model/QuoteTest.php | 142 ++++++++------- .../Test/Unit/Model/QuoteValidatorTest.php | 12 +- .../Quote/Item/CollectionTest.php | 28 ++- .../Model/ResourceModel/Quote/ItemTest.php | 21 ++- .../ResourceModel/Quote/QuoteAddressTest.php | 14 +- .../Model/ShippingAddressManagementTest.php | 39 ++-- .../Model/ShippingMethodManagementTest.php | 23 +-- .../Model/Webapi/ParamOverriderCartIdTest.php | 8 +- .../Backend/CustomerQuoteObserverTest.php | 24 +-- .../Address/CollectTotalsObserverTest.php | 28 +-- .../Quote/Address/VatValidatorTest.php | 8 +- .../Observer/Webapi/SubmitObserverTest.php | 14 +- 389 files changed, 2667 insertions(+), 2204 deletions(-) diff --git a/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php b/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php index a5bf6c9d433df..3267c13b0fc0e 100644 --- a/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php +++ b/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php @@ -35,10 +35,10 @@ class NavigationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->catalogLayerMock = $this->getMock('\Magento\Catalog\Model\Layer', [], [], '', false); - $this->filterListMock = $this->getMock('\Magento\Catalog\Model\Layer\FilterList', [], [], '', false); + $this->catalogLayerMock = $this->getMock(\Magento\Catalog\Model\Layer::class, [], [], '', false); + $this->filterListMock = $this->getMock(\Magento\Catalog\Model\Layer\FilterList::class, [], [], '', false); $this->visibilityFlagMock = $this->getMock( - '\Magento\Catalog\Model\Layer\AvailabilityFlagInterface', + \Magento\Catalog\Model\Layer\AvailabilityFlagInterface::class, [], [], '', @@ -46,7 +46,7 @@ protected function setUp() ); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */ - $layerResolver = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Resolver') + $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class) ->disableOriginalConstructor() ->setMethods(['get', 'create']) ->getMock(); @@ -56,14 +56,14 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\LayeredNavigation\Block\Navigation', + \Magento\LayeredNavigation\Block\Navigation::class, [ 'layerResolver' => $layerResolver, 'filterList' => $this->filterListMock, 'visibilityFlag' => $this->visibilityFlagMock ] ); - $this->layoutMock = $this->getMock('\Magento\Framework\View\LayoutInterface', [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); } public function testGetStateHtml() @@ -116,7 +116,7 @@ public function testGetClearUrl() $this->layoutMock->expects($this->once())->method('getChildName')->will($this->returnValue('sample block')); $blockMock = $this->getMockForAbstractClass( - '\Magento\Framework\View\Element\AbstractBlock', + \Magento\Framework\View\Element\AbstractBlock::class, [], '', false diff --git a/app/code/Magento/LayeredNavigation/Test/Unit/Model/Aggregation/StatusTest.php b/app/code/Magento/LayeredNavigation/Test/Unit/Model/Aggregation/StatusTest.php index 0552a1b172288..fe3ccdc73ef61 100644 --- a/app/code/Magento/LayeredNavigation/Test/Unit/Model/Aggregation/StatusTest.php +++ b/app/code/Magento/LayeredNavigation/Test/Unit/Model/Aggregation/StatusTest.php @@ -18,9 +18,10 @@ class StatusTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->resolver = $this->objectManagerHelper->getObject('Magento\LayeredNavigation\Model\Aggregation\Status'); + $this->resolver = $this->objectManagerHelper->getObject( + \Magento\LayeredNavigation\Model\Aggregation\Status::class + ); } public function testIsEnabled() diff --git a/app/code/Magento/Marketplace/Controller/Adminhtml/Partners/Index.php b/app/code/Magento/Marketplace/Controller/Adminhtml/Partners/Index.php index 12dcc13357685..02abfb653dd76 100644 --- a/app/code/Magento/Marketplace/Controller/Adminhtml/Partners/Index.php +++ b/app/code/Magento/Marketplace/Controller/Adminhtml/Partners/Index.php @@ -37,7 +37,7 @@ public function execute() { if ($this->getRequest()->isAjax()) { $output = $this->getLayoutFactory()->create() - ->createBlock('Magento\Marketplace\Block\Partners') + ->createBlock(\Magento\Marketplace\Block\Partners::class) ->toHtml(); $this->getResponse()->appendBody($output); } diff --git a/app/code/Magento/Marketplace/Test/Unit/Block/PartnersTest.php b/app/code/Magento/Marketplace/Test/Unit/Block/PartnersTest.php index 928875512fd47..bd0f75b0031e5 100644 --- a/app/code/Magento/Marketplace/Test/Unit/Block/PartnersTest.php +++ b/app/code/Magento/Marketplace/Test/Unit/Block/PartnersTest.php @@ -46,7 +46,7 @@ public function testGetPartners() */ public function getPartnersBlockMock($methods = null) { - return $this->getMock('Magento\Marketplace\Block\Partners', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Block\Partners::class, $methods, [], '', false); } /** @@ -56,6 +56,6 @@ public function getPartnersBlockMock($methods = null) */ public function getPartnersModelMock($methods) { - return $this->getMock('Magento\Marketplace\Model\Partners', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Model\Partners::class, $methods, [], '', false); } } diff --git a/app/code/Magento/Marketplace/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Marketplace/Test/Unit/Controller/Index/IndexTest.php index 0dc02f46cbdb0..7eea9680eea03 100644 --- a/app/code/Magento/Marketplace/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Marketplace/Test/Unit/Controller/Index/IndexTest.php @@ -60,7 +60,7 @@ public function testExecute() */ public function getControllerIndexMock($methods = null) { - return $this->getMock('Magento\Marketplace\Controller\Adminhtml\Index\Index', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Controller\Adminhtml\Index\Index::class, $methods, [], '', false); } /** @@ -68,7 +68,7 @@ public function getControllerIndexMock($methods = null) */ public function getResultPageFactoryMock($methods = null) { - return $this->getMock('Magento\Framework\View\Result\PageFactory', $methods, [], '', false); + return $this->getMock(\Magento\Framework\View\Result\PageFactory::class, $methods, [], '', false); } /** @@ -76,7 +76,7 @@ public function getResultPageFactoryMock($methods = null) */ public function getConfigMock($methods = null) { - return $this->getMock('Magento\Framework\View\Page\Config', $methods, [], '', false); + return $this->getMock(\Magento\Framework\View\Page\Config::class, $methods, [], '', false); } /** @@ -84,7 +84,7 @@ public function getConfigMock($methods = null) */ public function getTitleMock($methods = null) { - return $this->getMock('Magento\Framework\View\Page\Title', $methods, [], '', false); + return $this->getMock(\Magento\Framework\View\Page\Title::class, $methods, [], '', false); } /** @@ -92,6 +92,6 @@ public function getTitleMock($methods = null) */ public function getPageMock($methods = null) { - return $this->getMock('Magento\Framework\View\Result\Page', $methods, [], '', false); + return $this->getMock(\Magento\Framework\View\Result\Page::class, $methods, [], '', false); } } diff --git a/app/code/Magento/Marketplace/Test/Unit/Controller/Partners/IndexTest.php b/app/code/Magento/Marketplace/Test/Unit/Controller/Partners/IndexTest.php index 933249686c3e1..d9f9dd5b65df9 100644 --- a/app/code/Magento/Marketplace/Test/Unit/Controller/Partners/IndexTest.php +++ b/app/code/Magento/Marketplace/Test/Unit/Controller/Partners/IndexTest.php @@ -75,7 +75,7 @@ public function testExecute() */ public function getControllerIndexMock($methods = null) { - return $this->getMock('Magento\Marketplace\Controller\Adminhtml\Partners\Index', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Controller\Adminhtml\Partners\Index::class, $methods, [], '', false); } /** @@ -83,7 +83,7 @@ public function getControllerIndexMock($methods = null) */ public function getLayoutFactoryMock($methods = null) { - return $this->getMock('Magento\Framework\View\LayoutFactory', $methods, [], '', false); + return $this->getMock(\Magento\Framework\View\LayoutFactory::class, $methods, [], '', false); } /** @@ -91,7 +91,7 @@ public function getLayoutFactoryMock($methods = null) */ public function getLayoutMock() { - return $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface'); + return $this->getMockForAbstractClass(\Magento\Framework\View\LayoutInterface::class); } /** @@ -99,7 +99,7 @@ public function getLayoutMock() */ public function getResponseMock($methods = null) { - return $this->getMock('Magento\Framework\HTTP\PhpEnvironment\Response', $methods, [], '', false); + return $this->getMock(\Magento\Framework\HTTP\PhpEnvironment\Response::class, $methods, [], '', false); } /** @@ -107,7 +107,7 @@ public function getResponseMock($methods = null) */ public function getRequestMock($methods = null) { - return $this->getMock('Magento\Framework\App\Request\Http', $methods, [], '', false); + return $this->getMock(\Magento\Framework\App\Request\Http::class, $methods, [], '', false); } /** @@ -115,6 +115,6 @@ public function getRequestMock($methods = null) */ public function getBlockInterfaceMock() { - return $this->getMockForAbstractClass('Magento\Framework\View\Element\BlockInterface'); + return $this->getMockForAbstractClass(\Magento\Framework\View\Element\BlockInterface::class); } } diff --git a/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php b/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php index fa9a5eb60268b..20fea193f5740 100644 --- a/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php +++ b/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php @@ -60,7 +60,7 @@ public function testSavePartnersToCache() */ public function getCacheHelperMock($methods = null) { - return $this->getMock('Magento\Marketplace\Helper\Cache', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Helper\Cache::class, $methods, [], '', false); } /** @@ -70,6 +70,6 @@ public function getCacheHelperMock($methods = null) */ public function getCacheMock() { - return $this->getMockForAbstractClass('Magento\Framework\Config\CacheInterface'); + return $this->getMockForAbstractClass(\Magento\Framework\Config\CacheInterface::class); } } diff --git a/app/code/Magento/Marketplace/Test/Unit/Model/PartnersTest.php b/app/code/Magento/Marketplace/Test/Unit/Model/PartnersTest.php index 79667ced4385b..45df086bbf7ef 100644 --- a/app/code/Magento/Marketplace/Test/Unit/Model/PartnersTest.php +++ b/app/code/Magento/Marketplace/Test/Unit/Model/PartnersTest.php @@ -123,7 +123,7 @@ public function testGetPartnersException() */ public function getPartnersBlockMock($methods = null) { - return $this->getMock('Magento\Marketplace\Block\Partners', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Block\Partners::class, $methods, [], '', false); } /** @@ -133,7 +133,7 @@ public function getPartnersBlockMock($methods = null) */ public function getPartnersModelMock($methods) { - return $this->getMock('Magento\Marketplace\Model\Partners', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Model\Partners::class, $methods, [], '', false); } /** @@ -143,7 +143,7 @@ public function getPartnersModelMock($methods) */ public function getCurlMock($methods) { - return $this->getMock('Magento\Framework\HTTP\Client\Curl', $methods, [], '', false); + return $this->getMock(\Magento\Framework\HTTP\Client\Curl::class, $methods, [], '', false); } /** @@ -153,6 +153,6 @@ public function getCurlMock($methods) */ public function getCacheMock($methods) { - return $this->getMock('Magento\Marketplace\Helper\Cache', $methods, [], '', false); + return $this->getMock(\Magento\Marketplace\Helper\Cache::class, $methods, [], '', false); } } diff --git a/app/code/Magento/NewRelicReporting/Model/Counts.php b/app/code/Magento/NewRelicReporting/Model/Counts.php index 4b8a00a5fb254..34d570c0dee42 100644 --- a/app/code/Magento/NewRelicReporting/Model/Counts.php +++ b/app/code/Magento/NewRelicReporting/Model/Counts.php @@ -15,6 +15,6 @@ class Counts extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\ResourceModel\Counts'); + $this->_init(\Magento\NewRelicReporting\Model\ResourceModel\Counts::class); } } diff --git a/app/code/Magento/NewRelicReporting/Model/Module.php b/app/code/Magento/NewRelicReporting/Model/Module.php index 1ac8a397aa0d3..01dd4039af2f2 100644 --- a/app/code/Magento/NewRelicReporting/Model/Module.php +++ b/app/code/Magento/NewRelicReporting/Model/Module.php @@ -15,6 +15,6 @@ class Module extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\ResourceModel\Module'); + $this->_init(\Magento\NewRelicReporting\Model\ResourceModel\Module::class); } } diff --git a/app/code/Magento/NewRelicReporting/Model/Orders.php b/app/code/Magento/NewRelicReporting/Model/Orders.php index 69fb43eed5712..9d427d3b38693 100644 --- a/app/code/Magento/NewRelicReporting/Model/Orders.php +++ b/app/code/Magento/NewRelicReporting/Model/Orders.php @@ -15,6 +15,6 @@ class Orders extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\ResourceModel\Orders'); + $this->_init(\Magento\NewRelicReporting\Model\ResourceModel\Orders::class); } } diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php index b7d452c4d7d01..ed79f8ea25945 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php @@ -15,6 +15,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\Counts', 'Magento\NewRelicReporting\Model\ResourceModel\Counts'); + $this->_init( + \Magento\NewRelicReporting\Model\Counts::class, + \Magento\NewRelicReporting\Model\ResourceModel\Counts::class + ); } } diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php index 22a854da329df..cf22f46d20776 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php @@ -15,6 +15,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\Module', 'Magento\NewRelicReporting\Model\ResourceModel\Module'); + $this->_init( + \Magento\NewRelicReporting\Model\Module::class, + \Magento\NewRelicReporting\Model\ResourceModel\Module::class + ); } } diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php index 1220f8d6af974..a3eb8374f3b76 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php @@ -15,6 +15,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\Orders', 'Magento\NewRelicReporting\Model\ResourceModel\Orders'); + $this->_init( + \Magento\NewRelicReporting\Model\Orders::class, + \Magento\NewRelicReporting\Model\ResourceModel\Orders::class + ); } } diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php index f80d10d600a6b..a868f91ef9ebc 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php @@ -15,6 +15,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\System', 'Magento\NewRelicReporting\Model\ResourceModel\System'); + $this->_init( + \Magento\NewRelicReporting\Model\System::class, + \Magento\NewRelicReporting\Model\ResourceModel\System::class + ); } } diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php index 73c50c777f856..282d44fd0b499 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php @@ -15,6 +15,9 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\Users', 'Magento\NewRelicReporting\Model\ResourceModel\Users'); + $this->_init( + \Magento\NewRelicReporting\Model\Users::class, + \Magento\NewRelicReporting\Model\ResourceModel\Users::class + ); } } diff --git a/app/code/Magento/NewRelicReporting/Model/System.php b/app/code/Magento/NewRelicReporting/Model/System.php index 902a2dc01725f..3c0de6e6c7ecf 100644 --- a/app/code/Magento/NewRelicReporting/Model/System.php +++ b/app/code/Magento/NewRelicReporting/Model/System.php @@ -15,6 +15,6 @@ class System extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\ResourceModel\System'); + $this->_init(\Magento\NewRelicReporting\Model\ResourceModel\System::class); } } diff --git a/app/code/Magento/NewRelicReporting/Model/Users.php b/app/code/Magento/NewRelicReporting/Model/Users.php index 9ec63b8f1f6bc..9e55daae83188 100644 --- a/app/code/Magento/NewRelicReporting/Model/Users.php +++ b/app/code/Magento/NewRelicReporting/Model/Users.php @@ -15,6 +15,6 @@ class Users extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\NewRelicReporting\Model\ResourceModel\Users'); + $this->_init(\Magento\NewRelicReporting\Model\ResourceModel\Users::class); } } diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php index 6b183aab9dd54..3dd5cdf22aea9 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php @@ -40,21 +40,21 @@ class DeploymentsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->zendClientFactoryMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClientFactory') + $this->zendClientFactoryMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClientFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->zendClientMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClient') + $this->zendClientMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClient::class) ->setMethods(['request', 'setUri', 'setMethod', 'setHeaders', 'setParameterPost']) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->setMethods(['getNewRelicApiUrl', 'getNewRelicApiKey', 'getNewRelicAppName', 'getNewRelicAppId']) ->disableOriginalConstructor() ->getMock(); @@ -113,7 +113,9 @@ public function testSetDeploymentRequestOk() ->method('getNewRelicAppId') ->willReturn($data['app_id']); - $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); + $zendHttpResponseMock = $this->getMockBuilder( + \Zend_Http_Response::class + )->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->any())->method('getStatus')->willReturn($data['status_ok']); $zendHttpResponseMock->expects($this->once())->method('getBody')->willReturn($data['response_body']); @@ -174,7 +176,9 @@ public function testSetDeploymentBadStatus() ->method('getNewRelicAppId') ->willReturn($data['app_id']); - $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); + $zendHttpResponseMock = $this->getMockBuilder( + \Zend_Http_Response::class + )->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->any())->method('getStatus')->willReturn($data['status_bad']); $this->zendClientMock->expects($this->once())->method('request')->willReturn($zendHttpResponseMock); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/CounterTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/CounterTest.php index 42939d7e7ed61..67823698cd883 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/CounterTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/CounterTest.php @@ -15,6 +15,7 @@ /** * Class CounterTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CounterTest extends \PHPUnit_Framework_TestCase { @@ -60,23 +61,23 @@ class CounterTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->productManagement = $this->getMockBuilder('Magento\Catalog\Api\ProductManagementInterface') + $this->productManagement = $this->getMockBuilder(\Magento\Catalog\Api\ProductManagementInterface::class) ->disableOriginalConstructor() ->getMock(); $this->configurableManagement = $this - ->getMockBuilder('Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface') + ->getMockBuilder(\Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->categoryManagement = $this->getMockBuilder('Magento\Catalog\Api\CategoryManagementInterface') + $this->categoryManagement = $this->getMockBuilder(\Magento\Catalog\Api\CategoryManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->customerManagement = $this->getMockBuilder('Magento\Customer\Api\CustomerManagementInterface') + $this->customerManagement = $this->getMockBuilder(\Magento\Customer\Api\CustomerManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->websiteManagement = $this->getMockBuilder('Magento\Store\Api\WebsiteManagementInterface') + $this->websiteManagement = $this->getMockBuilder(\Magento\Store\Api\WebsiteManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManagement = $this->getMockBuilder('Magento\Store\Api\StoreManagementInterface') + $this->storeManagement = $this->getMockBuilder(\Magento\Store\Api\StoreManagementInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportCountsTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportCountsTest.php index 99480b70c579f..89f4b9781879e 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportCountsTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportCountsTest.php @@ -69,33 +69,33 @@ class ReportCountsTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->productManagementMock = $this->getMockBuilder('Magento\Catalog\Api\ProductManagementInterface') + $this->productManagementMock = $this->getMockBuilder(\Magento\Catalog\Api\ProductManagementInterface::class) ->disableOriginalConstructor() ->getMock(); $this->configurableManagementMock = $this - ->getMockBuilder('Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface') + ->getMockBuilder(\Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->categoryManagementMock = $this->getMockBuilder('Magento\Catalog\Api\CategoryManagementInterface') + $this->categoryManagementMock = $this->getMockBuilder(\Magento\Catalog\Api\CategoryManagementInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->countsFactoryMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\CountsFactory') + $this->countsFactoryMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\CountsFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->countsModelMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Counts') + $this->countsModelMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Counts::class) ->disableOriginalConstructor() ->getMock(); $this->countsCollectionFactoryMock = $this - ->getMockBuilder('Magento\NewRelicReporting\Model\ResourceModel\Counts\CollectionFactory') + ->getMockBuilder(\Magento\NewRelicReporting\Model\ResourceModel\Counts\CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $collectionClassName = 'Magento\NewRelicReporting\Model\ResourceModel\Counts\Collection'; + $collectionClassName = \Magento\NewRelicReporting\Model\ResourceModel\Counts\Collection::class; $this->countsCollectionMock = $this->getMockBuilder($collectionClassName) ->disableOriginalConstructor() ->setMethods(['addFieldToFilter', 'addOrder', 'setPageSize', 'getFirstItem']) diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportModulesInfoTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportModulesInfoTest.php index 0dd899a9ec223..018d44fbf6c8c 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportModulesInfoTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportModulesInfoTest.php @@ -49,22 +49,22 @@ class ReportModulesInfoTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->collectMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Module\Collect') + $this->collectMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Module\Collect::class) ->disableOriginalConstructor() ->setMethods(['getModuleData']) ->getMock(); - $this->systemFactoryMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\SystemFactory') + $this->systemFactoryMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\SystemFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->systemModelMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\System') + $this->systemModelMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\System::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoderMock = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->getMock(); $this->systemFactoryMock->expects($this->any()) diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php index 622ce4d30531c..7a49cd7345aaf 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php @@ -64,15 +64,15 @@ class ReportNewRelicCronTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->collect = $this->getMockBuilder('Magento\NewRelicReporting\Model\Module\Collect') + $this->collect = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Module\Collect::class) ->disableOriginalConstructor() ->setMethods(['getModuleData']) ->getMock(); - $this->counter = $this->getMockBuilder('Magento\NewRelicReporting\Model\Counter') + $this->counter = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Counter::class) ->disableOriginalConstructor() ->setMethods([ 'getAllProductsCount', @@ -84,23 +84,24 @@ protected function setUp() 'getCustomerCount', ]) ->getMock(); - $this->cronEventFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\CronEventFactory') + $this->cronEventFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\CronEventFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->cronEventModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\CronEvent') + $this->cronEventModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\CronEvent::class) ->disableOriginalConstructor() ->setMethods(['addData', 'sendRequest']) ->getMock(); - $this->deploymentsFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\Apm\DeploymentsFactory') - ->disableOriginalConstructor() + $this->deploymentsFactory = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\Apm\DeploymentsFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->deploymentsModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\Apm\Deployments') + $this->deploymentsModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Apm\Deployments::class) ->disableOriginalConstructor() ->setMethods(['setDeployment']) ->getMock(); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); $this->cronEventFactory->expects($this->any()) diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronEventTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronEventTest.php index aaf8cd33053e4..0abb75b911997 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronEventTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronEventTest.php @@ -40,21 +40,21 @@ class CronEventTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->zendClientFactoryMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClientFactory') + $this->zendClientFactoryMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClientFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->zendClientMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClient') + $this->zendClientMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClient::class) ->setMethods(['request', 'setUri', 'setMethod', 'setHeaders', 'setRawData']) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoderMock = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->setMethods([ 'getNewRelicAccountId', 'getInsightsApiUrl', @@ -118,7 +118,9 @@ public function testSendRequestStatusOk() $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturn($json); - $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); + $zendHttpResponseMock = $this->getMockBuilder( + \Zend_Http_Response::class + )->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->any())->method('getStatus')->willReturn($statusOk); $this->zendClientMock->expects($this->once())->method('request')->willReturn($zendHttpResponseMock); @@ -177,7 +179,9 @@ public function testSendRequestStatusBad() $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturn($json); - $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); + $zendHttpResponseMock = $this->getMockBuilder( + \Zend_Http_Response::class + )->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->any())->method('getStatus')->willReturn($statusBad); $this->zendClientMock->expects($this->once())->method('request')->willReturn($zendHttpResponseMock); @@ -208,7 +212,7 @@ public function testSendRequestException() ->method('getNewRelicAccountId') ->willReturn($accId); - $this->setExpectedException('Magento\Framework\Exception\LocalizedException'); + $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); $this->model->sendRequest(); } diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronTest.php index 2d3e0f7a009c8..7af4817423e0a 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/CronTest.php @@ -39,25 +39,25 @@ class CronTest extends \PHPUnit_Framework_TestCase protected function setUp() { - - - $this->configMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->configMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->setMethods([ 'isCronEnabled' ]) ->disableOriginalConstructor() ->getMock(); - $this->reportModulesInfoMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Cron\ReportModulesInfo') - ->disableOriginalConstructor() + $this->reportModulesInfoMock = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\Cron\ReportModulesInfo::class + )->disableOriginalConstructor() ->getMock(); - $this->reportCountsMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Cron\ReportCounts') + $this->reportCountsMock = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Cron\ReportCounts::class) ->disableOriginalConstructor() ->getMock(); - $this->reportNewRelicCronMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\Cron\ReportNewRelicCron') - ->disableOriginalConstructor() + $this->reportNewRelicCronMock = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\Cron\ReportNewRelicCron::class + )->disableOriginalConstructor() ->getMock(); $this->model = new Cron( diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php index fcf70fb33460b..5663cf5078733 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php @@ -50,31 +50,31 @@ class CollectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->moduleListMock = $this->getMockBuilder('Magento\Framework\Module\ModuleListInterface') + $this->moduleListMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleListInterface::class) ->setMethods(['getNames', 'has', 'getAll', 'getOne']) ->disableOriginalConstructor() ->getMock(); - $this->fullModuleListMock = $this->getMockBuilder('Magento\Framework\Module\FullModuleList') + $this->fullModuleListMock = $this->getMockBuilder(\Magento\Framework\Module\FullModuleList::class) ->setMethods(['getNames', 'getAll']) ->disableOriginalConstructor() ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder('Magento\Framework\Module\Manager') + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->setMethods(['isOutputEnabled']) ->disableOriginalConstructor() ->getMock(); - $this->moduleFactoryMock = $this->getMock( - 'Magento\NewRelicReporting\Model\ModuleFactory', + $this->moduleFactoryMock = $this->getMock( + \Magento\NewRelicReporting\Model\ModuleFactory::class, ['create'], [], '', false ); - $this->moduleCollectionFactoryMock = $this->getMock( - 'Magento\NewRelicReporting\Model\ResourceModel\Module\CollectionFactory', + $this->moduleCollectionFactoryMock = $this->getMock( + \Magento\NewRelicReporting\Model\ResourceModel\Module\CollectionFactory::class, ['create'], [], '', @@ -97,10 +97,11 @@ protected function setUp() */ public function testGetModuleDataWithoutRefresh() { - $moduleCollectionMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\ResourceModel\Module\Collection') + $moduleCollectionMock = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\ResourceModel\Module\Collection::class) ->disableOriginalConstructor() ->getMock(); - $itemMock = $this->getMock('Magento\NewRelicReporting\Model\Module', [], [], '', false); + $itemMock = $this->getMock(\Magento\NewRelicReporting\Model\Module::class, [], [], '', false); $modulesMockArray = [ 'Module_Name' => [ 'name' => 'Name', @@ -185,12 +186,13 @@ public function testGetModuleDataWithoutRefresh() */ public function testGetModuleDataRefresh($data) { - $moduleCollectionMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\ResourceModel\Module\Collection') + $moduleCollectionMock = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\ResourceModel\Module\Collection::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\NewRelicReporting\Model\Module|\PHPUnit_Framework_MockObject_MockObject $itemMock */ - $itemMock = $this->getMock( - 'Magento\NewRelicReporting\Model\Module', + $itemMock = $this->getMock( + \Magento\NewRelicReporting\Model\Module::class, ['getName', 'getData', 'setData', 'getState', 'save'], [], '', @@ -280,12 +282,13 @@ public function testGetModuleDataRefresh($data) */ public function testGetModuleDataRefreshOrStatement($data) { - $moduleCollectionMock = $this->getMockBuilder('Magento\NewRelicReporting\Model\ResourceModel\Module\Collection') + $moduleCollectionMock = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\ResourceModel\Module\Collection::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\NewRelicReporting\Model\Module|\PHPUnit_Framework_MockObject_MockObject $itemMock */ - $itemMock = $this->getMock( - 'Magento\NewRelicReporting\Model\Module', + $itemMock = $this->getMock( + \Magento\NewRelicReporting\Model\Module::class, ['getName', 'getData', 'setData', 'getState', 'save'], [], '', diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/CheckConfigTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/CheckConfigTest.php index 5e53f51453790..966479c791b31 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/CheckConfigTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/CheckConfigTest.php @@ -39,15 +39,15 @@ class CheckConfigTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled', 'disableModule']) ->getMock(); - $this->newRelicWrapper = $this->getMockBuilder('Magento\NewRelicReporting\Model\NewRelicWrapper') + $this->newRelicWrapper = $this->getMockBuilder(\Magento\NewRelicReporting\Model\NewRelicWrapper::class) ->disableOriginalConstructor() ->setMethods(['isExtensionInstalled']) ->getMock(); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -66,7 +66,7 @@ protected function setUp() public function testCheckConfigModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -85,7 +85,7 @@ public function testCheckConfigModuleDisabledFromConfig() public function testCheckConfigExtensionNotInstalled() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -107,7 +107,7 @@ public function testCheckConfigExtensionNotInstalled() public function testCheckConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsTest.php index cfe95e926bc0e..dcfdc4dffd66f 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsTest.php @@ -49,22 +49,22 @@ class ReportConcurrentAdminsTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->backendAuthSession = $this->getMockBuilder('Magento\Backend\Model\Auth\Session') + $this->backendAuthSession = $this->getMockBuilder(\Magento\Backend\Model\Auth\Session::class) ->disableOriginalConstructor() ->setMethods(['isLoggedIn', 'getUser']) ->getMock(); - $this->usersFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\UsersFactory') + $this->usersFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\UsersFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->usersModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\Users') + $this->usersModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Users::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoder = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoder = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->getMock(); $this->usersFactory->expects($this->any()) @@ -87,7 +87,7 @@ protected function setUp() public function testReportConcurrentAdminsModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -106,7 +106,7 @@ public function testReportConcurrentAdminsModuleDisabledFromConfig() public function testReportConcurrentAdminsUserIsNotLoggedIn() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -130,7 +130,7 @@ public function testReportConcurrentAdmins() $testAction = 'JSON string'; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -140,7 +140,7 @@ public function testReportConcurrentAdmins() $this->backendAuthSession->expects($this->once()) ->method('isLoggedIn') ->willReturn(true); - $userMock = $this->getMockBuilder('Magento\User\Model\User')->disableOriginalConstructor()->getMock(); + $userMock = $this->getMockBuilder(\Magento\User\Model\User::class)->disableOriginalConstructor()->getMock(); $this->backendAuthSession->expects($this->once()) ->method('getUser') ->willReturn($userMock); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsToNewRelicTest.php index e744543c5ed75..e10422366af6e 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentAdminsToNewRelicTest.php @@ -39,15 +39,15 @@ class ReportConcurrentAdminsToNewRelicTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->backendAuthSession = $this->getMockBuilder('Magento\Backend\Model\Auth\Session') + $this->backendAuthSession = $this->getMockBuilder(\Magento\Backend\Model\Auth\Session::class) ->disableOriginalConstructor() ->setMethods(['isLoggedIn', 'getUser']) ->getMock(); - $this->newRelicWrapper = $this->getMockBuilder('Magento\NewRelicReporting\Model\NewRelicWrapper') + $this->newRelicWrapper = $this->getMockBuilder(\Magento\NewRelicReporting\Model\NewRelicWrapper::class) ->disableOriginalConstructor() ->setMethods(['addCustomParameter']) ->getMock(); @@ -67,7 +67,7 @@ protected function setUp() public function testReportConcurrentAdminsToNewRelicModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -86,7 +86,7 @@ public function testReportConcurrentAdminsToNewRelicModuleDisabledFromConfig() public function testReportConcurrentAdminsToNewRelicUserIsNotLoggedIn() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -108,7 +108,7 @@ public function testReportConcurrentAdminsToNewRelicUserIsNotLoggedIn() public function testReportConcurrentAdminsToNewRelic() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -118,7 +118,7 @@ public function testReportConcurrentAdminsToNewRelic() $this->backendAuthSession->expects($this->once()) ->method('isLoggedIn') ->willReturn(true); - $userMock = $this->getMockBuilder('Magento\User\Model\User')->disableOriginalConstructor()->getMock(); + $userMock = $this->getMockBuilder(\Magento\User\Model\User::class)->disableOriginalConstructor()->getMock(); $this->backendAuthSession->expects($this->once()) ->method('getUser') ->willReturn($userMock); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersTest.php index 28acdf8801cae..303f934430efa 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersTest.php @@ -9,6 +9,8 @@ /** * Class ReportConcurrentUsersTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ReportConcurrentUsersTest extends \PHPUnit_Framework_TestCase { @@ -59,26 +61,26 @@ class ReportConcurrentUsersTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['isLoggedIn', 'getCustomerId']) ->getMock(); - $this->customerRepository = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepository = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMock(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->usersFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\UsersFactory') + $this->usersFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\UsersFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->usersModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\Users') + $this->usersModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Users::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoder = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoder = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->getMock(); $this->usersFactory->expects($this->any()) @@ -103,7 +105,7 @@ protected function setUp() public function testReportConcurrentUsersModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -122,7 +124,7 @@ public function testReportConcurrentUsersModuleDisabledFromConfig() public function testReportConcurrentUsersUserIsNotLoggedIn() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -147,7 +149,7 @@ public function testReportConcurrentUsers() $testAction = 'JSON string'; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -160,15 +162,17 @@ public function testReportConcurrentUsers() $this->customerSession->expects($this->once()) ->method('getCustomerId') ->willReturn($testCustomerId); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $this->customerRepository->expects($this->once()) ->method('getById') ->willReturn($customerMock); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->once()) ->method('getStore') ->willReturn($storeMock); - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMockBuilder( + \Magento\Store\Model\Website::class + )->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->once()) ->method('getWebsite') ->willReturn($websiteMock); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersToNewRelicTest.php index 7d2165c14d43a..930a57cbb8037 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportConcurrentUsersToNewRelicTest.php @@ -49,19 +49,19 @@ class ReportConcurrentUsersToNewRelicTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['isLoggedIn', 'getCustomerId']) ->getMock(); - $this->customerRepository = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepository = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMock(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->newRelicWrapper = $this->getMockBuilder('Magento\NewRelicReporting\Model\NewRelicWrapper') + $this->newRelicWrapper = $this->getMockBuilder(\Magento\NewRelicReporting\Model\NewRelicWrapper::class) ->disableOriginalConstructor() ->setMethods(['addCustomParameter']) ->getMock(); @@ -83,7 +83,7 @@ protected function setUp() public function testReportConcurrentUsersToNewRelicModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -102,7 +102,7 @@ public function testReportConcurrentUsersToNewRelicModuleDisabledFromConfig() public function testReportConcurrentUsersToNewRelicUserIsNotLoggedIn() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -112,11 +112,13 @@ public function testReportConcurrentUsersToNewRelicUserIsNotLoggedIn() $this->customerSession->expects($this->once()) ->method('isLoggedIn') ->willReturn(false); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->once()) ->method('getStore') ->willReturn($storeMock); - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMockBuilder( + \Magento\Store\Model\Website::class + )->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->once()) ->method('getWebsite') ->willReturn($websiteMock); @@ -137,7 +139,7 @@ public function testReportConcurrentUsersToNewRelic() $testCustomerId = 1; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -150,15 +152,17 @@ public function testReportConcurrentUsersToNewRelic() $this->customerSession->expects($this->once()) ->method('getCustomerId') ->willReturn($testCustomerId); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $this->customerRepository->expects($this->once()) ->method('getById') ->willReturn($customerMock); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->once()) ->method('getStore') ->willReturn($storeMock); - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMockBuilder( + \Magento\Store\Model\Website::class + )->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->once()) ->method('getWebsite') ->willReturn($websiteMock); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedTest.php index a42bab55866b2..a8178d354089d 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedTest.php @@ -39,15 +39,15 @@ class ReportOrderPlacedTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->ordersFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\OrdersFactory') + $this->ordersFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\OrdersFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->ordersModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\Orders') + $this->ordersModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Orders::class) ->disableOriginalConstructor() ->getMock(); $this->ordersFactory->expects($this->any()) @@ -68,7 +68,7 @@ protected function setUp() public function testReportOrderPlacedModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -93,20 +93,20 @@ public function testReportOrderPlaced() $testTotalQtyOrderedCount = 1; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getOrder']) ->disableOriginalConstructor() ->getMock(); $eventObserver->expects($this->once()) ->method('getEvent') ->willReturn($event); - $order = $this->getMockBuilder('Magento\Sales\Model\Order')->disableOriginalConstructor()->getMock(); + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->getMock(); $event->expects($this->once()) ->method('getOrder') ->willReturn($order); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedToNewRelicTest.php index 3a2138b42ce3b..c9ad4cec304e4 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportOrderPlacedToNewRelicTest.php @@ -34,11 +34,11 @@ class ReportOrderPlacedToNewRelicTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->newRelicWrapper = $this->getMockBuilder('Magento\NewRelicReporting\Model\NewRelicWrapper') + $this->newRelicWrapper = $this->getMockBuilder(\Magento\NewRelicReporting\Model\NewRelicWrapper::class) ->disableOriginalConstructor() ->setMethods(['addCustomParameter']) ->getMock(); @@ -57,7 +57,7 @@ protected function setUp() public function testReportOrderPlacedToNewRelicModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) @@ -79,20 +79,20 @@ public function testReportOrderPlacedToNewRelic() $testTotalQtyOrderedCount = 1; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getOrder']) ->disableOriginalConstructor() ->getMock(); $eventObserver->expects($this->once()) ->method('getEvent') ->willReturn($event); - $order = $this->getMockBuilder('Magento\Sales\Model\Order')->disableOriginalConstructor()->getMock(); + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->getMock(); $event->expects($this->once()) ->method('getOrder') ->willReturn($order); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedTest.php index 0e3217656665f..09c5c2b758434 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedTest.php @@ -44,18 +44,18 @@ class ReportProductDeletedTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->systemFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\SystemFactory') + $this->systemFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\SystemFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->systemModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\System') + $this->systemModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\System::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoder = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoder = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->getMock(); $this->systemFactory->expects($this->any()) ->method('create') @@ -76,7 +76,7 @@ protected function setUp() public function testReportProductDeletedModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) @@ -97,20 +97,20 @@ public function testReportProductDeleted() $testAction = 'JSON string'; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getProduct']) ->disableOriginalConstructor() ->getMock(); $eventObserver->expects($this->once()) ->method('getEvent') ->willReturn($event); - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getId']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedToNewRelicTest.php index 7e841d59edcae..a445a59052975 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductDeletedToNewRelicTest.php @@ -34,11 +34,11 @@ class ReportProductDeletedToNewRelicTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->newRelicWrapper = $this->getMockBuilder('Magento\NewRelicReporting\Model\NewRelicWrapper') + $this->newRelicWrapper = $this->getMockBuilder(\Magento\NewRelicReporting\Model\NewRelicWrapper::class) ->disableOriginalConstructor() ->setMethods(['addCustomParameter']) ->getMock(); @@ -57,7 +57,7 @@ protected function setUp() public function testReportProductDeletedToNewRelicModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -76,7 +76,7 @@ public function testReportProductDeletedToNewRelicModuleDisabledFromConfig() public function testReportProductDeletedToNewRelic() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedTest.php index f219462a10fb9..dfc04d73f108e 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedTest.php @@ -44,18 +44,18 @@ class ReportProductSavedTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->systemFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\SystemFactory') + $this->systemFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\SystemFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->systemModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\System') + $this->systemModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\System::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoder = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoder = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->getMock(); $this->systemFactory->expects($this->any()) ->method('create') @@ -76,7 +76,7 @@ protected function setUp() public function testReportProductSavedModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) @@ -97,13 +97,13 @@ public function testReportProductSaved() $testAction = 'JSON string'; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getProduct']) ->disableOriginalConstructor() ->getMock(); @@ -111,7 +111,7 @@ public function testReportProductSaved() ->method('getEvent') ->willReturn($event); /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getId']) ->disableOriginalConstructor() ->getMock(); @@ -143,13 +143,13 @@ public function testReportProductUpdated() $testAction = 'JSON string'; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getProduct']) ->disableOriginalConstructor() ->getMock(); @@ -157,7 +157,7 @@ public function testReportProductUpdated() ->method('getEvent') ->willReturn($event); /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getId']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php index 7f6c81ae50a9f..ebf019e41ddae 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php @@ -35,11 +35,11 @@ class ReportProductSavedToNewRelicTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->newRelicWrapper = $this->getMockBuilder('Magento\NewRelicReporting\Model\NewRelicWrapper') + $this->newRelicWrapper = $this->getMockBuilder(\Magento\NewRelicReporting\Model\NewRelicWrapper::class) ->disableOriginalConstructor() ->setMethods(['addCustomParameter']) ->getMock(); @@ -58,7 +58,7 @@ protected function setUp() public function testReportProductSavedToNewRelicModuleDisabledFromConfig() { /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) @@ -76,20 +76,20 @@ public function testReportProductSavedToNewRelicModuleDisabledFromConfig() public function testReportProductSavedToNewRelic() { /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getProduct']) ->disableOriginalConstructor() ->getMock(); $eventObserver->expects($this->once()) ->method('getEvent') ->willReturn($event); - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); $event->expects($this->once()) @@ -111,20 +111,20 @@ public function testReportProductSavedToNewRelic() public function testReportProductUpdatedToNewRelic($isNewObject) { /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $event = $this->getMockBuilder('Magento\Framework\Event') + $event = $this->getMockBuilder(\Magento\Framework\Event::class) ->setMethods(['getProduct']) ->disableOriginalConstructor() ->getMock(); $eventObserver->expects($this->once()) ->method('getEvent') ->willReturn($event); - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); $product->expects($this->any()) diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushTest.php index 8c6c1ea32d862..a9145eae25078 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushTest.php @@ -44,18 +44,18 @@ class ReportSystemCacheFlushTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->systemFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\SystemFactory') + $this->systemFactory = $this->getMockBuilder(\Magento\NewRelicReporting\Model\SystemFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->systemModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\System') + $this->systemModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\System::class) ->disableOriginalConstructor() ->getMock(); - $this->jsonEncoder = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') + $this->jsonEncoder = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class) ->getMock(); $this->systemFactory->expects($this->any()) ->method('create') @@ -76,7 +76,7 @@ protected function setUp() public function testReportSystemCacheFlushModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -98,7 +98,7 @@ public function testReportSystemCacheFlush() $testAction = 'JSON string'; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushToNewRelicTest.php index 87fce27b73a74..e0d65f3130642 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportSystemCacheFlushToNewRelicTest.php @@ -44,19 +44,20 @@ class ReportSystemCacheFlushToNewRelicTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->config = $this->getMockBuilder('Magento\NewRelicReporting\Model\Config') + $this->config = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Config::class) ->disableOriginalConstructor() ->setMethods(['isNewRelicEnabled']) ->getMock(); - $this->backendAuthSession = $this->getMockBuilder('Magento\Backend\Model\Auth\Session') + $this->backendAuthSession = $this->getMockBuilder(\Magento\Backend\Model\Auth\Session::class) ->disableOriginalConstructor() ->setMethods(['getUser']) ->getMock(); - $this->deploymentsFactory = $this->getMockBuilder('Magento\NewRelicReporting\Model\Apm\DeploymentsFactory') - ->disableOriginalConstructor() + $this->deploymentsFactory = $this->getMockBuilder( + \Magento\NewRelicReporting\Model\Apm\DeploymentsFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->deploymentsModel = $this->getMockBuilder('Magento\NewRelicReporting\Model\Apm\Deployments') + $this->deploymentsModel = $this->getMockBuilder(\Magento\NewRelicReporting\Model\Apm\Deployments::class) ->disableOriginalConstructor() ->setMethods(['setDeployment']) ->getMock(); @@ -79,7 +80,7 @@ protected function setUp() public function testReportSystemCacheFlushToNewRelicModuleDisabledFromConfig() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); @@ -98,14 +99,14 @@ public function testReportSystemCacheFlushToNewRelicModuleDisabledFromConfig() public function testReportSystemCacheFlushToNewRelic() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ - $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserver = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); $this->config->expects($this->once()) ->method('isNewRelicEnabled') ->willReturn(true); - $userMock = $this->getMockBuilder('Magento\User\Model\User')->disableOriginalConstructor()->getMock(); + $userMock = $this->getMockBuilder(\Magento\User\Model\User::class)->disableOriginalConstructor()->getMock(); $this->backendAuthSession->expects($this->once()) ->method('getUser') ->willReturn($userMock); diff --git a/app/code/Magento/OfflinePayments/Model/Banktransfer.php b/app/code/Magento/OfflinePayments/Model/Banktransfer.php index 5792720b322cf..3f68e8863baa9 100644 --- a/app/code/Magento/OfflinePayments/Model/Banktransfer.php +++ b/app/code/Magento/OfflinePayments/Model/Banktransfer.php @@ -26,14 +26,14 @@ class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod * * @var string */ - protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Banktransfer'; + protected $_formBlockType = \Magento\OfflinePayments\Block\Form\Banktransfer::class; /** * Instructions block path * * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Instructions'; + protected $_infoBlockType = \Magento\Payment\Block\Info\Instructions::class; /** * Availability option diff --git a/app/code/Magento/OfflinePayments/Model/Cashondelivery.php b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php index 8381ea0de8bd0..9e62968478d14 100644 --- a/app/code/Magento/OfflinePayments/Model/Cashondelivery.php +++ b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php @@ -26,14 +26,14 @@ class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod * * @var string */ - protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Cashondelivery'; + protected $_formBlockType = \Magento\OfflinePayments\Block\Form\Cashondelivery::class; /** * Info instructions block path * * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Instructions'; + protected $_infoBlockType = \Magento\Payment\Block\Info\Instructions::class; /** * Availability option diff --git a/app/code/Magento/OfflinePayments/Model/Checkmo.php b/app/code/Magento/OfflinePayments/Model/Checkmo.php index b657a96c0e648..95dbcdff15211 100644 --- a/app/code/Magento/OfflinePayments/Model/Checkmo.php +++ b/app/code/Magento/OfflinePayments/Model/Checkmo.php @@ -24,12 +24,12 @@ class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Checkmo'; + protected $_formBlockType = \Magento\OfflinePayments\Block\Form\Checkmo::class; /** * @var string */ - protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Checkmo'; + protected $_infoBlockType = \Magento\OfflinePayments\Block\Info\Checkmo::class; /** * Availability option diff --git a/app/code/Magento/OfflinePayments/Model/Purchaseorder.php b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php index 52eee8df4ba78..c4f9bf979a237 100644 --- a/app/code/Magento/OfflinePayments/Model/Purchaseorder.php +++ b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php @@ -24,12 +24,12 @@ class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Purchaseorder'; + protected $_formBlockType = \Magento\OfflinePayments\Block\Form\Purchaseorder::class; /** * @var string */ - protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Purchaseorder'; + protected $_infoBlockType = \Magento\OfflinePayments\Block\Info\Purchaseorder::class; /** * Availability option diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php index 24c7892d49022..2626d0c20c4f9 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php @@ -14,16 +14,16 @@ class AbstractInstructionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $this->_model = $this->getMockForAbstractClass( - 'Magento\OfflinePayments\Block\Form\AbstractInstruction', + \Magento\OfflinePayments\Block\Form\AbstractInstruction::class, ['context' => $context] ); } public function testGetInstructions() { - $method = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $method = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $method->expects($this->once()) diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Block/Info/CheckmoTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Block/Info/CheckmoTest.php index cafbad48edc68..848cfbae52b25 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Block/Info/CheckmoTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Block/Info/CheckmoTest.php @@ -14,7 +14,7 @@ class CheckmoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $this->_model = new \Magento\OfflinePayments\Block\Info\Checkmo($context); } @@ -23,7 +23,7 @@ protected function setUp() */ public function testGetPayableTo($details, $expected) { - $info = $this->getMock('Magento\Payment\Model\Info', ['getAdditionalData'], [], '', false); + $info = $this->getMock(\Magento\Payment\Model\Info::class, ['getAdditionalData'], [], '', false); $info->expects($this->once()) ->method('getAdditionalData') ->willReturn(serialize($details)); @@ -48,7 +48,7 @@ public function getPayableToDataProvider() */ public function testGetMailingAddress($details, $expected) { - $info = $this->getMock('Magento\Payment\Model\Info', ['getAdditionalData'], [], '', false); + $info = $this->getMock(\Magento\Payment\Model\Info::class, ['getAdditionalData'], [], '', false); $info->expects($this->once()) ->method('getAdditionalData') ->willReturn(serialize($details)); @@ -70,7 +70,7 @@ public function getMailingAddressDataProvider() public function testConvertAdditionalDataIsNeverCalled() { - $info = $this->getMock('Magento\Payment\Model\Info', ['getAdditionalData'], [], '', false); + $info = $this->getMock(\Magento\Payment\Model\Info::class, ['getAdditionalData'], [], '', false); $info->expects($this->once()) ->method('getAdditionalData') ->willReturn(serialize(['mailing_address' => 'blah@blah.com'])); diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/BanktransferTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/BanktransferTest.php index f9ce2b0cfc331..aaf89696157f8 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/BanktransferTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/BanktransferTest.php @@ -20,11 +20,17 @@ class BanktransferTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); - $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $paymentDataMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); + $this->_scopeConfig = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + [], + [], + '', + false + ); $this->_object = $objectManagerHelper->getObject( - 'Magento\OfflinePayments\Model\Banktransfer', + \Magento\OfflinePayments\Model\Banktransfer::class, [ 'eventManager' => $eventManager, 'paymentData' => $paymentDataMock, @@ -35,6 +41,6 @@ protected function setUp() public function testGetInfoBlockType() { - $this->assertEquals('Magento\Payment\Block\Info\Instructions', $this->_object->getInfoBlockType()); + $this->assertEquals(\Magento\Payment\Block\Info\Instructions::class, $this->_object->getInfoBlockType()); } } diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/CashondeliveryTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/CashondeliveryTest.php index 06f324f57f2d5..bc467504af744 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/CashondeliveryTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/CashondeliveryTest.php @@ -21,12 +21,18 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $paymentDataMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); - $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $this->_scopeConfig = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + [], + [], + '', + false + ); $this->_object = $helper->getObject( - 'Magento\OfflinePayments\Model\Cashondelivery', + \Magento\OfflinePayments\Model\Cashondelivery::class, [ 'eventManager' => $eventManager, 'paymentData' => $paymentDataMock, @@ -37,6 +43,6 @@ protected function setUp() public function testGetInfoBlockType() { - $this->assertEquals('Magento\Payment\Block\Info\Instructions', $this->_object->getInfoBlockType()); + $this->assertEquals(\Magento\Payment\Block\Info\Instructions::class, $this->_object->getInfoBlockType()); } } diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php index 53aa042ec7e52..8015df2343f05 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php @@ -22,15 +22,15 @@ class CheckmoConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->methodMock = $this->getMock('Magento\OfflinePayments\Model\Checkmo', [], [], '', false); + $this->methodMock = $this->getMock(\Magento\OfflinePayments\Model\Checkmo::class, [], [], '', false); - $paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $paymentHelperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $paymentHelperMock->expects($this->once()) ->method('getMethodInstance') ->with(Checkmo::PAYMENT_METHOD_CHECKMO_CODE) ->willReturn($this->methodMock); - $this->escaperMock = $this->getMock('Magento\Framework\Escaper'); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class); $this->escaperMock->expects($this->any()) ->method('escapeHtml') ->willReturnArgument(0); diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php index 4ca21b47d5b95..d8831dbfdea1f 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php @@ -20,17 +20,17 @@ class CheckmoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $paymentDataMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->_scopeConfig = $this->getMock( - 'Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, ['getValue', 'isSetFlag'], [], '', false ); $this->_object = $objectManagerHelper->getObject( - 'Magento\OfflinePayments\Model\Checkmo', + \Magento\OfflinePayments\Model\Checkmo::class, [ 'eventManager' => $eventManager, 'paymentData' => $paymentDataMock, diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php index 2f8c04f7055fa..c6bf0dfa4277a 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php @@ -28,21 +28,21 @@ class InstructionsConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->methodOneMock = $this->getMock( - 'Magento\Payment\Model\Method\AbstractMethod', + \Magento\Payment\Model\Method\AbstractMethod::class, ['isAvailable', 'getInstructions'], [], '', false ); $this->methodTwoMock = $this->getMock( - 'Magento\Payment\Model\Method\AbstractMethod', + \Magento\Payment\Model\Method\AbstractMethod::class, ['isAvailable', 'getInstructions'], [], '', false ); - $paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $paymentHelperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $paymentHelperMock->expects($this->exactly(2)) ->method('getMethodInstance') ->willReturnMap([ @@ -50,7 +50,7 @@ protected function setUp() [Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE, $this->methodTwoMock], ]); - $this->escaperMock = $this->getMock('Magento\Framework\Escaper'); + $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class); $this->escaperMock->expects($this->any()) ->method('escapeHtml') ->willReturnArgument(0); diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/PurchaseorderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/PurchaseorderTest.php index f91c474d01a88..9bf162257005d 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/PurchaseorderTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/PurchaseorderTest.php @@ -20,17 +20,17 @@ class PurchaseorderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $paymentDataMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->_scopeConfig = $this->getMock( - 'Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, ['getValue', 'isSetFlag'], [], '', false ); $this->_object = $objectManagerHelper->getObject( - 'Magento\OfflinePayments\Model\Purchaseorder', + \Magento\OfflinePayments\Model\Purchaseorder::class, [ 'eventManager' => $eventManager, 'paymentData' => $paymentDataMock, @@ -45,7 +45,7 @@ public function testAssignData() 'po_number' => '12345' ]); - $instance = $this->getMock('Magento\Payment\Model\Info', [], [], '', false); + $instance = $this->getMock(\Magento\Payment\Model\Info::class, [], [], '', false); $this->_object->setData('info_instance', $instance); $this->_object->assignData($data); } diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php index 9693762851f72..113f18bf545bb 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php @@ -20,7 +20,7 @@ protected function setUp() { $objectManagerHelper = new ObjectManager($this); $this->_model = $objectManagerHelper - ->getObject('Magento\OfflinePayments\Observer\BeforeOrderPaymentSaveObserver'); + ->getObject(\Magento\OfflinePayments\Observer\BeforeOrderPaymentSaveObserver::class); } /** @@ -29,10 +29,10 @@ protected function setUp() */ public function testBeforeOrderPaymentSaveWithInstructions($methodCode) { - $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); - $event = $this->getMock('Magento\Framework\Event', ['getPayment'], [], '', false); + $observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); + $event = $this->getMock(\Magento\Framework\Event::class, ['getPayment'], [], '', false); $payment = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, ['getMethod', 'setAdditionalInformation', 'getMethodInstance'], [], '', @@ -44,7 +44,7 @@ public function testBeforeOrderPaymentSaveWithInstructions($methodCode) $payment->expects($this->once()) ->method('setAdditionalInformation') ->with('instructions', 'payment configuration'); - $method = $this->getMockBuilder('\Magento\OfflinePayments\Model\Banktransfer') + $method = $this->getMockBuilder(\Magento\OfflinePayments\Model\Banktransfer::class) ->disableOriginalConstructor() ->getMock(); @@ -73,10 +73,10 @@ public function dataProviderBeforeOrderPaymentSaveWithInstructions() public function testBeforeOrderPaymentSaveWithCheckmo() { - $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); - $event = $this->getMock('Magento\Framework\Event', ['getPayment'], [], '', false); + $observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); + $event = $this->getMock(\Magento\Framework\Event::class, ['getPayment'], [], '', false); $payment = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, ['getMethod', 'setAdditionalInformation', 'getMethodInstance'], [], '', @@ -94,7 +94,7 @@ public function testBeforeOrderPaymentSaveWithCheckmo() ] ); - $method = $this->getMockBuilder('Magento\OfflinePayments\Model\Checkmo') + $method = $this->getMockBuilder(\Magento\OfflinePayments\Model\Checkmo::class) ->disableOriginalConstructor() ->getMock(); $method->expects($this->once()) @@ -117,10 +117,10 @@ public function testBeforeOrderPaymentSaveWithCheckmo() public function testBeforeOrderPaymentSaveWithOthers() { - $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); - $event = $this->getMock('Magento\Framework\Event', ['getPayment'], [], '', false); + $observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); + $event = $this->getMock(\Magento\Framework\Event::class, ['getPayment'], [], '', false); $payment = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, ['getMethod', 'setAdditionalInformation', 'getMethodInstance'], [], '', diff --git a/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php b/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php index 6983b42b98372..2ae8cccaf976a 100644 --- a/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php +++ b/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php @@ -41,7 +41,9 @@ public function __construct( public function getElementHtml() { /** @var \Magento\Backend\Block\Widget\Button $buttonBlock */ - $buttonBlock = $this->getForm()->getParent()->getLayout()->createBlock('Magento\Backend\Block\Widget\Button'); + $buttonBlock = $this->getForm()->getParent()->getLayout()->createBlock( + \Magento\Backend\Block\Widget\Button::class + ); $params = ['website' => $buttonBlock->getRequest()->getParam('website')]; diff --git a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php index 7ef7348ecc469..b754819dbd307 100644 --- a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php +++ b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php @@ -51,7 +51,7 @@ public function execute() $fileName = 'tablerates.csv'; /** @var $gridBlock \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid */ $gridBlock = $this->_view->getLayout()->createBlock( - 'Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid' + \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid::class ); $website = $this->_storeManager->getWebsite($this->getRequest()->getParam('website')); if ($this->getRequest()->getParam('conditionName')) { diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php index 22d7e56b0196e..c7aa7f2def11a 100644 --- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php +++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php @@ -34,8 +34,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab protected function _construct() { $this->_init( - 'Magento\OfflineShipping\Model\Carrier\Tablerate', - 'Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate' + \Magento\OfflineShipping\Model\Carrier\Tablerate::class, + \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class ); $this->_countryTable = $this->getTable('directory_country'); $this->_regionTable = $this->getTable('directory_country_region'); diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Carrier/Tablerate/GridTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Carrier/Tablerate/GridTest.php index d2bb6e4fee9e3..826fef6a4d50f 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Carrier/Tablerate/GridTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Carrier/Tablerate/GridTest.php @@ -41,24 +41,26 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $objectManager->getObject('Magento\Backend\Block\Template\Context', [ - 'storeManager' => $this->storeManagerMock - ]); + $this->context = $objectManager->getObject( + \Magento\Backend\Block\Template\Context::class, + ['storeManager' => $this->storeManagerMock] + ); - $this->backendHelperMock = $this->getMockBuilder('\Magento\Backend\Helper\Data') + $this->backendHelperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); $this->collectionFactoryMock = - $this->getMockBuilder('\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate\CollectionFactory') - ->disableOriginalConstructor() + $this->getMockBuilder( + \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate\CollectionFactory::class + )->disableOriginalConstructor() ->getMock(); - $this->tablerateMock = $this->getMockBuilder('Magento\OfflineShipping\Model\Carrier\Tablerate') + $this->tablerateMock = $this->getMockBuilder(\Magento\OfflineShipping\Model\Carrier\Tablerate::class) ->disableOriginalConstructor() ->getMock(); @@ -74,7 +76,7 @@ public function testSetWebsiteId() { $websiteId = 1; - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->setMethods(['getId']) ->disableOriginalConstructor() ->getMock(); @@ -96,7 +98,7 @@ public function testGetWebsiteId() { $websiteId = 10; - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ExportTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ExportTest.php index a915f3f2288a9..13a3869b62786 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ExportTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ExportTest.php @@ -14,12 +14,12 @@ class ExportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $backendUrl = $this->getMock('Magento\Backend\Model\UrlInterface', [], [], '', false, false); + $backendUrl = $this->getMock(\Magento\Backend\Model\UrlInterface::class, [], [], '', false, false); $backendUrl->expects($this->once())->method('getUrl')->with("*/*/exportTablerates", ['website' => 1]); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_object = $objectManager->getObject( - 'Magento\OfflineShipping\Block\Adminhtml\Form\Field\Export', + \Magento\OfflineShipping\Block\Adminhtml\Form\Field\Export::class, ['backendUrl' => $backendUrl] ); } @@ -28,23 +28,23 @@ public function testGetElementHtml() { $expected = 'some test data'; - $form = $this->getMock('Magento\Framework\Data\Form', ['getParent'], [], '', false, false); + $form = $this->getMock(\Magento\Framework\Data\Form::class, ['getParent'], [], '', false, false); $parentObjectMock = $this->getMock( - 'Magento\Backend\Block\Template', + \Magento\Backend\Block\Template::class, ['getLayout'], [], '', false, false ); - $layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false, false); + $layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false, false); - $blockMock = $this->getMock('Magento\Backend\Block\Widget\Button', [], [], '', false, false); + $blockMock = $this->getMock(\Magento\Backend\Block\Widget\Button::class, [], [], '', false, false); - $requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false, false); + $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false, false); $requestMock->expects($this->once())->method('getParam')->with('website')->will($this->returnValue(1)); - $mockData = $this->getMock('StdClass', ['toHtml']); + $mockData = $this->getMock(\StdClass::class, ['toHtml']); $mockData->expects($this->once())->method('toHtml')->will($this->returnValue($expected)); $blockMock->expects($this->once())->method('getRequest')->will($this->returnValue($requestMock)); diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ImportTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ImportTest.php index 1035323c39e85..4d52122628f17 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ImportTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Block/Adminhtml/Form/Field/ImportTest.php @@ -26,7 +26,7 @@ class ImportTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_formMock = $this->getMock( - 'Magento\Framework\Data\Form', + \Magento\Framework\Data\Form::class, ['getFieldNameSuffix', 'addSuffixToName'], [], '', @@ -36,7 +36,7 @@ protected function setUp() $testData = ['name' => 'test_name', 'html_id' => 'test_html_id']; $testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_object = $testHelper->getObject( - 'Magento\OfflineShipping\Block\Adminhtml\Form\Field\Import', + \Magento\OfflineShipping\Block\Adminhtml\Form\Field\Import::class, ['data' => $testData] ); $this->_object->setForm($this->_formMock); diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Backend/TablerateTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Backend/TablerateTest.php index df5c9bb7176fb..53279669788fc 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Backend/TablerateTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Backend/TablerateTest.php @@ -20,20 +20,21 @@ class TablerateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->tableateFactoryMock = - $this->getMockBuilder('Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory') + $this->getMockBuilder(\Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $helper->getObject('\Magento\OfflineShipping\Model\Config\Backend\Tablerate', [ - 'tablerateFactory' => $this->tableateFactoryMock - ]); + $this->model = $helper->getObject( + \Magento\OfflineShipping\Model\Config\Backend\Tablerate::class, + ['tablerateFactory' => $this->tableateFactoryMock] + ); } public function testAfterSave() { - $tablerateMock = $this->getMockBuilder('Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate') + $tablerateMock = $this->getMockBuilder(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class) ->disableOriginalConstructor() ->setMethods(['uploadAndImport']) ->getMock(); diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Source/TablerateTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Source/TablerateTest.php index 1f34af8f3d772..cdc22962695e2 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Source/TablerateTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/Config/Source/TablerateTest.php @@ -19,15 +19,16 @@ class TablerateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->carrierTablerateMock = $this->getMockBuilder('\Magento\OfflineShipping\Model\Carrier\Tablerate') + $this->carrierTablerateMock = $this->getMockBuilder(\Magento\OfflineShipping\Model\Carrier\Tablerate::class) ->disableOriginalConstructor() ->setMethods(['getCode']) ->getMock(); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $helper->getObject('Magento\OfflineShipping\Model\Config\Source\Tablerate', [ - 'carrierTablerate' => $this->carrierTablerateMock - ]); + $this->model = $helper->getObject( + \Magento\OfflineShipping\Model\Config\Source\Tablerate::class, + ['carrierTablerate' => $this->carrierTablerateMock] + ); } public function testToOptionArray() diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php index 5866f914db0f9..fb65aaa10eae0 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php @@ -21,7 +21,7 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfigMock = $this->getMockBuilder('\Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->setMethods([ 'getValue', @@ -29,9 +29,10 @@ protected function setUp() ]) ->getMock(); - $this->model = $helper->getObject('\Magento\OfflineShipping\Model\Plugin\Checkout\Block\Cart\Shipping', [ - 'scopeConfig' => $this->scopeConfigMock - ]); + $this->model = $helper->getObject( + \Magento\OfflineShipping\Model\Plugin\Checkout\Block\Cart\Shipping::class, + ['scopeConfig' => $this->scopeConfigMock] + ); } /** @@ -40,7 +41,7 @@ protected function setUp() public function testAfterGetStateActive($scopeConfigMockReturnValue, $result, $assertResult) { /** @var \Magento\Checkout\Block\Cart\LayoutProcessor $subjectMock */ - $subjectMock = $this->getMockBuilder('\Magento\Checkout\Block\Cart\LayoutProcessor') + $subjectMock = $this->getMockBuilder(\Magento\Checkout\Block\Cart\LayoutProcessor::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php index 34fc1756ddb7b..7d31dde0d73f9 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php @@ -15,7 +15,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = $this->getMock( - 'Magento\OfflineShipping\Model\SalesRule\Calculator', + \Magento\OfflineShipping\Model\SalesRule\Calculator::class, ['_getRules', '__wakeup'], [], '', @@ -25,10 +25,10 @@ protected function setUp() public function testProcessFreeShipping() { - $addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address') + $addressMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class) ->disableOriginalConstructor() ->getMock(); - $item = $this->getMock('Magento\Quote\Model\Quote\Item', ['getAddress', '__wakeup'], [], '', false); + $item = $this->getMock(\Magento\Quote\Model\Quote\Item::class, ['getAddress', '__wakeup'], [], '', false); $item->expects($this->once())->method('getAddress')->will($this->returnValue($addressMock)); $this->_model->expects($this->once()) @@ -37,7 +37,7 @@ public function testProcessFreeShipping() ->will($this->returnValue([])); $this->assertInstanceOf( - 'Magento\OfflineShipping\Model\SalesRule\Calculator', + \Magento\OfflineShipping\Model\SalesRule\Calculator::class, $this->_model->processFreeShipping($item) ); diff --git a/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php b/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php index 10788d38d6798..d4883e174a8e5 100644 --- a/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php +++ b/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php @@ -20,7 +20,7 @@ class Export extends \Magento\Config\Block\System\Config\Form\Field protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { /** @var \Magento\Backend\Block\Widget\Button $buttonBlock */ - $buttonBlock = $this->getForm()->getLayout()->createBlock('Magento\Backend\Block\Widget\Button'); + $buttonBlock = $this->getForm()->getLayout()->createBlock(\Magento\Backend\Block\Widget\Button::class); $params = [ 'website' => $buttonBlock->getRequest()->getParam('website'), diff --git a/app/code/Magento/PageCache/Observer/FlushAllCache.php b/app/code/Magento/PageCache/Observer/FlushAllCache.php index 15e77db5acaed..039599c07c66d 100644 --- a/app/code/Magento/PageCache/Observer/FlushAllCache.php +++ b/app/code/Magento/PageCache/Observer/FlushAllCache.php @@ -61,7 +61,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) private function getCache() { if (!$this->fullPageCache) { - $this->fullPageCache = ObjectManager::getInstance()->get('\Magento\PageCache\Model\Cache\Type'); + $this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class); } return $this->fullPageCache; } diff --git a/app/code/Magento/PageCache/Observer/FlushCacheByTags.php b/app/code/Magento/PageCache/Observer/FlushCacheByTags.php index 396a57c741abd..7fa52cba4d767 100644 --- a/app/code/Magento/PageCache/Observer/FlushCacheByTags.php +++ b/app/code/Magento/PageCache/Observer/FlushCacheByTags.php @@ -68,7 +68,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) private function getCache() { if (!$this->fullPageCache) { - $this->fullPageCache = ObjectManager::getInstance()->get('\Magento\PageCache\Model\Cache\Type'); + $this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class); } return $this->fullPageCache; } diff --git a/app/code/Magento/PageCache/Test/Unit/App/CacheIdentifierPluginTest.php b/app/code/Magento/PageCache/Test/Unit/App/CacheIdentifierPluginTest.php index 8fbcae237b1aa..3d7cf5711eed6 100644 --- a/app/code/Magento/PageCache/Test/Unit/App/CacheIdentifierPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/App/CacheIdentifierPluginTest.php @@ -39,15 +39,15 @@ class CacheIdentifierPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->designExceptionsMock = $this->getMock( - 'Magento\Framework\View\DesignExceptions', + \Magento\Framework\View\DesignExceptions::class, ['getThemeByRequest'], [], '', false ); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->pageCacheConfigMock = $this->getMock( - 'Magento\PageCache\Model\Config', + \Magento\PageCache\Model\Config::class, ['getType', 'isEnabled'], [], '', @@ -73,7 +73,7 @@ protected function setUp() */ public function testAfterGetValue($cacheType, $isPageCacheEnabled, $result, $uaException, $expected) { - $identifierMock = $this->getMock('Magento\Framework\App\PageCache\Identifier', [], [], '', false); + $identifierMock = $this->getMock(\Magento\Framework\App\PageCache\Identifier::class, [], [], '', false); $this->pageCacheConfigMock->expects($this->once()) ->method('getType') diff --git a/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php b/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php index 4bd4621ab690c..cc5597905f147 100644 --- a/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php @@ -44,11 +44,11 @@ class JavascriptTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); $this->requestMock = $this->getMock( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, [ 'getRouteName', 'getControllerName', @@ -68,13 +68,13 @@ protected function setUp() '', false ); - $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->layoutUpdateMock = $this->getMockBuilder('Magento\Framework\View\Layout\ProcessorInterface') + $this->layoutUpdateMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ProcessorInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) @@ -91,7 +91,7 @@ protected function setUp() ->willReturn($this->layoutUpdateMock); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->blockJavascript = $objectManager->getObject( - 'Magento\PageCache\Block\Javascript', + \Magento\PageCache\Block\Javascript::class, [ 'context' => $this->contextMock ] diff --git a/app/code/Magento/PageCache/Test/Unit/Controller/Adminhtml/PageCache/ExportVarnishConfigTest.php b/app/code/Magento/PageCache/Test/Unit/Controller/Adminhtml/PageCache/ExportVarnishConfigTest.php index 3546a806720be..ffc14b1893b57 100644 --- a/app/code/Magento/PageCache/Test/Unit/Controller/Adminhtml/PageCache/ExportVarnishConfigTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Controller/Adminhtml/PageCache/ExportVarnishConfigTest.php @@ -53,22 +53,24 @@ class ExportVarnishConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fileFactoryMock = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http\FileFactory' + \Magento\Framework\App\Response\Http\FileFactory::class )->disableOriginalConstructor()->getMock(); $this->configMock = $this->getMockBuilder( - 'Magento\PageCache\Model\Config' + \Magento\PageCache\Model\Config::class )->disableOriginalConstructor()->getMock(); $contextMock = $this->getMockBuilder( - 'Magento\Backend\App\Action\Context' + \Magento\Backend\App\Action\Context::class )->disableOriginalConstructor()->getMock(); $this->requestMock = $this->getMockBuilder( - 'Magento\Framework\App\Request\Http' + \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->getMock(); $this->responseMock = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' + \Magento\Framework\App\Response\Http::class + )->disableOriginalConstructor()->getMock(); + $this->viewMock = $this->getMockBuilder( + \Magento\Framework\App\View::class )->disableOriginalConstructor()->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\View')->disableOriginalConstructor()->getMock(); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); @@ -86,7 +88,7 @@ public function testExportVarnishConfigAction() $fileContent = 'some conetnt'; $filename = 'varnish.vcl'; $responseMock = $this->getMockBuilder( - 'Magento\Framework\App\ResponseInterface' + \Magento\Framework\App\ResponseInterface::class )->disableOriginalConstructor()->getMock(); $this->configMock->expects($this->once())->method('getVclFile')->will($this->returnValue($fileContent)); @@ -103,6 +105,6 @@ public function testExportVarnishConfigAction() ); $result = $this->action->execute(); - $this->assertInstanceOf('Magento\Framework\App\ResponseInterface', $result); + $this->assertInstanceOf(\Magento\Framework\App\ResponseInterface::class, $result); } } diff --git a/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php b/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php index 415d1a24da9ec..b218237197955 100644 --- a/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php @@ -46,27 +46,31 @@ class EsiTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->disableOriginalConstructor()->getMock(); $contextMock = - $this->getMockBuilder('Magento\Framework\App\Action\Context')->disableOriginalConstructor()->getMock(); + $this->getMockBuilder( + \Magento\Framework\App\Action\Context::class)->disableOriginalConstructor()->getMock( + ); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor()->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\View')->disableOriginalConstructor()->getMock(); + $this->viewMock = $this->getMockBuilder( + \Magento\Framework\App\View::class)->disableOriginalConstructor()->getMock( + ); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); - $this->translateInline = $this->getMock('Magento\Framework\Translate\InlineInterface'); + $this->translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class); $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->action = $helperObjectManager->getObject( - 'Magento\PageCache\Controller\Block\Esi', + \Magento\PageCache\Controller\Block\Esi::class, ['context' => $contextMock, 'translateInline' => $this->translateInline] ); } @@ -84,6 +88,7 @@ public function testExecute($blockClass, $shouldSetHeaders) $mapData = [['blocks', '', json_encode([$block])], ['handles', '', json_encode($handles)]]; $blockInstance1 = $this->getMock( + $blockClass, ['toHtml'], [], @@ -129,8 +134,8 @@ public function testExecute($blockClass, $shouldSetHeaders) public function executeDataProvider() { return [ - ['Magento\PageCache\Test\Unit\Block\Controller\StubBlock', true], - ['Magento\Framework\View\Element\AbstractBlock', false], + [\Magento\PageCache\Test\Unit\Block\Controller\StubBlock::class, true], + [\Magento\Framework\View\Element\AbstractBlock::class, false], ]; } diff --git a/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php b/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php index b75b56718409f..c734851abbe1c 100644 --- a/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php @@ -46,30 +46,34 @@ class RenderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMockBuilder( - 'Magento\Framework\View\Layout' + $this->layoutMock = $this->getMockBuilder( + \Magento\Framework\View\Layout::class )->disableOriginalConstructor()->getMock(); $contextMock = - $this->getMockBuilder('Magento\Framework\App\Action\Context')->disableOriginalConstructor()->getMock(); + $this->getMockBuilder( + \Magento\Framework\App\Action\Context::class)->disableOriginalConstructor()->getMock( + ); - $this->requestMock = $this->getMockBuilder( - 'Magento\Framework\App\Request\Http' + $this->requestMock = $this->getMockBuilder( + \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->getMock(); - $this->responseMock = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' + $this->responseMock = $this->getMockBuilder( + \Magento\Framework\App\Response\Http::class )->disableOriginalConstructor()->getMock(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\View')->disableOriginalConstructor()->getMock(); + $this->viewMock = $this->getMockBuilder( + \Magento\Framework\App\View::class)->disableOriginalConstructor()->getMock( + ); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); - $this->translateInline = $this->getMock('Magento\Framework\Translate\InlineInterface'); + $this->translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class); $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->action = $helperObjectManager->getObject( - 'Magento\PageCache\Controller\Block\Render', + $this->action = $helperObjectManager->getObject( + \Magento\PageCache\Controller\Block\Render::class, ['context' => $contextMock, 'translateInline' => $this->translateInline] ); } @@ -106,8 +110,8 @@ public function testExecute() $originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}'; $expectedData = ['block1' => 'data1', 'block2' => 'data2']; - $blockInstance1 = $this->getMock( - 'Magento\PageCache\Test\Unit\Block\Controller\StubBlock', + $blockInstance1 = $this->getMock( + \Magento\PageCache\Test\Unit\Block\Controller\StubBlock::class, ['toHtml'], [], '', @@ -115,8 +119,8 @@ public function testExecute() ); $blockInstance1->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block1'])); - $blockInstance2 = $this->getMock( - 'Magento\PageCache\Test\Unit\Block\Controller\StubBlock', + $blockInstance2 = $this->getMock( + \Magento\PageCache\Test\Unit\Block\Controller\StubBlock::class, ['toHtml'], [], '', diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php index 61a4766bb387f..103b0af2a8153 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php @@ -60,19 +60,19 @@ class BuiltinPluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configMock = $this->getMock('Magento\PageCache\Model\Config', [], [], '', false); - $this->versionMock = $this->getMock('Magento\Framework\App\PageCache\Version', [], [], '', false); - $this->kernelMock = $this->getMock('Magento\Framework\App\PageCache\Kernel', [], [], '', false); - $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->configMock = $this->getMock(\Magento\PageCache\Model\Config::class, [], [], '', false); + $this->versionMock = $this->getMock(\Magento\Framework\App\PageCache\Version::class, [], [], '', false); + $this->kernelMock = $this->getMock(\Magento\Framework\App\PageCache\Kernel::class, [], [], '', false); + $this->stateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->frontControllerMock = $this->getMock( - 'Magento\Framework\App\FrontControllerInterface', + \Magento\Framework\App\FrontControllerInterface::class, [], [], '', false ); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $response = $this->responseMock; $this->closure = function () use ($response) { return $response; @@ -157,7 +157,7 @@ public function testAroundDispatchReturnsResultInterfaceProcessIfCacheMissed($st ->method('getMode') ->will($this->returnValue($state)); - $result = $this->getMock('Magento\Framework\Controller\ResultInterface', [], [], '', false); + $result = $this->getMock(\Magento\Framework\Controller\ResultInterface::class, [], [], '', false); $result->expects($this->never())->method('setHeader'); $closure = function () use ($result) { return $result; diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/VarnishPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/VarnishPluginTest.php index a5cbb156a2fef..32328d7d02793 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/VarnishPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/VarnishPluginTest.php @@ -55,18 +55,18 @@ class VarnishPluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configMock = $this->getMock('Magento\PageCache\Model\Config', [], [], '', false); - $this->versionMock = $this->getMock('Magento\Framework\App\PageCache\Version', [], [], '', false); - $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->configMock = $this->getMock(\Magento\PageCache\Model\Config::class, [], [], '', false); + $this->versionMock = $this->getMock(\Magento\Framework\App\PageCache\Version::class, [], [], '', false); + $this->stateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $this->frontControllerMock = $this->getMock( - 'Magento\Framework\App\FrontControllerInterface', + \Magento\Framework\App\FrontControllerInterface::class, [], [], '', false ); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $response = $this->responseMock; $this->closure = function () use ($response) { return $response; @@ -136,14 +136,14 @@ public function dataProvider() $this->once(), $this->once(), $this->once(), - $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false), + $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false), ], 'production' => [ \Magento\Framework\App\State::MODE_PRODUCTION, $this->never(), $this->never(), $this->never(), - $this->getMock('Magento\Framework\Controller\ResultInterface', [], [], '', false), + $this->getMock(\Magento\Framework\Controller\ResultInterface::class, [], [], '', false), ], ]; } diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php index 449a9d98dba5a..ba519c0b7d811 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php @@ -20,8 +20,8 @@ class PageCachePluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->plugin = (new ObjectManager($this))->getObject('\Magento\PageCache\Model\App\PageCachePlugin'); - $this->subjectMock = $this->getMockBuilder('\Magento\Framework\App\PageCache\Cache') + $this->plugin = (new ObjectManager($this))->getObject(\Magento\PageCache\Model\App\PageCachePlugin::class); + $this->subjectMock = $this->getMockBuilder(\Magento\Framework\App\PageCache\Cache::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php index ac5d402f803ef..60506021a8173 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php @@ -29,8 +29,8 @@ public function testBeforeSendResponse($responseInstanceClass, $sendVaryCalled) public function beforeSendResponseDataProvider() { return [ - ['Magento\Framework\App\Response\Http', 1], - ['Magento\MediaStorage\Model\File\Storage\Response', 0] + [\Magento\Framework\App\Response\Http::class, 1], + [\Magento\MediaStorage\Model\File\Storage\Response::class, 0] ]; } } diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php index 4f1eb32b412c3..390daa53655ac 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php @@ -25,16 +25,16 @@ class ServerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->loggerMock = $this->getMock('Magento\Framework\Cache\InvalidateLogger', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + $this->configMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->loggerMock = $this->getMock(\Magento\Framework\Cache\InvalidateLogger::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\PageCache\Model\Cache\Server', + \Magento\PageCache\Model\Cache\Server::class, [ 'urlBuilder' => $this->urlBuilderMock, 'config' => $this->configMock, diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Cache/TypeTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Cache/TypeTest.php index 577ac0f0ca936..e62534d04b26f 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Cache/TypeTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Cache/TypeTest.php @@ -18,13 +18,13 @@ class TypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->cacheFrontendPoolMock = $this->getMockBuilder('Magento\Framework\App\Cache\Type\FrontendPool') + $this->cacheFrontendPoolMock = $this->getMockBuilder(\Magento\Framework\App\Cache\Type\FrontendPool::class) ->disableOriginalConstructor() ->getMock(); - $cacheFrontend = $this->getMockBuilder('Magento\Framework\Cache\FrontendInterface') + $cacheFrontend = $this->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class) ->disableOriginalConstructor() ->getMock(); $this->cacheFrontendPoolMock->expects($this->once()) @@ -32,7 +32,7 @@ protected function setUp() ->willReturn($cacheFrontend); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\PageCache\Model\Cache\Type', + \Magento\PageCache\Model\Cache\Type::class, [ 'eventManager' => $this->eventManagerMock, 'cacheFrontendPool' => $this->cacheFrontendPoolMock, diff --git a/app/code/Magento/PageCache/Test/Unit/Model/ConfigTest.php b/app/code/Magento/PageCache/Test/Unit/Model/ConfigTest.php index 30ac1c5784e25..2b1c389ca9a1f 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/ConfigTest.php @@ -34,12 +34,18 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $readFactoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); - $this->_coreConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->_cacheState = $this->getMockForAbstractClass('Magento\Framework\App\Cache\StateInterface'); + $readFactoryMock = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); + $this->_coreConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_cacheState = $this->getMockForAbstractClass(\Magento\Framework\App\Cache\StateInterface::class); $modulesDirectoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', + \Magento\Framework\Filesystem\Directory\Write::class, [], [], '', @@ -94,7 +100,7 @@ protected function setUp() ) ); - $this->moduleReader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->moduleReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $this->_model = new \Magento\PageCache\Model\Config( $readFactoryMock, $this->_coreConfigMock, diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/BuiltinPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/BuiltinPluginTest.php index b0be41165f80e..15934f3104b23 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/BuiltinPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/BuiltinPluginTest.php @@ -52,15 +52,15 @@ class BuiltinPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $result = $this->getMock('Magento\Framework\Controller\ResultInterface', [], [], '', false); + $result = $this->getMock(\Magento\Framework\Controller\ResultInterface::class, [], [], '', false); $this->closure = function() use ($result) { return $result; }; - $this->header = $this->getMock('Zend\Http\Header\HeaderInterface', [], [], '', false); - $this->subject = $this->getMock('Magento\Framework\Controller\ResultInterface', [], [], '', false); - $this->response = $this->getMock( - 'Magento\Framework\App\Response\Http', + $this->header = $this->getMock(\Zend\Http\Header\HeaderInterface::class, [], [], '', false); + $this->subject = $this->getMock(\Magento\Framework\Controller\ResultInterface::class, [], [], '', false); + $this->response = $this->getMock( + \Magento\Framework\App\Response\Http::class, ['getHeader', 'clearHeader', 'setHeader'], [], '', @@ -73,17 +73,17 @@ protected function setUp() ] ); - $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $config = $this->getMock('Magento\PageCache\Model\Config', ['isEnabled', 'getType'], [], '', false); + $config = $this->getMock(\Magento\PageCache\Model\Config::class, ['isEnabled', 'getType'], [], '', false); $config->expects($this->any())->method('isEnabled')->willReturn(true); $config->expects($this->any())->method('getType')->willReturn(\Magento\PageCache\Model\Config::BUILT_IN); - $this->kernel = $this->getMock('Magento\Framework\App\PageCache\Kernel', [], [], '', false); + $this->kernel = $this->getMock(\Magento\Framework\App\PageCache\Kernel::class, [], [], '', false); - $this->state = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->plugin = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\PageCache\Model\Controller\Result\BuiltinPlugin', + $this->state = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->plugin = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + \Magento\PageCache\Model\Controller\Result\BuiltinPlugin::class, [ 'registry' => $this->registry, 'config' => $config, diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/VarnishPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/VarnishPluginTest.php index c65a41aaa025d..e58aae1668ff8 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/VarnishPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Controller/Result/VarnishPluginTest.php @@ -17,42 +17,42 @@ class VarnishPluginTest extends \PHPUnit_Framework_TestCase public function testAroundResult($usePlugin, $setCacheDebugHeaderCount, $getModeCount, $processCount) { /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject $response */ - $response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $response->expects($setCacheDebugHeaderCount)->method('setHeader') ->with('X-Magento-Debug', 1); /** @var \Magento\Framework\Controller\ResultInterface $result */ - $result = $this->getMock('Magento\Framework\Controller\ResultInterface', [], [], '', false); + $result = $this->getMock(\Magento\Framework\Controller\ResultInterface::class, [], [], '', false); $closure = function () use ($result) { return $result; }; /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject $registry */ - $registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $registry->expects($this->once())->method('registry')->with('use_page_cache_plugin') ->will($this->returnValue($usePlugin)); /** @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject $config */ - $config = $this->getMock('Magento\PageCache\Model\Config', [], [], '', false); + $config = $this->getMock(\Magento\PageCache\Model\Config::class, [], [], '', false); $config->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); $config->expects($this->once())->method('getType') ->will($this->returnValue(\Magento\PageCache\Model\Config::VARNISH)); /** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject $state */ - $state = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $state = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $state->expects($getModeCount)->method('getMode') ->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER)); /** @var \Magento\Framework\Controller\ResultInterface|\PHPUnit_Framework_MockObject_MockObject $subject */ - $subject = $this->getMock('Magento\Framework\Controller\ResultInterface', [], [], '', false); + $subject = $this->getMock(\Magento\Framework\Controller\ResultInterface::class, [], [], '', false); /** @var \Magento\Framework\App\PageCache\Version|\PHPUnit_Framework_MockObject_MockObject $version */ - $version = $this->getMock('Magento\Framework\App\PageCache\Version', [], [], '', false); + $version = $this->getMock(\Magento\Framework\App\PageCache\Version::class, [], [], '', false); $version->expects($processCount)->method('process'); /** @var \Magento\PageCache\Model\Controller\Result\VarnishPlugin $plugin */ $plugin = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\PageCache\Model\Controller\Result\VarnishPlugin', + \Magento\PageCache\Model\Controller\Result\VarnishPlugin::class, [ 'registry' => $registry, 'config' => $config, diff --git a/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php b/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php index 958b270a96086..59639c3b683bb 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php @@ -26,9 +26,9 @@ class DepersonalizeCheckerTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->moduleManagerMock = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); - $this->cacheConfigMock = $this->getMock('Magento\PageCache\Model\Config', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->moduleManagerMock = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); + $this->cacheConfigMock = $this->getMock(\Magento\PageCache\Model\Config::class, [], [], '', false); } /** @@ -56,7 +56,7 @@ public function testCheckIfDepersonalize( ->willReturn($moduleManagerResult); $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn($cacheConfigResult); - $layoutMock = $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface', [], '', false); + $layoutMock = $this->getMockForAbstractClass(\Magento\Framework\View\LayoutInterface::class, [], '', false); $layoutMock->expects($this->any())->method('isCacheable')->willReturn($layoutResult); $object = new DepersonalizeChecker($this->requestMock, $this->moduleManagerMock, $this->cacheConfigMock); diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 21017ddcfa61a..4de1eaabe3f87 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -43,16 +43,17 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); - $this->messageSessionMock = $this->getMock('Magento\Framework\Message\Session', + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); + $this->messageSessionMock = $this->getMock( + \Magento\Framework\Message\Session::class, ['clearStorage'], [], '', false ); - $this->depersonalizeCheckerMock = $this->getMock( - 'Magento\PageCache\Model\DepersonalizeChecker', + $this->depersonalizeCheckerMock = $this->getMock( + \Magento\PageCache\Model\DepersonalizeChecker::class, [], [], '', @@ -67,7 +68,7 @@ protected function setUp() public function testAfterGenerateXml() { - $expectedResult = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $this->eventManagerMock->expects($this->once()) ->method('dispatch') @@ -86,7 +87,7 @@ public function testAfterGenerateXmlNoDepersonalize() ->method('dispatch'); $this->messageSessionMock->expects($this->never())->method('clearStorage'); - $expectedResult = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult); $this->assertEquals($expectedResult, $actualResult); } diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php index 010493d2035a7..df656cc700a20 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php @@ -30,7 +30,7 @@ class LayoutPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->layoutMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Layout', + \Magento\Framework\View\Layout::class, [], '', false, @@ -38,8 +38,8 @@ protected function setUp() true, ['isCacheable', 'getAllBlocks'] ); - $this->responseMock = $this->getMock('\Magento\Framework\App\Response\Http', [], [], '', false); - $this->configMock = $this->getMock('Magento\PageCache\Model\Config', [], [], '', false); + $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->configMock = $this->getMock(\Magento\PageCache\Model\Config::class, [], [], '', false); $this->model = new \Magento\PageCache\Model\Layout\LayoutPlugin( $this->responseMock, @@ -92,7 +92,13 @@ public function testAfterGetOutput($cacheState, $layoutIsCacheable, $expectedTag { $html = 'html'; $this->configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState)); - $blockStub = $this->getMock('Magento\PageCache\Test\Unit\Block\Controller\StubBlock', null, [], '', false); + $blockStub = $this->getMock( + \Magento\PageCache\Test\Unit\Block\Controller\StubBlock::class, + null, + [], + '', + false + ); $blockStub->setTtl($ttl); $this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue($layoutIsCacheable)); $this->layoutMock->expects($this->any())->method('getAllBlocks')->will($this->returnValue([$blockStub])); diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/FlushAllCacheTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/FlushAllCacheTest.php index 37833413d71b4..5e118717388d8 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/FlushAllCacheTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/FlushAllCacheTest.php @@ -32,22 +32,22 @@ class FlushAllCacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_configMock = $this->getMock( - 'Magento\PageCache\Model\Config', + \Magento\PageCache\Model\Config::class, ['getType', 'isEnabled'], [], '', false ); - $this->_cacheMock = $this->getMock('Magento\Framework\App\PageCache\Cache', ['clean'], [], '', false); - $this->fullPageCacheMock = $this->getMock('\Magento\PageCache\Model\Cache\Type', ['clean'], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer'); + $this->_cacheMock = $this->getMock(\Magento\Framework\App\PageCache\Cache::class, ['clean'], [], '', false); + $this->fullPageCacheMock = $this->getMock(\Magento\PageCache\Model\Cache\Type::class, ['clean'], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class); $this->_model = new \Magento\PageCache\Observer\FlushAllCache( $this->_configMock, $this->_cacheMock ); - $reflection = new \ReflectionClass('\Magento\PageCache\Observer\FlushAllCache'); + $reflection = new \ReflectionClass(\Magento\PageCache\Observer\FlushAllCache::class); $reflectionProperty = $reflection->getProperty('fullPageCache'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->_model, $this->fullPageCacheMock); diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php index 708770a31249e..2227228e007c7 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php @@ -29,20 +29,20 @@ class FlushCacheByTagsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_configMock = $this->getMock( - 'Magento\PageCache\Model\Config', + \Magento\PageCache\Model\Config::class, ['getType', 'isEnabled'], [], '', false ); - $this->_cacheMock = $this->getMock('Magento\Framework\App\PageCache\Cache', ['clean'], [], '', false); - $this->fullPageCacheMock = $this->getMock('\Magento\PageCache\Model\Cache\Type', ['clean'], [], '', false); + $this->_cacheMock = $this->getMock(\Magento\Framework\App\PageCache\Cache::class, ['clean'], [], '', false); + $this->fullPageCacheMock = $this->getMock(\Magento\PageCache\Model\Cache\Type::class, ['clean'], [], '', false); $this->_model = new \Magento\PageCache\Observer\FlushCacheByTags( $this->_configMock, $this->_cacheMock ); - $reflection = new \ReflectionClass('\Magento\PageCache\Observer\FlushCacheByTags'); + $reflection = new \ReflectionClass(\Magento\PageCache\Observer\FlushCacheByTags::class); $reflectionProperty = $reflection->getProperty('fullPageCache'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->_model, $this->fullPageCacheMock); @@ -57,14 +57,14 @@ protected function setUp() public function testExecute($cacheState) { $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState)); - $observerObject = $this->getMock('Magento\Framework\Event\Observer'); - $observedObject = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $observerObject = $this->getMock(\Magento\Framework\Event\Observer::class); + $observedObject = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); if ($cacheState) { $tags = ['cache_1', 'cache_group']; $expectedTags = ['cache_1', 'cache_group']; - $eventMock = $this->getMock('Magento\Framework\Event', ['getObject'], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getObject'], [], '', false); $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject)); $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock)); $this->_configMock->expects($this->once()) @@ -91,12 +91,12 @@ public function flushCacheByTagsDataProvider() public function testExecuteWithEmptyTags() { $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue(true)); - $observerObject = $this->getMock('Magento\Framework\Event\Observer'); - $observedObject = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $observerObject = $this->getMock(\Magento\Framework\Event\Observer::class); + $observedObject = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $tags = []; - $eventMock = $this->getMock('Magento\Framework\Event', ['getObject'], [], '', false); + $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getObject'], [], '', false); $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject)); $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock)); $this->_configMock->expects( diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/FlushFormKeyOnLogoutTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/FlushFormKeyOnLogoutTest.php index 3d5c146e017c4..43b33eba088ea 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/FlushFormKeyOnLogoutTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/FlushFormKeyOnLogoutTest.php @@ -14,12 +14,12 @@ public function testExecute() { /** @var FormKey | \PHPUnit_Framework_MockObject_MockObject $cookieFormKey */ $cookieFormKey = $this->getMockBuilder( - 'Magento\Framework\App\PageCache\FormKey' + \Magento\Framework\App\PageCache\FormKey::class ) ->disableOriginalConstructor() ->getMock(); - $observerObject = $this->getMock('Magento\Framework\Event\Observer'); + $observerObject = $this->getMock(\Magento\Framework\Event\Observer::class); $observer = new FlushFormKeyOnLogout($cookieFormKey); diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/InvalidateCacheTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/InvalidateCacheTest.php index c9ba860113f54..54ccf21ab3c00 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/InvalidateCacheTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/InvalidateCacheTest.php @@ -28,15 +28,15 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_configMock = $this->getMock( - 'Magento\PageCache\Model\Config', + \Magento\PageCache\Model\Config::class, ['getType', 'isEnabled'], [], '', false ); - $this->_typeListMock = $this->getMock('Magento\Framework\App\Cache\TypeList', [], [], '', false); + $this->_typeListMock = $this->getMock(\Magento\Framework\App\Cache\TypeList::class, [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer'); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class); $this->_model = new \Magento\PageCache\Observer\InvalidateCache( $this->_configMock, diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/ProcessLayoutRenderElementTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/ProcessLayoutRenderElementTest.php index 9f18dbfa2dfc8..f6f23fad3c83c 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/ProcessLayoutRenderElementTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/ProcessLayoutRenderElementTest.php @@ -34,8 +34,8 @@ class ProcessLayoutRenderElementTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_configMock = $this->getMock( - 'Magento\PageCache\Model\Config', + $this->_configMock = $this->getMock( + \Magento\PageCache\Model\Config::class, ['getType', 'isEnabled'], [], '', @@ -43,22 +43,22 @@ protected function setUp() ); $this->_model = new \Magento\PageCache\Observer\ProcessLayoutRenderElement($this->_configMock); - $this->_observerMock = $this->getMock( - 'Magento\Framework\Event\Observer', + $this->_observerMock = $this->getMock( + \Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false ); - $this->_layoutMock = $this->getMock( - 'Magento\Framework\View\Layout', + $this->_layoutMock = $this->getMock( + \Magento\Framework\View\Layout::class, ['isCacheable', 'getBlock', 'getUpdate', 'getHandles'], [], '', false ); - $this->_blockMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\AbstractBlock', + $this->_blockMock = $this->getMockForAbstractClass( + \Magento\Framework\View\Element\AbstractBlock::class, [], '', false, @@ -84,8 +84,8 @@ public function testExecute( $blockTtl, $expectedOutput ) { - $eventMock = $this->getMock( - 'Magento\Framework\Event', + $eventMock = $this->getMock( + \Magento\Framework\Event::class, ['getLayout', 'getElementName', 'getTransport'], [], '', diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/RegisterFormKeyFromCookieTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/RegisterFormKeyFromCookieTest.php index 7ea33970ae6eb..c1c971742128c 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/RegisterFormKeyFromCookieTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/RegisterFormKeyFromCookieTest.php @@ -47,30 +47,30 @@ class RegisterFormKeyFromCookieTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->cookieFormKey = $this->getMockBuilder( - 'Magento\Framework\App\PageCache\FormKey' + \Magento\Framework\App\PageCache\FormKey::class ) ->disableOriginalConstructor() ->getMock(); $this->escaper = $this->getMockBuilder( - 'Magento\Framework\Escaper' + \Magento\Framework\Escaper::class ) ->disableOriginalConstructor() ->getMock(); $this->sessionFormKey = $this->getMockBuilder( - 'Magento\Framework\Data\Form\FormKey' + \Magento\Framework\Data\Form\FormKey::class ) ->disableOriginalConstructor() ->getMock(); $this->cookieMetadataFactory = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class ) ->disableOriginalConstructor() ->getMock(); $this->sessionConfig = $this->getMock( - 'Magento\Framework\Session\Config\ConfigInterface' + \Magento\Framework\Session\Config\ConfigInterface::class ); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer'); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class); $this->observer = new RegisterFormKeyFromCookie( $this->cookieFormKey, @@ -103,7 +103,7 @@ public function testExecute() $cookieLifetime = 3600; $cookieMetadata = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Payment/Block/Info/Substitution.php b/app/code/Magento/Payment/Block/Info/Substitution.php index 5cbc7ba325dea..c06212ebe7315 100644 --- a/app/code/Magento/Payment/Block/Info/Substitution.php +++ b/app/code/Magento/Payment/Block/Info/Substitution.php @@ -25,7 +25,7 @@ protected function _beforeToHtml() $container = $parentBlock->getParentBlock(); if ($container) { $block = $this->_layout->createBlock( - 'Magento\Framework\View\Element\Template', + \Magento\Framework\View\Element\Template::class, '', ['data' => ['method' => $this->getMethod(), 'template' => 'Magento_Payment::info/substitution.phtml']] ); diff --git a/app/code/Magento/Payment/Gateway/Data/PaymentDataObjectFactory.php b/app/code/Magento/Payment/Gateway/Data/PaymentDataObjectFactory.php index 92dd860a28311..0ab98673d9afa 100644 --- a/app/code/Magento/Payment/Gateway/Data/PaymentDataObjectFactory.php +++ b/app/code/Magento/Payment/Gateway/Data/PaymentDataObjectFactory.php @@ -65,7 +65,7 @@ public function create(InfoInterface $paymentInfo) $data['payment'] = $paymentInfo; return $this->objectManager->create( - 'Magento\Payment\Gateway\Data\PaymentDataObject', + \Magento\Payment\Gateway\Data\PaymentDataObject::class, $data ); } diff --git a/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php b/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php index e43026ce3718e..2cb288dba0773 100644 --- a/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php +++ b/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php @@ -34,9 +34,9 @@ public function create($salesModel) { $arguments = ['salesModel' => $salesModel]; if ($salesModel instanceof \Magento\Quote\Model\Quote) { - return $this->_objectManager->create('Magento\Payment\Model\Cart\SalesModel\Quote', $arguments); + return $this->_objectManager->create(\Magento\Payment\Model\Cart\SalesModel\Quote::class, $arguments); } elseif ($salesModel instanceof \Magento\Sales\Model\Order) { - return $this->_objectManager->create('Magento\Payment\Model\Cart\SalesModel\Order', $arguments); + return $this->_objectManager->create(\Magento\Payment\Model\Cart\SalesModel\Order::class, $arguments); } throw new \InvalidArgumentException('Sales model has bad type!'); } diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index 24b543ca02d62..50c0f52e3f45b 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -70,12 +70,12 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl /** * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form'; + protected $_formBlockType = \Magento\Payment\Block\Form::class; /** * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info'; + protected $_infoBlockType = \Magento\Payment\Block\Info::class; /** * Payment Method feature diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index 1c6aba88d2118..be5c3066ccc05 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -14,12 +14,12 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form\Cc'; + protected $_formBlockType = \Magento\Payment\Block\Form\Cc::class; /** * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Cc'; + protected $_infoBlockType = \Magento\Payment\Block\Info\Cc::class; /** * @var bool diff --git a/app/code/Magento/Payment/Model/Method/Substitution.php b/app/code/Magento/Payment/Model/Method/Substitution.php index 375f4452494d3..3d2ca06609783 100644 --- a/app/code/Magento/Payment/Model/Method/Substitution.php +++ b/app/code/Magento/Payment/Model/Method/Substitution.php @@ -31,7 +31,7 @@ class Substitution extends AbstractMethod /** * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Substitution'; + protected $_infoBlockType = \Magento\Payment\Block\Info\Substitution::class; /** * Retrieve payment method title diff --git a/app/code/Magento/Payment/Test/Unit/Block/Adminhtml/Transparent/FormTest.php b/app/code/Magento/Payment/Test/Unit/Block/Adminhtml/Transparent/FormTest.php index c87b597825d1c..7b156f244165c 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Adminhtml/Transparent/FormTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Adminhtml/Transparent/FormTest.php @@ -32,25 +32,25 @@ protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['getParam']) ->getMockForAbstractClass(); - $this->urlBuilderMock = $this->getMockBuilder('\Magento\Framework\UrlInterface') + $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->setMethods(['getUrl']) ->getMockForAbstractClass(); - $context = $objectManagerHelper->getObject('Magento\Framework\View\Element\Template\Context'); + $context = $objectManagerHelper->getObject(\Magento\Framework\View\Element\Template\Context::class); - $this->methodMock = $this->getMockBuilder('Magento\Payment\Model\Method\TransparentInterface') + $this->methodMock = $this->getMockBuilder(\Magento\Payment\Model\Method\TransparentInterface::class) ->getMock(); - $this->checkoutSessionMock = $this->getMockBuilder('Magento\Checkout\Model\Session') + $this->checkoutSessionMock = $this->getMockBuilder(\Magento\Checkout\Model\Session::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); - $paymentConfigMock = $this->getMockBuilder('Magento\Payment\Model\Config') + $paymentConfigMock = $this->getMockBuilder(\Magento\Payment\Model\Config::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); @@ -64,10 +64,10 @@ protected function setUp() public function testToHtmlShouldRender() { - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->getMock(); - $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Block/Form/ContainerTest.php b/app/code/Magento/Payment/Test/Unit/Block/Form/ContainerTest.php index 4cb09ba321c3c..e6de90409de1d 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Form/ContainerTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Form/ContainerTest.php @@ -17,8 +17,8 @@ class ContainerTest extends \PHPUnit_Framework_TestCase public function testSetMethodFormTemplate() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $childBlockA = $objectManagerHelper->getObject('Magento\Framework\View\Element\Template'); - $childBlockB = $objectManagerHelper->getObject('Magento\Framework\View\Element\Template'); + $childBlockA = $objectManagerHelper->getObject(\Magento\Framework\View\Element\Template::class); + $childBlockB = $objectManagerHelper->getObject(\Magento\Framework\View\Element\Template::class); $func = function ($blockName) use ($childBlockA, $childBlockB) { switch ($blockName) { @@ -29,7 +29,7 @@ public function testSetMethodFormTemplate() } return null; }; - $block = $this->getMock('Magento\Payment\Block\Form\Container', ['getChildBlock'], [], '', false); + $block = $this->getMock(\Magento\Payment\Block\Form\Container::class, ['getChildBlock'], [], '', false); $block->expects($this->atLeastOnce())->method('getChildBlock')->will($this->returnCallback($func)); $template = 'any_template.phtml'; diff --git a/app/code/Magento/Payment/Test/Unit/Block/FormTest.php b/app/code/Magento/Payment/Test/Unit/Block/FormTest.php index 0524358d6562f..ac207c02b0691 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/FormTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/FormTest.php @@ -35,26 +35,26 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_storeManager = $this->getMockBuilder( - '\Magento\Store\Model\StoreManager' + $this->_storeManager = $this->getMockBuilder( + \Magento\Store\Model\StoreManager::class )->setMethods( ['getStore'] )->disableOriginalConstructor()->getMock(); - $this->_eventManager = $this->getMockBuilder( - '\Magento\Framework\Event\ManagerInterface' + $this->_eventManager = $this->getMockBuilder( + \Magento\Framework\Event\ManagerInterface::class )->setMethods( ['dispatch'] )->disableOriginalConstructor()->getMock(); - $this->_escaper = $this->getMock('\Magento\Framework\Escaper', null, [], '', true); - $context = $helper->getObject( - 'Magento\Framework\View\Element\Template\Context', + $this->_escaper = $this->getMock(\Magento\Framework\Escaper::class, null, [], '', true); + $context = $helper->getObject( + \Magento\Framework\View\Element\Template\Context::class, [ 'storeManager' => $this->_storeManager, 'eventManager' => $this->_eventManager, 'escaper' => $this->_escaper ] ); - $this->_object = $helper->getObject('Magento\Payment\Block\Form', ['context' => $context]); + $this->_object = $helper->getObject(\Magento\Payment\Block\Form::class, ['context' => $context]); } /** @@ -69,7 +69,7 @@ public function testGetMethodException() public function testGetMethodCode() { - $method = $this->getMock('Magento\Payment\Model\MethodInterface', [], [], '', false); + $method = $this->getMock(\Magento\Payment\Model\MethodInterface::class, [], [], '', false); $method->expects($this->once()) ->method('getCode') ->will($this->returnValue('method_code')); @@ -82,7 +82,7 @@ public function testGetMethodCode() */ public function testGetInfoData($field, $value, $expected) { - $methodInstance = $this->getMockBuilder('\Magento\Payment\Model\Method\AbstractMethod') + $methodInstance = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->setMethods(['getData']) ->disableOriginalConstructor() ->getMock(); @@ -90,8 +90,8 @@ public function testGetInfoData($field, $value, $expected) ->method('getData') ->with($field) ->will($this->returnValue($value)); - $method = $this->getMockBuilder( - 'Magento\Payment\Model\MethodInterface' + $method = $this->getMockBuilder( + \Magento\Payment\Model\MethodInterface::class )->getMockForAbstractClass(); $method->expects($this->any()) ->method('getInfoInstance') @@ -118,7 +118,7 @@ public function getInfoDataProvider() public function testSetMethod() { - $methodInterfaceMock = $this->getMockBuilder('\Magento\Payment\Model\MethodInterface') + $methodInterfaceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $this->assertSame($this->_object, $this->_object->setMethod($methodInterfaceMock)); diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php index 744beb6634a85..08f667eec9657 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php @@ -31,14 +31,26 @@ class CcTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->paymentConfig = $this->getMock('Magento\Payment\Model\Config', [], [], '', false); - $this->localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', [], [], '', false); - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', ['getLocaleDate'], [], '', false); + $this->paymentConfig = $this->getMock(\Magento\Payment\Model\Config::class, [], [], '', false); + $this->localeDate = $this->getMock( + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, + [], + [], + '', + false + ); + $context = $this->getMock( + \Magento\Framework\View\Element\Template\Context::class, + ['getLocaleDate'], + [], + '', + false + ); $context->expects($this->any()) ->method('getLocaleDate') ->will($this->returnValue($this->localeDate)); $this->model = $this->objectManager->getObject( - 'Magento\Payment\Block\Info\Cc', + \Magento\Payment\Block\Info\Cc::class, [ 'paymentConfig' => $this->paymentConfig, 'context' => $context @@ -54,7 +66,7 @@ public function testGetCcTypeName($configCcTypes, $ccType, $expected) $this->paymentConfig->expects($this->any()) ->method('getCcTypes') ->will($this->returnValue($configCcTypes)); - $paymentInfo = $this->getMock('Magento\Payment\Model\Info', ['getCcType'], [], '', false); + $paymentInfo = $this->getMock(\Magento\Payment\Model\Info::class, ['getCcType'], [], '', false); $paymentInfo->expects($this->any()) ->method('getCcType') ->will($this->returnValue($ccType)); @@ -79,7 +91,14 @@ public function getCcTypeNameDataProvider() */ public function testHasCcExpDate($ccExpMonth, $ccExpYear, $expected) { - $paymentInfo = $this->getMock('Magento\Payment\Model\Info', ['getCcExpMonth', 'getCcExpYear'], [], '', false); + $paymentInfo = $this->getMock( + \Magento\Payment\Model\Info::class, + ['getCcExpMonth', + 'getCcExpYear'], + [], + '', + false + ); $paymentInfo->expects($this->any()) ->method('getCcExpMonth') ->will($this->returnValue($ccExpMonth)); @@ -107,7 +126,7 @@ public function hasCcExpDateDataProvider() */ public function testGetCcExpMonth($ccExpMonth, $expected) { - $paymentInfo = $this->getMock('Magento\Payment\Model\Info', ['getCcExpMonth'], [], '', false); + $paymentInfo = $this->getMock(\Magento\Payment\Model\Info::class, ['getCcExpMonth'], [], '', false); $paymentInfo->expects($this->any()) ->method('getCcExpMonth') ->will($this->returnValue($ccExpMonth)); @@ -131,7 +150,14 @@ public function ccExpMonthDataProvider() */ public function testGetCcExpDate($ccExpMonth, $ccExpYear) { - $paymentInfo = $this->getMock('Magento\Payment\Model\Info', ['getCcExpMonth', 'getCcExpYear'], [], '', false); + $paymentInfo = $this->getMock( + \Magento\Payment\Model\Info::class, + ['getCcExpMonth', + 'getCcExpYear'], + [], + '', + false + ); $paymentInfo ->expects($this->any()) ->method('getCcExpMonth') diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/ContainerAbstractTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/ContainerAbstractTest.php index 7555a39917c43..5c87fb4ca28eb 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/ContainerAbstractTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/ContainerAbstractTest.php @@ -14,19 +14,19 @@ class ContainerAbstractTest extends \PHPUnit_Framework_TestCase public function testSetInfoTemplate() { $block = $this->getMock( - 'Magento\Payment\Block\Info\AbstractContainer', + \Magento\Payment\Block\Info\AbstractContainer::class, ['getChildBlock', 'getPaymentInfo'], [], '', false ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $paymentInfo = $objectManagerHelper->getObject('Magento\Payment\Model\Info'); - $methodInstance = $objectManagerHelper->getObject('Magento\OfflinePayments\Model\Checkmo'); + $paymentInfo = $objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); + $methodInstance = $objectManagerHelper->getObject(\Magento\OfflinePayments\Model\Checkmo::class); $paymentInfo->setMethodInstance($methodInstance); $block->expects($this->atLeastOnce())->method('getPaymentInfo')->will($this->returnValue($paymentInfo)); - $childBlock = $objectManagerHelper->getObject('Magento\Framework\View\Element\Template'); + $childBlock = $objectManagerHelper->getObject(\Magento\Framework\View\Element\Template::class); $block->expects( $this->atLeastOnce() )->method( diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/InstructionsTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/InstructionsTest.php index ab8171e262d5e..40efa750c596e 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/InstructionsTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/InstructionsTest.php @@ -23,9 +23,9 @@ class InstructionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); $this->_instructions = new \Magento\Payment\Block\Info\Instructions($context); - $this->_info = $this->getMock('Magento\Payment\Model\Info', [], [], '', false); + $this->_info = $this->getMock(\Magento\Payment\Model\Info::class, [], [], '', false); $this->_instructions->setData('info', $this->_info); } @@ -44,7 +44,7 @@ public function testGetInstructionAdditionalInformation() public function testGetInstruction() { $methodInstance = $this->getMockBuilder( - 'Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->getMockForAbstractClass(); $methodInstance->expects($this->once()) ->method('getConfigData') diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php index 97286561fad41..fb8f720b4735d 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php @@ -8,6 +8,9 @@ namespace Magento\Payment\Test\Unit\Block\Info; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SubstitutionTest extends \PHPUnit_Framework_TestCase { /** @@ -30,19 +33,19 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->layout = $this->getMockBuilder( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); $eventManager = $this->getMockBuilder( - 'Magento\Framework\Event\ManagerInterface' + \Magento\Framework\Event\ManagerInterface::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); $scopeConfig = $this->getMockBuilder( - 'Magento\Framework\App\Config\ScopeConfigInterface' + \Magento\Framework\App\Config\ScopeConfigInterface::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); @@ -62,7 +65,7 @@ protected function setUp() ); $context = $this->getMockBuilder( - 'Magento\Framework\View\Element\Template\Context' + \Magento\Framework\View\Element\Template\Context::class )->disableOriginalConstructor()->setMethods( ['getLayout', 'getEventManager', 'getScopeConfig'] )->getMock(); @@ -95,7 +98,7 @@ protected function setUp() ); $this->block = $this->objectManager->getObject( - 'Magento\Payment\Block\Info\Substitution', + \Magento\Payment\Block\Info\Substitution::class, [ 'context' => $context, 'data' => [ @@ -108,7 +111,7 @@ protected function setUp() public function testBeforeToHtml() { $abstractBlock = $this->getMockBuilder( - 'Magento\Framework\View\Element\AbstractBlock' + \Magento\Framework\View\Element\AbstractBlock::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); @@ -120,12 +123,12 @@ public function testBeforeToHtml() $this->layout->expects($this->any())->method('getBlock')->will($this->returnValue($abstractBlock)); $infoMock = $this->getMockBuilder( - 'Magento\Payment\Model\Info' + \Magento\Payment\Model\Info::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); $methodMock = $this->getMockBuilder( - 'Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->getMockForAbstractClass(); $infoMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock)); $this->block->setInfo($infoMock); @@ -136,7 +139,7 @@ public function testBeforeToHtml() )->method( 'createBlock' )->with( - 'Magento\Framework\View\Element\Template', + \Magento\Framework\View\Element\Template::class, '', ['data' => ['method' => $methodMock, 'template' => 'Magento_Payment::info/substitution.phtml']] )->will( diff --git a/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php b/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php index 913f570410a0a..61279d551d02f 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php @@ -33,25 +33,25 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_storeManager = $this->getMockBuilder( - '\Magento\Store\Model\StoreManager' + \Magento\Store\Model\StoreManager::class )->setMethods( ['getStore'] )->disableOriginalConstructor()->getMock(); $this->_eventManager = $this->getMockBuilder( - '\Magento\Framework\Event\ManagerInterface' + \Magento\Framework\Event\ManagerInterface::class )->setMethods( ['dispatch'] )->disableOriginalConstructor()->getMock(); - $this->_escaper = $this->getMock('\Magento\Framework\Escaper', null, [], '', true); + $this->_escaper = $this->getMock(\Magento\Framework\Escaper::class, null, [], '', true); $context = $helper->getObject( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [ 'storeManager' => $this->_storeManager, 'eventManager' => $this->_eventManager, 'escaper' => $this->_escaper ] ); - $this->_object = $helper->getObject('Magento\Payment\Block\Info', ['context' => $context]); + $this->_object = $helper->getObject(\Magento\Payment\Block\Info::class, ['context' => $context]); } /** @@ -73,7 +73,9 @@ public function testGetIsSecureMode($isSecureMode, $methodInstance, $store, $sto $this->_storeManager->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); } - $paymentInfo = $this->getMockBuilder('\Magento\Payment\Model\Info')->disableOriginalConstructor()->getMock(); + $paymentInfo = $this->getMockBuilder( + \Magento\Payment\Model\Info::class + )->disableOriginalConstructor()->getMock(); $paymentInfo->expects($this->any())->method('getMethodInstance')->will($this->returnValue($methodInstance)); $this->_object->setData('info', $paymentInfo); @@ -101,7 +103,7 @@ public function getIsSecureModeDataProvider() protected function _getMethodInstanceMock($store) { $methodInstance = $this->getMockBuilder( - '\Magento\Payment\Model\Method\AbstractMethod' + \Magento\Payment\Model\Method\AbstractMethod::class )->setMethods( ['getStore'] )->disableOriginalConstructor()->getMock(); @@ -115,7 +117,7 @@ protected function _getMethodInstanceMock($store) */ protected function _getStoreMock($storeCode) { - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $storeMock->expects($this->any())->method('getCode')->will($this->returnValue($storeCode)); return $storeMock; } @@ -131,7 +133,9 @@ public function testGetInfoThrowException() public function testGetSpecificInformation() { - $paymentInfo = $this->getMockBuilder('\Magento\Payment\Model\Info')->disableOriginalConstructor()->getMock(); + $paymentInfo = $this->getMockBuilder( + \Magento\Payment\Model\Info::class + )->disableOriginalConstructor()->getMock(); $this->_object->setData('info', $paymentInfo); $this->_object->getSpecificInformation(); diff --git a/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php b/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php index ad33b4cd37407..2366508c2d348 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php @@ -12,6 +12,9 @@ use Magento\Framework\UrlInterface; use Magento\Payment\Model\Method\TransparentInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class FormTest extends \PHPUnit_Framework_TestCase { /** @@ -43,31 +46,31 @@ protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->requestMock = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['getParam']) ->getMockForAbstractClass(); - $this->urlBuilderMock = $this->getMockBuilder('\Magento\Framework\UrlInterface') + $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->setMethods(['getUrl']) ->getMockForAbstractClass(); $context = $objectManagerHelper->getObject( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [ 'request' => $this->requestMock, 'urlBuilder' => $this->urlBuilderMock ] ); - $this->methodMock = $this->getMockBuilder('Magento\Payment\Model\Method\TransparentInterface') + $this->methodMock = $this->getMockBuilder(\Magento\Payment\Model\Method\TransparentInterface::class) ->getMock(); - $this->checkoutSessionMock = $this->getMockBuilder('Magento\Checkout\Model\Session') + $this->checkoutSessionMock = $this->getMockBuilder(\Magento\Checkout\Model\Session::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); - $paymentConfigMock = $this->getMockBuilder('Magento\Payment\Model\Config') + $paymentConfigMock = $this->getMockBuilder(\Magento\Payment\Model\Config::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); @@ -113,7 +116,7 @@ public function testGetMethodConfigData($fieldName, $fieldValue, $expected) */ private function initializeMethodWithConfigMock(array $configMap = []) { - $configInterface = $this->getMockBuilder('Magento\Payment\Model\Method\ConfigInterface') + $configInterface = $this->getMockBuilder(\Magento\Payment\Model\Method\ConfigInterface::class) ->getMock(); $configInterface->expects($this->any()) @@ -234,10 +237,10 @@ public function testGetCardFieldsMap() public function testToHtmlShouldRender() { - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->getMock(); - $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) ->disableOriginalConstructor() ->getMock(); @@ -265,7 +268,7 @@ public function testToHtmlShouldNotRenderEmptyQuote() public function testToHtmlShouldNotRenderEmptyPayment() { - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->getMock(); @@ -288,11 +291,11 @@ public function testGetMethodSuccess() public function testGetMethodNotTransparentInterface() { $this->setExpectedException( - 'Magento\Framework\Exception\LocalizedException', + \Magento\Framework\Exception\LocalizedException::class, __('We cannot retrieve the transparent payment method model object.') ); - $methodMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $this->form->setMethod($methodMock); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php index 4327cda62bdb3..6cecb6f7ac43a 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php @@ -12,13 +12,13 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase { public function testGet() { - $commandI = $this->getMockBuilder('Magento\Payment\Gateway\CommandInterface') + $commandI = $this->getMockBuilder(\Magento\Payment\Gateway\CommandInterface::class) ->getMockForAbstractClass(); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); @@ -26,7 +26,7 @@ public function testGet() ->method('create') ->with( [ - 'array' => ['Magento\Payment\Gateway\CommandInterface'], + 'array' => [\Magento\Payment\Gateway\CommandInterface::class], 'type' => CommandInterface::class ] ) @@ -40,20 +40,20 @@ public function testGet() ->with('command') ->willReturn($commandI); - $pool = new CommandPool($tMapFactory, ['Magento\Payment\Gateway\CommandInterface']); + $pool = new CommandPool($tMapFactory, [\Magento\Payment\Gateway\CommandInterface::class]); static::assertSame($commandI, $pool->get('command')); } public function testGetException() { - $this->setExpectedException('Magento\Framework\Exception\NotFoundException'); + $this->setExpectedException(\Magento\Framework\Exception\NotFoundException::class); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php index 8c42a625f1b55..ae939c881e4be 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php @@ -13,6 +13,9 @@ use Magento\Payment\Gateway\Validator\ValidatorInterface; use Psr\Log\LoggerInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class GatewayCommandTest extends \PHPUnit_Framework_TestCase { /** @var GatewayCommand */ @@ -86,12 +89,12 @@ public function testExecute() ]; $response = ['response_field1' => 'response_value1']; $validationResult = $this->getMockBuilder( - 'Magento\Payment\Gateway\Validator\ResultInterface' + \Magento\Payment\Gateway\Validator\ResultInterface::class ) ->getMockForAbstractClass(); $transferO = $this->getMockBuilder( - 'Magento\Payment\Gateway\Http\TransferInterface' + \Magento\Payment\Gateway\Http\TransferInterface::class ) ->getMockForAbstractClass(); @@ -127,7 +130,7 @@ public function testExecute() public function testExecuteValidationFail() { $this->setExpectedException( - 'Magento\Payment\Gateway\Command\CommandException' + \Magento\Payment\Gateway\Command\CommandException::class ); $commandSubject = ['authorize']; @@ -141,12 +144,12 @@ public function testExecuteValidationFail() __('Failure #2'), ]; $validationResult = $this->getMockBuilder( - 'Magento\Payment\Gateway\Validator\ResultInterface' + \Magento\Payment\Gateway\Validator\ResultInterface::class ) ->getMockForAbstractClass(); $transferO = $this->getMockBuilder( - 'Magento\Payment\Gateway\Http\TransferInterface' + \Magento\Payment\Gateway\Http\TransferInterface::class ) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigTest.php index d7f5f87fa83b4..d11b4ad562655 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigTest.php @@ -24,7 +24,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigValueHandlerTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigValueHandlerTest.php index f6f494076ec62..9b7f2d8d22605 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigValueHandlerTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ConfigValueHandlerTest.php @@ -23,7 +23,7 @@ class ConfigValueHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMockBuilder('Magento\Payment\Gateway\ConfigInterface') + $this->configMock = $this->getMockBuilder(\Magento\Payment\Gateway\ConfigInterface::class) ->getMockForAbstractClass(); $this->model = new ConfigValueHandler($this->configMock); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php index 9491df3b76d2e..ae49880c53d80 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php @@ -13,7 +13,7 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase public function testConstructorException() { $this->setExpectedException('LogicException'); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -25,17 +25,17 @@ public function testConstructorException() public function testGet() { - $defaultHandler = $this->getMockBuilder('Magento\Payment\Gateway\Config\ValueHandlerInterface') + $defaultHandler = $this->getMockBuilder(\Magento\Payment\Gateway\Config\ValueHandlerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $someValueHandler = $this->getMockBuilder('Magento\Payment\Gateway\Config\ValueHandlerInterface') + $someValueHandler = $this->getMockBuilder(\Magento\Payment\Gateway\Config\ValueHandlerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); @@ -44,8 +44,9 @@ public function testGet() ->with( [ 'array' => [ - ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', - 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + ValueHandlerPool::DEFAULT_HANDLER => + \Magento\Payment\Gateway\Config\ValueHandlerInterface::class, + 'some_value' => \Magento\Payment\Gateway\Config\ValueHandlerInterface::class ], 'type' => ValueHandlerInterface::class ] @@ -71,8 +72,8 @@ public function testGet() $pool = new ValueHandlerPool( $tMapFactory, [ - ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', - 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + ValueHandlerPool::DEFAULT_HANDLER => \Magento\Payment\Gateway\Config\ValueHandlerInterface::class, + 'some_value' => \Magento\Payment\Gateway\Config\ValueHandlerInterface::class ] ); static::assertSame($someValueHandler, $pool->get('some_value')); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php index fd8538b0994e8..7dd939fed7b46 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php @@ -23,7 +23,7 @@ class AddressAdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderAddressMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderAddressInterface') + $this->orderAddressMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderAddressInterface::class) ->getMockForAbstractClass(); $this->model = new AddressAdapter($this->orderAddressMock); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/OrderAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/OrderAdapterTest.php index ee83f7a2b0553..f128de111c2b1 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/OrderAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/OrderAdapterTest.php @@ -29,12 +29,12 @@ class OrderAdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); $this->addressAdapterFactoryMock = - $this->getMockBuilder('Magento\Payment\Gateway\Data\Order\AddressAdapterFactory') + $this->getMockBuilder(\Magento\Payment\Gateway\Data\Order\AddressAdapterFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -73,10 +73,10 @@ public function testGetBillingAddressIsNull() public function testGetBillingAddress() { /** @var AddressAdapterInterface $addressAdapterMock */ - $addressAdapterMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\AddressAdapterInterface') + $addressAdapterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\AddressAdapterInterface::class) ->getMockForAbstractClass(); /** @var \Magento\Sales\Api\Data\OrderAddressInterface $orderAddressMock */ - $orderAddressMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderAddressInterface') + $orderAddressMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderAddressInterface::class) ->getMockForAbstractClass(); $this->addressAdapterFactoryMock->expects($this->once()) ->method('create') @@ -97,10 +97,10 @@ public function testGetShippingAddressIsNull() public function testGetShippingAddress() { /** @var AddressAdapterInterface $addressAdapterMock */ - $addressAdapterMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\AddressAdapterInterface') + $addressAdapterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\AddressAdapterInterface::class) ->getMockForAbstractClass(); /** @var \Magento\Sales\Api\Data\OrderAddressInterface $orderAddressMock */ - $orderAddressMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderAddressInterface') + $orderAddressMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderAddressInterface::class) ->getMockForAbstractClass(); $this->addressAdapterFactoryMock->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectFactoryTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectFactoryTest.php index 1c192251da5d3..cf9e9f165007a 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectFactoryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectFactoryTest.php @@ -41,23 +41,23 @@ class PaymentDataObjectFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->getMockForAbstractClass(); $this->orderAdapterFactoryMock = - $this->getMockBuilder('Magento\Payment\Gateway\Data\Order\OrderAdapterFactory') + $this->getMockBuilder(\Magento\Payment\Gateway\Data\Order\OrderAdapterFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->quoteAdapterFactoryMock = - $this->getMockBuilder('Magento\Payment\Gateway\Data\Quote\QuoteAdapterFactory') + $this->getMockBuilder(\Magento\Payment\Gateway\Data\Quote\QuoteAdapterFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->paymentDataObjectMock = - $this->getMock('Magento\Payment\Gateway\Data\PaymentDataObjectInterface'); + $this->getMock(\Magento\Payment\Gateway\Data\PaymentDataObjectInterface::class); $this->model = new PaymentDataObjectFactory( $this->objectManagerMock, @@ -69,17 +69,17 @@ protected function setUp() public function testCreatePaymentDataObjectFromOrder() { /** @var Order $orderMock */ - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); /** @var OrderAdapter $orderAdapterMock */ - $orderAdapterMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\Order\OrderAdapter') + $orderAdapterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\Order\OrderAdapter::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Sales\Model\Order\Payment $paymentInfoMock */ - $paymentInfoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $paymentInfoMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->getMock(); @@ -95,7 +95,7 @@ public function testCreatePaymentDataObjectFromOrder() $this->objectManagerMock->expects($this->once()) ->method('create') ->with( - 'Magento\Payment\Gateway\Data\PaymentDataObject', + \Magento\Payment\Gateway\Data\PaymentDataObject::class, [ 'order' => $orderAdapterMock, 'payment' => $paymentInfoMock @@ -108,17 +108,17 @@ public function testCreatePaymentDataObjectFromOrder() public function testCreatePaymentDataObjectFromQuote() { /** @var \Magento\Quote\Model\Quote $quoteMock */ - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->getMock(); /** @var OrderAdapter $orderAdapterMock */ - $quoteAdapterMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\Quote\QuoteAdapter') + $quoteAdapterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\Quote\QuoteAdapter::class) ->disableOriginalConstructor() ->getMock(); /** @var \Magento\Quote\Model\Quote\Payment $paymentInfoMock */ - $paymentInfoMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + $paymentInfoMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) ->disableOriginalConstructor() ->getMock(); @@ -134,7 +134,7 @@ public function testCreatePaymentDataObjectFromQuote() $this->objectManagerMock->expects($this->once()) ->method('create') ->with( - 'Magento\Payment\Gateway\Data\PaymentDataObject', + \Magento\Payment\Gateway\Data\PaymentDataObject::class, [ 'order' => $quoteAdapterMock, 'payment' => $paymentInfoMock diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectTest.php index 1ff0bbe6b5d64..d28ad246367bc 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/PaymentDataObjectTest.php @@ -29,10 +29,10 @@ class PaymentDataObjectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\OrderAdapterInterface') + $this->orderMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\OrderAdapterInterface::class) ->getMockForAbstractClass(); - $this->paymentMock = $this->getMockBuilder('Magento\Payment\Model\InfoInterface') + $this->paymentMock = $this->getMockBuilder(\Magento\Payment\Model\InfoInterface::class) ->getMockForAbstractClass(); $this->model = new PaymentDataObject($this->orderMock, $this->paymentMock); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php index 7af4957c0af11..4583732a82910 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php @@ -23,7 +23,7 @@ class AddressAdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->quoteAddressMock = $this->getMockBuilder('Magento\Quote\Api\Data\AddressInterface') + $this->quoteAddressMock = $this->getMockBuilder(\Magento\Quote\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $this->model = new AddressAdapter($this->quoteAddressMock); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/QuoteAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/QuoteAdapterTest.php index c5d111662a036..4864e3c25ad7c 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/QuoteAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/QuoteAdapterTest.php @@ -29,10 +29,10 @@ class QuoteAdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->addressAdapterFactoryMock = - $this->getMockBuilder('Magento\Payment\Gateway\Data\Quote\AddressAdapterFactory') + $this->getMockBuilder(\Magento\Payment\Gateway\Data\Quote\AddressAdapterFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -44,7 +44,9 @@ public function testGetCurrencyCode() { $expected = 'USD'; /** @var \Magento\Quote\Api\Data\CurrencyInterface $currencyrMock */ - $currencyMock = $this->getMockBuilder('Magento\Quote\Api\Data\CurrencyInterface')->getMockForAbstractClass(); + $currencyMock = $this->getMockBuilder( + \Magento\Quote\Api\Data\CurrencyInterface::class + )->getMockForAbstractClass(); $currencyMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn($expected); $this->quoteMock->expects($this->once())->method('getCurrency')->willReturn($currencyMock); $this->assertEquals($expected, $this->model->getCurrencyCode()); @@ -61,7 +63,9 @@ public function testGetCustomerId() { $expected = 1; /** @var \Magento\Customer\Api\Data\CustomerInterface $customerMock */ - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customerMock = $this->getMockBuilder( + \Magento\Customer\Api\Data\CustomerInterface::class + )->getMockForAbstractClass(); $customerMock->expects($this->once())->method('getId')->willReturn($expected); $this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock); $this->assertEquals($expected, $this->model->getCustomerId()); @@ -77,10 +81,10 @@ public function testGetBillingAddressIsNull() public function testGetBillingAddress() { /** @var AddressAdapterInterface $addressAdapterMock */ - $addressAdapterMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\AddressAdapterInterface') + $addressAdapterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\AddressAdapterInterface::class) ->getMockForAbstractClass(); /** @var \Magento\Quote\Api\Data\AddressInterface $quoteAddressMock */ - $quoteAddressMock = $this->getMockBuilder('Magento\Quote\Api\Data\AddressInterface') + $quoteAddressMock = $this->getMockBuilder(\Magento\Quote\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $this->addressAdapterFactoryMock->expects($this->once()) ->method('create') @@ -101,10 +105,10 @@ public function testGetShippingAddressIsNull() public function testGetShippingAddress() { /** @var AddressAdapterInterface $addressAdapterMock */ - $addressAdapterMock = $this->getMockBuilder('Magento\Payment\Gateway\Data\AddressAdapterInterface') + $addressAdapterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Data\AddressAdapterInterface::class) ->getMockForAbstractClass(); /** @var \Magento\Quote\Api\Data\AddressInterface $quoteAddressMock */ - $quoteAddressMock = $this->getMockBuilder('Magento\Quote\Api\Data\AddressInterface') + $quoteAddressMock = $this->getMockBuilder(\Magento\Quote\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); $this->addressAdapterFactoryMock->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php index b8282228d7334..b8e1b0dcdf973 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php @@ -37,17 +37,17 @@ class SoapTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->logger = $this->getMockBuilder( - 'Magento\Payment\Model\Method\Logger' + \Magento\Payment\Model\Method\Logger::class ) ->disableOriginalConstructor() ->getMock(); $this->clientFactory = $this->getMockBuilder( - 'Magento\Framework\Webapi\Soap\ClientFactory' + \Magento\Framework\Webapi\Soap\ClientFactory::class )->getMock(); $this->converter = $this->getMockBuilder( - 'Magento\Payment\Gateway\Http\ConverterInterface' + \Magento\Payment\Gateway\Http\ConverterInterface::class )->getMockForAbstractClass(); - $this->client = $this->getMockBuilder('\SoapClient') + $this->client = $this->getMockBuilder(\SoapClient::class) ->disableOriginalConstructor() ->getMock(); @@ -137,7 +137,7 @@ public function testPlaceRequestSoapException() private function getTransferObject() { $transferObject = $this->getMockBuilder( - 'Magento\Payment\Gateway\Http\TransferInterface' + \Magento\Payment\Gateway\Http\TransferInterface::class )->getMock(); $transferObject->expects(static::any()) diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php index d94b6f1d31d8e..17c2e9401c3d3 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php @@ -46,23 +46,23 @@ class ZendTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->converterMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\ConverterInterface') + $this->converterMock = $this->getMockBuilder(\Magento\Payment\Gateway\Http\ConverterInterface::class) ->getMockForAbstractClass(); - $this->zendClientFactoryMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClientFactory') + $this->zendClientFactoryMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClientFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->clientMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClient') + $this->clientMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClient::class) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Magento\Payment\Model\Method\Logger') + $this->loggerMock = $this->getMockBuilder(\Magento\Payment\Model\Method\Logger::class) ->disableOriginalConstructor() ->getMock(); - $this->transferObjectMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\TransferInterface') + $this->transferObjectMock = $this->getMockBuilder(\Magento\Payment\Gateway\Http\TransferInterface::class) ->getMockForAbstractClass(); $this->model = new Zend( @@ -77,7 +77,9 @@ public function testPlaceRequest() $this->setClientTransferObjects(); $responseBody = 'Response body content'; - $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); + $zendHttpResponseMock = $this->getMockBuilder( + \Zend_Http_Response::class + )->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->once())->method('getBody')->willReturn($responseBody); $this->clientMock->expects($this->once())->method('request')->willReturn($zendHttpResponseMock); @@ -121,7 +123,9 @@ public function testPlaceRequestConvertResponseFail() $this->setClientTransferObjects(); $responseBody = 'Response body content'; - $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); + $zendHttpResponseMock = $this->getMockBuilder( + \Zend_Http_Response::class + )->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->once())->method('getBody')->willReturn($responseBody); $this->clientMock->expects($this->once())->method('request')->willReturn($zendHttpResponseMock); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php index fdc062210f81e..87049bddd0494 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php @@ -12,11 +12,11 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase { public function testBuildEmpty() { - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); @@ -44,18 +44,18 @@ public function testBuildEmpty() */ public function testBuild(array $expected) { - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); - $customerBuilder = $this->getMockBuilder('Magento\Payment\Gateway\Request\BuilderInterface') + $customerBuilder = $this->getMockBuilder(\Magento\Payment\Gateway\Request\BuilderInterface::class) ->getMockForAbstractClass(); - $productBuilder = $this->getMockBuilder('Magento\Payment\Gateway\Request\BuilderInterface') + $productBuilder = $this->getMockBuilder(\Magento\Payment\Gateway\Request\BuilderInterface::class) ->getMockForAbstractClass(); - $magentoBuilder = $this->getMockBuilder('Magento\Payment\Gateway\Request\BuilderInterface') + $magentoBuilder = $this->getMockBuilder(\Magento\Payment\Gateway\Request\BuilderInterface::class) ->getMockForAbstractClass(); $customerBuilder->expects(static::once()) @@ -91,9 +91,9 @@ public function testBuild(array $expected) ->with( [ 'array' => [ - 'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface', - 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', - 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'customer' => \Magento\Payment\Gateway\Request\BuilderInterface::class, + 'product' => \Magento\Payment\Gateway\Request\BuilderInterface::class, + 'magento' => \Magento\Payment\Gateway\Request\BuilderInterface::class ], 'type' => BuilderInterface::class ] @@ -106,9 +106,9 @@ public function testBuild(array $expected) $builder = new BuilderComposite( $tMapFactory, [ - 'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface', - 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', - 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'customer' => \Magento\Payment\Gateway\Request\BuilderInterface::class, + 'product' => \Magento\Payment\Gateway\Request\BuilderInterface::class, + 'magento' => \Magento\Payment\Gateway\Request\BuilderInterface::class ] ); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php index 2e556fb4f216f..b52e96af8bbae 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php @@ -12,15 +12,15 @@ class HandlerChainTest extends \PHPUnit_Framework_TestCase { public function testHandle() { - $handler1 = $this->getMockBuilder('Magento\Payment\Gateway\Response\HandlerInterface') + $handler1 = $this->getMockBuilder(\Magento\Payment\Gateway\Response\HandlerInterface::class) ->getMockForAbstractClass(); - $handler2 = $this->getMockBuilder('Magento\Payment\Gateway\Response\HandlerInterface') + $handler2 = $this->getMockBuilder(\Magento\Payment\Gateway\Response\HandlerInterface::class) ->getMockForAbstractClass(); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); @@ -29,8 +29,8 @@ public function testHandle() ->with( [ 'array' => [ - 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', - 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' + 'handler1' => \Magento\Payment\Gateway\Response\HandlerInterface::class, + 'handler2' => \Magento\Payment\Gateway\Response\HandlerInterface::class ], 'type' => HandlerInterface::class ] @@ -52,8 +52,8 @@ public function testHandle() $chain = new HandlerChain( $tMapFactory, [ - 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', - 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' + 'handler1' => \Magento\Payment\Gateway\Response\HandlerInterface::class, + 'handler2' => \Magento\Payment\Gateway\Response\HandlerInterface::class ] ); $chain->handle($handlingSubject, $response); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php index 8a429dbc88798..d36fda3fd6be5 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php @@ -27,13 +27,14 @@ class CountryValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMockBuilder('Magento\Payment\Gateway\ConfigInterface') + $this->configMock = $this->getMockBuilder(\Magento\Payment\Gateway\ConfigInterface::class) ->getMockForAbstractClass(); - $this->resultFactoryMock = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ResultInterfaceFactory') - ->setMethods(['create']) + $this->resultFactoryMock = $this->getMockBuilder( + \Magento\Payment\Gateway\Validator\ResultInterfaceFactory::class + )->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->resultMock = $this->getMockBuilder('Magento\Payment\Gateway\Validator\Result') + $this->resultMock = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\Result::class) ->disableOriginalConstructor() ->getMock(); @@ -43,7 +44,6 @@ protected function setUp() ); } - /** * @dataProvider validateAllowspecificTrueDataProvider */ diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php index 50310adb42e8a..49e7ace9a0a5f 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php @@ -31,7 +31,7 @@ public function testResult($isValid, $failsDescription, $expectedIsValid, $expec public function resultDataProvider() { - $phraseMock = $this->getMockBuilder('Magento\Framework\Phrase')->disableOriginalConstructor()->getMock(); + $phraseMock = $this->getMockBuilder(\Magento\Framework\Phrase::class)->disableOriginalConstructor()->getMock(); return [ [true, [$phraseMock, $phraseMock], true, [$phraseMock, $phraseMock]], ['', [], false, []], diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php index 027117eca5471..baf11d67773bc 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php @@ -13,15 +13,15 @@ class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase public function testValidate() { $validationSubject = []; - $validator1 = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ValidatorInterface') + $validator1 = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ValidatorInterface::class) ->getMockForAbstractClass(); - $validator2 = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ValidatorInterface') + $validator2 = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ValidatorInterface::class) ->getMockForAbstractClass(); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); @@ -30,8 +30,8 @@ public function testValidate() ->with( [ 'array' => [ - 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', - 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'validator1' => \Magento\Payment\Gateway\Validator\ValidatorInterface::class, + 'validator2' => \Magento\Payment\Gateway\Validator\ValidatorInterface::class ], 'type' => ValidatorInterface::class ] @@ -41,12 +41,12 @@ public function testValidate() ->method('getIterator') ->willReturn(new \ArrayIterator([$validator1, $validator2])); - $resultSuccess = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ResultInterface') + $resultSuccess = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ResultInterface::class) ->getMockForAbstractClass(); $resultSuccess->expects(static::once()) ->method('isValid') ->willReturn(true); - $resultFail = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ResultInterface') + $resultFail = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ResultInterface::class) ->getMockForAbstractClass(); $resultFail->expects(static::once()) ->method('isValid') @@ -64,9 +64,9 @@ public function testValidate() ->with($validationSubject) ->willReturn($resultFail); - $compositeResult = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ResultInterface') + $compositeResult = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ResultInterface::class) ->getMockForAbstractClass(); - $resultFactory = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ResultInterfaceFactory') + $resultFactory = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ResultInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -80,13 +80,12 @@ public function testValidate() ) ->willReturn($compositeResult); - $validatorComposite = new ValidatorComposite( $resultFactory, $tMapFactory, [ - 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', - 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'validator1' => \Magento\Payment\Gateway\Validator\ValidatorInterface::class, + 'validator2' => \Magento\Payment\Gateway\Validator\ValidatorInterface::class ] ); static::assertSame($compositeResult, $validatorComposite->validate($validationSubject)); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php index a568d0de60720..8d408abf147c4 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php @@ -12,12 +12,12 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase { public function testGet() { - $commandI = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ValidatorInterface') + $commandI = $this->getMockBuilder(\Magento\Payment\Gateway\Validator\ValidatorInterface::class) ->getMockForAbstractClass(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -26,7 +26,7 @@ public function testGet() ->method('create') ->with( [ - 'array' => ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], + 'array' => ['validator' => \Magento\Payment\Gateway\Validator\ValidatorInterface::class], 'type' => ValidatorInterface::class ] ) @@ -42,7 +42,7 @@ public function testGet() $pool = new ValidatorPool( $tMapFactory, - ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'] + ['validator' => \Magento\Payment\Gateway\Validator\ValidatorInterface::class] ); static::assertSame($commandI, $pool->get('validator')); @@ -50,13 +50,13 @@ public function testGet() public function testGetException() { - $this->setExpectedException('Magento\Framework\Exception\NotFoundException'); + $this->setExpectedException(\Magento\Framework\Exception\NotFoundException::class); - $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + $tMapFactory = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMap = $this->getMockBuilder(\Magento\Framework\ObjectManager\TMap::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php b/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php index 756810416c2ae..81329a9bb98cc 100644 --- a/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php @@ -37,12 +37,12 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $className = 'Magento\Payment\Helper\Data'; + $className = \Magento\Payment\Helper\Data::class; $arguments = $objectManagerHelper->getConstructArguments($className); /** @var \Magento\Framework\App\Helper\Context $context */ $context = $arguments['context']; $this->scopeConfig = $context->getScopeConfig(); - $this->layoutMock = $this->getMock('Magento\Framework\View\LayoutInterface', [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); $layoutFactoryMock = $arguments['layoutFactory']; $layoutFactoryMock->expects($this->once())->method('create')->willReturn($this->layoutMock); @@ -53,7 +53,6 @@ protected function setUp() $this->helper = $objectManagerHelper->getObject($className, $arguments); } - public function testGetMethodInstance() { list($code, $class, $methodInstance) = ['method_code', 'method_class', 'method_instance']; @@ -120,19 +119,19 @@ public function testSortMethods(array $methodA, array $methodB) $this->scopeConfig->expects(new MethodInvokedAtIndex(0)) ->method('getValue') ->with(sprintf('%s/%s/model', Data::XML_PATH_PAYMENT_METHODS, $methodA['code'])) - ->will($this->returnValue('Magento\Payment\Model\Method\AbstractMethod')); + ->will($this->returnValue(\Magento\Payment\Model\Method\AbstractMethod::class)); $this->scopeConfig->expects(new MethodInvokedAtIndex(1)) ->method('getValue') ->with( sprintf('%s/%s/model', Data::XML_PATH_PAYMENT_METHODS, $methodB['code']) ) - ->will($this->returnValue('Magento\Payment\Model\Method\AbstractMethod')); + ->will($this->returnValue(\Magento\Payment\Model\Method\AbstractMethod::class)); $this->scopeConfig->expects(new MethodInvokedAtIndex(2)) ->method('getValue') ->with(sprintf('%s/%s/model', Data::XML_PATH_PAYMENT_METHODS, 'empty')) ->will($this->returnValue(null)); - $methodInstanceMockA = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInstanceMockA = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $methodInstanceMockA->expects($this->any()) ->method('isAvailable') @@ -142,7 +141,7 @@ public function testSortMethods(array $methodA, array $methodB) ->with('sort_order', null) ->will($this->returnValue($methodA['data']['sort_order'])); - $methodInstanceMockB = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInstanceMockB = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $methodInstanceMockB->expects($this->any()) ->method('isAvailable') @@ -171,13 +170,13 @@ public function testGetMethodFormBlock() { list($blockType, $methodCode) = ['method_block_type', 'method_code']; - $methodMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class) ->disableOriginalConstructor() ->setMethods(['setMethod', 'toHtml']) ->getMock(); @@ -196,13 +195,13 @@ public function testGetInfoBlock() { $blockType = 'method_block_type'; - $methodMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); - $infoMock = $this->getMockBuilder('Magento\Payment\Model\Info') + $infoMock = $this->getMockBuilder(\Magento\Payment\Model\Info::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class) ->disableOriginalConstructor() ->setMethods(['setInfo', 'toHtml']) ->getMock(); @@ -221,13 +220,13 @@ public function testGetInfoBlockHtml() { list($storeId, $blockHtml, $secureMode, $blockType) = [1, 'HTML MARKUP', true, 'method_block_type']; - $methodMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); - $infoMock = $this->getMockBuilder('Magento\Payment\Model\Info') + $infoMock = $this->getMockBuilder(\Magento\Payment\Model\Info::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $paymentBlockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + $paymentBlockMock = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class) ->disableOriginalConstructor() ->setMethods(['setArea', 'setIsSecureMode', 'getMethod', 'setStore', 'toHtml', 'setInfo']) ->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php index d7bd9dfdc1483..c0b49635fea9e 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php @@ -15,7 +15,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Factory($this->_objectManagerMock); } @@ -43,8 +43,8 @@ public function testCreate($salesModelClass, $expectedType) public function createDataProvider() { return [ - ['Magento\Quote\Model\Quote', 'Magento\Payment\Model\Cart\SalesModel\Quote'], - ['Magento\Sales\Model\Order', 'Magento\Payment\Model\Cart\SalesModel\Order'] + [\Magento\Quote\Model\Quote::class, \Magento\Payment\Model\Cart\SalesModel\Quote::class], + [\Magento\Sales\Model\Order::class, \Magento\Payment\Model\Cart\SalesModel\Order::class] ]; } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php index b3c76b3407fe7..b3096c35258a5 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php @@ -15,7 +15,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $this->_orderMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Order($this->_orderMock); } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php index 7516ff49f9daf..aded897dcd21b 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php @@ -15,7 +15,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->_quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Quote($this->_quoteMock); } @@ -64,7 +64,7 @@ public function testGetTaxContainer() */ public function testGetAllItems($pItem, $name, $qty, $price) { - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item\AbstractItem', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item\AbstractItem::class, [], [], '', false); $itemMock->expects($this->any())->method('getParentItem')->will($this->returnValue($pItem)); $itemMock->expects($this->once())->method('__call')->with('getName')->will($this->returnValue($name)); $itemMock->expects($this->any())->method('getTotalQty')->will($this->returnValue($qty)); @@ -114,7 +114,7 @@ public function testGetBaseSubtotal() */ public function testGetter($isVirtual, $getterMethod) { - $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $address = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $address->expects( $this->any() )->method( @@ -124,7 +124,7 @@ public function testGetter($isVirtual, $getterMethod) )->will( $this->returnValue($getterMethod) ); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->any())->method('getIsVirtual')->will($this->returnValue($isVirtual)); $method = 'getShippingAddress'; if ($isVirtual) { diff --git a/app/code/Magento/Payment/Test/Unit/Model/CartTest.php b/app/code/Magento/Payment/Test/Unit/Model/CartTest.php index 67b04b8344d77..9a4041183f3e6 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CartTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CartTest.php @@ -20,9 +20,9 @@ class CartTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->_salesModelMock = $this->getMock('Magento\Payment\Model\Cart\SalesModel\SalesModelInterface'); - $factoryMock = $this->getMock('Magento\Payment\Model\Cart\SalesModel\Factory', [], [], '', false); + $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->_salesModelMock = $this->getMock(\Magento\Payment\Model\Cart\SalesModel\SalesModelInterface::class); + $factoryMock = $this->getMock(\Magento\Payment\Model\Cart\SalesModel\Factory::class, [], [], '', false); $factoryMock->expects($this->once())->method('create')->will($this->returnValue($this->_salesModelMock)); $this->_model = new \Magento\Payment\Model\Cart($factoryMock, $this->_eventManagerMock, null); diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php index 056cefeafdaa1..9897628514387 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php @@ -24,8 +24,8 @@ class CcConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ccConfigMock = $this->getMock('\Magento\Payment\Model\CcConfig', [], [], '', false); - $this->assetSourceMock = $this->getMock('\Magento\Framework\View\Asset\Source', [], [], '', false); + $this->ccConfigMock = $this->getMock(\Magento\Payment\Model\CcConfig::class, [], [], '', false); + $this->assetSourceMock = $this->getMock(\Magento\Framework\View\Asset\Source::class, [], [], '', false); $this->model = new \Magento\Payment\Model\CcConfigProvider( $this->ccConfigMock, $this->assetSourceMock @@ -66,7 +66,7 @@ public function testGetConfig() 'url' => 'http://cc.card/ae.png' ] ]; - $assetMock = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + $assetMock = $this->getMock(\Magento\Framework\View\Asset\File::class, [], [], '', false); $this->ccConfigMock->expects($this->once())->method('getCcAvailableTypes')->willReturn($ccAvailableTypesMock); diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php index aa4b8c0587a69..6893a18417c98 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php @@ -29,11 +29,11 @@ class CcConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('Magento\Payment\Model\Config', [], [], '', false); - $this->repositoryMock = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->configMock = $this->getMock(\Magento\Payment\Model\Config::class, [], [], '', false); + $this->repositoryMock = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->model = new \Magento\Payment\Model\CcConfig( $this->configMock, diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php index 4628eb9446bed..60827173f72d7 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php @@ -22,8 +22,8 @@ class CcGenericConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ccConfigMock = $this->getMock('Magento\Payment\Model\CcConfig', [], [], '', false); - $this->paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->ccConfigMock = $this->getMock(\Magento\Payment\Model\CcConfig::class, [], [], '', false); + $this->paymentHelperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->model = new CcGenericConfigProvider( $this->ccConfigMock, diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseCheckoutTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseCheckoutTest.php index d64efadbeb2f5..f397445418eb0 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseCheckoutTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseCheckoutTest.php @@ -26,11 +26,11 @@ protected function setUp() */ public function testIsApplicable($expectation) { - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods( [] )->getMock(); $paymentMethod = $this->getMockBuilder( - '\Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $paymentMethod->expects($this->once())->method('canUseCheckout')->will( $this->returnValue($expectation) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php index dd33a4c0b877d..5b14cc57a3035 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -19,15 +19,15 @@ class CountryProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directoryMock = $this->getMock('Magento\Directory\Helper\Data', [], [], '', false, false); + $this->directoryMock = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false, false); $this->model = new \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider($this->directoryMock); } public function testGetCountryForNonVirtualQuote() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false, false); $quoteMock->expects($this->once())->method('isVirtual')->willReturn(false); - $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false, false); $addressMock->expects($this->once())->method('getCountry')->will($this->returnValue(1)); $quoteMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($addressMock)); $this->assertEquals(1, $this->model->getCountry($quoteMock)); @@ -35,9 +35,9 @@ public function testGetCountryForNonVirtualQuote() public function testGetCountryForVirtualQuoteWhenBillingAddressNotExist() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false, false); $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true); - $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false, false); $addressMock->expects($this->never())->method('getCountry'); $quoteMock->expects($this->never())->method('getShippingAddress'); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn(null); @@ -47,9 +47,9 @@ public function testGetCountryForVirtualQuoteWhenBillingAddressNotExist() public function testGetCountryForVirtualQuoteWhenBillingAddressExist() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false, false); $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true); - $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false, false); $addressMock->expects($this->once())->method('getCountry')->willReturn(10); $quoteMock->expects($this->never())->method('getShippingAddress'); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($addressMock); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php index 2742f152b4f74..0842bc6a6f887 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php @@ -28,7 +28,7 @@ class CanUseForCountryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->countryProvider = $this->getMock( - 'Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider', + \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider::class, [], [], '', @@ -44,12 +44,12 @@ protected function setUp() */ public function testIsApplicable($expectation) { - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods( [] )->getMock(); $paymentMethod = $this->getMockBuilder( - '\Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $paymentMethod->expects($this->once())->method('canUseForCountry')->with( self::EXPECTED_COUNTRY_ID diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCurrencyTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCurrencyTest.php index a3b6c6db899a6..7b8d2587520dc 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCurrencyTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCurrencyTest.php @@ -32,17 +32,17 @@ protected function setUp() public function testIsApplicable($expectation) { $paymentMethod = $this->getMockBuilder( - '\Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $paymentMethod->expects($this->once())->method('canUseForCurrency')->with( self::EXPECTED_CURRENCY_CODE )->will($this->returnValue($expectation)); - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods( [] )->getMock(); $store = $this->getMockBuilder( - 'Magento\Store\Model\Store' + \Magento\Store\Model\Store::class )->disableOriginalConstructor()->setMethods([])->getMock(); $store->expects($this->once())->method('getBaseCurrencyCode')->will( $this->returnValue(self::EXPECTED_CURRENCY_CODE) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseInternalTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseInternalTest.php index 54f69431ff4a5..5d30493e485db 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseInternalTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseInternalTest.php @@ -26,11 +26,11 @@ protected function setUp() */ public function testIsApplicable($expectation) { - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods( [] )->getMock(); $paymentMethod = $this->getMockBuilder( - '\Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $paymentMethod->expects($this->once())->method('canUseInternal')->will( $this->returnValue($expectation) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CompositeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CompositeTest.php index e369d6e9550a7..8ce5abe8c180a 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CompositeTest.php @@ -16,15 +16,15 @@ class CompositeTest extends \PHPUnit_Framework_TestCase */ public function testIsApplicable($expectation) { - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods( [] )->getMock(); $paymentMethod = $this->getMockBuilder( - '\Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $specification = $this->getMockBuilder( - 'Magento\Payment\Model\Checks\SpecificationInterface' + \Magento\Payment\Model\Checks\SpecificationInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $specification->expects($this->once())->method('isApplicable')->with($paymentMethod, $quote)->will( $this->returnValue($expectation) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/SpecificationFactoryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/SpecificationFactoryTest.php index 898076d54f180..63aa63d96ed31 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/SpecificationFactoryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/SpecificationFactoryTest.php @@ -23,19 +23,19 @@ class SpecificationFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_compositeFactory = $this->getMockBuilder( - 'Magento\Payment\Model\Checks\CompositeFactory' + \Magento\Payment\Model\Checks\CompositeFactory::class )->disableOriginalConstructor()->setMethods(['create'])->getMock(); } public function testCreate() { $specification = $this->getMockBuilder( - 'Magento\Payment\Model\Checks\SpecificationInterface' + \Magento\Payment\Model\Checks\SpecificationInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $specificationMapping = [self::SPECIFICATION_KEY => $specification]; $expectedComposite = $this->getMockBuilder( - 'Magento\Payment\Model\Checks\Composite' + \Magento\Payment\Model\Checks\Composite::class )->disableOriginalConstructor()->setMethods([])->getMock(); $modelFactory = new SpecificationFactory($this->_compositeFactory, $specificationMapping); $this->_compositeFactory->expects($this->once())->method('create')->with( diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/TotalMinMaxTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/TotalMinMaxTest.php index acb786d0b796a..0adf1cb386455 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/TotalMinMaxTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/TotalMinMaxTest.php @@ -28,7 +28,7 @@ class TotalMinMaxTest extends \PHPUnit_Framework_TestCase public function testIsApplicable($baseGrandTotal, $expectation) { $paymentMethod = $this->getMockBuilder( - '\Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $paymentMethod->expects($this->at(0))->method('getConfigData')->with( TotalMinMax::MIN_ORDER_TOTAL @@ -37,7 +37,7 @@ public function testIsApplicable($baseGrandTotal, $expectation) TotalMinMax::MAX_ORDER_TOTAL )->will($this->returnValue(self::PAYMENT_MAX_TOTAL)); - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods( ['getBaseGrandTotal', '__wakeup'] )->getMock(); $quote->expects($this->once())->method('getBaseGrandTotal')->will($this->returnValue($baseGrandTotal)); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/ZeroTotalTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/ZeroTotalTest.php index 2b816a6151211..af6d7e78c2555 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/ZeroTotalTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/ZeroTotalTest.php @@ -18,7 +18,7 @@ class ZeroTotalTest extends \PHPUnit_Framework_TestCase */ public function testIsApplicable($code, $total, $expectation) { - $paymentMethod = $this->getMockBuilder('\Magento\Payment\Model\MethodInterface') + $paymentMethod = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -29,7 +29,7 @@ public function testIsApplicable($code, $total, $expectation) ->will($this->returnValue($code)); } - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->setMethods(['getBaseGrandTotal', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Payment/Test/Unit/Model/Config/SchemaLocatorTest.php index 665d5c6e882c7..9a744a94a2aa5 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Config/SchemaLocatorTest.php @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $moduleReader = $this->getMockBuilder( - 'Magento\Framework\Module\Dir\Reader' + \Magento\Framework\Module\Dir\Reader::class )->disableOriginalConstructor()->setMethods([])->getMock(); $moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Payment')->will( $this->returnValue(self::MODULE_DIR_PATH) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Config/Source/AllmethodsTest.php b/app/code/Magento/Payment/Test/Unit/Model/Config/Source/AllmethodsTest.php index 67de175ca0147..7d0224a46be7c 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Config/Source/AllmethodsTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Config/Source/AllmethodsTest.php @@ -27,7 +27,7 @@ class AllmethodsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_paymentData = $this->getMockBuilder( - 'Magento\Payment\Helper\Data' + \Magento\Payment\Helper\Data::class )->disableOriginalConstructor()->setMethods([])->getMock(); $this->_model = new Allmethods($this->_paymentData); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Config/Source/CctypeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Config/Source/CctypeTest.php index 87d32873be24e..58a9826c1ee89 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Config/Source/CctypeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Config/Source/CctypeTest.php @@ -25,7 +25,7 @@ class CctypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_paymentConfig = $this->getMockBuilder( - 'Magento\Payment\Model\Config' + \Magento\Payment\Model\Config::class )->disableOriginalConstructor()->setMethods([])->getMock(); $this->_model = new Cctype($this->_paymentConfig); diff --git a/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php index e67915c1fd846..6dac9c97a44ee 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php @@ -96,21 +96,21 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfig = $this->getMock( - 'Magento\Framework\App\Config\ScopeConfigInterface', + $this->scopeConfig = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false ); - $this->paymentMethodFactory = $this->getMock('Magento\Payment\Model\Method\Factory', [], [], '', false); - $this->localeResolver = $this->getMock('Magento\Framework\Locale\ResolverInterface', [], [], '', false); - $this->dataStorage = $this->getMock('Magento\Framework\Config\DataInterface', [], [], '', false); - $this->date = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); + $this->paymentMethodFactory = $this->getMock(\Magento\Payment\Model\Method\Factory::class, [], [], '', false); + $this->localeResolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class, [], [], '', false); + $this->dataStorage = $this->getMock(\Magento\Framework\Config\DataInterface::class, [], [], '', false); + $this->date = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->config = $this->objectManagerHelper->getObject( - 'Magento\Payment\Model\Config', + $this->config = $this->objectManagerHelper->getObject( + \Magento\Payment\Model\Config::class, [ 'scopeConfig' => $this->scopeConfig, 'paymentMethodFactory' => $this->paymentMethodFactory, @@ -127,8 +127,8 @@ protected function setUp() */ public function testGetActiveMethods($isActive) { - $abstractMethod = $this->getMockBuilder( - 'Magento\Payment\Model\Method\AbstractMethod' + $abstractMethod = $this->getMockBuilder( + \Magento\Payment\Model\Method\AbstractMethod::class )->disableOriginalConstructor()->setMethods(['setId', 'setStore', 'getConfigData'])->getMock(); $this->scopeConfig->expects($this->once())->method('getValue')->with( 'payment', ScopeInterface::SCOPE_STORE, null diff --git a/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php b/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php index 72a6e3eda5507..84412a32b9212 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php @@ -34,22 +34,28 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registryMock = $this->getMock('Magento\Framework\Registry'); - $this->paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', ['getMethodInstance'], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class); + $this->paymentHelperMock = $this->getMock( + \Magento\Payment\Helper\Data::class, + ['getMethodInstance'], + [], + '', + false + ); $this->encryptorInterfaceMock = $this->getMock( - 'Magento\Framework\Encryption\EncryptorInterface', + \Magento\Framework\Encryption\EncryptorInterface::class, [], [], '', false ); - $this->methodInstanceMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $this->methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->info = $this->objectManagerHelper->getObject( - 'Magento\Payment\Model\Info', + \Magento\Payment\Model\Info::class, [ 'context' => $this->contextMock, 'registry' => $this->registryMock, @@ -138,7 +144,7 @@ public function testGetMethodInstanceWithNoMethod() $this->info->setData('method', false); $this->info->getMethodInstance(); } - + public function testGetMethodInstanceRequestedMethod() { $code = 'real_method'; diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethodTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethodTest.php index 22c35df17e897..511d2821828dc 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethodTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethodTest.php @@ -15,6 +15,7 @@ * Class AbstractMethodTest * * Test for class \Magento\Payment\Model\Method\AbstractMethod + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AbstractMethodTest extends \PHPUnit_Framework_TestCase { @@ -45,24 +46,24 @@ class AbstractMethodTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->setMethods(['getValue']) ->getMockForAbstractClass(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->setMethods(['dispatch']) ->getMockForAbstractClass(); - $this->quoteMock = $this->getMockBuilder('Magento\Quote\Api\Data\CartInterface') + $this->quoteMock = $this->getMockBuilder(\Magento\Quote\Api\Data\CartInterface::class) ->setMethods(['getStoreId']) ->getMockForAbstractClass(); - $contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->setMethods(['getEventDispatcher']) ->getMock(); $contextMock->expects($this->once()) ->method('getEventDispatcher') ->willReturn($this->eventManagerMock); - $this->loggerMock = $this->getMockBuilder('\Magento\Payment\Model\Method\Logger') - ->setConstructorArgs([$this->getMockForAbstractClass('Psr\Log\LoggerInterface')]) + $this->loggerMock = $this->getMockBuilder(\Magento\Payment\Model\Method\Logger::class) + ->setConstructorArgs([$this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class)]) ->setMethods(['debug']) ->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php index 6de6726db31ba..e077f93c2b685 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php @@ -12,6 +12,9 @@ use Magento\Payment\Gateway\Validator\ValidatorPoolInterface; use Magento\Payment\Model\Method\Adapter; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AdapterTest extends \PHPUnit_Framework_TestCase { /** @@ -62,19 +65,19 @@ class AdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->eventManager = $this->getMock( - 'Magento\Framework\Event\ManagerInterface' + \Magento\Framework\Event\ManagerInterface::class ); $this->valueHandlerPool = $this->getMock( - 'Magento\Payment\Gateway\Config\ValueHandlerPoolInterface' + \Magento\Payment\Gateway\Config\ValueHandlerPoolInterface::class ); $this->validatorPool = $this->getMock( - 'Magento\Payment\Gateway\Validator\ValidatorPoolInterface' + \Magento\Payment\Gateway\Validator\ValidatorPoolInterface::class ); $this->commandPool = $this->getMock( - 'Magento\Payment\Gateway\Command\CommandPoolInterface' + \Magento\Payment\Gateway\Command\CommandPoolInterface::class ); $this->paymentDataObjectFactory = $this->getMockBuilder( - 'Magento\Payment\Gateway\Data\PaymentDataObjectFactory' + \Magento\Payment\Gateway\Data\PaymentDataObjectFactory::class ) ->disableOriginalConstructor() ->getMock(); @@ -98,7 +101,7 @@ protected function setUp() public function testIsAvailableNotActive() { $activeValueHandler = $this->getMock( - 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + \Magento\Payment\Gateway\Config\ValueHandlerInterface::class ); $this->valueHandlerPool->expects(static::once()) @@ -119,14 +122,14 @@ public function testIsAvailableNotActive() public function testIsAvailableEmptyQuote() { $activeValueHandler = $this->getMock( - 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + \Magento\Payment\Gateway\Config\ValueHandlerInterface::class ); $availabilityValidator = $this->getMock( - 'Magento\Payment\Gateway\Validator\ValidatorInterface' + \Magento\Payment\Gateway\Validator\ValidatorInterface::class ); - $paymentDO = $this->getMock('Magento\Payment\Gateway\Data\PaymentDataObjectInterface'); - $validationResult = $this->getMock('Magento\Payment\Gateway\Validator\ResultInterface'); - $paymentInfo = $this->getMock('Magento\Payment\Model\InfoInterface'); + $paymentDO = $this->getMock(\Magento\Payment\Gateway\Data\PaymentDataObjectInterface::class); + $validationResult = $this->getMock(\Magento\Payment\Gateway\Validator\ResultInterface::class); + $paymentInfo = $this->getMock(\Magento\Payment\Model\InfoInterface::class); $this->valueHandlerPool->expects(static::once()) ->method('get') diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/FactoryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/FactoryTest.php index b46d237fd8d11..712994f933f11 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/FactoryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/FactoryTest.php @@ -21,16 +21,16 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_factory = $objectManagerHelper->getObject( - 'Magento\Payment\Model\Method\Factory', + \Magento\Payment\Model\Method\Factory::class, ['objectManager' => $this->_objectManagerMock] ); } public function testCreateMethod() { - $className = 'Magento\Payment\Model\Method\AbstractMethod'; + $className = \Magento\Payment\Model\Method\AbstractMethod::class; $methodMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects( $this->once() @@ -48,7 +48,7 @@ public function testCreateMethod() public function testCreateMethodWithArguments() { - $className = 'Magento\Payment\Model\Method\AbstractMethod'; + $className = \Magento\Payment\Model\Method\AbstractMethod::class; $data = ['param1', 'param2']; $methodMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects( diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php index 59dafd905db20..4c9d6fd6fcdb1 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php @@ -8,6 +8,9 @@ namespace Magento\Payment\Test\Unit\Model\Method; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class FreeTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Payment\Model\Method\Free */ @@ -21,26 +24,40 @@ class FreeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); - $this->currencyPrice = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $paymentData = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); + $this->scopeConfig = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + [], + [], + '', + false + ); + $this->currencyPrice = $this->getMockBuilder( + \Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock( + ); - $context = $this->getMock('\Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); - $eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); + $context = $this->getMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); $context->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); - $registry = $this->getMock('\Magento\Framework\Registry', [], [], '', false); + $registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $extensionAttributesFactory = $this->getMock( - 'Magento\Framework\Api\ExtensionAttributesFactory', + \Magento\Framework\Api\ExtensionAttributesFactory::class, + [], + [], + '', + false + ); + $customAttributeFactory = $this->getMock( + \Magento\Framework\Api\AttributeValueFactory::class, [], [], '', false ); - $customAttributeFactory = $this->getMock('\Magento\Framework\Api\AttributeValueFactory', [], [], '', false); - $loggerMock = $this->getMockBuilder('\Magento\Payment\Model\Method\Logger') - ->setConstructorArgs([$this->getMockForAbstractClass('Psr\Log\LoggerInterface')]) + $loggerMock = $this->getMockBuilder(\Magento\Payment\Model\Method\Logger::class) + ->setConstructorArgs([$this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class)]) ->getMock(); $this->methodFree = new \Magento\Payment\Model\Method\Free( @@ -86,7 +103,7 @@ public function testIsAvailable($grandTotal, $isActive, $notEmptyQuote, $result) { $quote = null; if ($notEmptyQuote) { - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quote->expects($this->any()) ->method('__call') ->with($this->equalTo('getGrandTotal')) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php index 3a8107d0ba678..5d9720c7896e4 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php @@ -19,7 +19,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->loggerMock = $this->getMockForAbstractClass('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class); $this->logger = new Logger($this->loggerMock); } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/CompositeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/CompositeTest.php index fd905ab7612a4..d7c8928622535 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/CompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/CompositeTest.php @@ -18,7 +18,7 @@ class CompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->factoryMock = $this->getMock( - 'Magento\Payment\Model\Method\Specification\Factory', + \Magento\Payment\Model\Method\Specification\Factory::class, [], [], '', @@ -35,7 +35,7 @@ protected function createComposite($specifications = []) $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); return $objectManager->getObject( - 'Magento\Payment\Model\Method\Specification\Composite', + \Magento\Payment\Model\Method\Specification\Composite::class, ['factory' => $this->factoryMock, 'specifications' => $specifications] ); } @@ -50,7 +50,7 @@ public function testComposite($firstSpecificationResult, $secondSpecificationRes { $method = 'method-name'; - $specificationFirst = $this->getMock('Magento\Payment\Model\Method\SpecificationInterface'); + $specificationFirst = $this->getMock(\Magento\Payment\Model\Method\SpecificationInterface::class); $specificationFirst->expects( $this->once() )->method( @@ -61,7 +61,7 @@ public function testComposite($firstSpecificationResult, $secondSpecificationRes $this->returnValue($firstSpecificationResult) ); - $specificationSecond = $this->getMock('Magento\Payment\Model\Method\SpecificationInterface'); + $specificationSecond = $this->getMock(\Magento\Payment\Model\Method\SpecificationInterface::class); $specificationSecond->expects( $this->any() )->method( diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/FactoryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/FactoryTest.php index a5e878bd22f73..fbf0a79961448 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/FactoryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/Specification/FactoryTest.php @@ -22,18 +22,18 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->factory = $objectManagerHelper->getObject( - 'Magento\Payment\Model\Method\Specification\Factory', + \Magento\Payment\Model\Method\Specification\Factory::class, ['objectManager' => $this->objectManagerMock] ); } public function testCreateMethod() { - $className = 'Magento\Payment\Model\Method\SpecificationInterface'; + $className = \Magento\Payment\Model\Method\SpecificationInterface::class; $methodMock = $this->getMock($className); $this->objectManagerMock->expects( $this->once() diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/SubstitutionTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/SubstitutionTest.php index 1edfea43da258..0f60dce0d8e3a 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/SubstitutionTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/SubstitutionTest.php @@ -21,13 +21,13 @@ class SubstitutionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $this->objectManager->getObject('Magento\Payment\Model\Method\Substitution'); + $this->model = $this->objectManager->getObject(\Magento\Payment\Model\Method\Substitution::class); } public function testGetTitle() { $infoMock = $this->getMockBuilder( - 'Magento\Payment\Model\Info' + \Magento\Payment\Model\Info::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php b/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php index b1e5bedb5a250..5b210836b4113 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php @@ -36,12 +36,12 @@ class MethodListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->paymentHelperMock = $this->getMock('\Magento\Payment\Helper\Data', [], [], '', false); - $this->specificationFactoryMock = $this->getMock( - '\Magento\Payment\Model\Checks\SpecificationFactory', [], [], '', false + $this->paymentHelperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); + $this->specificationFactoryMock = $this->getMock( + \Magento\Payment\Model\Checks\SpecificationFactory::class, [], [], '', false ); - $this->methodList = $this->objectManager->getObject( - 'Magento\Payment\Model\MethodList', + $this->methodList = $this->objectManager->getObject( + \Magento\Payment\Model\MethodList::class, [ 'paymentHelper' => $this->paymentHelperMock, 'specificationFactory' => $this->specificationFactoryMock @@ -52,15 +52,15 @@ protected function setUp() public function testGetAvailableMethods() { $storeId = 1; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); $quoteMock->expects($this->atLeastOnce()) ->method('getPayment') - ->will($this->returnValue($this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false))); + ->will($this->returnValue($this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false))); - $methodMock = $this->getMock('Magento\Payment\Model\Method\AbstractMethod', [], [], '', false); + $methodMock = $this->getMock(\Magento\Payment\Model\Method\AbstractMethod::class, [], [], '', false); - $compositeMock = $this->getMock('\Magento\Payment\Model\Checks\Composite', [], [], '', false); + $compositeMock = $this->getMock(\Magento\Payment\Model\Checks\Composite::class, [], [], '', false); $compositeMock->expects($this->atLeastOnce()) ->method('isApplicable') ->with($methodMock, $quoteMock) @@ -79,7 +79,7 @@ public function testGetAvailableMethods() $methodMock->expects($this->atLeastOnce()) ->method('setInfoInstance') - ->with($this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false)) + ->with($this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false)) ->will($this->returnSelf()); $this->assertEquals([$methodMock], $this->methodList->getAvailableMethods($quoteMock)); diff --git a/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/GroupListTest.php b/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/GroupListTest.php index 63b3bf4d94cc4..4049cdb3d2151 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/GroupListTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/GroupListTest.php @@ -20,7 +20,7 @@ class GroupListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->helperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->groupArrayModel = new \Magento\Payment\Model\ResourceModel\Grid\GroupList($this->helperMock); } diff --git a/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/TypeListTest.php b/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/TypeListTest.php index e509c30741959..c42c2e0c26c83 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/TypeListTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/ResourceModel/Grid/TypeListTest.php @@ -20,7 +20,7 @@ class TypeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->helperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->typesArrayModel = new \Magento\Payment\Model\ResourceModel\Grid\TypeList($this->helperMock); } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Source/CctypeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Source/CctypeTest.php index 6380e7013d5fd..13e8775fa6b24 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Source/CctypeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Source/CctypeTest.php @@ -46,7 +46,7 @@ class CctypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_paymentConfig = $this->getMockBuilder( - 'Magento\Payment\Model\Config' + \Magento\Payment\Model\Config::class )->disableOriginalConstructor()->setMethods([])->getMock(); $this->_model = new Cctype($this->_paymentConfig); diff --git a/app/code/Magento/Payment/Test/Unit/Observer/SalesOrderBeforeSaveObserverTest.php b/app/code/Magento/Payment/Test/Unit/Observer/SalesOrderBeforeSaveObserverTest.php index d6336d6cd04df..be6cc1957a31d 100644 --- a/app/code/Magento/Payment/Test/Unit/Observer/SalesOrderBeforeSaveObserverTest.php +++ b/app/code/Magento/Payment/Test/Unit/Observer/SalesOrderBeforeSaveObserverTest.php @@ -26,12 +26,12 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->salesOrderBeforeSaveObserver = $this->objectManagerHelper->getObject( - 'Magento\Payment\Observer\SalesOrderBeforeSaveObserver', + \Magento\Payment\Observer\SalesOrderBeforeSaveObserver::class, [] ); $this->observerMock = $this->getMockBuilder( - 'Magento\Framework\Event\Observer' + \Magento\Framework\Event\Observer::class )->disableOriginalConstructor()->setMethods([])->getMock(); } @@ -131,7 +131,7 @@ public function testSalesOrderBeforeSaveSetForced() private function _prepareEventMockWithMethods($methodsList) { $this->eventMock = $this->getMockBuilder( - 'Magento\Framework\Event' + \Magento\Framework\Event::class )->disableOriginalConstructor()->setMethods($methodsList)->getMock(); $this->observerMock->expects($this->any())->method('getEvent')->will($this->returnValue($this->eventMock)); } @@ -145,15 +145,15 @@ private function _prepareEventMockWithMethods($methodsList) */ private function _getPreparedOrderMethod($methodCode, $orderMethods = []) { - $order = $this->getMockBuilder('Magento\Sales\Model\Order')->disableOriginalConstructor()->setMethods( + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->setMethods( array_merge(['__wakeup', 'getPayment'], $orderMethods) )->getMock(); $paymentMock = $this->getMockBuilder( - 'Magento\Sales\Model\Order\Payment' + \Magento\Sales\Model\Order\Payment::class )->disableOriginalConstructor()->setMethods([])->getMock(); $order->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); $methodInstance = $this->getMockBuilder( - 'Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->getMockForAbstractClass(); $paymentMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodInstance)); $methodInstance->expects($this->once())->method('getCode')->will($this->returnValue($methodCode)); diff --git a/app/code/Magento/Payment/Test/Unit/Observer/UpdateOrderStatusForPaymentMethodsObserverTest.php b/app/code/Magento/Payment/Test/Unit/Observer/UpdateOrderStatusForPaymentMethodsObserverTest.php index 781a7f9a43429..bf666dd76f55c 100644 --- a/app/code/Magento/Payment/Test/Unit/Observer/UpdateOrderStatusForPaymentMethodsObserverTest.php +++ b/app/code/Magento/Payment/Test/Unit/Observer/UpdateOrderStatusForPaymentMethodsObserverTest.php @@ -37,13 +37,19 @@ class UpdateOrderStatusForPaymentMethodsObserverTest extends \PHPUnit_Framework_ protected function setUp() { - $this->orderConfigMock = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); - $this->paymentConfigMock = $this->getMock('Magento\Payment\Model\Config', [], [], '', false); - $this->coreResourceConfigMock = $this->getMock('Magento\Config\Model\ResourceModel\Config', [], [], '', false); + $this->orderConfigMock = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); + $this->paymentConfigMock = $this->getMock(\Magento\Payment\Model\Config::class, [], [], '', false); + $this->coreResourceConfigMock = $this->getMock( + \Magento\Config\Model\ResourceModel\Config::class, + [], + [], + '', + false + ); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->updateOrderStatusForPaymentMethodsObserver = $this->objectManagerHelper->getObject( - 'Magento\Payment\Observer\UpdateOrderStatusForPaymentMethodsObserver', + \Magento\Payment\Observer\UpdateOrderStatusForPaymentMethodsObserver::class, [ 'salesOrderConfig' => $this->orderConfigMock, 'paymentConfig' => $this->paymentConfigMock, @@ -52,7 +58,7 @@ protected function setUp() ); $this->observerMock = $this->getMockBuilder( - 'Magento\Framework\Event\Observer' + \Magento\Framework\Event\Observer::class )->disableOriginalConstructor()->setMethods([])->getMock(); } @@ -99,7 +105,7 @@ public function testUpdateOrderStatusForPaymentMethodsNewState() private function _prepareEventMockWithMethods($methodsList) { $this->eventMock = $this->getMockBuilder( - 'Magento\Framework\Event' + \Magento\Framework\Event::class )->disableOriginalConstructor()->setMethods($methodsList)->getMock(); $this->observerMock->expects($this->any())->method('getEvent')->will($this->returnValue($this->eventMock)); } @@ -112,7 +118,7 @@ private function _prepareEventMockWithMethods($methodsList) private function _getPreparedActiveMethods() { $method1 = $this->getMockBuilder( - 'Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->getMockForAbstractClass(); $method1->expects($this->once())->method('getConfigData')->with('order_status')->will( $this->returnValue(self::ORDER_STATUS) @@ -122,7 +128,7 @@ private function _getPreparedActiveMethods() ); $method2 = $this->getMockBuilder( - 'Magento\Payment\Model\MethodInterface' + \Magento\Payment\Model\MethodInterface::class )->getMockForAbstractClass(); $method2->expects($this->once())->method('getConfigData')->with('order_status')->will( $this->returnValue('not_a_status') diff --git a/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details.php b/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details.php index fdbb240b0f75c..933ff3362c4e8 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details.php @@ -36,7 +36,7 @@ protected function _construct() protected function _prepareLayout() { parent::_prepareLayout(); - $this->addChild('form', 'Magento\Paypal\Block\Adminhtml\Settlement\Details\Form'); + $this->addChild('form', \Magento\Paypal\Block\Adminhtml\Settlement\Details\Form::class); return $this; } } diff --git a/app/code/Magento/Paypal/Block/Billing/Agreement/View.php b/app/code/Magento/Paypal/Block/Billing/Agreement/View.php index 7fb0014b74226..f230ca24979ab 100644 --- a/app/code/Magento/Paypal/Block/Billing/Agreement/View.php +++ b/app/code/Magento/Paypal/Block/Billing/Agreement/View.php @@ -172,7 +172,7 @@ protected function _prepareLayout() parent::_prepareLayout(); $pager = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager' + \Magento\Theme\Block\Html\Pager::class )->setCollection( $this->getRelatedOrders() )->setIsOutputRequired( diff --git a/app/code/Magento/Paypal/Block/Billing/Agreements.php b/app/code/Magento/Paypal/Block/Billing/Agreements.php index b768b2468685c..802fb8f0a2450 100644 --- a/app/code/Magento/Paypal/Block/Billing/Agreements.php +++ b/app/code/Magento/Paypal/Block/Billing/Agreements.php @@ -69,7 +69,7 @@ protected function _prepareLayout() { parent::_prepareLayout(); $pager = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager' + \Magento\Theme\Block\Html\Pager::class )->setCollection( $this->getBillingAgreements() )->setIsOutputRequired( diff --git a/app/code/Magento/Paypal/Block/Express/Form.php b/app/code/Magento/Paypal/Block/Express/Form.php index 20e50bc66247d..5893222cbb222 100644 --- a/app/code/Magento/Paypal/Block/Express/Form.php +++ b/app/code/Magento/Paypal/Block/Express/Form.php @@ -121,7 +121,7 @@ public function getMethodCode() protected function _getMarkTemplate() { /** @var $mark Template */ - $mark = $this->_layout->createBlock('Magento\Framework\View\Element\Template'); + $mark = $this->_layout->createBlock(\Magento\Framework\View\Element\Template::class); $mark->setTemplate('Magento_Paypal::payment/mark.phtml'); return $mark; } diff --git a/app/code/Magento/Paypal/Block/Express/Review/Billing.php b/app/code/Magento/Paypal/Block/Express/Review/Billing.php index a95a541c984f0..0a4bac7f1727d 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Billing.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Billing.php @@ -197,7 +197,7 @@ public function getSaveUrl() protected function _getTaxvat() { if (!$this->taxvat) { - $this->taxvat = $this->getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat'); + $this->taxvat = $this->getLayout()->createBlock(\Magento\Customer\Block\Widget\Taxvat::class); } return $this->taxvat; diff --git a/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php index 1e740f5c13446..6476b2ec2f51d 100644 --- a/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php @@ -42,7 +42,9 @@ public function __construct(\Magento\Backend\App\Action\Context $context, \Magen protected function _initBillingAgreement() { $agreementId = $this->getRequest()->getParam('agreement'); - $agreementModel = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement')->load($agreementId); + $agreementModel = $this->_objectManager->create( + \Magento\Paypal\Model\Billing\Agreement::class + )->load($agreementId); if (!$agreementModel->getId()) { $this->messageManager->addErrorMessage( diff --git a/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Details.php b/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Details.php index fcc8c26ce0f34..1fb07e9c822a4 100644 --- a/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Details.php +++ b/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Details.php @@ -33,7 +33,7 @@ public function execute() $this->_view->getPage()->getConfig()->getTitle()->prepend(__('View Transaction')); $this->_addContent( $this->_view->getLayout()->createBlock( - 'Magento\Paypal\Block\Adminhtml\Settlement\Details', + \Magento\Paypal\Block\Adminhtml\Settlement\Details::class, 'settlementDetails' ) ); diff --git a/app/code/Magento/Paypal/Controller/Billing/Agreement.php b/app/code/Magento/Paypal/Controller/Billing/Agreement.php index a973fb8cfb921..62ae634b30101 100644 --- a/app/code/Magento/Paypal/Controller/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Controller/Billing/Agreement.php @@ -58,7 +58,7 @@ protected function _initAgreement() $agreementId = $this->getRequest()->getParam('agreement'); if ($agreementId) { /** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */ - $billingAgreement = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement') + $billingAgreement = $this->_objectManager->create(\Magento\Paypal\Model\Billing\Agreement::class) ->load($agreementId); $currentCustomerId = $this->_getSession()->getCustomerId(); $agreementCustomerId = $billingAgreement->getCustomerId(); @@ -81,6 +81,6 @@ protected function _initAgreement() */ protected function _getSession() { - return $this->_objectManager->get('Magento\Customer\Model\Session'); + return $this->_objectManager->get(\Magento\Customer\Model\Session::class); } } diff --git a/app/code/Magento/Paypal/Controller/Billing/Agreement/ReturnWizard.php b/app/code/Magento/Paypal/Controller/Billing/Agreement/ReturnWizard.php index 38d012c65c219..fdf84f25696d2 100644 --- a/app/code/Magento/Paypal/Controller/Billing/Agreement/ReturnWizard.php +++ b/app/code/Magento/Paypal/Controller/Billing/Agreement/ReturnWizard.php @@ -18,7 +18,7 @@ class ReturnWizard extends \Magento\Paypal\Controller\Billing\Agreement public function execute() { /** @var \Magento\Paypal\Model\Billing\Agreement $agreement */ - $agreement = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement'); + $agreement = $this->_objectManager->create(\Magento\Paypal\Model\Billing\Agreement::class); $paymentCode = $this->getRequest()->getParam('payment_method'); $token = $this->getRequest()->getParam('token'); @@ -28,7 +28,7 @@ public function execute() if ($token && $paymentCode) { try { $agreement->setStoreId( - $this->_objectManager->get('Magento\Store\Model\StoreManager')->getStore()->getId() + $this->_objectManager->get(\Magento\Store\Model\StoreManager::class)->getStore()->getId() )->setToken( $token )->setMethodCode( diff --git a/app/code/Magento/Paypal/Controller/Billing/Agreement/StartWizard.php b/app/code/Magento/Paypal/Controller/Billing/Agreement/StartWizard.php index b85bb8ccd72d4..d9eada9107c06 100644 --- a/app/code/Magento/Paypal/Controller/Billing/Agreement/StartWizard.php +++ b/app/code/Magento/Paypal/Controller/Billing/Agreement/StartWizard.php @@ -15,20 +15,20 @@ class StartWizard extends \Magento\Paypal\Controller\Billing\Agreement */ public function execute() { - $agreement = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement'); + $agreement = $this->_objectManager->create(\Magento\Paypal\Model\Billing\Agreement::class); $paymentCode = $this->getRequest()->getParam('payment_method'); if ($paymentCode) { try { $agreement->setStoreId( - $this->_objectManager->get('Magento\Store\Model\StoreManager')->getStore()->getId() + $this->_objectManager->get(\Magento\Store\Model\StoreManager::class)->getStore()->getId() )->setMethodCode( $paymentCode )->setReturnUrl( $this->_objectManager->create( - 'Magento\Framework\UrlInterface' + \Magento\Framework\UrlInterface::class )->getUrl('*/*/returnWizard', ['payment_method' => $paymentCode]) )->setCancelUrl( - $this->_objectManager->create('Magento\Framework\UrlInterface') + $this->_objectManager->create(\Magento\Framework\UrlInterface::class) ->getUrl('*/*/cancelWizard', ['payment_method' => $paymentCode]) ); diff --git a/app/code/Magento/Paypal/Controller/Express/AbstractExpress/ShippingOptionsCallback.php b/app/code/Magento/Paypal/Controller/Express/AbstractExpress/ShippingOptionsCallback.php index bd7a04eafec8a..5383a3e487182 100644 --- a/app/code/Magento/Paypal/Controller/Express/AbstractExpress/ShippingOptionsCallback.php +++ b/app/code/Magento/Paypal/Controller/Express/AbstractExpress/ShippingOptionsCallback.php @@ -62,7 +62,7 @@ public function execute() $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams()); $this->getResponse()->setBody($response); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } } } diff --git a/app/code/Magento/Paypal/Controller/Express/Cancel.php b/app/code/Magento/Paypal/Controller/Express/Cancel.php index 591da04c1e26c..dbeaa8bb85a7f 100644 --- a/app/code/Magento/Paypal/Controller/Express/Cancel.php +++ b/app/code/Magento/Paypal/Controller/Express/Cancel.php @@ -13,7 +13,7 @@ class Cancel extends \Magento\Paypal\Controller\Express\AbstractExpress\Cancel * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Cancel extends \Magento\Paypal\Controller\Express\AbstractExpress\Cancel * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/Edit.php b/app/code/Magento/Paypal/Controller/Express/Edit.php index b05b6b122f8da..b3609893ff910 100644 --- a/app/code/Magento/Paypal/Controller/Express/Edit.php +++ b/app/code/Magento/Paypal/Controller/Express/Edit.php @@ -13,7 +13,7 @@ class Edit extends \Magento\Paypal\Controller\Express\AbstractExpress\Edit * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Edit extends \Magento\Paypal\Controller\Express\AbstractExpress\Edit * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/GetToken.php b/app/code/Magento/Paypal/Controller/Express/GetToken.php index a7c00bf1f3832..1cc33552b1af0 100644 --- a/app/code/Magento/Paypal/Controller/Express/GetToken.php +++ b/app/code/Magento/Paypal/Controller/Express/GetToken.php @@ -25,7 +25,7 @@ class GetToken extends AbstractExpress * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -39,7 +39,7 @@ class GetToken extends AbstractExpress * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; /** * @inheritdoc diff --git a/app/code/Magento/Paypal/Controller/Express/PlaceOrder.php b/app/code/Magento/Paypal/Controller/Express/PlaceOrder.php index 2cfb25f4f72ad..18ddead81e0fd 100644 --- a/app/code/Magento/Paypal/Controller/Express/PlaceOrder.php +++ b/app/code/Magento/Paypal/Controller/Express/PlaceOrder.php @@ -13,7 +13,7 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress\Plac * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress\Plac * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/ReturnAction.php b/app/code/Magento/Paypal/Controller/Express/ReturnAction.php index 74362b9877b21..5fa352d648034 100644 --- a/app/code/Magento/Paypal/Controller/Express/ReturnAction.php +++ b/app/code/Magento/Paypal/Controller/Express/ReturnAction.php @@ -13,7 +13,7 @@ class ReturnAction extends \Magento\Paypal\Controller\Express\AbstractExpress\Re * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class ReturnAction extends \Magento\Paypal\Controller\Express\AbstractExpress\Re * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/Review.php b/app/code/Magento/Paypal/Controller/Express/Review.php index 88c3ac78d0cd1..ca1e08ae7c877 100644 --- a/app/code/Magento/Paypal/Controller/Express/Review.php +++ b/app/code/Magento/Paypal/Controller/Express/Review.php @@ -13,7 +13,7 @@ class Review extends \Magento\Paypal\Controller\Express\AbstractExpress\Review * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Review extends \Magento\Paypal\Controller\Express\AbstractExpress\Review * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/SaveShippingMethod.php b/app/code/Magento/Paypal/Controller/Express/SaveShippingMethod.php index 1bba6bf1da60b..5da5d0a5869ea 100644 --- a/app/code/Magento/Paypal/Controller/Express/SaveShippingMethod.php +++ b/app/code/Magento/Paypal/Controller/Express/SaveShippingMethod.php @@ -13,7 +13,7 @@ class SaveShippingMethod extends \Magento\Paypal\Controller\Express\AbstractExpr * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class SaveShippingMethod extends \Magento\Paypal\Controller\Express\AbstractExpr * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/ShippingOptionsCallback.php b/app/code/Magento/Paypal/Controller/Express/ShippingOptionsCallback.php index 5c66518916b8f..3ab143a0cd6f0 100644 --- a/app/code/Magento/Paypal/Controller/Express/ShippingOptionsCallback.php +++ b/app/code/Magento/Paypal/Controller/Express/ShippingOptionsCallback.php @@ -13,7 +13,7 @@ class ShippingOptionsCallback extends \Magento\Paypal\Controller\Express\Abstrac * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class ShippingOptionsCallback extends \Magento\Paypal\Controller\Express\Abstrac * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/Start.php b/app/code/Magento/Paypal/Controller/Express/Start.php index 3410e07fa596e..23664c433194e 100644 --- a/app/code/Magento/Paypal/Controller/Express/Start.php +++ b/app/code/Magento/Paypal/Controller/Express/Start.php @@ -13,7 +13,7 @@ class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Express/UpdateShippingMethods.php b/app/code/Magento/Paypal/Controller/Express/UpdateShippingMethods.php index 66209e276559d..31c8296822fd7 100644 --- a/app/code/Magento/Paypal/Controller/Express/UpdateShippingMethods.php +++ b/app/code/Magento/Paypal/Controller/Express/UpdateShippingMethods.php @@ -13,7 +13,7 @@ class UpdateShippingMethods extends \Magento\Paypal\Controller\Express\AbstractE * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class UpdateShippingMethods extends \Magento\Paypal\Controller\Express\AbstractE * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\Express\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\Express\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Hostedpro/ReturnAction.php b/app/code/Magento/Paypal/Controller/Hostedpro/ReturnAction.php index 79478a62d3f13..2a7d6e94e11bd 100644 --- a/app/code/Magento/Paypal/Controller/Hostedpro/ReturnAction.php +++ b/app/code/Magento/Paypal/Controller/Hostedpro/ReturnAction.php @@ -15,7 +15,7 @@ class ReturnAction extends \Magento\Framework\App\Action\Action */ public function execute() { - $session = $this->_objectManager->get('Magento\Checkout\Model\Session'); + $session = $this->_objectManager->get(\Magento\Checkout\Model\Session::class); //TODO: some actions with order if ($session->getLastRealOrderId()) { $this->_redirect('checkout/onepage/success'); diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/Cancel.php b/app/code/Magento/Paypal/Controller/Payflowexpress/Cancel.php index b71d4ca01125f..9a162808da1ba 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/Cancel.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/Cancel.php @@ -13,7 +13,7 @@ class Cancel extends \Magento\Paypal\Controller\Express\AbstractExpress\Cancel * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Cancel extends \Magento\Paypal\Controller\Express\AbstractExpress\Cancel * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/Edit.php b/app/code/Magento/Paypal/Controller/Payflowexpress/Edit.php index 53082b7b83705..b4f0b85b023b0 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/Edit.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/Edit.php @@ -13,7 +13,7 @@ class Edit extends \Magento\Paypal\Controller\Express\AbstractExpress\Edit * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Edit extends \Magento\Paypal\Controller\Express\AbstractExpress\Edit * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/PlaceOrder.php b/app/code/Magento/Paypal/Controller/Payflowexpress/PlaceOrder.php index 80702806350f4..dcb7529fb021e 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/PlaceOrder.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/PlaceOrder.php @@ -13,7 +13,7 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress\Plac * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress\Plac * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/ReturnAction.php b/app/code/Magento/Paypal/Controller/Payflowexpress/ReturnAction.php index d796805ee3ec0..c6555e203beda 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/ReturnAction.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/ReturnAction.php @@ -13,7 +13,7 @@ class ReturnAction extends \Magento\Paypal\Controller\Express\AbstractExpress\Re * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class ReturnAction extends \Magento\Paypal\Controller\Express\AbstractExpress\Re * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/Review.php b/app/code/Magento/Paypal/Controller/Payflowexpress/Review.php index 59399a9a79302..944760b02e913 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/Review.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/Review.php @@ -13,7 +13,7 @@ class Review extends \Magento\Paypal\Controller\Express\AbstractExpress\Review * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Review extends \Magento\Paypal\Controller\Express\AbstractExpress\Review * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/SaveShippingMethod.php b/app/code/Magento/Paypal/Controller/Payflowexpress/SaveShippingMethod.php index 5718741d15ee2..84231ad6c3ef5 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/SaveShippingMethod.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/SaveShippingMethod.php @@ -13,7 +13,7 @@ class SaveShippingMethod extends \Magento\Paypal\Controller\Express\AbstractExpr * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class SaveShippingMethod extends \Magento\Paypal\Controller\Express\AbstractExpr * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/ShippingOptionsCallback.php b/app/code/Magento/Paypal/Controller/Payflowexpress/ShippingOptionsCallback.php index 6147da0c4c93e..daf57acc636d9 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/ShippingOptionsCallback.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/ShippingOptionsCallback.php @@ -13,7 +13,7 @@ class ShippingOptionsCallback extends \Magento\Paypal\Controller\Express\Abstrac * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class ShippingOptionsCallback extends \Magento\Paypal\Controller\Express\Abstrac * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php b/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php index 0d87185a774fa..15816af52b9ae 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php @@ -13,7 +13,7 @@ class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/UpdateShippingMethods.php b/app/code/Magento/Paypal/Controller/Payflowexpress/UpdateShippingMethods.php index e3fbe7cd8a2ce..c250b6385edaf 100644 --- a/app/code/Magento/Paypal/Controller/Payflowexpress/UpdateShippingMethods.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress/UpdateShippingMethods.php @@ -13,7 +13,7 @@ class UpdateShippingMethods extends \Magento\Paypal\Controller\Express\AbstractE * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Config method type @@ -27,5 +27,5 @@ class UpdateShippingMethods extends \Magento\Paypal\Controller\Express\AbstractE * * @var string */ - protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; + protected $_checkoutType = \Magento\Paypal\Model\PayflowExpress\Checkout::class; } diff --git a/app/code/Magento/Paypal/Helper/Shortcut/Factory.php b/app/code/Magento/Paypal/Helper/Shortcut/Factory.php index 62ee1d9fc523e..ef12c4d1182ff 100644 --- a/app/code/Magento/Paypal/Helper/Shortcut/Factory.php +++ b/app/code/Magento/Paypal/Helper/Shortcut/Factory.php @@ -11,12 +11,12 @@ class Factory /** * Default validator */ - const DEFAULT_VALIDATOR = 'Magento\Paypal\Helper\Shortcut\Validator'; + const DEFAULT_VALIDATOR = \Magento\Paypal\Helper\Shortcut\Validator::class; /** * Checkout validator */ - const CHECKOUT_VALIDATOR = 'Magento\Paypal\Helper\Shortcut\CheckoutValidator'; + const CHECKOUT_VALIDATOR = \Magento\Paypal\Helper\Shortcut\CheckoutValidator::class; /** * @var \Magento\Framework\ObjectManagerInterface diff --git a/app/code/Magento/Paypal/Model/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Billing/Agreement.php index fc49a24676634..5f81ede744324 100644 --- a/app/code/Magento/Paypal/Model/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Model/Billing/Agreement.php @@ -28,6 +28,8 @@ * @method \Magento\Paypal\Model\Billing\Agreement setStoreId(int $value) * @method string getAgreementLabel() * @method \Magento\Paypal\Model\Billing\Agreement setAgreementLabel(string $value) + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement { @@ -84,7 +86,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Paypal\Model\ResourceModel\Billing\Agreement'); + $this->_init(\Magento\Paypal\Model\ResourceModel\Billing\Agreement::class); } /** diff --git a/app/code/Magento/Paypal/Model/Bml.php b/app/code/Magento/Paypal/Model/Bml.php index d67000b121467..4c255e1f754ac 100644 --- a/app/code/Magento/Paypal/Model/Bml.php +++ b/app/code/Magento/Paypal/Model/Bml.php @@ -18,7 +18,7 @@ class Bml extends Express * Checkout payment form * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Bml\Form'; + protected $_formBlockType = \Magento\Paypal\Block\Bml\Form::class; /** * Checkout redirect URL getter for onepage checkout diff --git a/app/code/Magento/Paypal/Model/Cert.php b/app/code/Magento/Paypal/Model/Cert.php index cf7c682f6fb68..a8683c058a536 100644 --- a/app/code/Magento/Paypal/Model/Cert.php +++ b/app/code/Magento/Paypal/Model/Cert.php @@ -58,7 +58,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Paypal\Model\ResourceModel\Cert'); + $this->_init(\Magento\Paypal\Model\ResourceModel\Cert::class); } /** diff --git a/app/code/Magento/Paypal/Model/Config/Rules/Reader.php b/app/code/Magento/Paypal/Model/Config/Rules/Reader.php index b02fd0b27bc1a..bafb6177c63a5 100644 --- a/app/code/Magento/Paypal/Model/Config/Rules/Reader.php +++ b/app/code/Magento/Paypal/Model/Config/Rules/Reader.php @@ -48,7 +48,7 @@ public function __construct( Backend $helper, $fileName = 'adminhtml/rules/payment_{country}.xml', $idAttributes = [], - $domDocumentClass = 'Magento\Framework\Config\Dom', + $domDocumentClass = \Magento\Framework\Config\Dom::class, $defaultScope = 'primary' ) { $fileName = str_replace('{country}', strtolower($helper->getConfigurationCountryCode()), $fileName); diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index b22913c7d9048..25a8ec3045504 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -23,7 +23,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc /** * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Payment\Info'; + protected $_infoBlockType = \Magento\Paypal\Block\Payment\Info::class; /** * Availability option diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php index 80c9ef0625d96..d377e8ed626e1 100644 --- a/app/code/Magento/Paypal/Model/Express.php +++ b/app/code/Magento/Paypal/Model/Express.php @@ -31,12 +31,12 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Express\Form'; + protected $_formBlockType = \Magento\Paypal\Block\Express\Form::class; /** * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Payment\Info'; + protected $_infoBlockType = \Magento\Paypal\Block\Payment\Info::class; /** * Availability option diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index d84c5e48faa2f..7e7596b7fbdf7 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -70,7 +70,7 @@ class Checkout * * @var string */ - protected $_apiType = 'Magento\Paypal\Model\Api\Nvp'; + protected $_apiType = \Magento\Paypal\Model\Api\Nvp::class; /** * Payment method type diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index 30b069711e967..88bd8325c1204 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -42,12 +42,12 @@ class Hostedpro extends Direct /** * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Hosted\Pro\Form'; + protected $_formBlockType = \Magento\Paypal\Block\Hosted\Pro\Form::class; /** * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Hosted\Pro\Info'; + protected $_infoBlockType = \Magento\Paypal\Block\Hosted\Pro\Info::class; /** * Availability option diff --git a/app/code/Magento/Paypal/Model/IpnFactory.php b/app/code/Magento/Paypal/Model/IpnFactory.php index e49519f9301a3..d575f73c3f741 100644 --- a/app/code/Magento/Paypal/Model/IpnFactory.php +++ b/app/code/Magento/Paypal/Model/IpnFactory.php @@ -40,7 +40,7 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan public function create(array $data = []) { $type = isset($data['data']['txn_type']) ? $data['data']['txn_type'] : ''; - $instanceType = isset($this->mapping[$type]) ? $this->mapping[$type] : 'Magento\Paypal\Model\Ipn'; + $instanceType = isset($this->mapping[$type]) ? $this->mapping[$type] : \Magento\Paypal\Model\Ipn::class; return $this->_objectManager->create($instanceType, $data); } } diff --git a/app/code/Magento/Paypal/Model/Payflow/Bml.php b/app/code/Magento/Paypal/Model/Payflow/Bml.php index b1a30674c92dc..9df11fd0d9f9b 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Bml.php +++ b/app/code/Magento/Paypal/Model/Payflow/Bml.php @@ -20,7 +20,7 @@ class Bml extends Model\Express * Checkout payment form * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Payflow\Bml\Form'; + protected $_formBlockType = \Magento\Paypal\Block\Payflow\Bml\Form::class; /** * Checkout redirect URL getter for onepage checkout diff --git a/app/code/Magento/Paypal/Model/Payflow/Pro.php b/app/code/Magento/Paypal/Model/Payflow/Pro.php index 904bd1f92cfb8..e0b58eb679e37 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Pro.php +++ b/app/code/Magento/Paypal/Model/Payflow/Pro.php @@ -17,14 +17,14 @@ class Pro extends \Magento\Paypal\Model\Pro * * @var string */ - protected $_apiType = 'Magento\Paypal\Model\Api\PayflowNvp'; + protected $_apiType = \Magento\Paypal\Model\Api\PayflowNvp::class; /** * Config model type * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * Payflow trx_id key in transaction info diff --git a/app/code/Magento/Paypal/Model/Payflow/Transparent.php b/app/code/Magento/Paypal/Model/Payflow/Transparent.php index 2c8d43d30b26b..35ae33af82189 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Transparent.php +++ b/app/code/Magento/Paypal/Model/Payflow/Transparent.php @@ -35,12 +35,12 @@ class Transparent extends Payflowpro implements TransparentInterface /** * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Transparent\Info'; + protected $_formBlockType = \Magento\Payment\Block\Transparent\Info::class; /** * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Payflow\Info'; + protected $_infoBlockType = \Magento\Paypal\Block\Payflow\Info::class; /** * @var ResponseValidator @@ -131,7 +131,6 @@ public function getResponceValidator() return $this->responseValidator; } - /** * Do not validate payment form using server methods * diff --git a/app/code/Magento/Paypal/Model/PayflowExpress.php b/app/code/Magento/Paypal/Model/PayflowExpress.php index c66e683bf5518..db717b1d38da6 100644 --- a/app/code/Magento/Paypal/Model/PayflowExpress.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress.php @@ -21,7 +21,7 @@ class PayflowExpress extends \Magento\Paypal\Model\Express /** * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\PayflowExpress\Form'; + protected $_formBlockType = \Magento\Paypal\Block\PayflowExpress\Form::class; /** * Express Checkout payment method instance diff --git a/app/code/Magento/Paypal/Model/PayflowExpress/Checkout.php b/app/code/Magento/Paypal/Model/PayflowExpress/Checkout.php index 6360040b0764f..d35eed6f3aba1 100644 --- a/app/code/Magento/Paypal/Model/PayflowExpress/Checkout.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress/Checkout.php @@ -16,7 +16,7 @@ class Checkout extends \Magento\Paypal\Model\Express\Checkout * * @var string */ - protected $_apiType = 'Magento\Paypal\Model\Api\PayflowNvp'; + protected $_apiType = \Magento\Paypal\Model\Api\PayflowNvp::class; /** * Payment method type diff --git a/app/code/Magento/Paypal/Model/Payflowadvanced.php b/app/code/Magento/Paypal/Model/Payflowadvanced.php index 129df8362c92a..4bb30c3c8c956 100644 --- a/app/code/Magento/Paypal/Model/Payflowadvanced.php +++ b/app/code/Magento/Paypal/Model/Payflowadvanced.php @@ -23,14 +23,14 @@ class Payflowadvanced extends \Magento\Paypal\Model\Payflowlink * * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Payflow\Advanced\Form'; + protected $_formBlockType = \Magento\Paypal\Block\Payflow\Advanced\Form::class; /** * Type of block that displays method information * * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Payflow\Advanced\Info'; + protected $_infoBlockType = \Magento\Paypal\Block\Payflow\Advanced\Info::class; /** * Controller for callback urls diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 6543ef7ebbc50..394ba05fe086d 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -41,12 +41,12 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro /** * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Payflow\Link\Form'; + protected $_formBlockType = \Magento\Paypal\Block\Payflow\Link\Form::class; /** * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Payflow\Link\Info'; + protected $_infoBlockType = \Magento\Paypal\Block\Payflow\Link\Info::class; /** * Availability option diff --git a/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php index 42894ddeec49d..57e9d31d55921 100644 --- a/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php +++ b/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php @@ -27,12 +27,12 @@ abstract class AbstractAgreement extends \Magento\Payment\Model\Method\AbstractM /** * @var string */ - protected $_infoBlockType = 'Magento\Paypal\Block\Payment\Info\Billing\Agreement'; + protected $_infoBlockType = \Magento\Paypal\Block\Payment\Info\Billing\Agreement::class; /** * @var string */ - protected $_formBlockType = 'Magento\Paypal\Block\Payment\Form\Billing\Agreement'; + protected $_formBlockType = \Magento\Paypal\Block\Payment\Form\Billing\Agreement::class; /** * Is method instance available diff --git a/app/code/Magento/Paypal/Model/Pro.php b/app/code/Magento/Paypal/Model/Pro.php index 29279064b898c..9f0e9e0250995 100644 --- a/app/code/Magento/Paypal/Model/Pro.php +++ b/app/code/Magento/Paypal/Model/Pro.php @@ -51,14 +51,14 @@ class Pro * * @var string */ - protected $_apiType = 'Magento\Paypal\Model\Api\Nvp'; + protected $_apiType = \Magento\Paypal\Model\Api\Nvp::class; /** * Config model type * * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; + protected $_configType = \Magento\Paypal\Model\Config::class; /** * @var \Magento\Paypal\Model\Config\Factory diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index e1d2c482e2c6b..8e7a3e60721c7 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -203,7 +203,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Paypal\Model\ResourceModel\Report\Settlement'); + $this->_init(\Magento\Paypal\Model\ResourceModel\Report\Settlement::class); } /** diff --git a/app/code/Magento/Paypal/Model/Report/Settlement/Row.php b/app/code/Magento/Paypal/Model/Report/Settlement/Row.php index de5b7f782b5ac..8e92291dbd046 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement/Row.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement/Row.php @@ -72,7 +72,7 @@ class Row extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Paypal\Model\ResourceModel\Report\Settlement\Row'); + $this->_init(\Magento\Paypal\Model\ResourceModel\Report\Settlement\Row::class); } /** diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php b/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php index dbb5cdd610481..cc746f0054bbd 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php @@ -67,7 +67,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Paypal\Model\Billing\Agreement', 'Magento\Paypal\Model\ResourceModel\Billing\Agreement'); + $this->_init( + \Magento\Paypal\Model\Billing\Agreement::class, + \Magento\Paypal\Model\ResourceModel\Billing\Agreement::class + ); } /** diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php index 248c41478d2b5..9b4ef0ca179e9 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php @@ -21,8 +21,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab protected function _construct() { $this->_init( - 'Magento\Paypal\Model\Report\Settlement\Row', - 'Magento\Paypal\Model\ResourceModel\Report\Settlement\Row' + \Magento\Paypal\Model\Report\Settlement\Row::class, + \Magento\Paypal\Model\ResourceModel\Report\Settlement\Row::class ); } diff --git a/app/code/Magento/Paypal/Observer/AddPaypalShortcutsObserver.php b/app/code/Magento/Paypal/Observer/AddPaypalShortcutsObserver.php index d97393141da58..b782c1ef0874e 100644 --- a/app/code/Magento/Paypal/Observer/AddPaypalShortcutsObserver.php +++ b/app/code/Magento/Paypal/Observer/AddPaypalShortcutsObserver.php @@ -50,13 +50,14 @@ public function execute(EventObserver $observer) /** @var \Magento\Catalog\Block\ShortcutButtons $shortcutButtons */ $shortcutButtons = $observer->getEvent()->getContainer(); $blocks = [ - 'Magento\Paypal\Block\Express\InContext\Minicart\Button' => PaypalConfig::METHOD_WPS_EXPRESS, - 'Magento\Paypal\Block\Express\Shortcut' => PaypalConfig::METHOD_WPP_EXPRESS, - 'Magento\Paypal\Block\Bml\Shortcut' => PaypalConfig::METHOD_WPP_EXPRESS, - 'Magento\Paypal\Block\WpsExpress\Shortcut' => PaypalConfig::METHOD_WPS_EXPRESS, - 'Magento\Paypal\Block\WpsBml\Shortcut' => PaypalConfig::METHOD_WPS_EXPRESS, - 'Magento\Paypal\Block\PayflowExpress\Shortcut' => PaypalConfig::METHOD_WPP_PE_EXPRESS, - 'Magento\Paypal\Block\Payflow\Bml\Shortcut' => PaypalConfig::METHOD_WPP_PE_EXPRESS + \Magento\Paypal\Block\Express\InContext\Minicart\Button::class => + PaypalConfig::METHOD_WPS_EXPRESS, + \Magento\Paypal\Block\Express\Shortcut::class => PaypalConfig::METHOD_WPP_EXPRESS, + \Magento\Paypal\Block\Bml\Shortcut::class => PaypalConfig::METHOD_WPP_EXPRESS, + \Magento\Paypal\Block\WpsExpress\Shortcut::class => PaypalConfig::METHOD_WPS_EXPRESS, + \Magento\Paypal\Block\WpsBml\Shortcut::class => PaypalConfig::METHOD_WPS_EXPRESS, + \Magento\Paypal\Block\PayflowExpress\Shortcut::class => PaypalConfig::METHOD_WPP_PE_EXPRESS, + \Magento\Paypal\Block\Payflow\Bml\Shortcut::class => PaypalConfig::METHOD_WPP_PE_EXPRESS ]; foreach ($blocks as $blockInstanceName => $paymentMethodCode) { if (!$this->paypalConfig->isMethodAvailable($paymentMethodCode)) { diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/Store/SwitcherPluginTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/Store/SwitcherPluginTest.php index 8acc3ec50b5b1..320e89d567b9c 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/Store/SwitcherPluginTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/Store/SwitcherPluginTest.php @@ -24,12 +24,12 @@ protected function setUp() */ public function testAroundGetUrl($countryParam, $getUrlParams) { - $subjectRequest = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface'); + $subjectRequest = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); $subjectRequest->expects($this->once()) ->method('getParam') ->with(\Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY) ->will($this->returnValue($countryParam)); - $subject = $this->getMock('Magento\Backend\Block\Store\Switcher', ['getRequest'], [], '', false); + $subject = $this->getMock(\Magento\Backend\Block\Store\Switcher::class, ['getRequest'], [], '', false); $subject->expects($this->any())->method('getRequest')->will($this->returnValue($subjectRequest)); $getUrl = function ($route, $params) { return [$route, $params]; diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php index f37034459931c..9f5cd79ea597f 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php @@ -38,7 +38,7 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_element = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Form\Element\AbstractElement', + \Magento\Framework\Data\Form\Element\AbstractElement::class, [], '', false, @@ -55,11 +55,11 @@ protected function setUp() $this->_element->expects($this->any()) ->method('getName') ->will($this->returnValue('name')); - $this->_request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface'); - $this->_jsHelper = $this->getMock('Magento\Framework\View\Helper\Js', [], [], '', false); - $this->_url = $this->getMock('Magento\Backend\Model\Url', [], [], '', false); + $this->_request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); + $this->_jsHelper = $this->getMock(\Magento\Framework\View\Helper\Js::class, [], [], '', false); + $this->_url = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); $this->_model = $helper->getObject( - 'Magento\Paypal\Block\Adminhtml\System\Config\Field\Country', + \Magento\Paypal\Block\Adminhtml\System\Config\Field\Country::class, ['request' => $this->_request, 'jsHelper' => $this->_jsHelper, 'url' => $this->_url] ); } diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/Enable/AbstractEnableTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/Enable/AbstractEnableTest.php index dfb50078febb6..d4664961e796f 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/Enable/AbstractEnableTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/Enable/AbstractEnableTest.php @@ -33,7 +33,7 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->elementMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\AbstractElement') + $this->elementMock = $this->getMockBuilder(\Magento\Framework\Data\Form\Element\AbstractElement::class) ->setMethods( [ 'getHtmlId', @@ -44,7 +44,7 @@ protected function setUp() ->getMockForAbstractClass(); $this->abstractEnable = $objectManager->getObject( - 'Magento\Paypal\Test\Unit\Block\Adminhtml\System\Config\Field\Enable\AbstractEnable\Stub' + \Magento\Paypal\Test\Unit\Block\Adminhtml\System\Config\Field\Enable\AbstractEnable\Stub::class ); } @@ -65,7 +65,7 @@ public function testGetUiId() */ public function testRender() { - $formMock = $this->getMockBuilder('Magento\Framework\Data\Form') + $formMock = $this->getMockBuilder(\Magento\Framework\Data\Form::class) ->setMethods(['getFieldNameSuffix']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php index d8da95f6002d6..cff71bce5671a 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php @@ -38,9 +38,9 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_group = $this->getMock('Magento\Config\Model\Config\Structure\Element\Group', [], [], '', false); - $this->_element = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Form\Element\AbstractElement', + $this->_group = $this->getMock(\Magento\Config\Model\Config\Structure\Element\Group::class, [], [], '', false); + $this->_element = $this->getMockForAbstractClass( + \Magento\Framework\Data\Form\Element\AbstractElement::class, [], '', false, @@ -63,14 +63,14 @@ protected function setUp() $this->_element->expects($this->any()) ->method('getId') ->will($this->returnValue('id')); - $this->_user = $this->getMock('Magento\User\Model\User', [], [], '', false); - $this->_authSession = $this->getMock('Magento\Backend\Model\Auth\Session', [], [], '', false); + $this->_user = $this->getMock(\Magento\User\Model\User::class, [], [], '', false); + $this->_authSession = $this->getMock(\Magento\Backend\Model\Auth\Session::class, [], [], '', false); $this->_authSession->expects($this->any()) ->method('__call') ->with('getUser') ->will($this->returnValue($this->_user)); - $this->_model = $helper->getObject( - 'Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group', + $this->_model = $helper->getObject( + \Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group::class, ['authSession' => $this->_authSession] ); $this->_model->setGroup($this->_group); diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php index 036e570e9d04e..955354ef740ec 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php @@ -37,9 +37,9 @@ class PaymentTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_group = $this->getMock('Magento\Config\Model\Config\Structure\Element\Group', [], [], '', false); + $this->_group = $this->getMock(\Magento\Config\Model\Config\Structure\Element\Group::class, [], [], '', false); $this->_element = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Form\Element\AbstractElement', + \Magento\Framework\Data\Form\Element\AbstractElement::class, [], '', false, @@ -62,9 +62,9 @@ protected function setUp() $this->_element->expects($this->any()) ->method('getId') ->will($this->returnValue('id')); - $this->_backendConfig = $this->getMock('Magento\Config\Model\Config', [], [], '', false); + $this->_backendConfig = $this->getMock(\Magento\Config\Model\Config::class, [], [], '', false); $this->_model = $helper->getObject( - 'Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment', + \Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment::class, ['backendConfig' => $this->_backendConfig] ); $this->_model->setGroup($this->_group); diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Billing/Agreement/ViewTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Billing/Agreement/ViewTest.php index 038f3ea178a94..23d6dabcdef6f 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Billing/Agreement/ViewTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Billing/Agreement/ViewTest.php @@ -31,16 +31,16 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->orderCollectionFactory = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\CollectionFactory', + \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class, ['create'], [], '', false ); - $this->orderConfig = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); + $this->orderConfig = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); $this->block = $objectManager->getObject( - 'Magento\Paypal\Block\Billing\Agreement\View', + \Magento\Paypal\Block\Billing\Agreement\View::class, [ 'orderCollectionFactory' => $this->orderCollectionFactory, 'orderConfig' => $this->orderConfig, @@ -53,7 +53,7 @@ public function testGetRelatedOrders() $visibleStatuses = []; $orderCollection = $this->getMock( - 'Magento\Sales\Model\ResourceModel\Order\Collection', + \Magento\Sales\Model\ResourceModel\Order\Collection::class, ['addFieldToSelect', 'addFieldToFilter', 'setOrder'], [], '', diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php index 57ecd1ec8cfbf..444cd9fdc708a 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Paypal\Test\Unit\Block\Billing; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AgreementsTest extends \PHPUnit_Framework_TestCase { /** @@ -61,39 +64,44 @@ class AgreementsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->escaper = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->escaper = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper); $localeDate = $this->getMockForAbstractClass( - 'Magento\Framework\Stdlib\DateTime\TimezoneInterface', + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, [], '', false ); $this->context->expects($this->once())->method('getLocaleDate')->willReturn($localeDate); - $this->urlBuilder = $this->getMockForAbstractClass('Magento\Framework\UrlInterface', [], '', false); + $this->urlBuilder = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class, [], '', false); $this->context->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilder); - $this->layout = $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface', [], '', false); + $this->layout = $this->getMockForAbstractClass(\Magento\Framework\View\LayoutInterface::class, [], '', false); $this->context->expects($this->once())->method('getLayout')->willReturn($this->layout); - $this->eventManager = $this->getMockForAbstractClass('Magento\Framework\Event\ManagerInterface', [], '', false); + $this->eventManager = $this->getMockForAbstractClass( + \Magento\Framework\Event\ManagerInterface::class, + [], + '', + false + ); $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager); $this->scopeConfig = $this->getMockForAbstractClass( - 'Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false ); $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig); - $this->cache = $this->getMockForAbstractClass('Magento\Framework\App\CacheInterface', [], '', false); + $this->cache = $this->getMockForAbstractClass(\Magento\Framework\App\CacheInterface::class, [], '', false); $this->context->expects($this->once())->method('getCache')->willReturn($this->cache); $this->agreementCollection = $this->getMockBuilder( - 'Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory' + \Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory::class )->disableOriginalConstructor()->setMethods(['create'])->getMock(); - $this->helper = $this->getMock('Magento\Paypal\Helper\Data', [], [], '', false); + $this->helper = $this->getMock(\Magento\Paypal\Helper\Data::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $objectManager->getObject( - 'Magento\Paypal\Block\Billing\Agreements', + \Magento\Paypal\Block\Billing\Agreements::class, [ 'context' => $this->context, 'agreementCollection' => $this->agreementCollection, @@ -105,7 +113,7 @@ protected function setUp() public function testGetBillingAgreements() { $collection = $this->getMock( - 'Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection', + \Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection::class, [], [], '', @@ -122,7 +130,7 @@ public function testGetBillingAgreements() public function testGetItemValueCreatedAt() { $this->escaper->expects($this->once())->method('escapeHtml'); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $item->expects($this->exactly(2))->method('getData')->with('created_at')->willReturn('03/10/2014'); $this->block->getItemValue($item, 'created_at'); } @@ -130,7 +138,7 @@ public function testGetItemValueCreatedAt() public function testGetItemValueCreatedAtNoData() { $this->escaper->expects($this->once())->method('escapeHtml'); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $item->expects($this->once())->method('getData')->with('created_at')->willReturn(false); $this->block->getItemValue($item, 'created_at'); } @@ -138,7 +146,7 @@ public function testGetItemValueCreatedAtNoData() public function testGetItemValueUpdatedAt() { $this->escaper->expects($this->once())->method('escapeHtml'); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $item->expects($this->exactly(2))->method('getData')->with('updated_at')->willReturn('03/10/2014'); $this->block->getItemValue($item, 'updated_at'); } @@ -146,7 +154,7 @@ public function testGetItemValueUpdatedAt() public function testGetItemValueUpdatedAtNoData() { $this->escaper->expects($this->once())->method('escapeHtml'); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $item->expects($this->once())->method('getData')->with('updated_at')->willReturn(false); $this->block->getItemValue($item, 'updated_at'); } @@ -154,7 +162,7 @@ public function testGetItemValueUpdatedAtNoData() public function testGetItemValueEditUrl() { $this->escaper->expects($this->once())->method('escapeHtml'); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', ['getAgreementId'], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, ['getAgreementId'], [], '', false); $item->expects($this->once())->method('getAgreementId')->willReturn(1); $this->urlBuilder ->expects($this->once()) @@ -166,7 +174,7 @@ public function testGetItemValueEditUrl() public function testGetItemPaymentMethodLabel() { $this->escaper->expects($this->once())->method('escapeHtml')->with('label', null); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', ['getAgreementLabel'], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, ['getAgreementLabel'], [], '', false); $item->expects($this->once())->method('getAgreementLabel')->willReturn('label'); $this->block->getItemValue($item, 'payment_method_label'); } @@ -174,7 +182,7 @@ public function testGetItemPaymentMethodLabel() public function testGetItemStatus() { $this->escaper->expects($this->once())->method('escapeHtml')->with('status', null); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $item->expects($this->once())->method('getStatusLabel')->willReturn('status'); $this->block->getItemValue($item, 'status'); } @@ -182,7 +190,7 @@ public function testGetItemStatus() public function testGetItemDefault() { $this->escaper->expects($this->once())->method('escapeHtml')->with('value', null); - $item = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $item = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $item->expects($this->exactly(2))->method('getData')->with('default')->willReturn('value'); $this->block->getItemValue($item, 'default'); } @@ -190,21 +198,21 @@ public function testGetItemDefault() public function testGetWizardPaymentMethodOptions() { $method1 = $this->getMock( - 'Magento\Paypal\Model\Method\Agreement', + \Magento\Paypal\Model\Method\Agreement::class, ['getConfigData', 'getCode', 'getTitle'], [], '', false ); $method2 = $this->getMock( - 'Magento\Paypal\Model\Method\Agreement', + \Magento\Paypal\Model\Method\Agreement::class, ['getConfigData', 'getCode', 'getTitle'], [], '', false ); $method3 = $this->getMock( - 'Magento\Paypal\Model\Method\Agreement', + \Magento\Paypal\Model\Method\Agreement::class, ['getConfigData', 'getCode', 'getTitle'], [], '', diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Bml/ShortcutTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Bml/ShortcutTest.php index d8d054ca285a4..beb8248c869cd 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Bml/ShortcutTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Bml/ShortcutTest.php @@ -28,13 +28,13 @@ class ShortcutTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); - $this->randomMock = $this->getMock('Magento\Framework\Math\Random'); - $this->paypalShortcutHelperMock = $this->getMock('Magento\Paypal\Helper\Shortcut\ValidatorInterface'); + $this->paymentHelperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); + $this->randomMock = $this->getMock(\Magento\Framework\Math\Random::class); + $this->paypalShortcutHelperMock = $this->getMock(\Magento\Paypal\Helper\Shortcut\ValidatorInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->shortcut = $this->objectManagerHelper->getObject( - 'Magento\Paypal\Block\Bml\Shortcut', + \Magento\Paypal\Block\Bml\Shortcut::class, [ 'paymentData' => $this->paymentHelperMock, 'mathRandom' => $this->randomMock, @@ -80,7 +80,7 @@ public function testToHtmlMethodNotAvailable() $paymentMethodCode = ''; $bmlMethodCode = ''; $this->shortcut->setIsInCatalogProduct($isInCatalog); - $expressMethod = $this->getMockBuilder('Magento\Paypal\Model\Express')->disableOriginalConstructor() + $expressMethod = $this->getMockBuilder(\Magento\Paypal\Model\Express::class)->disableOriginalConstructor() ->setMethods([])->getMock(); $this->paypalShortcutHelperMock->expects($this->once())->method('validate') @@ -99,7 +99,7 @@ public function testToHtmlMethodSetBmlData() $bmlMethodCode = ''; $hash = 'hash'; $this->shortcut->setIsInCatalogProduct($isInCatalog); - $expressMethod = $this->getMockBuilder('Magento\Paypal\Model\Express')->disableOriginalConstructor() + $expressMethod = $this->getMockBuilder(\Magento\Paypal\Model\Express::class)->disableOriginalConstructor() ->setMethods([])->getMock(); $expectedData = [ 'is_in_catalog_product' => $isInCatalog, diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Express/FormTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Express/FormTest.php index 6f52d98cd9b5e..838626a591f17 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Express/FormTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Express/FormTest.php @@ -12,6 +12,9 @@ use Magento\Paypal\Model\Config; use Magento\Paypal\Model\Express\Checkout; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class FormTest extends \PHPUnit_Framework_TestCase { /** @@ -37,7 +40,7 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_paypalData = $this->getMock( - 'Magento\Paypal\Helper\Data', + \Magento\Paypal\Helper\Data::class, [], [], '', @@ -45,7 +48,7 @@ protected function setUp() ); $this->_paypalConfig = $this->getMock( - 'Magento\Paypal\Model\Config', + \Magento\Paypal\Model\Config::class, [], [], '', @@ -56,7 +59,7 @@ protected function setUp() ->will($this->returnSelf()); $paypalConfigFactory = $this->getMock( - 'Magento\Paypal\Model\ConfigFactory', + \Magento\Paypal\Model\ConfigFactory::class, ['create'], [], '', @@ -67,7 +70,7 @@ protected function setUp() ->will($this->returnValue($this->_paypalConfig)); $mark = $this->getMock( - 'Magento\Framework\View\Element\Template', + \Magento\Framework\View\Element\Template::class, [], [], '', @@ -80,20 +83,20 @@ protected function setUp() ->method('__call') ->will($this->returnSelf()); $layout = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); $layout->expects($this->once()) ->method('createBlock') - ->with('Magento\Framework\View\Element\Template') + ->with(\Magento\Framework\View\Element\Template::class) ->will($this->returnValue($mark)); $this->currentCustomer = $this - ->getMockBuilder('\Magento\Customer\Helper\Session\CurrentCustomer') + ->getMockBuilder(\Magento\Customer\Helper\Session\CurrentCustomer::class) ->disableOriginalConstructor() ->getMock(); $localeResolver = $this->getMock( - 'Magento\Framework\Locale\ResolverInterface', + \Magento\Framework\Locale\ResolverInterface::class, [], [], '', @@ -103,7 +106,7 @@ protected function setUp() $helper = new ObjectManager($this); $this->_model = $helper->getObject( - 'Magento\Paypal\Block\Express\Form', + \Magento\Paypal\Block\Express\Form::class, [ 'paypalData' => $this->_paypalData, 'paypalConfigFactory' => $paypalConfigFactory, diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php index c45deb18faf76..71ca138ae6eff 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php @@ -9,6 +9,9 @@ use Magento\Paypal\Block\Express\Review; use Magento\Quote\Model\Quote\Address\Rate; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ReviewTest extends \PHPUnit_Framework_TestCase { /** @@ -30,9 +33,9 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $layout = $this->getMock('Magento\Framework\View\LayoutInterface', [], [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); $scopeConfig->expects($this->any()) ->method('getValue') @@ -41,19 +44,19 @@ protected function setUp() \Magento\Store\Model\ScopeInterface::SCOPE_STORE )->will($this->returnValue(false)); - $urlBuilder = $this->getMock('Magento\Framework\UrlInterface'); + $urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnArgument(0)); $context = $this->getMock( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, ['getLayout', 'getEventManager', 'getScopeConfig', 'getRequest', 'getAssetRepository', 'getUrlBuilder'], [], '', false ); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); $context->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); $context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager)); @@ -62,7 +65,7 @@ protected function setUp() $context->expects($this->any())->method('getAssetRepository')->will($this->returnValue($this->assetRepo)); $context->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); - $this->model = $helper->getObject('Magento\Paypal\Block\Express\Review', ['context' => $context]); + $this->model = $helper->getObject(\Magento\Paypal\Block\Express\Review::class, ['context' => $context]); } /** @@ -145,14 +148,14 @@ public function testBeforeToHtmlWhenQuoteIsVirtual() protected function _getQuoteMock() { $methodInstance = new \Magento\Framework\DataObject(['title' => 'Payment Method']); - $payment = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $payment = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $payment->expects($this->any())->method('getMethodInstance')->will($this->returnValue($methodInstance)); - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quote->expects($this->any())->method('getPayment')->will($this->returnValue($payment)); $quote->setPayment($payment); - $address = $this->getMockBuilder('Magento\Quote\Model\Quote\Address') + $address = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class) ->disableOriginalConstructor() ->setMethods(['getShippingMethod', 'getGroupedAllShippingRates', '__wakeup']) ->getMock(); @@ -163,8 +166,8 @@ protected function _getQuoteMock() public function testGetEmail() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $billingAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock); $billingAddressMock->expects($this->once())->method('getEmail')->willReturn('test@example.com'); $this->model->setQuote($quoteMock); @@ -173,7 +176,7 @@ public function testGetEmail() public function testGetEmailWhenBillingAddressNotExist() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn(null); $this->model->setQuote($quoteMock); $this->assertEquals('', $this->model->getEmail()); diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php index 88a6846d53ae9..c41cb65acda07 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php @@ -58,15 +58,21 @@ class IframeTest extends \PHPUnit_Framework_TestCase public function prepare() { - $this->contextMock = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['getQuote'], [], '', false); - $this->hssHelperMock = $this->getMock('Magento\Paypal\Helper\Hss', [], [], '', false); - $this->paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', ['getPayment', '__wakeup'], [], '', false); - $this->paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - $this->reader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); - $this->readFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->orderFactoryMock = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['getQuote'], [], '', false); + $this->hssHelperMock = $this->getMock(\Magento\Paypal\Helper\Hss::class, [], [], '', false); + $this->paymentDataMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getPayment', '__wakeup'], [], '', false); + $this->paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); + $this->reader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); + $this->readFactory = $this->getMock( + \Magento\Framework\Filesystem\Directory\ReadFactory::class, + [], + [], + '', + false + ); $this->checkoutSessionMock->expects($this->any()) ->method('getQuote') @@ -103,7 +109,7 @@ public function testGetTransactionUrlLive() $this->prepare(); $expected = 'https://live.url'; - $methodInstance = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInstance = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $methodInstance->expects($this->exactly(2)) ->method('getConfigData') @@ -132,7 +138,7 @@ public function testGetTransactionUrlTest() $this->prepare(); $expected = 'https://test.url'; - $methodInstance = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInstance = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $methodInstance->expects($this->exactly(2)) ->method('getConfigData') diff --git a/app/code/Magento/Paypal/Test/Unit/Block/PayflowExpress/FormTest.php b/app/code/Magento/Paypal/Test/Unit/Block/PayflowExpress/FormTest.php index 157edabfbad22..9e0946fb77c56 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/PayflowExpress/FormTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/PayflowExpress/FormTest.php @@ -24,7 +24,7 @@ class FormTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_paypalConfig = $this->getMock( - 'Magento\Paypal\Model\Config', + \Magento\Paypal\Model\Config::class, [], [], '', @@ -36,7 +36,7 @@ protected function setUp() ->will($this->returnSelf()); $paypalConfigFactory = $this->getMock( - 'Magento\Paypal\Model\ConfigFactory', + \Magento\Paypal\Model\ConfigFactory::class, ['create'], [], '', @@ -47,7 +47,7 @@ protected function setUp() ->will($this->returnValue($this->_paypalConfig)); $mark = $this->getMock( - 'Magento\Framework\View\Element\Template', + \Magento\Framework\View\Element\Template::class, [], [], '', @@ -60,15 +60,15 @@ protected function setUp() ->method('__call') ->will($this->returnSelf()); $layout = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface' + \Magento\Framework\View\LayoutInterface::class ); $layout->expects($this->once()) ->method('createBlock') - ->with('Magento\Framework\View\Element\Template') + ->with(\Magento\Framework\View\Element\Template::class) ->will($this->returnValue($mark)); $localeResolver = $this->getMock( - 'Magento\Framework\Locale\ResolverInterface', + \Magento\Framework\Locale\ResolverInterface::class, [], [], '', @@ -78,7 +78,7 @@ protected function setUp() $helper = new ObjectManager($this); $this->_model = $helper->getObject( - 'Magento\Paypal\Block\PayflowExpress\Form', + \Magento\Paypal\Block\PayflowExpress\Form::class, [ 'paypalConfigFactory' => $paypalConfigFactory, 'layout' => $layout, diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Billing/Agreement/CancelTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Billing/Agreement/CancelTest.php index e5dc2500ae106..7cffa383a967b 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Billing/Agreement/CancelTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Billing/Agreement/CancelTest.php @@ -44,10 +44,10 @@ class CancelTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_session = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->_session = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->_agreement = $this->getMock( - 'Magento\Paypal\Model\Billing\Agreement', + \Magento\Paypal\Model\Billing\Agreement::class, ['load', 'getId', 'getCustomerId', 'getReferenceId', 'canCancel', 'cancel', '__wakeup'], [], '', @@ -57,48 +57,45 @@ protected function setUp() $this->_agreement->expects($this->once())->method('getId')->will($this->returnValue(15)); $this->_agreement->expects($this->once())->method('getCustomerId')->will($this->returnValue(871)); - $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_objectManager->expects( $this->atLeastOnce() )->method( 'get' )->will( - $this->returnValueMap([['Magento\Customer\Model\Session', $this->_session]]) + $this->returnValueMap([[\Magento\Customer\Model\Session::class, $this->_session]]) ); $this->_objectManager->expects( $this->once() )->method( 'create' )->with( - 'Magento\Paypal\Model\Billing\Agreement' + \Magento\Paypal\Model\Billing\Agreement::class )->will( $this->returnValue($this->_agreement) ); - $this->_request = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->_request = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->_request->expects($this->once())->method('getParam')->with('agreement')->will($this->returnValue(15)); - $response = $this->getMock('Magento\Framework\App\ResponseInterface'); + $response = $this->getMock(\Magento\Framework\App\ResponseInterface::class); - $redirect = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); + $redirect = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->_messageManager = $this->getMock('Magento\Framework\Message\ManagerInterface'); + $this->_messageManager = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); - $context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); + $context = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->_objectManager)); $context->expects($this->any())->method('getRequest')->will($this->returnValue($this->_request)); $context->expects($this->any())->method('getResponse')->will($this->returnValue($response)); $context->expects($this->any())->method('getRedirect')->will($this->returnValue($redirect)); $context->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->_messageManager)); - $this->_registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - - $title = $this->getMock('Magento\Framework\App\Action\Title', [], [], '', false); + $this->_registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->_controller = new \Magento\Paypal\Controller\Billing\Agreement\Cancel( $context, - $this->_registry, - $title + $this->_registry ); } diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php index d6bc013bf126b..a16588afa3eb9 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php @@ -55,9 +55,9 @@ public function testExecuteProcessableException($code, $paymentAction = null) $oldCallback = &$this->objectManagerCallback; $this->objectManagerCallback = function ($className) use ($code, $oldCallback) { $instance = call_user_func($oldCallback, $className); - if ($className == '\Magento\CheckoutAgreements\Model\AgreementsValidator') { + if ($className == \Magento\CheckoutAgreements\Model\AgreementsValidator::class) { $exception = $this->getMock( - 'Magento\Paypal\Model\Api\ProcessableException', + \Magento\Paypal\Model\Api\ProcessableException::class, ['getUserMessage'], ['message', $code] ); diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/ExpressTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/ExpressTest.php index 26c36a0ad1664..e4274636812b4 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/ExpressTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/ExpressTest.php @@ -60,33 +60,39 @@ abstract class ExpressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->markTestIncomplete(); - $this->messageManager = $this->getMockForAbstractClass('Magento\Framework\Message\ManagerInterface'); - $this->config = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->messageManager = $this->getMockForAbstractClass(\Magento\Framework\Message\ManagerInterface::class); + $this->config = $this->getMock(\Magento\Paypal\Model\Config::class, [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quote->expects($this->any()) ->method('hasItems') ->will($this->returnValue(true)); - $this->redirect = $this->getMockForAbstractClass('Magento\Framework\App\Response\RedirectInterface'); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->customerData = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); - $this->checkout = $this->getMock('Magento\Paypal\Model\Express\Checkout', [], [], '', false); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->redirect = $this->getMockForAbstractClass(\Magento\Framework\App\Response\RedirectInterface::class); + $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->customerData = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $this->checkout = $this->getMock(\Magento\Paypal\Model\Express\Checkout::class, [], [], '', false); + $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->customerSession->expects($this->any()) ->method('getCustomerDataObject') ->will($this->returnValue($this->customerData)); - $this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->checkoutFactory = $this->getMock('Magento\Paypal\Model\Express\Checkout\Factory', [], [], '', false); + $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->checkoutFactory = $this->getMock( + \Magento\Paypal\Model\Express\Checkout\Factory::class, + [], + [], + '', + false + ); $this->checkoutFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->checkout)); $this->checkoutSession->expects($this->any()) ->method('getQuote') ->will($this->returnValue($this->quote)); - $this->session = $this->getMock('Magento\Framework\Session\Generic', [], [], '', false); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->session = $this->getMock(\Magento\Framework\Session\Generic::class, [], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerCallback = function ($className) { - if ($className == 'Magento\Paypal\Model\Config') { + if ($className == \Magento\Paypal\Model\Config::class) { return $this->config; } return $this->getMock($className, [], [], '', false); @@ -104,7 +110,7 @@ protected function setUp() $helper = new ObjectManagerHelper($this); $this->model = $helper->getObject( - '\\Magento\\\Paypal\\Controller\\Express\\' . $this->name, + '\\Magento\\Paypal\\Controller\\Express\\' . $this->name, [ 'messageManager' => $this->messageManager, 'response' => $this->response, diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Ipn/IndexTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Ipn/IndexTest.php index 1f1f6bf6ba4d6..debfc06cea182 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Ipn/IndexTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Ipn/IndexTest.php @@ -22,13 +22,13 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Paypal\Controller\Ipn\Index', + \Magento\Paypal\Controller\Ipn\Index::class, [ 'logger' => $this->logger, 'request' => $this->request, diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/RequestSecureTokenTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/RequestSecureTokenTest.php index a46bf5771eb70..20a0f22b0e79e 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/RequestSecureTokenTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/RequestSecureTokenTest.php @@ -16,6 +16,8 @@ /** * Class RequestSecureTokenTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class RequestSecureTokenTest extends \PHPUnit_Framework_TestCase { @@ -62,28 +64,28 @@ class RequestSecureTokenTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->sessionTransparentMock = $this->getMockBuilder('Magento\Framework\Session\Generic') + $this->sessionTransparentMock = $this->getMockBuilder(\Magento\Framework\Session\Generic::class) ->setMethods(['setQuoteId']) ->disableOriginalConstructor() ->getMock(); $this->secureTokenServiceMock = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Request\SecureToken' + \Magento\Paypal\Model\Payflow\Service\Request\SecureToken::class ) ->setMethods(['requestToken']) ->disableOriginalConstructor() ->getMock(); - $this->sessionManagerMock = $this->getMockBuilder('Magento\Framework\Session\SessionManager') + $this->sessionManagerMock = $this->getMockBuilder(\Magento\Framework\Session\SessionManager::class) ->setMethods(['getQuote']) ->disableOriginalConstructor() ->getMock(); - $this->transparentMock = $this->getMockBuilder('Magento\Paypal\Model\Payflow\Transparent') + $this->transparentMock = $this->getMockBuilder(\Magento\Paypal\Model\Payflow\Transparent::class) ->setMethods(['getCode']) ->disableOriginalConstructor() ->getMock(); @@ -111,13 +113,13 @@ public function testExecuteSuccess() 'error' => false ]; - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->getMock(); - $tokenMock = $this->getMockBuilder('Magento\Framework\DataObject') + $tokenMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); - $jsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $jsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); @@ -165,10 +167,10 @@ public function testExecuteTokenRequestException() 'error_messages' => __('Your payment has been declined. Please try again.') ]; - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->getMock(); - $jsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $jsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); @@ -205,7 +207,7 @@ public function testExecuteEmptyQuoteError() ]; $quoteMock = null; - $jsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $jsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php index 51a6bbdaa72a7..2d44c0abd670b 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php @@ -19,6 +19,8 @@ * Class ResponseTest * * Test for class \Magento\Paypal\Controller\Transparent\Response + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ResponseTest extends \PHPUnit_Framework_TestCase { @@ -53,22 +55,22 @@ class ResponseTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['getPostValue']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->viewMock = $this->getMockBuilder('Magento\Framework\App\ViewInterface') + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\ViewInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->coreRegistryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->coreRegistryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->setMethods(['register']) ->disableOriginalConstructor() ->getMock(); - $this->resultLayoutMock = $this->getMockBuilder('Magento\Framework\View\Result\Layout') + $this->resultLayoutMock = $this->getMockBuilder(\Magento\Framework\View\Result\Layout::class) ->setMethods(['addDefaultHandle', 'getLayout', 'getUpdate', 'load']) ->disableOriginalConstructor() ->getMock(); - $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\LayoutFactory') + $this->resultLayoutFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\LayoutFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -76,11 +78,11 @@ protected function setUp() ->method('create') ->willReturn($this->resultLayoutMock); $this->transactionMock = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\Transaction' + \Magento\Paypal\Model\Payflow\Service\Response\Transaction::class )->setMethods(['getResponseObject', 'validateResponse', 'savePaymentInQuote']) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('\Magento\Framework\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->setMethods(['getRequest']) ->disableOriginalConstructor() ->getMock(); @@ -88,12 +90,10 @@ protected function setUp() ->method('getRequest') ->willReturn($this->requestMock); $this->responseValidatorMock = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator' + \Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator::class )->disableOriginalConstructor() ->getMock(); - $this->payflowFacade = $this->getMockBuilder( - Transparent::class - ) + $this->payflowFacade = $this->getMockBuilder(Transparent::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -110,7 +110,7 @@ protected function setUp() public function testExecute() { - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); $this->transactionMock->expects($this->once()) @@ -132,12 +132,12 @@ public function testExecute() ->method('getLayout') ->willReturn($this->getLayoutMock()); - $this->assertInstanceOf('\Magento\Framework\Controller\ResultInterface', $this->object->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\ResultInterface::class, $this->object->execute()); } public function testExecuteWithException() { - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); $this->transactionMock->expects($this->once()) @@ -157,7 +157,7 @@ public function testExecuteWithException() ->method('getLayout') ->willReturn($this->getLayoutMock()); - $this->assertInstanceOf('\Magento\Framework\Controller\ResultInterface', $this->object->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\ResultInterface::class, $this->object->execute()); } /** @@ -165,9 +165,9 @@ public function testExecuteWithException() */ private function getLayoutMock() { - $processorInterfaceMock = $this->getMockBuilder('\Magento\Framework\View\Layout\ProcessorInterface') + $processorInterfaceMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ProcessorInterface::class) ->getMockForAbstractClass(); - $layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) ->setMethods(['getUpdate']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php b/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php index c260f192303f3..98fd146947926 100644 --- a/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php @@ -50,20 +50,20 @@ class BackendTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->context->expects(static::once()) ->method('getRequest') ->willReturn($this->request); - $this->directoryHelperMock = $this->getMockBuilder('Magento\Directory\Helper\Data') + $this->directoryHelperMock = $this->getMockBuilder(\Magento\Directory\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->backendConfig = $this->getMockBuilder('Magento\Config\Model\Config') + $this->backendConfig = $this->getMockBuilder(\Magento\Config\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeDefiner = $this->getMockBuilder('Magento\Config\Model\Config\ScopeDefiner') + $this->scopeDefiner = $this->getMockBuilder(\Magento\Config\Model\Config\ScopeDefiner::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Helper/DataTest.php b/app/code/Magento/Paypal/Test/Unit/Helper/DataTest.php index 91d44cb7a82d0..fa0620a36a681 100644 --- a/app/code/Magento/Paypal/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Helper/DataTest.php @@ -25,19 +25,19 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_paymentDataMock = $this->getMockBuilder( - 'Magento\Payment\Helper\Data' + \Magento\Payment\Helper\Data::class )->disableOriginalConstructor()->setMethods( ['getStoreMethods', 'getPaymentMethods'] )->getMock(); $this->configMock = $this->getMock( - 'Magento\Paypal\Model\Config', + \Magento\Paypal\Model\Config::class, [], [], '', false ); - $configMockFactory = $this->getMockBuilder('Magento\Paypal\Model\ConfigFactory') + $configMockFactory = $this->getMockBuilder(\Magento\Paypal\Model\ConfigFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -46,7 +46,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_helper = $objectManager->getObject( - 'Magento\Paypal\Helper\Data', + \Magento\Paypal\Helper\Data::class, [ 'paymentData' => $this->_paymentDataMock, 'methodCodes' => ['expressCheckout' => 'paypal_express', 'hostedPro' => 'hosted_pro'], @@ -83,12 +83,12 @@ public function testGetBillingAgreementMethods($store, $quote, $paymentMethods, public function getBillingAgreementMethodsDataProvider() { $quoteMock = $this->getMockBuilder( - 'Magento\Quote\Model\Quote' + \Magento\Quote\Model\Quote::class )->disableOriginalConstructor()->setMethods( null ); $methodInterfaceMock = $this->getMockBuilder( - 'Magento\Paypal\Model\Billing\Agreement\MethodInterface' + \Magento\Paypal\Model\Billing\Agreement\MethodInterface::class )->getMock(); return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/CheckoutValidatorTest.php b/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/CheckoutValidatorTest.php index 6d2d5d08b9305..0236242a0849c 100644 --- a/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/CheckoutValidatorTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/CheckoutValidatorTest.php @@ -27,13 +27,19 @@ class CheckoutValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->paypalShortcutHelperMock = $this->getMock('Magento\Paypal\Helper\Shortcut\Validator', [], [], '', false); - $this->paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->paypalShortcutHelperMock = $this->getMock( + \Magento\Paypal\Helper\Shortcut\Validator::class, + [], + [], + '', + false + ); + $this->paymentHelperMock = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->checkoutValidator = $this->objectManagerHelper->getObject( - 'Magento\Paypal\Helper\Shortcut\CheckoutValidator', + \Magento\Paypal\Helper\Shortcut\CheckoutValidator::class, [ 'checkoutSession' => $this->sessionMock, 'shortcutValidator' => $this->paypalShortcutHelperMock, @@ -46,7 +52,7 @@ public function testValidate() { $code = 'code'; $isInCatalog = true; - $methodInstanceMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + $methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->disableOriginalConstructor()->setMethods([])->getMock(); $this->paypalShortcutHelperMock->expects($this->once())->method('isContextAvailable') @@ -66,7 +72,7 @@ public function testIsMethodQuoteAvailableNoQuoteMethodNotAvailableFalse() $quote = null; $isInCatalog = true; $paymentCode = 'code'; - $methodInstanceMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + $methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->disableOriginalConstructor()->setMethods([])->getMock(); $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($paymentCode) @@ -83,11 +89,11 @@ public function testIsMethodQuoteAvailableNoQuoteMethodNotAvailableFalse() */ public function testIsMethodQuoteAvailableWithQuoteMethodNotAvailable($availability) { - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods([]) + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods([]) ->getMock(); $isInCatalog = false; $paymentCode = 'code'; - $methodInstanceMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + $methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->disableOriginalConstructor()->setMethods([])->getMock(); $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote)); @@ -119,7 +125,7 @@ public function testIsQuoteSummaryValidNoQuote() public function testIsQuoteSummaryValidMinimumAmountFalse() { $isInCatalog = false; - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods([]) + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods([]) ->getMock(); $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote)); @@ -131,7 +137,7 @@ public function testIsQuoteSummaryValidMinimumAmountFalse() public function testIsQuoteSummaryValidGrandTotalFalse() { $isInCatalog = false; - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor() + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor() ->setMethods(['getGrandTotal', 'validateMinimumAmount', '__wakeup']) ->getMock(); @@ -145,7 +151,7 @@ public function testIsQuoteSummaryValidGrandTotalFalse() public function testIsQuoteSummaryValidTrue() { $isInCatalog = false; - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor() + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor() ->setMethods(['getGrandTotal', 'validateMinimumAmount', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/FactoryTest.php b/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/FactoryTest.php index 662ac44da29e1..41e67ff3c21af 100644 --- a/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/FactoryTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/FactoryTest.php @@ -22,11 +22,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->factory = $this->objectManagerHelper->getObject( - 'Magento\Paypal\Helper\Shortcut\Factory', + \Magento\Paypal\Helper\Shortcut\Factory::class, [ 'objectManager' => $this->objectManagerMock ] @@ -35,28 +35,28 @@ protected function setUp() public function testCreateDefault() { - $instance = $this->getMockBuilder('Magento\Paypal\Helper\Shortcut\ValidatorInterface')->getMock(); + $instance = $this->getMockBuilder(\Magento\Paypal\Helper\Shortcut\ValidatorInterface::class)->getMock(); $this->objectManagerMock->expects($this->once())->method('create')->with(Factory::DEFAULT_VALIDATOR) ->will($this->returnValue($instance)); $this->assertInstanceOf( - 'Magento\Paypal\Helper\Shortcut\ValidatorInterface', + \Magento\Paypal\Helper\Shortcut\ValidatorInterface::class, $this->factory->create() ); } public function testCreateCheckout() { - $checkoutMock = $this->getMockBuilder('Magento\Checkout\Model\Session')->disableOriginalConstructor() + $checkoutMock = $this->getMockBuilder(\Magento\Checkout\Model\Session::class)->disableOriginalConstructor() ->setMethods([])->getMock(); - $instance = $this->getMockBuilder('Magento\Paypal\Helper\Shortcut\ValidatorInterface')->getMock(); + $instance = $this->getMockBuilder(\Magento\Paypal\Helper\Shortcut\ValidatorInterface::class)->getMock(); $this->objectManagerMock->expects($this->once())->method('create')->with(Factory::CHECKOUT_VALIDATOR) ->will($this->returnValue($instance)); $this->assertInstanceOf( - 'Magento\Paypal\Helper\Shortcut\ValidatorInterface', + \Magento\Paypal\Helper\Shortcut\ValidatorInterface::class, $this->factory->create($checkoutMock) ); } diff --git a/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/ValidatorTest.php b/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/ValidatorTest.php index 1f8b89d04a04f..9868df5f6e0a6 100644 --- a/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/ValidatorTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Helper/Shortcut/ValidatorTest.php @@ -25,20 +25,26 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_paypalConfigFactory = $this->getMock('\Magento\Paypal\Model\ConfigFactory', ['create'], [], '', false); + $this->_paypalConfigFactory = $this->getMock( + \Magento\Paypal\Model\ConfigFactory::class, + ['create'], + [], + '', + false + ); $this->_productTypeConfig = $this->getMock( - 'Magento\Catalog\Model\ProductTypes\ConfigInterface', + \Magento\Catalog\Model\ProductTypes\ConfigInterface::class, [], [], '', false ); - $this->_registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->_paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->_registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->_paymentData = $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->helper = $objectManager->getObject( - 'Magento\Paypal\Helper\Shortcut\Validator', + \Magento\Paypal\Helper\Shortcut\Validator::class, [ 'paypalConfigFactory' => $this->_paypalConfigFactory, 'registry' => $this->_registry, @@ -55,7 +61,7 @@ protected function setUp() */ public function testIsContextAvailable($isVisible, $expected) { - $paypalConfig = $this->getMockBuilder('Magento\Paypal\Model\Config') + $paypalConfig = $this->getMockBuilder(\Magento\Paypal\Model\Config::class) ->disableOriginalConstructor() ->getMock(); $paypalConfig->expects($this->any()) @@ -90,10 +96,10 @@ public function testIsContextAvailableDataProvider() */ public function testIsPriceOrSetAvailable($isInCatalog, $productPrice, $isProductSet, $expected) { - $currentProduct = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + $currentProduct = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods(['__wakeup', 'getFinalPrice', 'getTypeId', 'getTypeInstance']) ->getMock(); - $typeInstance = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\AbstractType') + $typeInstance = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -139,7 +145,7 @@ public function testIsPriceOrSetAvailableDataProvider() */ public function testIsMethodAvailable($methodIsAvailable, $expected) { - $methodInstance = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInstance = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $methodInstance->expects($this->any()) ->method('isAvailable') diff --git a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php index 28d546cfb17ec..7920498fe83bb 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php @@ -28,7 +28,7 @@ class AbstractConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->setMethods(['getValue', 'isSetFlag']) ->getMockForAbstractClass(); @@ -49,7 +49,7 @@ public function testSetMethod($method, $expected) public function testSetMethodInstance() { /** @var $methodInterfaceMock MethodInterface */ - $methodInterfaceMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInterfaceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $this->assertSame($this->config, $this->config->setMethodInstance($methodInterfaceMock)); } @@ -64,7 +64,7 @@ public function testSetMethodInstance() public function setMethodDataProvider() { /** @var $methodInterfaceMock MethodInterface */ - $methodInterfaceMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $methodInterfaceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $methodInterfaceMock->expects($this->once()) ->method('getCode') diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php index f6010e3d40b1a..b4eac27135c6f 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php @@ -50,17 +50,17 @@ class NvpTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerAddressHelper = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->customLoggerMock = $this->getMockBuilder('\Magento\Payment\Model\Method\Logger') - ->setConstructorArgs([$this->getMockForAbstractClass('Psr\Log\LoggerInterface')]) + $this->customerAddressHelper = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->customLoggerMock = $this->getMockBuilder(\Magento\Payment\Model\Method\Logger::class) + ->setConstructorArgs([$this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class)]) ->setMethods(['debug']) ->getMock(); - $this->resolver = $this->getMock('Magento\Framework\Locale\ResolverInterface'); - $this->regionFactory = $this->getMock('Magento\Directory\Model\RegionFactory', [], [], '', false); - $this->countryFactory = $this->getMock('Magento\Directory\Model\CountryFactory', [], [], '', false); - $processableExceptionFactory = $this->getMock( - 'Magento\Paypal\Model\Api\ProcessableExceptionFactory', + $this->resolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $this->regionFactory = $this->getMock(\Magento\Directory\Model\RegionFactory::class, [], [], '', false); + $this->countryFactory = $this->getMock(\Magento\Directory\Model\CountryFactory::class, [], [], '', false); + $processableExceptionFactory = $this->getMock( + \Magento\Paypal\Model\Api\ProcessableExceptionFactory::class, ['create'], [], '', @@ -69,15 +69,15 @@ protected function setUp() $processableExceptionFactory->expects($this->any()) ->method('create') ->will($this->returnCallback(function ($arguments) { - $this->processableException = $this->getMock( - 'Magento\Paypal\Model\Api\ProcessableException', + $this->processableException = $this->getMock( + \Magento\Paypal\Model\Api\ProcessableException::class, null, [$arguments['phrase'], null, $arguments['code']] ); return $this->processableException; })); - $exceptionFactory = $this->getMock( - 'Magento\Framework\Exception\LocalizedExceptionFactory', + $exceptionFactory = $this->getMock( + \Magento\Framework\Exception\LocalizedExceptionFactory::class, ['create'], [], '', @@ -86,21 +86,21 @@ protected function setUp() $exceptionFactory->expects($this->any()) ->method('create') ->will($this->returnCallback(function ($arguments) { - $this->exception = $this->getMock( - 'Magento\Framework\Exception\LocalizedException', + $this->exception = $this->getMock( + \Magento\Framework\Exception\LocalizedException::class, null, [$arguments['phrase']] ); return $this->exception; })); - $this->curl = $this->getMock('Magento\Framework\HTTP\Adapter\Curl', [], [], '', false); - $curlFactory = $this->getMock('Magento\Framework\HTTP\Adapter\CurlFactory', ['create'], [], '', false); + $this->curl = $this->getMock(\Magento\Framework\HTTP\Adapter\Curl::class, [], [], '', false); + $curlFactory = $this->getMock(\Magento\Framework\HTTP\Adapter\CurlFactory::class, ['create'], [], '', false); $curlFactory->expects($this->any())->method('create')->will($this->returnValue($this->curl)); - $this->config = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); + $this->config = $this->getMock(\Magento\Paypal\Model\Config::class, [], [], '', false); $helper = new ObjectManagerHelper($this); - $this->model = $helper->getObject( - 'Magento\Paypal\Model\Api\Nvp', + $this->model = $helper->getObject( + \Magento\Paypal\Model\Api\Nvp::class, [ 'customerAddress' => $this->customerAddressHelper, 'logger' => $this->logger, @@ -158,30 +158,26 @@ public function callDataProvider() ['', [], null], [ "\r\n" . 'ACK=Failure&L_ERRORCODE0=10417&L_SHORTMESSAGE0=Message.&L_LONGMESSAGE0=Long%20Message.', - [], - 'Magento\Framework\Exception\LocalizedException', + [], \Magento\Framework\Exception\LocalizedException::class, 'PayPal gateway has rejected request. Long Message (#10417: Message).', 0 ], [ "\r\n" . 'ACK=Failure&L_ERRORCODE0=10417&L_SHORTMESSAGE0=Message.&L_LONGMESSAGE0=Long%20Message.', - [10417, 10422], - 'Magento\Paypal\Model\Api\ProcessableException', + [10417, 10422], \Magento\Paypal\Model\Api\ProcessableException::class, 'PayPal gateway has rejected request. Long Message (#10417: Message).', 10417 ], [ "\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10417' . '&L_SHORTMESSAGE0[8]=Message.&L_LONGMESSAGE0[15]=Long%20Message.', - [10417, 10422], - 'Magento\Paypal\Model\Api\ProcessableException', + [10417, 10422], \Magento\Paypal\Model\Api\ProcessableException::class, 'PayPal gateway has rejected request. Long Message (#10417: Message).', 10417 ], [ "\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10417&L_SHORTMESSAGE0[8]=Message.', - [10417, 10422], - 'Magento\Paypal\Model\Api\ProcessableException', + [10417, 10422], \Magento\Paypal\Model\Api\ProcessableException::class, 'PayPal gateway has rejected request. #10417: Message.', 10417 ], diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Billing/AbstractAgreementTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Billing/AbstractAgreementTest.php index a95d2bb75dc15..2e012d4ea3ff7 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Billing/AbstractAgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Billing/AbstractAgreementTest.php @@ -19,23 +19,23 @@ class AbstractAgreementTest extends \PHPUnit_Framework_TestCase */ protected $paymentDataMock; - protected function setUp() { $objectManager = new ObjectManager($this); - $this->paymentDataMock = $this->getMockBuilder('Magento\Payment\Helper\Data') + $this->paymentDataMock = $this->getMockBuilder(\Magento\Payment\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->model = $objectManager->getObject('Magento\Paypal\Model\Billing\Agreement', [ - 'paymentData' => $this->paymentDataMock - ]); + $this->model = $objectManager->getObject( + \Magento\Paypal\Model\Billing\Agreement::class, + ['paymentData' => $this->paymentDataMock] + ); } public function testGetPaymentMethodInstance() { - $paymentMethodInstance = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + $paymentMethodInstance = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->disableOriginalConstructor() ->setMethods(['setStore']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Billing/Agreement/OrdersUpdaterTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Billing/Agreement/OrdersUpdaterTest.php index 42109074e206b..26abb0dead2e3 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Billing/Agreement/OrdersUpdaterTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Billing/Agreement/OrdersUpdaterTest.php @@ -24,9 +24,9 @@ class OrdersUpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->_registry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->_agreementResource = $this->getMock( - '\Magento\Paypal\Model\ResourceModel\Billing\Agreement', + \Magento\Paypal\Model\ResourceModel\Billing\Agreement::class, [], [], '', @@ -35,15 +35,15 @@ protected function setUp() $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $helper->getObject( - 'Magento\Paypal\Model\Billing\Agreement\OrdersUpdater', + \Magento\Paypal\Model\Billing\Agreement\OrdersUpdater::class, ['coreRegistry' => $this->_registry, 'agreementResource' => $this->_agreementResource] ); } public function testUpdate() { - $agreement = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); - $argument = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Collection', [], [], '', false); + $agreement = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); + $argument = $this->getMock(\Magento\Sales\Model\ResourceModel\Order\Collection::class, [], [], '', false); $this->_registry->expects( $this->once() diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Billing/AgreementTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Billing/AgreementTest.php index 98e43a4ffd1b9..fcbb00f0a7752 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Billing/AgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Billing/AgreementTest.php @@ -24,17 +24,16 @@ class AgreementTest extends \PHPUnit_Framework_TestCase */ protected $paymentMethodInstanceMock; - protected function setUp() { $objectManager = new ObjectManager($this); - $this->paymentDataMock = $this->getMockBuilder('Magento\Payment\Helper\Data') + $this->paymentDataMock = $this->getMockBuilder(\Magento\Payment\Helper\Data::class) ->disableOriginalConstructor() ->setMethods(['getMethodInstance']) ->getMock(); - $this->paymentMethodInstanceMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + $this->paymentMethodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\Method\AbstractMethod::class) ->disableOriginalConstructor() ->setMethods([ 'setStore', @@ -48,12 +47,12 @@ protected function setUp() ]) ->getMock(); - $this->model = $objectManager->getObject('Magento\Paypal\Model\Billing\Agreement', [ - 'paymentData' => $this->paymentDataMock - ]); + $this->model = $objectManager->getObject( + \Magento\Paypal\Model\Billing\Agreement::class, + ['paymentData' => $this->paymentDataMock] + ); } - public function testImportOrderPaymentWithMethodCode() { $baData = [ @@ -79,7 +78,6 @@ public function testImportOrderPaymentWithMethodCode() $this->assertSame($this->model, $this->model->importOrderPayment($paymentMock)); } - public function testImportOrderPaymentWithoutMethodCode() { $baData = [ @@ -105,7 +103,7 @@ public function testImportOrderPaymentWithoutMethodCode() */ private function importOrderPaymentCommonPart($baData) { - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['getBillingAgreementData', 'getMethodInstance', 'getOrder']) ->getMock(); @@ -113,7 +111,7 @@ private function importOrderPaymentCommonPart($baData) $storeId = null; $customerId = 2; - $order = $this->getMockBuilder('Magento\Sales\Model\Order') + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['getCustomerId']) ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/BillingAgreementConfigProviderTest.php b/app/code/Magento/Paypal/Test/Unit/Model/BillingAgreementConfigProviderTest.php index fd45f2f70d24a..f394ef1c8c00e 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/BillingAgreementConfigProviderTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/BillingAgreementConfigProviderTest.php @@ -24,12 +24,12 @@ class BillingAgreementConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->currentCustomerMock = $this->getMockBuilder('Magento\Customer\Helper\Session\CurrentCustomer') + $this->currentCustomerMock = $this->getMockBuilder(\Magento\Customer\Helper\Session\CurrentCustomer::class) ->setMethods(['getCustomerId']) ->disableOriginalConstructor() ->getMock(); - $this->agreementFactoryMock = $this->getMockBuilder('Magento\Paypal\Model\Billing\AgreementFactory') + $this->agreementFactoryMock = $this->getMockBuilder(\Magento\Paypal\Model\Billing\AgreementFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -63,7 +63,7 @@ public function testGetConfig() $this->currentCustomerMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); - $agreementMock = $this->getMockBuilder('Magento\Paypal\Model\Billing\Agreement') + $agreementMock = $this->getMockBuilder(\Magento\Paypal\Model\Billing\Agreement::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php b/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php index e79e7e0f3453e..1e270ee4584bd 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php @@ -46,9 +46,9 @@ public function __construct($name = null, array $data = [], $dataName = '') protected function setUp() { $this->_salesModel = $this->getMockForAbstractClass( - 'Magento\Payment\Model\Cart\SalesModel\SalesModelInterface' + \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface::class ); - $factoryMock = $this->getMock('Magento\Payment\Model\Cart\SalesModel\Factory', ['create'], [], '', false); + $factoryMock = $this->getMock(\Magento\Payment\Model\Cart\SalesModel\Factory::class, ['create'], [], '', false); $factoryMock->expects( $this->once() )->method( @@ -58,7 +58,7 @@ protected function setUp() )->will( $this->returnValue($this->_salesModel) ); - $eventManagerMock = $this->getMockForAbstractClass('Magento\Framework\Event\ManagerInterface'); + $eventManagerMock = $this->getMockForAbstractClass(\Magento\Framework\Event\ManagerInterface::class); $this->_model = new \Magento\Paypal\Model\Cart($factoryMock, $eventManagerMock, 'sales model'); } diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/FileResolverTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/FileResolverTest.php index c405ab9fdec25..1476689a36214 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/FileResolverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/FileResolverTest.php @@ -29,7 +29,7 @@ class FileResolverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->readerMock = $this->getMockBuilder('Magento\Framework\Module\Dir\Reader') + $this->readerMock = $this->getMockBuilder(\Magento\Framework\Module\Dir\Reader::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/ReaderTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/ReaderTest.php index 8095dd63c8b2d..d6c6d5d6ad80c 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/ReaderTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/ReaderTest.php @@ -40,23 +40,23 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->fileResolver = $this->getMockForAbstractClass( - '\Magento\Framework\Config\FileResolverInterface' + \Magento\Framework\Config\FileResolverInterface::class ); $this->converter = $this->getMock( - '\Magento\Paypal\Model\Config\Rules\Converter', + \Magento\Paypal\Model\Config\Rules\Converter::class, [], [], '', false ); $this->schemaLocator = $this->getMockForAbstractClass( - '\Magento\Framework\Config\SchemaLocatorInterface' + \Magento\Framework\Config\SchemaLocatorInterface::class ); $this->validationState = $this->getMockForAbstractClass( - '\Magento\Framework\Config\ValidationStateInterface' + \Magento\Framework\Config\ValidationStateInterface::class ); $this->helper = $this->getMock( - '\Magento\Paypal\Helper\Backend', + \Magento\Paypal\Helper\Backend::class, [], [], '', diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/SchemaLocatorTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/SchemaLocatorTest.php index 51a1cde3f8cbe..83b579506cd56 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/SchemaLocatorTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/SchemaLocatorTest.php @@ -29,7 +29,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->readerMock = $this->getMockBuilder('Magento\Framework\Module\Dir\Reader') + $this->readerMock = $this->getMockBuilder(\Magento\Framework\Module\Dir\Reader::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php index bdb2b8f38593c..e630e3c57207c 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php @@ -19,12 +19,12 @@ class FieldPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface'); - $this->subject = $this->getMock('Magento\Config\Model\Config\Structure\Element\Field', [], [], '', false); + $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); + $this->subject = $this->getMock(\Magento\Config\Model\Config\Structure\Element\Field::class, [], [], '', false); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Paypal\Model\Config\Structure\Element\FieldPlugin', + \Magento\Paypal\Model\Config\Structure\Element\FieldPlugin::class, ['request' => $this->request] ); } diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/StructurePluginTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/StructurePluginTest.php index 0c4e4218d293d..4e1c6c8955ba8 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Config/StructurePluginTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/StructurePluginTest.php @@ -22,12 +22,12 @@ class StructurePluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_scopeDefiner = $this->getMock('Magento\Config\Model\Config\ScopeDefiner', [], [], '', false); - $this->_helper = $this->getMock('Magento\Paypal\Helper\Backend', [], [], '', false); + $this->_scopeDefiner = $this->getMock(\Magento\Config\Model\Config\ScopeDefiner::class, [], [], '', false); + $this->_helper = $this->getMock(\Magento\Paypal\Helper\Backend::class, [], [], '', false); $objectManagerHelper = new ObjectManagerHelper($this); $this->_model = $objectManagerHelper->getObject( - 'Magento\Paypal\Model\Config\StructurePlugin', + \Magento\Paypal\Model\Config\StructurePlugin::class, ['scopeDefiner' => $this->_scopeDefiner, 'helper' => $this->_helper] ); } @@ -54,7 +54,7 @@ public function testGetPaypalConfigCountries() public function testAroundGetElementByPathPartsNonPayment($pathParts, $returnResult) { $result = $returnResult - ? $this->getMockForAbstractClass('Magento\Config\Model\Config\Structure\ElementInterface') + ? $this->getMockForAbstractClass(\Magento\Config\Model\Config\Structure\ElementInterface::class) : null; $this->_aroundGetElementByPathPartsAssertResult( $result, @@ -98,7 +98,7 @@ public function testAroundGetElementByPathPartsNoResult($pathParts, $countryCode public function testAroundGetElementByPathParts($pathParts, $countryCode, $expectedPathParts) { $this->_getElementByPathPartsPrepareHelper($countryCode); - $result = $this->getMockForAbstractClass('Magento\Config\Model\Config\Structure\ElementInterface'); + $result = $this->getMockForAbstractClass(\Magento\Config\Model\Config\Structure\ElementInterface::class); $this->_aroundGetElementByPathPartsAssertResult( $result, $this->_getElementByPathPartsCallback($expectedPathParts, $result), @@ -131,7 +131,7 @@ public function aroundGetElementByPathPartsDataProvider() public function testAroundGetSectionByPathParts($pathParts, $countryCode, $expectedPathParts) { $this->_getElementByPathPartsPrepareHelper($countryCode); - $result = $this->getMock('Magento\Config\Model\Config\Structure\Element\Section', [], [], '', false); + $result = $this->getMock(\Magento\Config\Model\Config\Structure\Element\Section::class, [], [], '', false); $self = $this; $getElementByPathParts = function ($pathParts) use ($self, $expectedPathParts, $result) { $self->assertEquals($expectedPathParts, $pathParts); @@ -169,7 +169,7 @@ public function aroundGetSectionByPathPartsDataProvider() private function _aroundGetElementByPathPartsAssertResult($result, $getElementByPathParts, $pathParts) { $this->assertEquals($result, $this->_model->aroundGetElementByPathParts( - $this->getMock('Magento\Config\Model\Config\Structure', [], [], '', false), + $this->getMock(\Magento\Config\Model\Config\Structure::class, [], [], '', false), $getElementByPathParts, $pathParts )); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/ConfigTest.php index 1419fc2f16a4d..ea229a33bff51 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/ConfigTest.php @@ -42,19 +42,19 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->directoryHelper = $this->getMockBuilder('Magento\Directory\Helper\Data') + $this->directoryHelper = $this->getMockBuilder(\Magento\Directory\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->ccTypeFactory = $this->getMockBuilder('Magento\Payment\Model\Source\CctypeFactory') + $this->ccTypeFactory = $this->getMockBuilder(\Magento\Payment\Model\Source\CctypeFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->certFactory = $this->getMockBuilder('Magento\Paypal\Model\CertFactory') + $this->certFactory = $this->getMockBuilder(\Magento\Paypal\Model\CertFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -141,7 +141,6 @@ public function testIsMethodAvailableForIsMethodActive($methodName, $expected) $this->assertEquals($expected, $this->model->isMethodAvailable($methodName)); } - public function testGetMerchantCountryPaypal() { $this->scopeConfig->expects(static::once()) diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Express/CheckoutTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Express/CheckoutTest.php index 6f661194f958c..1179a974079c8 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Express/CheckoutTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Express/CheckoutTest.php @@ -13,6 +13,9 @@ use Magento\Quote\Model\ShippingAssignment; use Magento\Quote\Api\Data\CartExtensionInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CheckoutTest extends \PHPUnit_Framework_TestCase { const SHIPPING_METHOD = 'new_shipping_method'; @@ -54,29 +57,30 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', + $this->customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $this->quoteMock = $this->getMock( + \Magento\Quote\Model\Quote::class, [ 'getId', 'assignCustomer', 'assignCustomerWithAddressChange', 'getBillingAddress', 'getShippingAddress', 'isVirtual', 'addCustomerAddress', 'collectTotals', '__wakeup', 'save', 'getCustomerData', 'getIsVirtual', 'getExtensionAttributes' ], [], '', false); $this->customerAccountManagementMock = $this->getMock( - '\Magento\Customer\Model\AccountManagement', + \Magento\Customer\Model\AccountManagement::class, [], [], '', false ); - $this->objectCopyServiceMock = $this->getMockBuilder('\Magento\Framework\DataObject\Copy') + $this->objectCopyServiceMock = $this->getMockBuilder(\Magento\Framework\DataObject\Copy::class) ->disableOriginalConstructor() ->getMock(); - $this->customerSessionMock = $this->getMockBuilder('\Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $paypalConfigMock = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); + $paypalConfigMock = $this->getMock(\Magento\Paypal\Model\Config::class, [], [], '', false); $this->checkoutModel = $this->objectManager->getObject( - 'Magento\Paypal\Model\Express\Checkout', + \Magento\Paypal\Model\Express\Checkout::class, [ 'params' => [ 'quote' => $this->quoteMock, @@ -92,7 +96,7 @@ protected function setUp() public function testSetCustomerData() { - $customerDataMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerDataMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->quoteMock->expects($this->once())->method('assignCustomer')->with($customerDataMock); $customerDataMock->expects($this->once()) ->method('getId'); @@ -102,9 +106,9 @@ public function testSetCustomerData() public function testSetCustomerWithAddressChange() { /** @var \Magento\Customer\Api\Data\CustomerInterface $customerDataMock */ - $customerDataMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerDataMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); /** @var \Magento\Quote\Model\Quote\Address $customerDataMock */ - $quoteAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->quoteMock ->expects($this->once()) ->method('assignCustomerWithAddressChange') diff --git a/app/code/Magento/Paypal/Test/Unit/Model/ExpressConfigProviderTest.php b/app/code/Magento/Paypal/Test/Unit/Model/ExpressConfigProviderTest.php index 20ccd038ba649..13ef7ca7d2925 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/ExpressConfigProviderTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/ExpressConfigProviderTest.php @@ -11,20 +11,20 @@ class ExpressConfigProviderTest extends \PHPUnit_Framework_TestCase { public function testGetConfig() { - $localeResolver = $this->getMock('Magento\Framework\Locale\ResolverInterface', [], [], '', false); + $localeResolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class, [], [], '', false); $localeResolver->expects($this->once())->method('getLocale'); - $configFactory = $this->getMock('Magento\Paypal\Model\ConfigFactory', ['create'], [], '', false); + $configFactory = $this->getMock(\Magento\Paypal\Model\ConfigFactory::class, ['create'], [], '', false); - $currentCustomer = $this->getMock('Magento\Customer\Helper\Session\CurrentCustomer', [], [], '', false); + $currentCustomer = $this->getMock(\Magento\Customer\Helper\Session\CurrentCustomer::class, [], [], '', false); $currentCustomer->expects($this->atLeastOnce())->method('getCustomerId')->willReturn(12); - $paymentHelper= $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $paymentHelper= $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); - $paypalHelper = $this->getMock('Magento\Paypal\Helper\Data', [], [], '', false); + $paypalHelper = $this->getMock(\Magento\Paypal\Helper\Data::class, [], [], '', false); $paypalHelper->expects($this->atLeastOnce())->method('shouldAskToCreateBillingAgreement')->willReturn(false); - $config = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); + $config = $this->getMock(\Magento\Paypal\Model\Config::class, [], [], '', false); $config->expects($this->once())->method('getPaymentMarkWhatIsPaypalUrl'); $config->expects($this->once())->method('getPaymentMarkImageUrl'); $config->expects($this->atLeastOnce())->method('setMethod'); @@ -32,7 +32,7 @@ public function testGetConfig() $configFactory->expects($this->once())->method('create')->willReturn($config); $payment = $this->getMock( - 'Magento\Paypal\Model\Payflowpro', + \Magento\Paypal\Model\Payflowpro::class, ['isAvailable', 'getCheckoutRedirectUrl'], [], 'paymentInstance', @@ -43,7 +43,7 @@ public function testGetConfig() $paymentHelper->expects($this->atLeastOnce())->method('getMethodInstance')->willReturn($payment); /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject $urlBuilderMock */ - $urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); $configProvider = new ExpressConfigProvider( $configFactory, diff --git a/app/code/Magento/Paypal/Test/Unit/Model/ExpressTest.php b/app/code/Magento/Paypal/Test/Unit/Model/ExpressTest.php index 6abf963cf7b26..33065cc22713b 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/ExpressTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/ExpressTest.php @@ -13,6 +13,10 @@ use Magento\Paypal\Model\Express; use Magento\Quote\Api\Data\PaymentInterface; +/** + * Class ExpressTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ExpressTest extends \PHPUnit_Framework_TestCase { /** @@ -69,28 +73,28 @@ class ExpressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_checkoutSession = $this->getMock( - 'Magento\Checkout\Model\Session', + \Magento\Checkout\Model\Session::class, ['getPaypalTransactionData', 'setPaypalTransactionData'], [], '', false ); $this->transactionBuilder = $this->getMockForAbstractClass( - 'Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface', + \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface::class, [], '', false, false ); $this->_nvp = $this->getMock( - 'Magento\Paypal\Model\Api\Nvp', + \Magento\Paypal\Model\Api\Nvp::class, ['setProcessableErrors', 'setAmount', 'setCurrencyCode', 'setTransactionId', 'callDoAuthorization'], [], '', false ); $this->_pro = $this->getMock( - 'Magento\Paypal\Model\Pro', + \Magento\Paypal\Model\Pro::class, ['setMethod', 'getApi', 'importPaymentInfo', 'resetApi'], [], '', @@ -109,7 +113,7 @@ public function testSetApiProcessableErrors() $this->_nvp->expects($this->once())->method('setProcessableErrors')->with($this->errorCodes); $this->_model = $this->_helper->getObject( - 'Magento\Paypal\Model\Express', + \Magento\Paypal\Model\Express::class, [ 'data' => [$this->_pro], 'checkoutSession' => $this->_checkoutSession, @@ -131,9 +135,9 @@ public function testOrder() ); $this->_checkoutSession->expects($this->once())->method('setPaypalTransactionData')->with([]); - $currency = $this->getMock('Magento\Directory\Model\Currency', ['__wakeup', 'formatTxt'], [], '', false); + $currency = $this->getMock(\Magento\Directory\Model\Currency::class, ['__wakeup', 'formatTxt'], [], '', false); $paymentModel = $this->getMock( - 'Magento\Sales\Model\Order\Payment', + \Magento\Sales\Model\Order\Payment::class, [ '__wakeup', 'getBaseCurrency', @@ -147,7 +151,7 @@ public function testOrder() false ); $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['setState', 'getBaseCurrency', 'getBaseCurrencyCode', 'setStatus'], [], '', @@ -161,7 +165,7 @@ public function testOrder() $this->transactionBuilder->expects($this->any())->method('setPayment')->will($this->returnSelf()); $this->transactionBuilder->expects($this->any())->method('setTransactionId')->will($this->returnSelf()); $this->_model = $this->_helper->getObject( - 'Magento\Paypal\Model\Express', + \Magento\Paypal\Model\Express::class, [ 'data' => [$this->_pro], 'checkoutSession' => $this->_checkoutSession, @@ -184,7 +188,7 @@ public function testAssignData() ); $this->_model = $this->_helper->getObject( - 'Magento\Paypal\Model\Express', + \Magento\Paypal\Model\Express::class, [ 'data' => [$this->_pro], 'checkoutSession' => $this->_checkoutSession, diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php index 751d7c0eecf44..6011935f6e161 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php @@ -32,14 +32,14 @@ protected function setUp() { $this->helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\Resolver') + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\Resolver::class) ->disableOriginalConstructor() ->getMock(); - $this->taxData = $this->helper->getObject('Magento\Tax\Helper\Data'); + $this->taxData = $this->helper->getObject(\Magento\Tax\Helper\Data::class); $this->_model = $this->helper->getObject( - 'Magento\Paypal\Model\Hostedpro\Request', + \Magento\Paypal\Model\Hostedpro\Request::class, [ 'localeResolver' => $this->localeResolverMock, 'taxData' => $this->taxData @@ -144,7 +144,7 @@ public function testSetPaymentMethod() 'showCardInfo' => 'true', 'showHostedThankyouPage' => 'false' ]; - $paymentMethodMock = $this->getMockBuilder('Magento\Paypal\Model\Hostedpro') + $paymentMethodMock = $this->getMockBuilder(\Magento\Paypal\Model\Hostedpro::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -171,7 +171,7 @@ public function testSetOrder() 'buyer_email' => 'buyer@email.com', ]; - $order = $this->getMockBuilder('Magento\Sales\Model\Order') + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); @@ -311,18 +311,18 @@ public function testSetAmountWithoutTaxZeroSubtotal($total, $subtotal, $tax, $sh public function testSetAmountWithIncludedTax() { /** @var \Magento\Tax\Model\Config $config */ - $config = $this->helper->getObject('Magento\Tax\Model\Config'); + $config = $this->helper->getObject(\Magento\Tax\Model\Config::class); $config->setPriceIncludesTax(true); $this->taxData = $this->helper->getObject( - 'Magento\Tax\Helper\Data', + \Magento\Tax\Helper\Data::class, [ 'taxConfig' => $config ] ); $this->_model = $this->helper->getObject( - 'Magento\Paypal\Model\Hostedpro\Request', + \Magento\Paypal\Model\Hostedpro\Request::class, [ 'localeResolver' => $this->localeResolverMock, 'taxData' => $this->taxData @@ -338,11 +338,11 @@ public function testSetAmountWithIncludedTax() 'subtotal' => $amount ]; - $payment = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $payment = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->getMock(); - $order = $this->getMockBuilder('Magento\Sales\Model\Order') + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/IframeConfigProviderTest.php b/app/code/Magento/Paypal/Test/Unit/Model/IframeConfigProviderTest.php index 46e215faa6588..d14f9cbc1b823 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/IframeConfigProviderTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/IframeConfigProviderTest.php @@ -12,7 +12,7 @@ class IframeConfigProviderTest extends \PHPUnit_Framework_TestCase public function testGetConfig() { $urlBuilder = $this->getMockForAbstractClass( - 'Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, ['getUrl'], '', false @@ -20,13 +20,13 @@ public function testGetConfig() $urlBuilder->expects($this->atLeastOnce())->method('getUrl')->willReturn('http://iframe.url'); $payment = $this->getMock( - 'Magento\Paypal\Model\Payflowpro', + \Magento\Paypal\Model\Payflowpro::class, ['isAvailable', 'getFrameActionUrl'], [], 'paymentInstance', false ); - $paymentHelper= $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $paymentHelper= $this->getMock(\Magento\Payment\Helper\Data::class, [], [], '', false); $payment->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/InfoTest.php b/app/code/Magento/Paypal/Test/Unit/Model/InfoTest.php index c5435c69b3111..c9430a0afac5f 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/InfoTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/InfoTest.php @@ -21,7 +21,7 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->info = $this->objectManagerHelper->getObject( - 'Magento\Paypal\Model\Info' + \Magento\Paypal\Model\Info::class ); } @@ -33,7 +33,7 @@ protected function setUp() public function testGetPaymentInfo($additionalInfo, $expectation) { /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $paymentInfo->setAdditionalInformation($additionalInfo); $this->assertEquals($expectation, $this->info->getPaymentInfo($paymentInfo)); } @@ -46,7 +46,7 @@ public function testGetPaymentInfo($additionalInfo, $expectation) public function testGetPaymentInfoLabelValues($additionalInfo, $expectation) { /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $paymentInfo->setAdditionalInformation($additionalInfo); $this->assertEquals( $this->_prepareLabelValuesExpectation($expectation), @@ -62,7 +62,7 @@ public function testGetPaymentInfoLabelValues($additionalInfo, $expectation) public function testGetPublicPaymentInfo($additionalInfo, $expectation) { /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $paymentInfo->setAdditionalInformation($additionalInfo); $this->assertEquals( $this->_prepareLabelValuesExpectation($expectation), @@ -78,7 +78,7 @@ public function testGetPublicPaymentInfo($additionalInfo, $expectation) public function testGetPublicPaymentInfoLabelValues($additionalInfo, $expectation) { /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $paymentInfo->setAdditionalInformation($additionalInfo); $this->assertEquals($expectation, $this->info->getPublicPaymentInfo($paymentInfo)); } @@ -93,7 +93,7 @@ public function testImportToPayment($mapping, $expectation) // we create $from object, based on mapping $from = new \Magento\Framework\DataObject($mapping); /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $this->info->importToPayment($from, $paymentInfo); $this->assertEquals($expectation, $paymentInfo->getAdditionalInformation()); } @@ -106,7 +106,7 @@ public function testImportToPayment($mapping, $expectation) public function testExportFromPayment($mapping, $expectation) { /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $paymentInfo->setAdditionalInformation($expectation); // we create $to empty object @@ -123,7 +123,7 @@ public function testExportFromPayment($mapping, $expectation) public function testExportFromPaymentCustomMapping($mapping, $expectation) { /** @var \Magento\Payment\Model\InfoInterface $paymentInfo */ - $paymentInfo = $this->objectManagerHelper->getObject('Magento\Payment\Model\Info'); + $paymentInfo = $this->objectManagerHelper->getObject(\Magento\Payment\Model\Info::class); $paymentInfo->setAdditionalInformation($expectation); // we create $to empty object diff --git a/app/code/Magento/Paypal/Test/Unit/Model/IpnTest.php b/app/code/Magento/Paypal/Test/Unit/Model/IpnTest.php index 9ca1e27b060ea..e27d6969b5bd6 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/IpnTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/IpnTest.php @@ -56,7 +56,7 @@ protected function setUp() 'save', 'getState', ]; - $this->_orderMock = $this->getMock('Magento\Sales\Model\OrderFactory', $methods, [], '', false); + $this->_orderMock = $this->getMock(\Magento\Sales\Model\OrderFactory::class, $methods, [], '', false); $this->_orderMock->expects($this->any())->method('create')->will($this->returnSelf()); $this->_orderMock->expects($this->any())->method('loadByIncrementId')->will($this->returnSelf()); $this->_orderMock->expects($this->any())->method('getId')->will($this->returnSelf()); @@ -64,14 +64,14 @@ protected function setUp() $this->_orderMock->expects($this->any())->method('getStoreId')->will($this->returnSelf()); $this->_orderMock->expects($this->any())->method('getEmailSent')->will($this->returnValue(true)); - $this->configFactory = $this->getMock( - 'Magento\Paypal\Model\ConfigFactory', + $this->configFactory = $this->getMock( + \Magento\Paypal\Model\ConfigFactory::class, ['create'], [], '', false ); - $configMock = $this->getMockBuilder('Magento\Paypal\Model\Config') + $configMock = $this->getMockBuilder(\Magento\Paypal\Model\Config::class) ->disableOriginalConstructor() ->getMock(); $this->configFactory->expects($this->any())->method('create')->willReturn($configMock); @@ -81,8 +81,8 @@ protected function setUp() $configMock->expects($this->any())->method('getPayPalIpnUrl') ->will($this->returnValue('https://ipnpb_paypal_url')); - $this->curlFactory = $this->getMock( - 'Magento\Framework\HTTP\Adapter\CurlFactory', + $this->curlFactory = $this->getMock( + \Magento\Framework\HTTP\Adapter\CurlFactory::class, ['create', 'setConfig', 'write', 'read'], [], '', @@ -95,8 +95,8 @@ protected function setUp() ' VERIFIED' )); - $this->_paypalInfo = $this->getMock( - 'Magento\Paypal\Model\Info', + $this->_paypalInfo = $this->getMock( + \Magento\Paypal\Model\Info::class, ['importToPayment', 'getMethod', 'getAdditionalInformation'], [], '', @@ -104,7 +104,8 @@ protected function setUp() ); $this->_paypalInfo->expects($this->any())->method('getMethod')->will($this->returnValue('some_method')); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_ipn = $objectHelper->getObject('Magento\Paypal\Model\Ipn', + $this->_ipn = $objectHelper->getObject( + \Magento\Paypal\Model\Ipn::class, [ 'configFactory' => $this->configFactory, 'curlFactory' => $this->curlFactory, @@ -128,7 +129,7 @@ public function testLegacyRegisterPaymentAuthorization() 'setIsTransactionClosed', 'registerAuthorizationNotification', ]; - $payment = $this->getMock('Magento\Sales\Model\Order\Payment', $methods, [], '', false); + $payment = $this->getMock(\Magento\Sales\Model\Order\Payment::class, $methods, [], '', false); $payment->expects($this->any())->method('setPreparedMessage')->will($this->returnSelf()); $payment->expects($this->any())->method('setTransactionId')->will($this->returnSelf()); $payment->expects($this->any())->method('setParentTransactionId')->will($this->returnSelf()); @@ -150,8 +151,8 @@ public function testPaymentReviewRegisterPaymentAuthorization() public function testPaymentReviewRegisterPaymentFraud() { - $paymentMock = $this->getMock( - '\Magento\Sales\Model\Order\Payment', + $paymentMock = $this->getMock( + \Magento\Sales\Model\Order\Payment::class, ['getAdditionalInformation', '__wakeup', 'registerCaptureNotification'], [], '', @@ -179,7 +180,8 @@ public function testPaymentReviewRegisterPaymentFraud() $paymentMock ); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_ipn = $objectHelper->getObject('Magento\Paypal\Model\Ipn', + $this->_ipn = $objectHelper->getObject( + \Magento\Paypal\Model\Ipn::class, [ 'configFactory' => $this->configFactory, 'curlFactory' => $this->curlFactory, @@ -199,7 +201,7 @@ public function testPaymentReviewRegisterPaymentFraud() public function testRegisterPaymentDenial() { /** @var \Magento\Sales\Model\Order\Payment $paymentMock */ - $paymentMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->setMethods([ 'getAdditionalInformation', 'setTransactionId', @@ -223,7 +225,8 @@ public function testRegisterPaymentDenial() ->with(['payment_status' => 'denied'], $paymentMock); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_ipn = $objectHelper->getObject('Magento\Paypal\Model\Ipn', + $this->_ipn = $objectHelper->getObject( + \Magento\Paypal\Model\Ipn::class, [ 'configFactory' => $this->configFactory, 'curlFactory' => $this->curlFactory, diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Method/AgreementTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Method/AgreementTest.php index 446cce9b8f4b1..84f0e4c1348f4 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Method/AgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Method/AgreementTest.php @@ -27,17 +27,17 @@ protected function setUp() $this->_helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $paypalConfigMock = $this->getMockBuilder( - '\Magento\Paypal\Model\Config' + \Magento\Paypal\Model\Config::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); $this->_apiNvpMock = $this->getMockBuilder( - '\Magento\Paypal\Model\Api\Nvp' + \Magento\Paypal\Model\Api\Nvp::class )->disableOriginalConstructor()->setMethods( ['callDoReferenceTransaction', 'callGetTransactionDetails'] )->getMock(); $proMock = $this->getMockBuilder( - '\Magento\Paypal\Model\Pro' + \Magento\Paypal\Model\Pro::class )->setMethods( ['getApi', 'setMethod', 'getConfig', 'importPaymentInfo'] )->disableOriginalConstructor()->getMock(); @@ -45,14 +45,14 @@ protected function setUp() $proMock->expects($this->any())->method('getConfig')->will($this->returnValue($paypalConfigMock)); $billingAgreementMock = $this->getMockBuilder( - '\Magento\Paypal\Model\Billing\Agreement' + \Magento\Paypal\Model\Billing\Agreement::class )->disableOriginalConstructor()->setMethods( ['load', '__wakeup'] )->getMock(); $billingAgreementMock->expects($this->any())->method('load')->will($this->returnValue($billingAgreementMock)); $agreementFactoryMock = $this->getMockBuilder( - '\Magento\Paypal\Model\Billing\AgreementFactory' + \Magento\Paypal\Model\Billing\AgreementFactory::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); @@ -64,9 +64,9 @@ protected function setUp() $this->returnValue($billingAgreementMock) ); - $cartMock = $this->getMockBuilder('\Magento\Paypal\Model\Cart')->disableOriginalConstructor()->getMock(); + $cartMock = $this->getMockBuilder(\Magento\Paypal\Model\Cart::class)->disableOriginalConstructor()->getMock(); $cartFactoryMock = $this->getMockBuilder( - '\Magento\Paypal\Model\CartFactory' + \Magento\Paypal\Model\CartFactory::class )->disableOriginalConstructor()->setMethods( ['create'] )->getMock(); @@ -78,18 +78,18 @@ protected function setUp() 'data' => [$proMock], ]; - $this->_model = $this->_helper->getObject('Magento\Paypal\Model\Method\Agreement', $arguments); + $this->_model = $this->_helper->getObject(\Magento\Paypal\Model\Method\Agreement::class, $arguments); } public function testAuthorizeWithBaseCurrency() { $payment = $this->getMockBuilder( - '\Magento\Sales\Model\Order\Payment' + \Magento\Sales\Model\Order\Payment::class )->disableOriginalConstructor()->setMethods( ['__wakeup'] )->getMock(); $order = $this->getMockBuilder( - 'Magento\Sales\Model\Order' + \Magento\Sales\Model\Order::class )->disableOriginalConstructor()->setMethods( ['__wakeup'] )->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Method/Checks/SpecificationPluginTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Method/Checks/SpecificationPluginTest.php index ad2c39beeac3e..eb8eb1091b083 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Method/Checks/SpecificationPluginTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Method/Checks/SpecificationPluginTest.php @@ -21,14 +21,14 @@ class SpecificationPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->agreementFactory = $this->getMockBuilder('Magento\Paypal\Model\Billing\AgreementFactory') + $this->agreementFactory = $this->getMockBuilder(\Magento\Paypal\Model\Billing\AgreementFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Paypal\Model\Method\Checks\SpecificationPlugin', + \Magento\Paypal\Model\Method\Checks\SpecificationPlugin::class, [ 'agreementFactory' => $this->agreementFactory ] @@ -69,7 +69,7 @@ public function testAroundIsApplicable($count) $quote = $this->getQuote(1); $proceed = $this->getProceedClosure(true, $paymentMethod, $quote); $agreementCollection = $this->getMock( - 'Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection', + \Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection::class, [], [], '', @@ -78,7 +78,7 @@ public function testAroundIsApplicable($count) $agreementCollection->expects($this->once()) ->method('count') ->will($this->returnValue($count)); - $agreement = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $agreement = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $agreement->expects($this->once()) ->method('getAvailableCustomerBillingAgreements') ->with(1) @@ -118,7 +118,7 @@ private function getProceedClosure($result, MethodInterface $paymentMethod, Quot */ private function getPaymentMethod($code) { - $paymentMethod = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $paymentMethod = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class); $paymentMethod->expects($this->any()) ->method('getCode') ->will($this->returnValue($code)); @@ -133,7 +133,7 @@ private function getPaymentMethod($code) */ private function getQuote($customerId) { - $quote = $this->getMock('Magento\Quote\Model\Quote', ['__wakeup'], [], '', false); + $quote = $this->getMock(\Magento\Quote\Model\Quote::class, ['__wakeup'], [], '', false); $quote->setCustomerId($customerId); return $quote; } @@ -151,7 +151,7 @@ private function callAroundIsApplicable( MethodInterface $paymentMethod, Quote $quote ) { - $specification = $this->getMockForAbstractClass('Magento\Payment\Model\Checks\SpecificationInterface'); + $specification = $this->getMockForAbstractClass(\Magento\Payment\Model\Checks\SpecificationInterface::class); return $this->model->aroundIsApplicable($specification, $proceed, $paymentMethod, $quote); } } diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php index e6fc68222dcd1..521d4cc61eb52 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php @@ -38,9 +38,9 @@ class SecureTokenTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->url = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); - $this->mathRandom = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); - $this->transparent = $this->getMock('Magento\Paypal\Model\Payflow\Transparent', [], [], '', false); + $this->url = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->mathRandom = $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false); + $this->transparent = $this->getMock(\Magento\Paypal\Model\Payflow\Transparent::class, [], [], '', false); $this->model = new SecureToken( $this->url, @@ -61,7 +61,7 @@ public function testRequestToken() ->method('fillCustomerContacts'); $this->transparent->expects($this->once()) ->method('getConfig') - ->willReturn($this->getMock('Magento\Paypal\Model\PayflowConfig', [], [], '', false)); + ->willReturn($this->getMock(\Magento\Paypal\Model\PayflowConfig::class, [], [], '', false)); $this->transparent->expects($this->once()) ->method('postRequest') ->willReturn(new DataObject()); @@ -73,7 +73,7 @@ public function testRequestToken() $this->url->expects($this->exactly(3)) ->method('getUrl'); - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->model->requestToken($quote); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/CreditCardValidationHandlerTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/CreditCardValidationHandlerTest.php index 5300f475838d3..de79a915a9316 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/CreditCardValidationHandlerTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/CreditCardValidationHandlerTest.php @@ -20,13 +20,12 @@ public function testHandleCreditCardValidationFields() Info::PAYPAL_IAVS => 'X' ]; - - $paypalInfoManager = $this->getMockBuilder('Magento\Paypal\Model\Info') + $paypalInfoManager = $this->getMockBuilder(\Magento\Paypal\Model\Info::class) ->disableOriginalConstructor() ->getMock(); - $paymentMock = $this->getMockBuilder('Magento\Payment\Model\InfoInterface') + $paymentMock = $this->getMockBuilder(\Magento\Payment\Model\InfoInterface::class) ->getMock(); - $responseMock = $this->getMockBuilder('Magento\Framework\DataObject') + $responseMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/FraudHandlerTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/FraudHandlerTest.php index d5b7dbddb089e..e8a8c04796a14 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/FraudHandlerTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/FraudHandlerTest.php @@ -35,12 +35,12 @@ class FraudHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentMock = $this->getMockBuilder('Magento\Payment\Model\InfoInterface') + $this->paymentMock = $this->getMockBuilder(\Magento\Payment\Model\InfoInterface::class) ->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\DataObject') + $this->responseMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); - $this->paypalInfoManagerMock = $this->getMockBuilder('Magento\Paypal\Model\Info') + $this->paypalInfoManagerMock = $this->getMockBuilder(\Magento\Paypal\Model\Info::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php index 8c9c521c75422..86ebd731227cb 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php @@ -12,7 +12,7 @@ class HandlerCompositeTest extends \PHPUnit_Framework_TestCase public function testConstructorSuccess() { $handler = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface' + \Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface::class )->getMock(); new HandlerComposite( @@ -34,14 +34,14 @@ public function testConstructorException() public function testHandle() { - $paymentMock = $this->getMockBuilder('Magento\Payment\Model\InfoInterface') + $paymentMock = $this->getMockBuilder(\Magento\Payment\Model\InfoInterface::class) ->getMock(); - $responseMock = $this->getMockBuilder('Magento\Framework\DataObject') + $responseMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); $handler = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface' + \Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface::class )->getMock(); $handler->expects($this->once()) ->method('handle') diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/TransactionTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/TransactionTest.php index b4601c46a898f..7a2af6aed8a89 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/TransactionTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/TransactionTest.php @@ -12,6 +12,8 @@ /** * Test class for \Magento\Paypal\Model\Payflow\Service\Response\Transaction + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class TransactionTest extends \PHPUnit_Framework_TestCase { @@ -52,21 +54,27 @@ class TransactionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionTransparent = $this->getMock('Magento\Framework\Session\Generic', ['getQuoteId'], [], '', false); - $this->quoteRepository = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->transparent = $this->getMock('Magento\Paypal\Model\Payflow\Transparent', [], [], '', false); + $this->sessionTransparent = $this->getMock( + \Magento\Framework\Session\Generic::class, + ['getQuoteId'], + [], + '', + false + ); + $this->quoteRepository = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->transparent = $this->getMock(\Magento\Paypal\Model\Payflow\Transparent::class, [], [], '', false); $this->paymentMethodManagementInterface = $this->getMock( - 'Magento\Quote\Api\PaymentMethodManagementInterface', + \Magento\Quote\Api\PaymentMethodManagementInterface::class, [], [], '', false ); $this->errorHandlerMock = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface' + \Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface::class )->getMock(); - $this->loggerMock = $this->getMockBuilder('Magento\Payment\Model\Method\Logger') + $this->loggerMock = $this->getMockBuilder(\Magento\Payment\Model\Method\Logger::class) ->disableOriginalConstructor() ->getMock(); @@ -101,7 +109,6 @@ public function testGetResponseObject() ->method('debug') ->with($gatewayTransactionResponse, ['key1', 'key2'], true); - $this->assertEquals($result, $this->model->getResponseObject($gatewayTransactionResponse)); } @@ -110,7 +117,7 @@ public function testSavePaymentInQuote() $quoteId = 1; $response = new DataObject(); - $payment = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + $payment = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) ->disableOriginalConstructor() ->getMock(); @@ -120,7 +127,7 @@ public function testSavePaymentInQuote() $this->errorHandlerMock->expects($this->once()) ->method('handle') ->with($payment, $response); - $quote = $this->getMock('Magento\Quote\Api\Data\CartInterface', [], [], '', false); + $quote = $this->getMock(\Magento\Quote\Api\Data\CartInterface::class, [], [], '', false); $quote->expects($this->exactly(2)) ->method('getId') ->willReturn($quoteId); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Validator/ResponseValidatorTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Validator/ResponseValidatorTest.php index 0874f796e70a5..5b86da77a375f 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Validator/ResponseValidatorTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Validator/ResponseValidatorTest.php @@ -36,7 +36,7 @@ class ResponseValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->validatorMock = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\ValidatorInterface' + \Magento\Paypal\Model\Payflow\Service\Response\ValidatorInterface::class ) ->setMethods(['validate']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/TransparentTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/TransparentTest.php index bbbb3ea187d18..5fbb2d858da40 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/TransparentTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/TransparentTest.php @@ -66,26 +66,26 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->paymentTokenFactory = $this->getMockBuilder('\Magento\Vault\Api\Data\PaymentTokenInterfaceFactory') + $this->paymentTokenFactory = $this->getMockBuilder(\Magento\Vault\Api\Data\PaymentTokenInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->gatewayMock = $this->getMockBuilder('\Magento\Paypal\Model\Payflow\Service\Gateway') + $this->gatewayMock = $this->getMockBuilder(\Magento\Paypal\Model\Payflow\Service\Gateway::class) ->setMethods(['postRequest']) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->setMethods(['getStore', 'getId']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->storeManagerMock->expects($this->once()) ->method('getStore') ->willReturnSelf(); - $this->configMock = $this->getMockBuilder('Magento\Paypal\Model\PayflowConfig') + $this->configMock = $this->getMockBuilder(\Magento\Paypal\Model\PayflowConfig::class) ->disableOriginalConstructor() ->getMock(); - $this->configFactoryMock = $this->getMockBuilder('\Magento\Payment\Model\Method\ConfigInterfaceFactory') + $this->configFactoryMock = $this->getMockBuilder(\Magento\Payment\Model\Method\ConfigInterfaceFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -94,14 +94,14 @@ protected function setUp() ->willReturn($this->configMock); $this->responseMock = new \Magento\Framework\DataObject(); $this->responseValidator = $this->getMockBuilder( - 'Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator' + \Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator::class )->disableOriginalConstructor() ->setMethods(['validate']) ->getMock(); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->object = $objectHelper->getObject( - 'Magento\Paypal\Model\Payflow\Transparent', + \Magento\Paypal\Model\Payflow\Transparent::class, [ 'gateway' => $this->gatewayMock, 'storeManager' => $this->storeManagerMock, @@ -119,14 +119,14 @@ protected function setUp() */ protected function initializationAuthorizeMock() { - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods([ 'getCustomerId', 'getBillingAddress', 'getShippingAddress', 'getCustomerEmail', 'getId', 'getIncrementId' ]) ->disableOriginalConstructor() ->getMock(); - $this->addressBillingMock = $this->getMockBuilder('Magento\Framework\DataObject') + $this->addressBillingMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods( [ 'getFirstname', @@ -139,7 +139,7 @@ protected function initializationAuthorizeMock() ] )->disableOriginalConstructor() ->getMock(); - $this->addressShippingMock = $this->getMockBuilder('Magento\Framework\DataObject') + $this->addressShippingMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods( [ 'getFirstname', @@ -364,7 +364,7 @@ public function testAuthorize() $this->buildRequestData(); $paymentTokenMock = $this->getMock(PaymentTokenInterface::class); - $extensionAttributes = $this->getMockBuilder('Magento\Sales\Api\Data\OrderPaymentExtensionInterface') + $extensionAttributes = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderPaymentExtensionInterface::class) ->disableOriginalConstructor() ->setMethods(['setVaultPaymentToken']) ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/PayflowConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/PayflowConfigTest.php index 68d0b75997071..99dac56afd932 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/PayflowConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/PayflowConfigTest.php @@ -36,15 +36,15 @@ class PayflowConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->setMethods(['getValue', 'isSetFlag']) ->getMockForAbstractClass(); - $this->methodInterfaceMock = $this->getMockBuilder('Magento\Payment\Model\MethodInterface') + $this->methodInterfaceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); $om = new ObjectManager($this); $this->config = $om->getObject( - 'Magento\Paypal\Model\PayflowConfig', + \Magento\Paypal\Model\PayflowConfig::class, [ 'scopeConfig' => $this->scopeConfigMock ] diff --git a/app/code/Magento/Paypal/Test/Unit/Model/PayflowExpressTest.php b/app/code/Magento/Paypal/Test/Unit/Model/PayflowExpressTest.php index 69893da9cf411..441c5c63e03b3 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/PayflowExpressTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/PayflowExpressTest.php @@ -30,13 +30,13 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $proFactory = $this->getMockBuilder( - 'Magento\Paypal\Model\ProFactory' + \Magento\Paypal\Model\ProFactory::class )->disableOriginalConstructor()->setMethods(['create'])->getMock(); - $api = $this->getMock('Magento\Paypal\Model\Api\Nvp', [], [], '', false); + $api = $this->getMock(\Magento\Paypal\Model\Api\Nvp::class, [], [], '', false); $paypalPro = $this->getMockBuilder( - 'Magento\Paypal\Model\Pro' + \Magento\Paypal\Model\Pro::class )->disableOriginalConstructor()->setMethods([])->getMock(); - $this->transactionRepository = $this->getMockBuilder('\Magento\Sales\Api\TransactionRepositoryInterface') + $this->transactionRepository = $this->getMockBuilder(\Magento\Sales\Api\TransactionRepositoryInterface::class) ->disableOriginalConstructor() ->setMethods(['getByTransactionType']) ->getMockForAbstractClass(); @@ -45,7 +45,7 @@ protected function setUp() $proFactory->expects($this->once())->method('create')->will($this->returnValue($paypalPro)); $this->_model = $objectManager->getObject( - 'Magento\Paypal\Model\PayflowExpress', + \Magento\Paypal\Model\PayflowExpress::class, ['proFactory' => $proFactory, 'transactionRepository' => $this->transactionRepository] ); } @@ -99,7 +99,7 @@ public function testCanRefundCaptureExistValid() protected function _getPreparedPaymentInfo() { $paymentInfo = $this->getMockBuilder( - 'Magento\Sales\Model\Order\Payment' + \Magento\Sales\Model\Order\Payment::class )->disableOriginalConstructor()->setMethods([])->getMock(); $this->_model->setData('info_instance', $paymentInfo); return $paymentInfo; @@ -113,7 +113,7 @@ protected function _getPreparedPaymentInfo() protected function _getCaptureTransaction() { return $this->getMockBuilder( - 'Magento\Sales\Model\Order\Payment\Transaction' + \Magento\Sales\Model\Order\Payment\Transaction::class )->disableOriginalConstructor()->setMethods([])->getMock(); } diff --git a/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php b/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php index 604bd3588aa63..b1897e18ad95c 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php @@ -10,6 +10,9 @@ use Magento\Store\Model\ScopeInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class PayflowlinkTest extends \PHPUnit_Framework_TestCase { /** @var Payflowlink */ @@ -36,41 +39,41 @@ class PayflowlinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->store = $this->getMock( - 'Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, [], [], '', false ); $storeManager = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface' + \Magento\Store\Model\StoreManagerInterface::class ); - $this->paypalConfig = $this->getMockBuilder('Magento\Paypal\Model\Config') + $this->paypalConfig = $this->getMockBuilder(\Magento\Paypal\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $configFactoryMock = $this->getMockBuilder('Magento\Payment\Model\Method\ConfigInterfaceFactory') + $configFactoryMock = $this->getMockBuilder(\Magento\Payment\Model\Method\ConfigInterfaceFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $requestFactory = $this->getMockBuilder('Magento\Paypal\Model\Payflow\RequestFactory') + $requestFactory = $this->getMockBuilder(\Magento\Paypal\Model\Payflow\RequestFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->payflowRequest = $this->getMockBuilder('Magento\Paypal\Model\Payflow\Request') + $this->payflowRequest = $this->getMockBuilder(\Magento\Paypal\Model\Payflow\Request::class) ->disableOriginalConstructor() ->getMock(); - $this->infoInstance = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $this->infoInstance = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); - $this->gatewayMock = $this->getMockBuilder('Magento\Paypal\Model\Payflow\Service\Gateway') + $this->gatewayMock = $this->getMockBuilder(\Magento\Paypal\Model\Payflow\Service\Gateway::class) ->disableOriginalConstructor() ->getMock(); @@ -90,7 +93,7 @@ protected function setUp() $helper = new ObjectManagerHelper($this); $this->model = $helper->getObject( - 'Magento\Paypal\Model\Payflowlink', + \Magento\Paypal\Model\Payflowlink::class, [ 'scopeConfig' => $this->scopeConfigMock, 'storeManager' => $storeManager, @@ -105,7 +108,7 @@ protected function setUp() public function testInitialize() { $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', diff --git a/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php b/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php index 5c899714253fa..f70593acca625 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php @@ -57,28 +57,28 @@ class PayflowproTest extends \PHPUnit_Framework_TestCase protected function setUp() { $configFactoryMock = $this->getMock( - 'Magento\Payment\Model\Method\ConfigInterfaceFactory', + \Magento\Payment\Model\Method\ConfigInterfaceFactory::class, ['create'], [], '', false ); $this->configMock = $this->getMock( - 'Magento\Paypal\Model\PayflowConfig', + \Magento\Paypal\Model\PayflowConfig::class, [], [], '', false ); $client = $this->getMock( - 'Magento\Framework\HTTP\ZendClient', + \Magento\Framework\HTTP\ZendClient::class, [], [], '', false ); $this->storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -87,13 +87,13 @@ protected function setUp() ['getStore'] ); $this->gatewayMock = $this->getMock( - 'Magento\Paypal\Model\Payflow\Service\Gateway', + \Magento\Paypal\Model\Payflow\Service\Gateway::class, [], [], '', false ); - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->setMethods(['getValue']) ->getMockForAbstractClass(); @@ -111,12 +111,12 @@ protected function setUp() $client->expects($this->any())->method('request')->will($this->returnSelf()); $client->expects($this->any())->method('getBody')->will($this->returnValue('RESULT name=value&name2=value2')); - $clientFactory = $this->getMock('Magento\Framework\HTTP\ZendClientFactory', ['create'], [], '', false); + $clientFactory = $this->getMock(\Magento\Framework\HTTP\ZendClientFactory::class, ['create'], [], '', false); $clientFactory->expects($this->any())->method('create')->will($this->returnValue($client)); $this->helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->payflowpro = $this->helper->getObject( - 'Magento\Paypal\Model\Payflowpro', + \Magento\Paypal\Model\Payflowpro::class, [ 'configFactory' => $configFactoryMock, 'httpClientFactory' => $clientFactory, @@ -147,8 +147,8 @@ public function testCanVoid($amountPaid, $paymentType, $expected) public function canVoidDataProvider() { return [ - [0, 'Magento\Sales\Model\Order\Payment', true], - [null, 'Magento\Sales\Model\Order\Payment', true] + [0, \Magento\Sales\Model\Order\Payment::class, true], + [null, \Magento\Sales\Model\Order\Payment::class, true] ]; } @@ -175,7 +175,7 @@ public function testFetchTransactionInfoForBN() $this->initStoreMock(); $this->configMock->expects($this->once())->method('getBuildNotationCode') ->will($this->returnValue('BNCODE')); - $payment = $this->getMock('Magento\Payment\Model\Info', ['setTransactionId', '__wakeup'], [], '', false); + $payment = $this->getMock(\Magento\Payment\Model\Info::class, ['setTransactionId', '__wakeup'], [], '', false); $payment->expects($this->once())->method('setTransactionId')->will($this->returnSelf()); $this->payflowpro->fetchTransactionInfo($payment, 'AD49G8N825'); } @@ -186,7 +186,7 @@ public function testFetchTransactionInfoForBN() */ public function testSetTransStatus($response, $paymentExpected) { - $payment = $this->helper->getObject('Magento\Payment\Model\Info'); + $payment = $this->helper->getObject(\Magento\Payment\Model\Info::class); $this->payflowpro->setTransStatus($payment, $response); $this->assertEquals($paymentExpected->getData(), $payment->getData()); } @@ -350,7 +350,7 @@ public function testRefund() protected function initStoreMock() { $storeId = 27; - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); @@ -392,8 +392,8 @@ protected function execGatewayRequest() $this->gatewayMock->expects(static::once()) ->method('postRequest') ->with( - $this->isInstanceOf('Magento\Framework\DataObject'), - $this->isInstanceOf('Magento\Paypal\Model\PayflowConfig') + $this->isInstanceOf(\Magento\Framework\DataObject::class), + $this->isInstanceOf(\Magento\Paypal\Model\PayflowConfig::class) ) ->willReturn($response); return $response; @@ -405,7 +405,7 @@ protected function execGatewayRequest() */ protected function getPaymentMock() { - $paymentMock = $this->getMockBuilder('Magento\Payment\Model\Info') + $paymentMock = $this->getMockBuilder(\Magento\Payment\Model\Info::class) ->disableOriginalConstructor() ->setMethods([ 'getAdditionalInformation', 'getParentTransactionId', 'getOrder', @@ -445,7 +445,7 @@ protected function getOrderMock() 'id' => 4, 'increment_id' => '0000004' ]; - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['getBaseCurrencyCode', 'getIncrementId', 'getId', 'getBillingAddress', 'getShippingAddress']) ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payment/Method/Billing/AbstractAgreementTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payment/Method/Billing/AbstractAgreementTest.php index e471edcf4a701..187f109a7861b 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payment/Method/Billing/AbstractAgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payment/Method/Billing/AbstractAgreementTest.php @@ -15,6 +15,10 @@ use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Payment; +/** + * Class AbstractAgreementTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractAgreementTest extends \PHPUnit_Framework_TestCase { /** @@ -40,7 +44,7 @@ public function setUp() ->setMethods(['dispatch']) ->getMockForAbstractClass(); - $this->agreementFactory = $this->getMockBuilder('Magento\Paypal\Model\Billing\AgreementFactory') + $this->agreementFactory = $this->getMockBuilder(\Magento\Paypal\Model\Billing\AgreementFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/ProTest.php b/app/code/Magento/Paypal/Test/Unit/Model/ProTest.php index 5c4208cc7d6dd..e35beb50e3568 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/ProTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/ProTest.php @@ -8,12 +8,17 @@ /** * Test class for \Magento\Paypal\Model\Pro + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ namespace Magento\Paypal\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Paypal\Model\Config as PaypalConfig; +/** + * Class ProTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ProTest extends \PHPUnit_Framework_TestCase { /** @@ -32,7 +37,7 @@ protected function setUp() $configFactory = $this->getConfigFactory($storeId); $apiFactory = $this->getApiFactory($objectHelper); $args = $objectHelper->getConstructArguments( - 'Magento\Paypal\Model\Pro', + \Magento\Paypal\Model\Pro::class, [ 'configFactory' => $configFactory, 'infoFactory' => $infoFactory, @@ -40,7 +45,7 @@ protected function setUp() ] ); /** @var $pro \Magento\Paypal\Model\Pro */ - $this->pro = $this->getMock('Magento\Paypal\Model\Pro', ['_isPaymentReviewRequired'], $args); + $this->pro = $this->getMock(\Magento\Paypal\Model\Pro::class, ['_isPaymentReviewRequired'], $args); $this->pro->setMethod(PaypalConfig::METHOD_PAYMENT_PRO, $storeId); } @@ -60,7 +65,7 @@ public function testCanReviewPayment($pendingReason, $isReviewRequired, $expecte $this->returnValue($isReviewRequired) ); $payment = $this->getMockBuilder( - 'Magento\Payment\Model\Info' + \Magento\Payment\Model\Info::class )->disableOriginalConstructor()->setMethods( ['getAdditionalInformation', '__wakeup'] )->getMock(); @@ -129,11 +134,11 @@ public function testCapture() */ protected function getInfoFactory() { - $infoFactory = $this->getMockBuilder('Magento\Paypal\Model\InfoFactory') + $infoFactory = $this->getMockBuilder(\Magento\Paypal\Model\InfoFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $infoMock = $this->getMockBuilder('Magento\Paypal\Model\Info') + $infoMock = $this->getMockBuilder(\Magento\Paypal\Model\Info::class) ->disableOriginalConstructor() ->setMethods(['isPaymentReviewRequired']) ->getMock(); @@ -148,11 +153,11 @@ protected function getInfoFactory() */ protected function getConfigFactory($storeId) { - $configType = 'Magento\Paypal\Model\Config'; + $configType = \Magento\Paypal\Model\Config::class; $configMock = $this->getMockBuilder($configType) ->disableOriginalConstructor() ->getMock(); - $configFactory = $this->getMockBuilder('Magento\Paypal\Model\Config\Factory') + $configFactory = $this->getMockBuilder(\Magento\Paypal\Model\Config\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -174,12 +179,12 @@ protected function getConfigFactory($storeId) */ protected function getApiFactory(ObjectManager $objectHelper) { - $apiFactory = $this->getMockBuilder('Magento\Paypal\Model\Api\Type\Factory') + $apiFactory = $this->getMockBuilder(\Magento\Paypal\Model\Api\Type\Factory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $httpClient = $this->getMockBuilder('Magento\Framework\HTTP\Adapter\Curl') + $httpClient = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\Curl::class) ->disableOriginalConstructor() ->getMock(); @@ -189,13 +194,13 @@ protected function getApiFactory(ObjectManager $objectHelper) "\r\n" . 'ACK=Success&CORRELATIONID=32342431' )); - $curlFactory = $this->getMockBuilder('Magento\Framework\HTTP\Adapter\CurlFactory') + $curlFactory = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\CurlFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $curlFactory->expects(static::any())->method('create')->willReturn($httpClient); - $apiType = 'Magento\Paypal\Model\Api\Nvp'; + $apiType = \Magento\Paypal\Model\Api\Nvp::class; $args = $objectHelper->getConstructArguments( $apiType, [ @@ -217,7 +222,7 @@ protected function getApiFactory(ObjectManager $objectHelper) */ protected function getPaymentMock() { - $paymentMock = $this->getMockBuilder('Magento\Payment\Model\Info') + $paymentMock = $this->getMockBuilder(\Magento\Payment\Model\Info::class) ->disableOriginalConstructor() ->setMethods([ 'getParentTransactionId', 'getOrder', 'getShouldCloseParentTransaction' @@ -244,7 +249,7 @@ protected function getOrderMock() 'id' => 4, 'increment_id' => '0000004' ]; - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->setMethods(['getBaseCurrencyCode', 'getIncrementId', 'getId', 'getBillingAddress', 'getShippingAddress']) ->getMock(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php index f427798367940..364dec5d567ff 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php @@ -18,7 +18,7 @@ class RowTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->row = $objectManagerHelper->getObject('Magento\Paypal\Model\Report\Settlement\Row'); + $this->row = $objectManagerHelper->getObject(\Magento\Paypal\Model\Report\Settlement\Row::class); } /** diff --git a/app/code/Magento/Paypal/Test/Unit/Model/ResourceModel/Billing/AgreementTest.php b/app/code/Magento/Paypal/Test/Unit/Model/ResourceModel/Billing/AgreementTest.php index 34625c2ec4344..0d7d40bc2c4c6 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/ResourceModel/Billing/AgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/ResourceModel/Billing/AgreementTest.php @@ -41,11 +41,11 @@ class AgreementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManagerHelper($this); - $contextMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\Context') + $contextMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\Context::class) ->disableOriginalConstructor() ->getMock(); $this->resourceConnectionMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [ 'getConnection', 'getTableName' @@ -54,21 +54,21 @@ protected function setUp() '', false ); - $this->collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $this->collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['getSelect']) ->getMockForAbstractClass(); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); - $this->selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceConnectionMock); $this->agreementResource = $objectManager->getObject( - 'Magento\Paypal\Model\ResourceModel\Billing\Agreement', + \Magento\Paypal\Model\ResourceModel\Billing\Agreement::class, [ 'context' => $contextMock, ] diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php index 17eb9994a6a9c..d66ee1711d6b3 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php @@ -45,16 +45,16 @@ protected function setUp() $this->_observer->setEvent($this->_event); $this->_agreementFactory = $this->getMock( - 'Magento\Paypal\Model\Billing\AgreementFactory', + \Magento\Paypal\Model\Billing\AgreementFactory::class, ['create'], [], '', false ); - $this->_checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->_checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManagerHelper->getObject( - 'Magento\Paypal\Observer\AddBillingAgreementToSessionObserver', + \Magento\Paypal\Observer\AddBillingAgreementToSessionObserver::class, [ 'agreementFactory' => $this->_agreementFactory, 'checkoutSession' => $this->_checkoutSession, @@ -64,7 +64,7 @@ protected function setUp() public function testAddBillingAgreementToSessionNoData() { - $payment = $this->getMock('Magento\Sales\Model\Order\Payment', [], [], '', false); + $payment = $this->getMock(\Magento\Sales\Model\Order\Payment::class, [], [], '', false); $payment->expects( $this->once() )->method( @@ -86,10 +86,10 @@ public function testAddBillingAgreementToSessionNoData() */ public function testAddBillingAgreementToSession($isValid) { - $agreement = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false); + $agreement = $this->getMock(\Magento\Paypal\Model\Billing\Agreement::class, [], [], '', false); $agreement->expects($this->once())->method('isValid')->will($this->returnValue($isValid)); $comment = $this->getMockForAbstractClass( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [], '', false, @@ -97,7 +97,7 @@ public function testAddBillingAgreementToSession($isValid) true, ['__wakeup'] ); - $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $order = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); $order->expects( $this->once() )->method( @@ -144,7 +144,7 @@ public function testAddBillingAgreementToSession($isValid) } $order->expects(new MethodInvokedAtIndex($isValid ? 1 : 0))->method('addRelatedObject')->with($comment); - $payment = $this->getMock('Magento\Sales\Model\Order\Payment', [], [], '', false); + $payment = $this->getMock(\Magento\Sales\Model\Order\Payment::class, [], [], '', false); $payment->expects( $this->once() )->method( diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/AddPaypalShortcutsObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/AddPaypalShortcutsObserverTest.php index b5a9159f37df9..0cf0dfbc9ef9e 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/AddPaypalShortcutsObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/AddPaypalShortcutsObserverTest.php @@ -20,6 +20,7 @@ * Class AddPaypalShortcutsObserverTest * * @see \Magento\Paypal\Observer\AddPaypalShortcutsObserver + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddPaypalShortcutsObserverTest extends \PHPUnit_Framework_TestCase { @@ -158,37 +159,37 @@ public function dataProviderShortcutsButtons() return [ [ 'blocks1' => [ - 'Magento\Paypal\Block\Express\InContext\Minicart\Button' => [ + \Magento\Paypal\Block\Express\InContext\Minicart\Button::class => [ self::PAYMENT_CODE => Config::METHOD_WPS_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\Express\Shortcut' => [ + \Magento\Paypal\Block\Express\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\Bml\Shortcut' => [ + \Magento\Paypal\Block\Bml\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => true, ], - 'Magento\Paypal\Block\WpsExpress\Shortcut' => [ + \Magento\Paypal\Block\WpsExpress\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPS_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\WpsBml\Shortcut' => [ + \Magento\Paypal\Block\WpsBml\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPS_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\PayflowExpress\Shortcut' => [ + \Magento\Paypal\Block\PayflowExpress\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_PE_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\Payflow\Bml\Shortcut' => [ + \Magento\Paypal\Block\Payflow\Bml\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_PE_EXPRESS, self::PAYMENT_AVAILABLE => true, self::PAYMENT_IS_BML => true, @@ -197,37 +198,37 @@ public function dataProviderShortcutsButtons() ], [ 'blocks2' => [ - 'Magento\Paypal\Block\Express\InContext\Minicart\Button' => [ + \Magento\Paypal\Block\Express\InContext\Minicart\Button::class => [ self::PAYMENT_CODE => Config::METHOD_WPS_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\Express\Shortcut' => [ + \Magento\Paypal\Block\Express\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\Bml\Shortcut' => [ + \Magento\Paypal\Block\Bml\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => true, ], - 'Magento\Paypal\Block\WpsExpress\Shortcut' => [ + \Magento\Paypal\Block\WpsExpress\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPS_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\WpsBml\Shortcut' => [ + \Magento\Paypal\Block\WpsBml\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPS_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\PayflowExpress\Shortcut' => [ + \Magento\Paypal\Block\PayflowExpress\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_PE_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => false, ], - 'Magento\Paypal\Block\Payflow\Bml\Shortcut' => [ + \Magento\Paypal\Block\Payflow\Bml\Shortcut::class => [ self::PAYMENT_CODE => Config::METHOD_WPP_PE_EXPRESS, self::PAYMENT_AVAILABLE => false, self::PAYMENT_IS_BML => true, diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/HtmlTransactionIdObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/HtmlTransactionIdObserverTest.php index ebf2c6f1089f3..c55d173808203 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/HtmlTransactionIdObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/HtmlTransactionIdObserverTest.php @@ -38,7 +38,7 @@ protected function setUp() $this->_observer->setEvent($this->_event); $this->paypalDataMock = $this->getMock( - '\Magento\Paypal\Helper\Data', + \Magento\Paypal\Helper\Data::class, ['getHtmlTransactionId'], [], '', @@ -46,7 +46,7 @@ protected function setUp() ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManagerHelper->getObject( - 'Magento\Paypal\Observer\HtmlTransactionIdObserver', + \Magento\Paypal\Observer\HtmlTransactionIdObserver::class, [ 'paypalData' => $this->paypalDataMock, ] @@ -55,23 +55,23 @@ protected function setUp() public function testObserveHtmlTransactionId() { - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->setMethods(['getDataObject']) ->disableOriginalConstructor() ->getMock(); - $transactionMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Payment\Transaction') + $transactionMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment\Transaction::class) ->setMethods(['getOrder', 'getTxnId', 'setData']) ->disableOriginalConstructor() ->getMock(); - $orderMock = $this->getMockBuilder('\Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods(['getPayment']) ->disableOriginalConstructor() ->getMock(); - $paymentMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->setMethods(['getMethodInstance']) ->disableOriginalConstructor() ->getMock(); - $methodInstanceMock = $this->getMockBuilder('\Magento\Payment\Model\MethodInterface') + $methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->setMethods(['getCode']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php index a9c5a74f99282..08ab107449ce7 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php @@ -43,7 +43,7 @@ protected function setUp() $this->_observer = new \Magento\Framework\Event\Observer(); $this->_observer->setEvent($this->_event); - $this->_authorization = $this->getMockForAbstractClass('Magento\Framework\AuthorizationInterface'); + $this->_authorization = $this->getMockForAbstractClass(\Magento\Framework\AuthorizationInterface::class); $this->_model = new \Magento\Paypal\Observer\RestrictAdminBillingAgreementUsageObserver($this->_authorization); } @@ -53,8 +53,8 @@ public function restrictAdminBillingAgreementUsageDataProvider() return [ [new \stdClass(), false, true], [ - $this->getMockForAbstractClass( - 'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement', + $this->getMockForAbstractClass( + \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::class, [], '', false @@ -63,8 +63,8 @@ public function restrictAdminBillingAgreementUsageDataProvider() true ], [ - $this->getMockForAbstractClass( - 'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement', + $this->getMockForAbstractClass( + \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::class, [], '', false diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/SetResponseAfterSaveOrderObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/SetResponseAfterSaveOrderObserverTest.php index f70a52ff30666..75e1a7088bcf1 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/SetResponseAfterSaveOrderObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/SetResponseAfterSaveOrderObserverTest.php @@ -48,21 +48,21 @@ protected function setUp() $this->_observer->setEvent($this->_event); $this->coreRegistryMock = $this->getMock( - 'Magento\Framework\Registry', + \Magento\Framework\Registry::class, [], [], '', false ); $this->paypalHssMock = $this->getMock( - 'Magento\Paypal\Helper\Hss', + \Magento\Paypal\Helper\Hss::class, ['getHssMethods'], [], '', false ); $this->viewMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\ViewInterface', + \Magento\Framework\App\ViewInterface::class, [], '', false, @@ -72,7 +72,7 @@ protected function setUp() ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $objectManagerHelper->getObject( - 'Magento\Paypal\Observer\SetResponseAfterSaveOrderObserver', + \Magento\Paypal\Observer\SetResponseAfterSaveOrderObserver::class, [ 'coreRegistry' => $this->coreRegistryMock, 'paypalHss' => $this->paypalHssMock, @@ -124,22 +124,22 @@ public function testSetResponseAfterSaveOrderSuccess() { $testData = $this->getSetResponseAfterSaveOrderTestData(); - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) ->disableOriginalConstructor() ->getMock(); - $resultMock = $this->getMockBuilder('Magento\Framework\DataObject') + $resultMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->getMock(); - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/Persistent/Model/Observer.php b/app/code/Magento/Persistent/Model/Observer.php index f26b71fd6d1c0..283d7bb45a5e8 100644 --- a/app/code/Magento/Persistent/Model/Observer.php +++ b/app/code/Magento/Persistent/Model/Observer.php @@ -108,7 +108,7 @@ public function emulateWelcomeBlock($block) protected function _applyAccountLinksPersistentData() { if (!$this->_layout->getBlock('header.additional')) { - $this->_layout->addBlock('Magento\Persistent\Block\Header\Additional', 'header.additional'); + $this->_layout->addBlock(\Magento\Persistent\Block\Header\Additional::class, 'header.additional'); } } diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 48ba5e8918d29..ff990e658cae6 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -10,6 +10,7 @@ * * @method int getCustomerId() * @method Session setCustomerId() + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Session extends \Magento\Framework\Model\AbstractModel { @@ -146,7 +147,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Persistent\Model\ResourceModel\Session'); + $this->_init(\Magento\Persistent\Model\ResourceModel\Session::class); } /** diff --git a/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php b/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php index 24e46b772c352..c5f93d1557c08 100644 --- a/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php @@ -94,7 +94,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->contextMock = $this->getMock( - 'Magento\Framework\View\Element\Template\Context', + \Magento\Framework\View\Element\Template\Context::class, [ 'getEventManager', 'getScopeConfig', @@ -111,21 +111,21 @@ protected function setUp() false ); $this->customerViewHelperMock = $this->getMock( - 'Magento\Customer\Helper\View', + \Magento\Customer\Helper\View::class, [], [], '', false ); $this->persistentSessionHelperMock = $this->getMock( - 'Magento\Persistent\Helper\Session', + \Magento\Persistent\Helper\Session::class, ['getSession'], [], '', false ); $this->customerRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false, @@ -135,7 +135,7 @@ protected function setUp() ); $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', + \Magento\Framework\Event\ManagerInterface::class, [], '', false, @@ -144,7 +144,7 @@ protected function setUp() ['dispatch'] ); $this->scopeConfigMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false, @@ -153,7 +153,7 @@ protected function setUp() ['getValue'] ); $this->cacheStateMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\Cache\StateInterface', + \Magento\Framework\App\Cache\StateInterface::class, [], '', false, @@ -162,7 +162,7 @@ protected function setUp() ['isEnabled'] ); $this->cacheMock = $this->getMockForAbstractClass( - 'Magento\Framework\App\CacheInterface', + \Magento\Framework\App\CacheInterface::class, [], '', false, @@ -171,7 +171,7 @@ protected function setUp() ['load'] ); $this->sidResolverMock = $this->getMockForAbstractClass( - 'Magento\Framework\Session\SidResolverInterface', + \Magento\Framework\Session\SidResolverInterface::class, [], '', false, @@ -180,7 +180,7 @@ protected function setUp() ['getSessionIdQueryParam'] ); $this->sessionMock = $this->getMockForAbstractClass( - 'Magento\Framework\Session\SessionManagerInterface', + \Magento\Framework\Session\SessionManagerInterface::class, [], '', false, @@ -189,7 +189,7 @@ protected function setUp() ['getSessionId'] ); $this->escaperMock = $this->getMockForAbstractClass( - 'Magento\Framework\Escaper', + \Magento\Framework\Escaper::class, [], '', false, @@ -198,7 +198,7 @@ protected function setUp() ['escapeHtml'] ); $this->urlBuilderMock = $this->getMockForAbstractClass( - 'Magento\Framework\UrlInterface', + \Magento\Framework\UrlInterface::class, [], '', false, @@ -233,7 +233,7 @@ protected function setUp() ->willReturn($this->urlBuilderMock); $this->additional = $this->objectManager->getObject( - 'Magento\Persistent\Block\Header\Additional', + \Magento\Persistent\Block\Header\Additional::class, [ 'context' => $this->contextMock, 'customerViewHelper' => $this->customerViewHelperMock, @@ -295,7 +295,7 @@ public function testToHtml($customerId) // call protected _toHtml method $sessionMock = $this->getMock( - 'Magento\Persistent\Model\Session', + \Magento\Persistent\Model\Session::class, ['getCustomerId'], [], '', diff --git a/app/code/Magento/Persistent/Test/Unit/Helper/DataTest.php b/app/code/Magento/Persistent/Test/Unit/Helper/DataTest.php index 33ada3241e4e0..72ad4c20192ec 100644 --- a/app/code/Magento/Persistent/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Helper/DataTest.php @@ -19,10 +19,10 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_modulesReader = $this->getMock('\Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->_modulesReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_helper = $objectManager->getObject( - 'Magento\Persistent\Helper\Data', + \Magento\Persistent\Helper\Data::class, ['modulesReader' => $this->_modulesReader] ); } diff --git a/app/code/Magento/Persistent/Test/Unit/Model/Checkout/ConfigProviderPluginTest.php b/app/code/Magento/Persistent/Test/Unit/Model/Checkout/ConfigProviderPluginTest.php index 75d4ba33c611b..f5646293cd143 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/Checkout/ConfigProviderPluginTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/Checkout/ConfigProviderPluginTest.php @@ -44,18 +44,18 @@ class ConfigProviderPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->persistentSessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->persistentHelperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->persistentSessionMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); $this->maskFactoryMock = $this->getMock( - 'Magento\Quote\Model\QuoteIdMaskFactory', + \Magento\Quote\Model\QuoteIdMaskFactory::class, ['create', '__wakeup'], [], '', false ); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->subjectMock = $this->getMock('\Magento\Checkout\Model\DefaultConfigProvider', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Checkout\Model\DefaultConfigProvider::class, [], [], '', false); $this->plugin = new \Magento\Persistent\Model\Checkout\ConfigProviderPlugin( $this->persistentHelperMock, @@ -108,14 +108,14 @@ public function testAfterGetConfigPositive() $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false); $quoteMaskMock = $this->getMock( - 'Magento\Quote\Model\QuoteIdMask', + \Magento\Quote\Model\QuoteIdMask::class, ['load', 'getMaskedId'], [], '', false ); $this->maskFactoryMock->expects($this->once())->method('create')->willReturn($quoteMaskMock); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $quoteMaskMock->expects($this->once())->method('load')->willReturnSelf(); diff --git a/app/code/Magento/Persistent/Test/Unit/Model/FactoryTest.php b/app/code/Magento/Persistent/Test/Unit/Model/FactoryTest.php index f211676cb8c36..4674a4f63d1d9 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/FactoryTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/FactoryTest.php @@ -21,9 +21,9 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->_factory = $helper->getObject( - 'Magento\Persistent\Model\Factory', + \Magento\Persistent\Model\Factory::class, ['objectManager' => $this->_objectManagerMock] ); } diff --git a/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 2c2b2cac7aef6..259916447fee2 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -40,19 +40,25 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->persistentSessionMock = $this->getMock( - 'Magento\Persistent\Model\Session', + \Magento\Persistent\Model\Session::class, ['setCustomerId'], [], '', false ); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->moduleManagerMock = $this->getMock('Magento\Framework\Module\Manager', ['isEnabled'], [], '', false); - $this->cacheConfigMock = $this->getMock('Magento\PageCache\Model\Config', ['isEnabled'], [], '', false); + $this->moduleManagerMock = $this->getMock( + \Magento\Framework\Module\Manager::class, + ['isEnabled'], + [], + '', + false + ); + $this->cacheConfigMock = $this->getMock(\Magento\PageCache\Model\Config::class, ['isEnabled'], [], '', false); $this->depersonalizeCheckerMock = $this->getMock( - 'Magento\PageCache\Model\DepersonalizeChecker', + \Magento\PageCache\Model\DepersonalizeChecker::class, [], [], '', @@ -60,7 +66,7 @@ protected function setUp() ); $this->plugin = $this->objectManager->getObject( - 'Magento\Persistent\Model\Layout\DepersonalizePlugin', + \Magento\Persistent\Model\Layout\DepersonalizePlugin::class, [ 'persistentSession' => $this->persistentSessionMock, 'depersonalizeChecker' => $this->depersonalizeCheckerMock, @@ -72,7 +78,7 @@ public function testAfterGenerateXml() { /** @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject $subjectMock */ $subjectMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, [], '', false, @@ -82,7 +88,7 @@ public function testAfterGenerateXml() ); /** @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject $resultMock */ $resultMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, [], '', false, @@ -101,7 +107,7 @@ public function testAfterGenerateXmlNoDepersonalize() { /** @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject $subjectMock */ $subjectMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, [], '', false, @@ -111,7 +117,7 @@ public function testAfterGenerateXmlNoDepersonalize() ); /** @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject $resultMock */ $resultMock = $this->getMockForAbstractClass( - 'Magento\Framework\View\LayoutInterface', + \Magento\Framework\View\LayoutInterface::class, [], '', false, diff --git a/app/code/Magento/Persistent/Test/Unit/Model/Plugin/CustomerDataTest.php b/app/code/Magento/Persistent/Test/Unit/Model/Plugin/CustomerDataTest.php index 1a8619fc66da9..317e7c2a67770 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/Plugin/CustomerDataTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/Plugin/CustomerDataTest.php @@ -35,10 +35,10 @@ class CustomerDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->persistentSessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->subjectMock = $this->getMock('\Magento\Customer\CustomerData\Customer', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->persistentSessionMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->subjectMock = $this->getMock(\Magento\Customer\CustomerData\Customer::class, [], [], '', false); $this->plugin = new \Magento\Persistent\Model\Plugin\CustomerData( $this->helperMock, $this->customerSessionMock, @@ -60,7 +60,6 @@ public function testAroundGetSectionDataForPersistentSession() $this->assertEquals([], $this->plugin->aroundGetSectionData($this->subjectMock, $proceed)); } - public function testAroundGetSectionData() { $result = 'result'; diff --git a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php index 6971e0f54f6e0..166f10c510e9b 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php @@ -55,9 +55,10 @@ class QuoteManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->persistentSessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->persistentSessionMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); $this->sessionMock = - $this->getMock('Magento\Persistent\Model\Session', + $this->getMock( + \Magento\Persistent\Model\Session::class, [ 'setLoadInactive', 'setCustomerData', @@ -70,14 +71,15 @@ protected function setUp() [], '', false); - $this->persistentDataMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + $this->persistentDataMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); $this->abstractCollectionMock = - $this->getMock('Magento\Eav\Model\Entity\Collection\AbstractCollection', [], [], '', false); + $this->getMock(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], [], '', false); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->quoteMock = $this->getMock( + \Magento\Quote\Model\Quote::class, [ 'getId', 'getIsPersistent', @@ -183,7 +185,7 @@ public function testSetGuest() ->method('setIsPersistent')->with(false)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('removeAllAddresses')->will($this->returnValue($this->quoteMock)); - $quoteAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($quoteAddressMock)); $this->quoteMock->expects($this->once()) diff --git a/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php b/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php index 1cb59428f709f..3b1e240adb59b 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php @@ -30,15 +30,15 @@ class SessionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->configMock = $this->getMock('Magento\Framework\Session\Config\ConfigInterface'); - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'); + $this->configMock = $this->getMock(\Magento\Framework\Session\Config\ConfigInterface::class); + $this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); $this->cookieMetadataFactoryMock = $this->getMockBuilder( - 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class )->disableOriginalConstructor() ->getMock(); $resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, @@ -48,7 +48,7 @@ protected function setUp() ); $actionValidatorMock = $this->getMock( - 'Magento\Framework\Model\ActionValidator\RemoveAction', + \Magento\Framework\Model\ActionValidator\RemoveAction::class, [], [], '', @@ -57,14 +57,14 @@ protected function setUp() $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $context = $helper->getObject( - 'Magento\Framework\Model\Context', + \Magento\Framework\Model\Context::class, [ 'actionValidator' => $actionValidatorMock, ] ); $this->session = $helper->getObject( - 'Magento\Persistent\Model\Session', + \Magento\Persistent\Model\Session::class, [ 'sessionConfig' => $this->configMock, 'cookieManager' => $this->cookieManagerMock, @@ -91,7 +91,7 @@ public function testAfterDeleteCommit() { $cookiePath = 'some_path'; $this->configMock->expects($this->once())->method('getCookiePath')->will($this->returnValue($cookiePath)); - $cookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata') + $cookieMetadataMock = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class) ->disableOriginalConstructor() ->getMock(); $cookieMetadataMock->expects($this->once()) @@ -118,7 +118,7 @@ public function testSetPersistentCookie() $duration = 1000; $key = 'sessionKey'; $this->session->setKey($key); - $cookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata') + $cookieMetadataMock = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class) ->disableOriginalConstructor() ->getMock(); $cookieMetadataMock->expects($this->once()) @@ -161,7 +161,7 @@ public function testRenewPersistentCookie( $cookieValue = 'cookieValue', $cookiePath = 'cookiePath' ) { - $cookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata') + $cookieMetadataMock = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class) ->disableOriginalConstructor() ->getMock(); $cookieMetadataMock->expects($this->exactly($numCalls)) diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/ApplyBlockPersistentDataObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/ApplyBlockPersistentDataObserverTest.php index 927e1d2f83661..287c9cf72444b 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/ApplyBlockPersistentDataObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/ApplyBlockPersistentDataObserverTest.php @@ -59,15 +59,21 @@ class ApplyBlockPersistentDataObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $eventMethods = ['getConfigFilePath', 'getBlock', '__wakeUp']; - $this->sessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->persistentHelperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); $this->configMock = - $this->getMock('\Magento\Persistent\Model\Persistent\ConfigFactory', ['create'], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->eventMock = $this->getMock('Magento\Framework\Event', $eventMethods, [], '', false); - $this->blockMock = $this->getMock('Magento\Framework\View\Element\AbstractBlock', [], [], '', false); - $this->persistentConfigMock = $this->getMock('\Magento\Persistent\Model\Persistent\Config', [], [], '', false); + $this->getMock(\Magento\Persistent\Model\Persistent\ConfigFactory::class, ['create'], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->eventMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->blockMock = $this->getMock(\Magento\Framework\View\Element\AbstractBlock::class, [], [], '', false); + $this->persistentConfigMock = $this->getMock( + \Magento\Persistent\Model\Persistent\Config::class, + [], + [], + '', + false + ); $this->model = new \Magento\Persistent\Observer\ApplyBlockPersistentDataObserver( $this->sessionMock, $this->persistentHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/ApplyPersistentDataObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/ApplyPersistentDataObserverTest.php index b1f20054bf5f7..e2d919854ca34 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/ApplyPersistentDataObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/ApplyPersistentDataObserverTest.php @@ -38,6 +38,7 @@ class ApplyPersistentDataObserverTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject */ protected $observerMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -45,13 +46,19 @@ class ApplyPersistentDataObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->persistentConfigMock = $this->getMock('\Magento\Persistent\Model\Persistent\Config', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->persistentHelperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->persistentConfigMock = $this->getMock( + \Magento\Persistent\Model\Persistent\Config::class, + [], + [], + '', + false + ); $this->configMock = - $this->getMock('\Magento\Persistent\Model\Persistent\ConfigFactory', ['create'], [], '', false); + $this->getMock(\Magento\Persistent\Model\Persistent\ConfigFactory::class, ['create'], [], '', false); $this->model = new \Magento\Persistent\Observer\ApplyPersistentDataObserver( $this->sessionMock, $this->persistentHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php index 95515988a7f5b..006e2277a5a16 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php @@ -51,14 +51,21 @@ class CheckExpirePersistentQuoteObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->persistentHelperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->persistentHelperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); $this->observerMock - = $this->getMock('Magento\Framework\Event\Observer', ['getControllerAction', '__wakeUp'], [], '', false); - $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + = $this->getMock( + \Magento\Framework\Event\Observer::class, + ['getControllerAction', + '__wakeUp'], + [], + '', + false + ); + $this->quoteManagerMock = $this->getMock(\Magento\Persistent\Model\QuoteManager::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\CheckExpirePersistentQuoteObserver( $this->sessionMock, $this->persistentHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/ClearExpiredCronJobObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/ClearExpiredCronJobObserverTest.php index fc80f9396caa1..fa5e36ce0a709 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/ClearExpiredCronJobObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/ClearExpiredCronJobObserverTest.php @@ -42,18 +42,24 @@ class ClearExpiredCronJobObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->collectionFactoryMock = - $this->getMock('Magento\Store\Model\ResourceModel\Website\CollectionFactory', ['create'], [], '', false); + $this->getMock( + \Magento\Store\Model\ResourceModel\Website\CollectionFactory::class, + ['create'], + [], + '', + false + ); $this->sessionFactoryMock = $this->getMock( - 'Magento\Persistent\Model\SessionFactory', + \Magento\Persistent\Model\SessionFactory::class, ['create'], [], '', false ); - $this->scheduleMock = $this->getMock('\Magento\Cron\Model\Schedule', [], [], '', false); - $this->sessionMock = $this->getMock('\Magento\Persistent\Model\Session', [], [], '', false); + $this->scheduleMock = $this->getMock(\Magento\Cron\Model\Schedule::class, [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Model\Session::class, [], [], '', false); $this->websiteCollectionMock - = $this->getMock('\Magento\Store\Model\ResourceModel\Website\Collection', [], [], '', false); + = $this->getMock(\Magento\Store\Model\ResourceModel\Website\Collection::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\ClearExpiredCronJobObserver( $this->collectionFactoryMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/CustomerAuthenticatedEventObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/CustomerAuthenticatedEventObserverTest.php index 19b1b06f7df25..cae66b29d1950 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/CustomerAuthenticatedEventObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/CustomerAuthenticatedEventObserverTest.php @@ -36,10 +36,10 @@ class CustomerAuthenticatedEventObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->quoteManagerMock = $this->getMock(\Magento\Persistent\Model\QuoteManager::class, [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); $this->model = new \Magento\Persistent\Observer\CustomerAuthenticatedEventObserver( $this->customerSessionMock, $this->requestMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/EmulateCustomerObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/EmulateCustomerObserverTest.php index 854113a33edc7..40f8bf9d13a6e 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/EmulateCustomerObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/EmulateCustomerObserverTest.php @@ -47,7 +47,7 @@ class EmulateCustomerObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false @@ -61,11 +61,11 @@ protected function setUp() 'setIsCustomerEmulated', '__wakeUp' ]; - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', $methods, [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->addressRepositoryMock = $this->getMock('Magento\Customer\Api\AddressRepositoryInterface'); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, $methods, [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->addressRepositoryMock = $this->getMock(\Magento\Customer\Api\AddressRepositoryInterface::class); $this->model = new \Magento\Persistent\Observer\EmulateCustomerObserver( $this->sessionHelperMock, $this->helperMock, @@ -107,16 +107,16 @@ public function testExecuteWhenSessionPersistAndCustomerNotLoggedIn() $regionId = 4; $postcode = 90210; $sessionMock = $this->getMock( - 'Magento\Persistent\Model\Session', + \Magento\Persistent\Model\Session::class, ['getCustomerId', '__wakeUp'], [], '', false ); $methods = ['getCountryId', 'getRegion', 'getRegionId', 'getPostcode']; - $defaultShippingAddressMock = $this->getMock('Magento\Customer\Model\Address', $methods, [], '', false); - $defaultBillingAddressMock = $this->getMock('Magento\Customer\Model\Address', $methods, [], '', false); - $customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); + $defaultShippingAddressMock = $this->getMock(\Magento\Customer\Model\Address::class, $methods, [], '', false); + $defaultBillingAddressMock = $this->getMock(\Magento\Customer\Model\Address::class, $methods, [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerMock ->expects($this->once()) ->method('getDefaultShipping') diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/EmulateQuoteObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/EmulateQuoteObserverTest.php index cd3ad26d63a3b..038e9db2e670b 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/EmulateQuoteObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/EmulateQuoteObserverTest.php @@ -7,6 +7,9 @@ namespace Magento\Persistent\Test\Unit\Observer; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EmulateQuoteObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -68,21 +71,21 @@ protected function setUp() { $eventMethods = ['getRequest', 'dispatch', '__wakeUp']; $this->customerRepository = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false ); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); - $this->eventMock = $this->getMock('Magento\Framework\Event', $eventMethods, [], '', false); - $this->requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); - $this->customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->eventMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->sessionMock = - $this->getMock('\Magento\Persistent\Model\Session', ['getCustomerId', '__wakeUp'], [], '', false); + $this->getMock(\Magento\Persistent\Model\Session::class, ['getCustomerId', '__wakeUp'], [], '', false); $this->model = new \Magento\Persistent\Observer\EmulateQuoteObserver( $this->sessionHelperMock, $this->helperMock, @@ -152,7 +155,7 @@ public function testExecuteWhenActionIsStop() public function testExecuteWhenShoppingCartIsPersistent() { $customerId = 1; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->helperMock ->expects($this->once()) ->method('canProcess') diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/MakePersistentQuoteGuestObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/MakePersistentQuoteGuestObserverTest.php index 6f39f92cadfff..45cf296757eb7 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/MakePersistentQuoteGuestObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/MakePersistentQuoteGuestObserverTest.php @@ -51,14 +51,14 @@ class MakePersistentQuoteGuestObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->actionMock = $this->getMock('Magento\Persistent\Controller\Index', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); + $this->actionMock = $this->getMock(\Magento\Persistent\Controller\Index::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->quoteManagerMock = $this->getMock(\Magento\Persistent\Model\QuoteManager::class, [], [], '', false); $this->eventManagerMock = - $this->getMock('Magento\Framework\Event', ['getControllerAction', '__wakeUp'], [], '', false); + $this->getMock(\Magento\Framework\Event::class, ['getControllerAction', '__wakeUp'], [], '', false); $this->observerMock ->expects($this->once()) ->method('getEvent') diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/PreventClearCheckoutSessionObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/PreventClearCheckoutSessionObserverTest.php index 8e7c6d373060f..183f9dc724506 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/PreventClearCheckoutSessionObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/PreventClearCheckoutSessionObserverTest.php @@ -52,12 +52,12 @@ class PreventClearCheckoutSessionObserverTest extends \PHPUnit_Framework_TestCas protected function setUp() { $eventMethods = ['getControllerAction', 'dispatch', '__wakeUp']; - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->eventMock = $this->getMock('Magento\Framework\Event', $eventMethods, [], '', false); - $this->actionMock = $this->getMock('Magento\Persistent\Controller\Index', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->eventMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->actionMock = $this->getMock(\Magento\Persistent\Controller\Index::class, [], [], '', false); $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock)); $this->model = new \Magento\Persistent\Observer\PreventClearCheckoutSessionObserver( $this->sessionHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php index 9757383858c64..8bdfe68c88b79 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Persistent\Test\Unit\Observer; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class PreventExpressCheckoutObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -63,37 +66,37 @@ protected function setUp() $this->_observer->setEvent($this->_event); $this->_customerSession = $this->getMockBuilder( - 'Magento\Customer\Model\Session' + \Magento\Customer\Model\Session::class )->disableOriginalConstructor()->setMethods( ['isLoggedIn'] )->getMock(); $this->_persistentSession = $this->getMockBuilder( - 'Magento\Persistent\Helper\Session' + \Magento\Persistent\Helper\Session::class )->disableOriginalConstructor()->setMethods( ['isPersistent'] )->getMock(); $this->_messageManager = $this->getMockBuilder( - 'Magento\Framework\Message\ManagerInterface' + \Magento\Framework\Message\ManagerInterface::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); $this->_url = $this->getMockBuilder( - 'Magento\Framework\UrlInterface' + \Magento\Framework\UrlInterface::class )->disableOriginalConstructor()->setMethods( [] )->getMock(); $this->_expressRedirectHelper = $this->getMockBuilder( - 'Magento\Checkout\Helper\ExpressRedirect' + \Magento\Checkout\Helper\ExpressRedirect::class )->disableOriginalConstructor()->setMethods( ['redirectLogin'] )->getMock(); $this->_model = $helper->getObject( - 'Magento\Persistent\Observer\PreventExpressCheckoutObserver', + \Magento\Persistent\Observer\PreventExpressCheckoutObserver::class, [ 'customerSession' => $this->_customerSession, 'persistentSession' => $this->_persistentSession, @@ -127,7 +130,7 @@ public function testPreventExpressCheckoutEmpty() $request = new \Magento\Framework\DataObject(); $request->setActionName($unexpectedActionName); $expressRedirectMock = $this->getMockBuilder( - 'Magento\Checkout\Controller\Express\RedirectLoginInterface' + \Magento\Checkout\Controller\Express\RedirectLoginInterface::class )->disableOriginalConstructor()->setMethods( [ 'getActionFlagList', diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/RemovePersistentCookieObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/RemovePersistentCookieObserverTest.php index 5c790dbe87f07..5c4b955e8223c 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/RemovePersistentCookieObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/RemovePersistentCookieObserverTest.php @@ -50,12 +50,12 @@ class RemovePersistentCookieObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->persistentMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->sessionModelMock = $this->getMock('Magento\Persistent\Model\Session', [], [], '', false); - $this->persistentDataMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->persistentMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->sessionModelMock = $this->getMock(\Magento\Persistent\Model\Session::class, [], [], '', false); + $this->persistentDataMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->quoteManagerMock = $this->getMock(\Magento\Persistent\Model\QuoteManager::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $this->model = new RemovePersistentCookieObserver( $this->persistentMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/RenewCookieObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/RenewCookieObserverTest.php index 970e8b98945ef..14615ad96f3e8 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/RenewCookieObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/RenewCookieObserverTest.php @@ -48,6 +48,7 @@ class RenewCookieObserverTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject */ protected $sessionMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -55,16 +56,16 @@ class RenewCookieObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->sessionFactoryMock = - $this->getMock('Magento\Persistent\Model\SessionFactory', ['create'], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->getMock(\Magento\Persistent\Model\SessionFactory::class, ['create'], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $eventMethods = ['getRequest', '__wakeUp']; - $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); - $this->sessionMock = $this->getMock('Magento\Persistent\Model\Session', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Model\Session::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\RenewCookieObserver( $this->helperMock, $this->sessionHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SetLoadPersistentQuoteObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SetLoadPersistentQuoteObserverTest.php index 457ff3f5c182d..c3a74e4692a93 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SetLoadPersistentQuoteObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SetLoadPersistentQuoteObserverTest.php @@ -41,11 +41,11 @@ class SetLoadPersistentQuoteObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\SetLoadPersistentQuoteObserver( $this->sessionHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php index fabdbee91c91c..8d96e22610299 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php @@ -53,13 +53,13 @@ protected function setUp() { $quoteMethods = ['setIsActive', 'setIsPersistent', '__wakeUp']; $eventMethods = ['getQuote', '__wakeUp']; - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', $quoteMethods, [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->quoteManagerMock = $this->getMock('Magento\Persistent\Model\QuoteManager', [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, $quoteMethods, [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->quoteManagerMock = $this->getMock(\Magento\Persistent\Model\QuoteManager::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\SetQuotePersistentDataObserver( $this->sessionHelperMock, $this->helperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SetRememberMeCheckedStatusObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SetRememberMeCheckedStatusObserverTest.php index 051c015180a6c..9d6eb04308319 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SetRememberMeCheckedStatusObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SetRememberMeCheckedStatusObserverTest.php @@ -46,14 +46,20 @@ class SetRememberMeCheckedStatusObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); $checkoutMethods = ['setRememberMeChecked', '__wakeUp']; - $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', $checkoutMethods, [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->checkoutSessionMock = $this->getMock( + \Magento\Checkout\Model\Session::class, + $checkoutMethods, + [], + '', + false + ); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $eventMethods = ['getRequest', '__wakeUp']; - $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); $this->model = new \Magento\Persistent\Observer\SetRememberMeCheckedStatusObserver( $this->helperMock, $this->sessionHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php index 7338cf16c68af..ae66fc8a44630 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php @@ -43,6 +43,7 @@ class SynchronizePersistentInfoObserverTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject */ protected $sessionMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -50,14 +51,14 @@ class SynchronizePersistentInfoObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $eventMethods = ['getRequest', '__wakeUp']; - $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); - $this->sessionMock = $this->getMock('Magento\Persistent\Model\Session', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Model\Session::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\SynchronizePersistentInfoObserver( $this->helperMock, $this->sessionHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentOnLogoutObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentOnLogoutObserverTest.php index 78eb4a490fb14..fa1c17a3df1ce 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentOnLogoutObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentOnLogoutObserverTest.php @@ -34,7 +34,6 @@ class SynchronizePersistentOnLogoutObserverTest extends \PHPUnit_Framework_TestC */ protected $observerMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -42,12 +41,12 @@ class SynchronizePersistentOnLogoutObserverTest extends \PHPUnit_Framework_TestC protected function setUp() { - $this->helperMock = $this->getMock('Magento\Persistent\Helper\Data', [], [], '', false); - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); + $this->helperMock = $this->getMock(\Magento\Persistent\Helper\Data::class, [], [], '', false); + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); $this->sessionFactoryMock = - $this->getMock('Magento\Persistent\Model\SessionFactory', ['create'], [], '', false); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->sessionMock = $this->getMock('Magento\Persistent\Model\Session', [], [], '', false); + $this->getMock(\Magento\Persistent\Model\SessionFactory::class, ['create'], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Model\Session::class, [], [], '', false); $this->model = new \Magento\Persistent\Observer\SynchronizePersistentOnLogoutObserver( $this->helperMock, $this->sessionHelperMock, diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/UpdateCustomerCookiesObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/UpdateCustomerCookiesObserverTest.php index c162d8343ca02..931fb64164f7a 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/UpdateCustomerCookiesObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/UpdateCustomerCookiesObserverTest.php @@ -52,18 +52,18 @@ protected function setUp() { $eventMethods = ['getCustomerCookies', '__wakeUp']; $sessionMethods = ['getId', 'getGroupId', 'getCustomerId', '__wakeUp']; - $this->sessionHelperMock = $this->getMock('Magento\Persistent\Helper\Session', [], [], '', false); - $this->customerRepository = $this->getMockForAbstractClass( - '\Magento\Customer\Api\CustomerRepositoryInterface', + $this->sessionHelperMock = $this->getMock(\Magento\Persistent\Helper\Session::class, [], [], '', false); + $this->customerRepository = $this->getMockForAbstractClass( + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false ); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $this->eventManagerMock = $this->getMock('\Magento\Framework\Event', $eventMethods, [], '', false); - $this->sessionMock = $this->getMock('Magento\Persistent\Model\Session', $sessionMethods, [], '', false); - $this->customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event::class, $eventMethods, [], '', false); + $this->sessionMock = $this->getMock(\Magento\Persistent\Model\Session::class, $sessionMethods, [], '', false); + $this->customerMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false @@ -86,7 +86,8 @@ public function testExecuteWhenCustomerCookieExist() $customerId = 1; $customerGroupId = 2; $cookieMock = - $this->getMock('Magento\Framework\DataObject', + $this->getMock( + \Magento\Framework\DataObject::class, ['setCustomerId', 'setCustomerGroupId', '__wakeUp'], [], '', false); $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); diff --git a/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php b/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php index 21fd41f9338a5..21ec42f7654b3 100644 --- a/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php +++ b/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php @@ -100,7 +100,7 @@ public function get($cartId) $this->dataObjectHelper->populateWithArray( $quoteTotals, $addressTotalsData, - '\Magento\Quote\Api\Data\TotalsInterface' + \Magento\Quote\Api\Data\TotalsInterface::class ); $items = []; foreach ($quote->getAllVisibleItems() as $index => $item) { diff --git a/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php b/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php index 1fd529a6b8a7f..3cce0b07dcc41 100644 --- a/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php +++ b/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php @@ -75,7 +75,7 @@ public function modelToDataObject($item) $this->dataObjectHelper->populateWithArray( $itemsData, $items, - '\Magento\Quote\Api\Data\TotalsItemInterface' + \Magento\Quote\Api\Data\TotalsItemInterface::class ); return $itemsData; } diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index ddaf1e5f96dc3..483dd37ba370d 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -487,7 +487,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote::class); } /** @@ -962,7 +962,7 @@ public function setCustomer(\Magento\Customer\Api\Data\CustomerInterface $custom $this->extensibleDataObjectConverter->toFlatArray( $customer, [], - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ) ); $customer->setAddresses($origAddresses); diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index 6684d4c04d5e8..2bb516dc642c0 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -347,7 +347,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\Address'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Address::class); } /** @@ -512,7 +512,7 @@ public function exportCustomerAddress() $this->dataObjectHelper->populateWithArray( $addressDataObject, $customerAddressData, - '\Magento\Customer\Api\Data\AddressInterface' + \Magento\Customer\Api\Data\AddressInterface::class ); return $addressDataObject; } @@ -1056,7 +1056,7 @@ public function addTotal($total) $addressTotal = null; if (is_array($total)) { /** @var \Magento\Quote\Model\Quote\Address\Total $addressTotal */ - $addressTotal = $this->_addressTotalFactory->create('Magento\Quote\Model\Quote\Address\Total'); + $addressTotal = $this->_addressTotalFactory->create(\Magento\Quote\Model\Quote\Address\Total::class); $addressTotal->setData($total); } elseif ($total instanceof \Magento\Quote\Model\Quote\Address\Total) { $addressTotal = $total; diff --git a/app/code/Magento/Quote/Model/Quote/Address/Item.php b/app/code/Magento/Quote/Model/Quote/Address/Item.php index fcd4fdd4eab0a..878ebfa361f75 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Address/Item.php @@ -105,7 +105,7 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\Address\Item'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Address\Item::class); } /** diff --git a/app/code/Magento/Quote/Model/Quote/Address/Rate.php b/app/code/Magento/Quote/Model/Quote/Address/Rate.php index 74033fd24b460..2c8242762639c 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/Rate.php +++ b/app/code/Magento/Quote/Model/Quote/Address/Rate.php @@ -47,7 +47,7 @@ class Rate extends AbstractModel */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\Address\Rate'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Address\Rate::class); } /** diff --git a/app/code/Magento/Quote/Model/Quote/Address/RateCollectorInterfaceFactory.php b/app/code/Magento/Quote/Model/Quote/Address/RateCollectorInterfaceFactory.php index f5208ccbab45e..a807a03d99d3e 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/RateCollectorInterfaceFactory.php +++ b/app/code/Magento/Quote/Model/Quote/Address/RateCollectorInterfaceFactory.php @@ -32,7 +32,7 @@ class RateCollectorInterfaceFactory */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Quote\Model\Quote\Address\RateCollectorInterface' + $instanceName = \Magento\Quote\Model\Quote\Address\RateCollectorInterface::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/app/code/Magento/Quote/Model/Quote/Address/ToOrder.php b/app/code/Magento/Quote/Model/Quote/Address/ToOrder.php index 1c03469755ff8..205eede2ec361 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/ToOrder.php +++ b/app/code/Magento/Quote/Model/Quote/Address/ToOrder.php @@ -74,12 +74,17 @@ public function convert(Address $object, $data = []) $this->dataObjectHelper->populateWithArray( $order, array_merge($orderData, $data), - '\Magento\Sales\Api\Data\OrderInterface' + \Magento\Sales\Api\Data\OrderInterface::class ); $order->setStoreId($object->getQuote()->getStoreId()) ->setQuoteId($object->getQuote()->getId()) ->setIncrementId($object->getQuote()->getReservedOrderId()); - $this->objectCopyService->copyFieldsetToTarget('sales_convert_quote', 'to_order', $object->getQuote(), $order); + $this->objectCopyService->copyFieldsetToTarget( + 'sales_convert_quote', + 'to_order', + $object->getQuote(), + $order + ); $this->eventManager->dispatch( 'sales_convert_quote_to_order', ['order' => $order, 'quote' => $object->getQuote()] diff --git a/app/code/Magento/Quote/Model/Quote/Address/ToOrderAddress.php b/app/code/Magento/Quote/Model/Quote/Address/ToOrderAddress.php index 535f2efebea08..d71e797921642 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/ToOrderAddress.php +++ b/app/code/Magento/Quote/Model/Quote/Address/ToOrderAddress.php @@ -64,7 +64,7 @@ public function convert(Address $object, $data = []) $this->dataObjectHelper->populateWithArray( $orderAddress, array_merge($orderAddressData, $data), - '\Magento\Sales\Api\Data\OrderAddressInterface' + \Magento\Sales\Api\Data\OrderAddressInterface::class ); return $orderAddress; diff --git a/app/code/Magento/Quote/Model/Quote/Item.php b/app/code/Magento/Quote/Model/Quote/Item.php index d88500c95c0ae..ac3a1109d7172 100644 --- a/app/code/Magento/Quote/Model/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Item.php @@ -234,7 +234,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\Item'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Item::class); } /** diff --git a/app/code/Magento/Quote/Model/Quote/Item/Option.php b/app/code/Magento/Quote/Model/Quote/Item/Option.php index 3f61b52433273..c51d0daca31fc 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/Option.php +++ b/app/code/Magento/Quote/Model/Quote/Item/Option.php @@ -38,7 +38,7 @@ class Option extends \Magento\Framework\Model\AbstractModel implements */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\Item\Option'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Item\Option::class); } /** diff --git a/app/code/Magento/Quote/Model/Quote/Item/ToOrderItem.php b/app/code/Magento/Quote/Model/Quote/Item/ToOrderItem.php index 7d04d2877125e..dcb6a5d41c1c8 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/ToOrderItem.php +++ b/app/code/Magento/Quote/Model/Quote/Item/ToOrderItem.php @@ -78,7 +78,7 @@ public function convert($item, $data = []) $this->dataObjectHelper->populateWithArray( $orderItem, array_merge($orderItemData, $data), - '\Magento\Sales\Api\Data\OrderItemInterface' + \Magento\Sales\Api\Data\OrderItemInterface::class ); $orderItem->setProductOptions($options); if ($item->getParentItem()) { diff --git a/app/code/Magento/Quote/Model/Quote/Payment.php b/app/code/Magento/Quote/Model/Quote/Payment.php index cdd295114c3d5..616d0f31be5b8 100644 --- a/app/code/Magento/Quote/Model/Quote/Payment.php +++ b/app/code/Magento/Quote/Model/Quote/Payment.php @@ -106,7 +106,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\Payment'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Payment::class); } /** diff --git a/app/code/Magento/Quote/Model/Quote/Payment/ToOrderPayment.php b/app/code/Magento/Quote/Model/Quote/Payment/ToOrderPayment.php index be602529cb321..79db47646bf17 100644 --- a/app/code/Magento/Quote/Model/Quote/Payment/ToOrderPayment.php +++ b/app/code/Magento/Quote/Model/Quote/Payment/ToOrderPayment.php @@ -64,7 +64,7 @@ public function convert(Payment $object, $data = []) $this->dataObjectHelper->populateWithArray( $orderPayment, array_merge($paymentData, $data), - '\Magento\Sales\Api\Data\OrderPaymentInterface' + \Magento\Sales\Api\Data\OrderPaymentInterface::class ); $orderPayment->setAdditionalInformation( array_merge( diff --git a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php index b9e82f63719ef..a78f09f00edbe 100644 --- a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php +++ b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php @@ -121,7 +121,7 @@ public function collectQuoteTotals(\Magento\Quote\Model\Quote $quote) public function collect(\Magento\Quote\Model\Quote $quote) { /** @var \Magento\Quote\Model\Quote\Address\Total $total */ - $total = $this->totalFactory->create('Magento\Quote\Model\Quote\Address\Total'); + $total = $this->totalFactory->create(\Magento\Quote\Model\Quote\Address\Total::class); $this->eventManager->dispatch( 'sales_quote_collect_totals_before', @@ -250,7 +250,7 @@ public function collectAddressTotals( $shippingAssignment->setItems($address->getAllItems()); /** @var \Magento\Quote\Model\Quote\Address\Total $total */ - $total = $this->totalFactory->create('Magento\Quote\Model\Quote\Address\Total'); + $total = $this->totalFactory->create(\Magento\Quote\Model\Quote\Address\Total::class); $this->eventManager->dispatch( 'sales_quote_address_collect_totals_before', [ diff --git a/app/code/Magento/Quote/Model/Quote/TotalsReader.php b/app/code/Magento/Quote/Model/Quote/TotalsReader.php index 55bb0fe6e9ea2..bd5e8c75fef24 100644 --- a/app/code/Magento/Quote/Model/Quote/TotalsReader.php +++ b/app/code/Magento/Quote/Model/Quote/TotalsReader.php @@ -14,6 +14,7 @@ class TotalsReader * @var \Magento\Quote\Model\Quote\Address\TotalFactory */ protected $totalFactory; + /** * @var \Magento\Quote\Model\Quote\TotalsCollectorList */ @@ -39,7 +40,7 @@ public function __construct( public function fetch(\Magento\Quote\Model\Quote $quote, array $total) { $output = []; - $total = $this->totalFactory->create('Magento\Quote\Model\Quote\Address\Total')->setData($total); + $total = $this->totalFactory->create(\Magento\Quote\Model\Quote\Address\Total::class)->setData($total); /** @var ReaderInterface $reader */ foreach ($this->collectorList->getCollectors($quote->getStoreId()) as $reader) { $data = $reader->fetch($quote, $total); @@ -72,12 +73,14 @@ protected function convert($total) if (count(array_column($total, 'code')) > 0) { $totals = []; foreach ($total as $item) { - $totals[] = $this->totalFactory->create('Magento\Quote\Model\Quote\Address\Total')->setData($item); + $totals[] = $this->totalFactory->create( + \Magento\Quote\Model\Quote\Address\Total::class + )->setData($item); } return $totals; } - return $this->totalFactory->create('Magento\Quote\Model\Quote\Address\Total')->setData($total); + return $this->totalFactory->create(\Magento\Quote\Model\Quote\Address\Total::class)->setData($total); } /** diff --git a/app/code/Magento/Quote/Model/QuoteIdMask.php b/app/code/Magento/Quote/Model/QuoteIdMask.php index 2873fb7412448..1fd1ad593935b 100644 --- a/app/code/Magento/Quote/Model/QuoteIdMask.php +++ b/app/code/Magento/Quote/Model/QuoteIdMask.php @@ -46,7 +46,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask'); + $this->_init(\Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask::class); } /** diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 2325ccaad612a..560c1340e9f75 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -433,13 +433,13 @@ protected function submitQuote(QuoteEntity $quote, $orderData = []) $quote->reserveOrderId(); if ($quote->isVirtual()) { $this->dataObjectHelper->mergeDataObjects( - '\Magento\Sales\Api\Data\OrderInterface', + \Magento\Sales\Api\Data\OrderInterface::class, $order, $this->quoteAddressToOrder->convert($quote->getBillingAddress(), $orderData) ); } else { $this->dataObjectHelper->mergeDataObjects( - '\Magento\Sales\Api\Data\OrderInterface', + \Magento\Sales\Api\Data\OrderInterface::class, $order, $this->quoteAddressToOrder->convert($quote->getShippingAddress(), $orderData) ); diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Collection.php index 49e26036f54b4..753bc87146daa 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Collection.php @@ -33,7 +33,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Address', 'Magento\Quote\Model\ResourceModel\Quote\Address'); + $this->_init( + \Magento\Quote\Model\Quote\Address::class, + \Magento\Quote\Model\ResourceModel\Quote\Address::class + ); } /** diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Item/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Item/Collection.php index 896d0f4341f8a..9bfdef1f38ffb 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Item/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Item/Collection.php @@ -19,7 +19,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Address\Item', 'Magento\Quote\Model\ResourceModel\Quote\Address\Item'); + $this->_init( + \Magento\Quote\Model\Quote\Address\Item::class, + \Magento\Quote\Model\ResourceModel\Quote\Address\Item::class + ); } /** diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Rate/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Rate/Collection.php index 5ec86a298739e..8af1d84ac1448 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Rate/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Address/Rate/Collection.php @@ -58,7 +58,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Address\Rate', 'Magento\Quote\Model\ResourceModel\Quote\Address\Rate'); + $this->_init( + \Magento\Quote\Model\Quote\Address\Rate::class, + \Magento\Quote\Model\ResourceModel\Quote\Address\Rate::class + ); } /** diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Collection.php index 57325cb42b543..2a9cc2307dbf6 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Collection.php @@ -19,6 +19,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote', 'Magento\Quote\Model\ResourceModel\Quote'); + $this->_init(\Magento\Quote\Model\Quote::class, \Magento\Quote\Model\ResourceModel\Quote::class); } } diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php index 963114b0b1ae1..82544a72aff0f 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php @@ -7,6 +7,8 @@ /** * Quote item resource collection + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionControl\Collection { @@ -85,7 +87,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Item', 'Magento\Quote\Model\ResourceModel\Quote\Item'); + $this->_init(\Magento\Quote\Model\Quote\Item::class, \Magento\Quote\Model\ResourceModel\Quote\Item::class); } /** diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Option/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Option/Collection.php index c86b427244d07..15e93a0ceaa44 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Option/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Option/Collection.php @@ -35,7 +35,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Item\Option', 'Magento\Quote\Model\ResourceModel\Quote\Item\Option'); + $this->_init( + \Magento\Quote\Model\Quote\Item\Option::class, + \Magento\Quote\Model\ResourceModel\Quote\Item\Option::class + ); } /** diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Payment/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Payment/Collection.php index ccaf02fd060b4..2da6f3967a8a1 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Payment/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Payment/Collection.php @@ -46,7 +46,10 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Payment', 'Magento\Quote\Model\ResourceModel\Quote\Payment'); + $this->_init( + \Magento\Quote\Model\Quote\Payment::class, + \Magento\Quote\Model\ResourceModel\Quote\Payment::class + ); } /** diff --git a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php index 96e3896b61b02..3219b137b4775 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php @@ -10,6 +10,9 @@ use \Magento\Quote\Model\BillingAddressManagement; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase { /** @@ -43,12 +46,12 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->validatorMock = $this->getMock('\Magento\Quote\Model\QuoteAddressValidator', [], [], '', false); - $this->addressRepository = $this->getMock('\Magento\Customer\Api\AddressRepositoryInterface'); - $logger = $this->getMock('\Psr\Log\LoggerInterface'); + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->validatorMock = $this->getMock(\Magento\Quote\Model\QuoteAddressValidator::class, [], [], '', false); + $this->addressRepository = $this->getMock(\Magento\Customer\Api\AddressRepositoryInterface::class); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class); $this->model = $this->objectManager->getObject( - '\Magento\Quote\Model\BillingAddressManagement', + \Magento\Quote\Model\BillingAddressManagement::class, [ 'quoteRepository' => $this->quoteRepositoryMock, 'addressValidator' => $this->validatorMock, @@ -63,11 +66,11 @@ protected function setUp() */ public function testGetAddress() { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once())->method('getActive') ->with('cartId')->will($this->returnValue($quoteMock)); - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); $this->assertEquals($addressMock, $this->model->get('cartId')); @@ -81,8 +84,8 @@ public function testGetAddress() public function testSetAddressValidationFailed() { $this->markTestSkipped('MAGETWO-48531'); - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') ->with('cartId') @@ -107,13 +110,13 @@ public function testSetAddress() $customerAddressId = 10; $address = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['setSaveInAddressBook', 'getCustomerAddressId', 'getSaveInAddressBook'], [], '', false ); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') @@ -126,13 +129,13 @@ public function testSetAddress() $address->expects($this->once())->method('getCustomerAddressId')->willReturn($customerAddressId); $address->expects($this->once())->method('getSaveInAddressBook')->willReturn(1); - $customerAddressMock = $this->getMock('Magento\Customer\Api\Data\AddressInterface', [], [], '', false); + $customerAddressMock = $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class, [], [], '', false); $this->addressRepository->expects($this->once()) ->method('getById') ->with($customerAddressId) ->willReturn($customerAddressMock); - $quoteBillingAddress = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteBillingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $quoteBillingAddress->expects($this->once())->method('getId')->will($this->returnValue($addressId)); $quoteMock->expects($this->exactly(2))->method('getBillingAddress')->willReturn($quoteBillingAddress); $quoteBillingAddress->expects($this->once()) @@ -141,7 +144,7 @@ public function testSetAddress() ->willReturnSelf(); $quoteShippingAddress = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['setSaveInAddressBook', 'setSameAsBilling', 'setCollectShippingRates', 'importCustomerAddressData'], [], '', @@ -175,9 +178,9 @@ public function testSetAddress() public function testSetAddressWithInabilityToSaveQuote() { $this->markTestSkipped('MAGETWO-48531'); - $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $address = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false, false); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') ->with('cartId') diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php index f6435b4bf3142..426e2e00da77c 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php @@ -39,11 +39,23 @@ class CartTotalManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->shippingMock = $this->getMock('\Magento\Quote\Model\ShippingMethodManagement', [], [], '', false); - $this->paymentMock = $this->getMock('\Magento\Quote\Api\PaymentMethodManagementInterface', [], [], '', false); - $this->cartTotalMock = $this->getMock('\Magento\Quote\Api\CartTotalRepositoryInterface', [], [], '', false); + $this->shippingMock = $this->getMock(\Magento\Quote\Model\ShippingMethodManagement::class, [], [], '', false); + $this->paymentMock = $this->getMock( + \Magento\Quote\Api\PaymentMethodManagementInterface::class, + [], + [], + '', + false + ); + $this->cartTotalMock = $this->getMock( + \Magento\Quote\Api\CartTotalRepositoryInterface::class, + [], + [], + '', + false + ); $this->model = $this->objectManager->getObject( - '\Magento\Quote\Model\Cart\CartTotalManagement', + \Magento\Quote\Model\Cart\CartTotalManagement::class, [ 'shippingMethodManagement' => $this->shippingMock, 'paymentMethodManagement' => $this->paymentMock, @@ -58,7 +70,7 @@ public function testCollectTotals() $shippingCarrierCode = 'careful_carrier'; $shippingMethodCode = 'drone_delivery'; $total = 3322.31; - $paymentDataMock = $this->getMock('\Magento\Quote\Api\Data\PaymentInterface', [], [], '', false); + $paymentDataMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class, [], [], '', false); $this->shippingMock->expects($this->once()) ->method('set') @@ -80,7 +92,7 @@ public function testCollectTotalsNoShipping($shippingCarrierCode, $shippingMetho { $cartId = 123; $total = 3322.31; - $paymentDataMock = $this->getMock('\Magento\Quote\Api\Data\PaymentInterface', [], [], '', false); + $paymentDataMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class, [], [], '', false); $this->shippingMock->expects($this->never()) ->method('set') diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php index d47748c1df3e6..eeceebcd042de 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php @@ -8,6 +8,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CartTotalRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -64,14 +67,14 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); $this->totalsFactoryMock = $this->getMock( - 'Magento\Quote\Api\Data\TotalsInterfaceFactory', + \Magento\Quote\Api\Data\TotalsInterfaceFactory::class, ['create'], [], '', false ); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'isVirtual', 'getShippingAddress', @@ -85,27 +88,33 @@ protected function setUp() '', false ); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->addressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getData', 'getTotals'], [], '', false ); - $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); $this->converterMock = $this->getMock( - 'Magento\Quote\Model\Cart\Totals\ItemConverter', + \Magento\Quote\Model\Cart\Totals\ItemConverter::class, [], [], '', false ); - $this->couponServiceMock = $this->getMock('\Magento\Quote\Api\CouponManagementInterface'); - $this->totalsConverterMock = $this->getMock('\Magento\Quote\Model\Cart\TotalsConverter', [], [], '', false); + $this->couponServiceMock = $this->getMock(\Magento\Quote\Api\CouponManagementInterface::class); + $this->totalsConverterMock = $this->getMock( + \Magento\Quote\Model\Cart\TotalsConverter::class, + [], + [], + '', + false + ); $this->model = new \Magento\Quote\Model\Cart\CartTotalRepository( $this->totalsFactoryMock, @@ -128,7 +137,7 @@ public function testGet($isVirtual, $getAddressType) $itemsQty = 100; $coupon = 'coupon'; $addressTotals = ['address' => 'totals']; - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $visibleItems = [ 11 => $itemMock, ]; @@ -151,7 +160,7 @@ public function testGet($isVirtual, $getAddressType) $this->addressMock->expects($this->any())->method('getData')->willReturn($addressTotals); $this->addressMock->expects($this->once())->method('getTotals')->willReturn($addressTotals); - $totalsMock = $this->getMock('\Magento\Quote\Api\Data\TotalsInterface'); + $totalsMock = $this->getMock(\Magento\Quote\Api\Data\TotalsInterface::class); $this->totalsFactoryMock->expects($this->once())->method('create')->willReturn($totalsMock); $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray'); $this->converterMock->expects($this->once()) @@ -159,7 +168,7 @@ public function testGet($isVirtual, $getAddressType) ->with($itemMock) ->willReturn($itemArray); - $totalSegmentsMock = $this->getMock('\Magento\Quote\Api\Data\TotalSegmentInterface'); + $totalSegmentsMock = $this->getMock(\Magento\Quote\Api\Data\TotalSegmentInterface::class); $this->totalsConverterMock->expects($this->once()) ->method('process') ->with($addressTotals) diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php index 7823cc86eb97f..fcddc737c4827 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php @@ -56,16 +56,17 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->shippingMethodDataFactoryMock = $this->getMock( - '\Magento\Quote\Api\Data\ShippingMethodInterfaceFactory', + $this->shippingMethodDataFactoryMock = $this->getMock( + \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory::class, ['create'], [], '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); - $this->currencyMock = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); - $this->shippingMethodMock = $this->getMock('\Magento\Quote\Model\Cart\ShippingMethod', + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->currencyMock = $this->getMock(\Magento\Directory\Model\Currency::class, [], [], '', false); + $this->shippingMethodMock = $this->getMock( + \Magento\Quote\Model\Cart\ShippingMethod::class, [ 'create', 'setCarrierCode', @@ -81,7 +82,8 @@ protected function setUp() [], '', false); - $this->rateModelMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', + $this->rateModelMock = $this->getMock( + \Magento\Quote\Model\Quote\Address\Rate::class, [ 'getPrice', 'getCarrier', @@ -94,11 +96,11 @@ protected function setUp() [], '', false); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->taxHelper = $this->getMock('\Magento\Tax\Helper\Data', [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->taxHelper = $this->getMock(\Magento\Tax\Helper\Data::class, [], [], '', false); - $this->converter = $objectManager->getObject( - 'Magento\Quote\Model\Cart\ShippingMethodConverter', + $this->converter = $objectManager->getObject( + \Magento\Quote\Model\Cart\ShippingMethodConverter::class, [ 'shippingMethodDataFactory' => $this->shippingMethodDataFactoryMock, 'storeManager' => $this->storeManagerMock, @@ -134,8 +136,8 @@ public function testModelToDataObject() $this->rateModelMock->expects($this->once()) ->method('getMethodTitle')->will($this->returnValue('METHOD_TITLE')); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->rateModelMock->expects($this->exactly(4))->method('getAddress')->willReturn($addressMock); $addressMock->expects($this->exactly(2))->method('getQuote')->willReturn($quoteMock); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/Totals/ItemConverterTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/Totals/ItemConverterTest.php index 0d18bd4c03221..52198424cda9f 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/Totals/ItemConverterTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/Totals/ItemConverterTest.php @@ -35,11 +35,17 @@ class ItemConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configPoolMock = $this->getMock('Magento\Catalog\Helper\Product\ConfigurationPool', [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); - $this->dataObjectHelperMock = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->configPoolMock = $this->getMock( + \Magento\Catalog\Helper\Product\ConfigurationPool::class, + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->dataObjectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $this->totalsFactoryMock = $this->getMock( - 'Magento\Quote\Api\Data\TotalsItemInterfaceFactory', + \Magento\Quote\Api\Data\TotalsItemInterfaceFactory::class, ['create'], [], '', @@ -58,12 +64,12 @@ public function testModelToDataObject() { $productType = 'simple'; - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $itemMock->expects($this->once())->method('toArray')->will($this->returnValue(['options' => []])); $itemMock->expects($this->any())->method('getProductType')->will($this->returnValue($productType)); - $simpleConfigMock = $this->getMock('Magento\Catalog\Helper\Product\Configuration', [], [], '', false); - $defaultConfigMock = $this->getMock('Magento\Catalog\Helper\Product\Configuration', [], [], '', false); + $simpleConfigMock = $this->getMock(\Magento\Catalog\Helper\Product\Configuration::class, [], [], '', false); + $defaultConfigMock = $this->getMock(\Magento\Catalog\Helper\Product\Configuration::class, [], [], '', false); $this->configPoolMock->expects($this->any())->method('getByProductType') ->will($this->returnValueMap([['simple', $simpleConfigMock], ['default', $defaultConfigMock]])); @@ -84,7 +90,7 @@ public function testModelToDataObject() 'options' => '{"1":{"data":"optionsData","label":"option1"},"2":{"data":"optionsData","label":"option2"}}' ]; $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray') - ->with(null, $expectedData, '\Magento\Quote\Api\Data\TotalsItemInterface'); + ->with(null, $expectedData, \Magento\Quote\Api\Data\TotalsItemInterface::class); $this->model->modelToDataObject($itemMock); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php index 8cded011e8873..e5d9a5c158992 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php @@ -40,10 +40,10 @@ class CouponManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->quoteMock = $this->getMock( + \Magento\Quote\Model\Quote::class, [ 'getItemsCount', 'setCouponCode', @@ -57,8 +57,8 @@ protected function setUp() '', false ); - $this->quoteAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + $this->quoteAddressMock = $this->getMock( + \Magento\Quote\Model\Quote\Address::class, [ 'setCollectShippingRates', '__wakeup' @@ -76,7 +76,7 @@ public function testGetCoupon() $cartId = 11; $couponCode = 'test_coupon_code'; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', ['getCouponCode', '__wakeup'], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getCouponCode', '__wakeup'], [], '', false); $quoteMock->expects($this->any())->method('getCouponCode')->will($this->returnValue($couponCode)); $this->quoteRepositoryMock->expects($this->once()) diff --git a/app/code/Magento/Quote/Test/Unit/Model/CustomerManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/CustomerManagementTest.php index c77b0ae69d0c7..600bf1723a5c0 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/CustomerManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/CustomerManagementTest.php @@ -53,7 +53,7 @@ class CustomerManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false, @@ -62,7 +62,7 @@ protected function setUp() ['getById'] ); $this->customerAddressRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AddressRepositoryInterface', + \Magento\Customer\Api\AddressRepositoryInterface::class, [], '', false, @@ -71,7 +71,7 @@ protected function setUp() ['getById'] ); $this->accountManagementMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\AccountManagementInterface', + \Magento\Customer\Api\AccountManagementInterface::class, [], '', false, @@ -80,21 +80,21 @@ protected function setUp() [] ); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getId', 'getCustomer', 'getBillingAddress', 'getShippingAddress', 'setCustomer', 'getPasswordHash'], [], '', false ); $this->quoteAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [], [], '', false ); $this->customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false, @@ -103,7 +103,7 @@ protected function setUp() ['getId', 'getDefaultBilling'] ); $this->customerAddressMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false, diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestBillingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestBillingAddressManagementTest.php index c2ecc4589ea86..d38c248052531 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestBillingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestBillingAddressManagementTest.php @@ -49,9 +49,9 @@ class GuestBillingAddressManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $this->addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->billingAddressManagementMock = $this->getMock( - 'Magento\Quote\Api\BillingAddressManagementInterface', + \Magento\Quote\Api\BillingAddressManagementInterface::class, [], [], '', @@ -68,7 +68,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestBillingAddressManagement', + \Magento\Quote\Model\GuestCart\GuestBillingAddressManagement::class, [ 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, 'billingAddressManagement' => $this->billingAddressManagementMock diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php index 5c284e0da949a..2b6f378e7e31d 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php @@ -68,7 +68,7 @@ protected function setUp() ->method('getMaskedId') ->willReturn($this->maskedCartId); - $this->quoteItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $this->quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $this->quoteItemMock->expects($this->any()) ->method('getItemId') ->willReturn($this->maskedCartId); @@ -79,10 +79,10 @@ protected function setUp() ->method('setQuoteId') ->with($this->cartId); - $this->cartItemRepositoryMock = $this->getMock('\Magento\Quote\Api\CartItemRepositoryInterface'); + $this->cartItemRepositoryMock = $this->getMock(\Magento\Quote\Api\CartItemRepositoryInterface::class); $this->guestCartItemRepository = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestCartItemRepository', + \Magento\Quote\Model\GuestCart\GuestCartItemRepository::class, [ 'repository' => $this->cartItemRepositoryMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, @@ -107,7 +107,7 @@ public function testSave() */ public function testGetList() { - $itemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $itemMock->expects($this->any()) ->method('setQuoteId') ->with($this->maskedCartId); diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php index 3df378dc2df42..5f13a802a6705 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php @@ -49,7 +49,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->quoteManagementMock = $this->getMockForAbstractClass( - 'Magento\Quote\Api\CartManagementInterface', + \Magento\Quote\Api\CartManagementInterface::class, [], '', false, @@ -58,24 +58,24 @@ protected function setUp() [] ); $this->quoteIdMaskFactoryMock = $this->getMock( - 'Magento\Quote\Model\QuoteIdMaskFactory', + \Magento\Quote\Model\QuoteIdMaskFactory::class, ['create'], [], '', false ); $this->quoteIdMaskMock = $this->getMock( - 'Magento\Quote\Model\QuoteIdMask', + \Magento\Quote\Model\QuoteIdMask::class, ['getQuoteId', 'getMaskedId', 'load', 'save', 'setQuoteId'], [], '', false ); - $this->cartRepositoryMock = $this->getMock('Magento\Quote\Api\CartRepositoryInterface'); + $this->cartRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->quoteMock = $this->getMockForAbstractClass( - 'Magento\Quote\Api\Data\CartInterface', + \Magento\Quote\Api\Data\CartInterface::class, [], '', false, @@ -85,7 +85,7 @@ protected function setUp() ); $this->guestCartManagement = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestCartManagement', + \Magento\Quote\Model\GuestCart\GuestCartManagement::class, [ 'quoteManagement' => $this->quoteManagementMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartRepositoryTest.php index b72501554743b..72fc16b7c4fd9 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartRepositoryTest.php @@ -46,8 +46,14 @@ class GuestCartRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('Magento\Quote\Api\CartRepositoryInterface', [], [], '', false); - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock = $this->getMock( + \Magento\Quote\Api\CartRepositoryInterface::class, + [], + [], + '', + false + ); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; $this->cartId = 123; @@ -59,7 +65,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestCartRepository', + \Magento\Quote\Model\GuestCart\GuestCartRepository::class, [ 'quoteRepository' => $this->quoteRepositoryMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php index de50a0eadada1..702bf995a2022 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php @@ -39,13 +39,13 @@ public function __construct(\PHPUnit_Framework_TestCase $testCase) public function mockQuoteIdMask($maskedCartId, $cartId) { $quoteIdMaskMock = $this->testCase->getMock( - 'Magento\Quote\Model\QuoteIdMask', + \Magento\Quote\Model\QuoteIdMask::class, ['load', 'getQuoteId', 'getMaskedId'], [], '', false ); - $quoteIdMaskFactoryMock = $this->testCase->getMockBuilder('Magento\Quote\Model\QuoteIdMaskFactory') + $quoteIdMaskFactoryMock = $this->testCase->getMockBuilder(\Magento\Quote\Model\QuoteIdMaskFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php index 1f4eb01ca4d02..0c6416c9b0846 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php @@ -47,7 +47,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->cartTotalRepository = $this->getMockBuilder('Magento\Quote\Api\CartTotalRepositoryInterface') + $this->cartTotalRepository = $this->getMockBuilder(\Magento\Quote\Api\CartTotalRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -61,7 +61,7 @@ protected function setUp() ); $this->model = $this->objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestCartTotalRepository', + \Magento\Quote\Model\GuestCart\GuestCartTotalRepository::class, [ 'cartTotalRepository' => $this->cartTotalRepository, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCouponManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCouponManagementTest.php index ec637ec3c370e..d6febdf61877a 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCouponManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCouponManagementTest.php @@ -46,7 +46,13 @@ class GuestCouponManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->couponManagementMock = $this->getMock('Magento\Quote\Api\CouponManagementInterface', [], [], '', false); + $this->couponManagementMock = $this->getMock( + \Magento\Quote\Api\CouponManagementInterface::class, + [], + [], + '', + false + ); $this->couponCode = 'test_coupon_code'; $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; @@ -59,7 +65,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestCouponManagement', + \Magento\Quote\Model\GuestCart\GuestCouponManagement::class, [ 'couponManagement' => $this->couponManagementMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestPaymentMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestPaymentMethodManagementTest.php index 73f29975f0b53..b93bdb5ac1dcd 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestPaymentMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestPaymentMethodManagementTest.php @@ -46,13 +46,13 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->paymentMethodManagementMock = $this->getMock( - 'Magento\Quote\Api\PaymentMethodManagementInterface', + \Magento\Quote\Api\PaymentMethodManagementInterface::class, [], [], '', false ); - $this->paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $this->paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; $this->cartId = 11; @@ -64,7 +64,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestPaymentMethodManagement', + \Magento\Quote\Model\GuestCart\GuestPaymentMethodManagement::class, [ 'paymentMethodManagement' => $this->paymentMethodManagementMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock @@ -80,7 +80,7 @@ public function testGet() public function testGetList() { - $paymentMethod = $this->getMock('Magento\Quote\Api\Data\PaymentMethodInterface', [], [], '', false); + $paymentMethod = $this->getMock(\Magento\Quote\Api\Data\PaymentMethodInterface::class, [], [], '', false); $this->paymentMethodManagementMock->expects($this->once())->method('getList')->willReturn([$paymentMethod]); $this->assertEquals([$paymentMethod], $this->model->getList($this->maskedCartId)); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php index 75f5a707afd10..c825b12770b04 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php @@ -48,13 +48,13 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->shippingAddressManagementMock = $this->getMock( - 'Magento\Quote\Model\ShippingAddressManagementInterface', + \Magento\Quote\Model\ShippingAddressManagementInterface::class, [], [], '', false ); - $this->quoteAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $this->quoteAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; $this->cartId = 123; @@ -66,7 +66,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestShippingAddressManagement', + \Magento\Quote\Model\GuestCart\GuestShippingAddressManagement::class, [ 'shippingAddressManagement' => $this->shippingAddressManagementMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php index 2b428728ca7cf..53d81f0b50c16 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php @@ -44,7 +44,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->shippingMethodManagementMock = - $this->getMock('Magento\Quote\Model\ShippingMethodManagement', [], [], '', false); + $this->getMock(\Magento\Quote\Model\ShippingMethodManagement::class, [], [], '', false); $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; $this->cartId = 867; @@ -56,7 +56,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\GuestCart\GuestShippingMethodManagement', + \Magento\Quote\Model\GuestCart\GuestShippingMethodManagement::class, [ 'shippingMethodManagement' => $this->shippingMethodManagementMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCartManagement/Plugin/AuthorizationTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCartManagement/Plugin/AuthorizationTest.php index 5dc10a334f76e..ae83c5009252c 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCartManagement/Plugin/AuthorizationTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCartManagement/Plugin/AuthorizationTest.php @@ -27,9 +27,9 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->userContextMock = $this->getMock('Magento\Authorization\Model\UserContextInterface'); + $this->userContextMock = $this->getMock(\Magento\Authorization\Model\UserContextInterface::class); $this->quoteManagementMock = $this->getMock( - 'Magento\Quote\Model\GuestCart\GuestCartManagement', + \Magento\Quote\Model\GuestCart\GuestCartManagement::class, [], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php index 60d7618413676..9e4173a164bf5 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php @@ -16,7 +16,7 @@ class PaymentMethodManagementTest extends \PHPUnit_Framework_TestCase * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $objectManager; - + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -36,7 +36,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->quoteRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Quote\Api\CartRepositoryInterface', + \Magento\Quote\Api\CartRepositoryInterface::class, [], '', false, @@ -44,11 +44,11 @@ protected function setUp() true, [] ); - $this->methodListMock = $this->getMock('Magento\Payment\Model\MethodList', [], [], '', false); - $this->zeroTotalMock = $this->getMock('Magento\Payment\Model\Checks\ZeroTotal', [], [], '', false); + $this->methodListMock = $this->getMock(\Magento\Payment\Model\MethodList::class, [], [], '', false); + $this->zeroTotalMock = $this->getMock(\Magento\Payment\Model\Checks\ZeroTotal::class, [], [], '', false); $this->model = $this->objectManager->getObject( - 'Magento\Quote\Model\PaymentMethodManagement', + \Magento\Quote\Model\PaymentMethodManagement::class, [ 'quoteRepository' => $this->quoteRepositoryMock, 'methodList' => $this->methodListMock, @@ -60,8 +60,8 @@ protected function setUp() public function testGetPaymentIfPaymentMethodNotSet() { $cartId = 11; - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(null)); @@ -77,10 +77,10 @@ public function testGetPaymentSuccess() { $cartId = 11; - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $paymentMock->expects($this->once())->method('getId')->will($this->returnValue(1)); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $quoteMock->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock)); $this->quoteRepositoryMock->expects($this->once()) @@ -93,13 +93,13 @@ public function testGetPaymentSuccess() public function testGetList() { $cartId = 10; - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('get') ->with($cartId) ->will($this->returnValue($quoteMock)); - $paymentMethod = $this->getMock('Magento\Quote\Api\Data\PaymentMethodInterface'); + $paymentMethod = $this->getMock(\Magento\Quote\Api\Data\PaymentMethodInterface::class); $this->methodListMock->expects($this->once()) ->method('getAvailableMethods') ->with($quoteMock) @@ -116,7 +116,7 @@ public function testSetVirtualProduct() $paymentMethod = 'checkmo'; $quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['setTotalsCollectedFlag', 'getPayment', 'isVirtual', 'getBillingAddress', 'collectTotals', 'save'], [], '', @@ -124,7 +124,13 @@ public function testSetVirtualProduct() ); $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock); - $methodMock = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock = $this->getMock( + \Magento\Quote\Model\Quote\Payment::class, + ['setChecks', 'getData'], + [], + '', + false + ); $methodMock->expects($this->once()) ->method('setChecks') ->with([ @@ -137,7 +143,7 @@ public function testSetVirtualProduct() $methodMock->expects($this->once())->method('getData')->willReturn($methodDataWithAdditionalData); $paymentMock = $this->getMock( - 'Magento\Quote\Model\Quote\Payment', + \Magento\Quote\Model\Quote\Payment::class, ['importData', 'getMethod', 'getMethodInstance', 'getId'], [], '', @@ -147,7 +153,7 @@ public function testSetVirtualProduct() $paymentMock->expects($this->once())->method('getMethod')->willReturn($paymentMethod); $billingAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getCountryId', 'setPaymentMethod'], [], '', @@ -162,7 +168,7 @@ public function testSetVirtualProduct() $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(true); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock); - $methodInstance = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $methodInstance = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class); $paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance); $this->zeroTotalMock->expects($this->once()) @@ -189,7 +195,7 @@ public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable( $paymentMethod = 'checkmo'; $quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getPayment', 'isVirtual', 'getBillingAddress'], [], '', @@ -197,7 +203,13 @@ public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable( ); $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock); - $methodMock = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock = $this->getMock( + \Magento\Quote\Model\Quote\Payment::class, + ['setChecks', 'getData'], + [], + '', + false + ); $methodMock->expects($this->once()) ->method('setChecks') ->with([ @@ -210,7 +222,7 @@ public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable( $methodMock->expects($this->once())->method('getData')->willReturn($methodData); $paymentMock = $this->getMock( - 'Magento\Quote\Model\Quote\Payment', + \Magento\Quote\Model\Quote\Payment::class, ['importData', 'getMethod', 'getMethodInstance'], [], '', @@ -220,7 +232,7 @@ public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable( $paymentMock->expects($this->once())->method('getMethod')->willReturn($paymentMethod); $billingAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getCountryId', 'setPaymentMethod'], [], '', @@ -235,7 +247,7 @@ public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable( $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(true); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock); - $methodInstance = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $methodInstance = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class); $paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance); $this->zeroTotalMock->expects($this->once()) @@ -253,7 +265,7 @@ public function testSetSimpleProduct() $paymentMethod = 'checkmo'; $quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getPayment', 'isVirtual', 'getShippingAddress', 'setTotalsCollectedFlag', 'collectTotals', 'save'], [], '', @@ -261,7 +273,13 @@ public function testSetSimpleProduct() ); $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock); - $methodMock = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock = $this->getMock( + \Magento\Quote\Model\Quote\Payment::class, + ['setChecks', 'getData'], + [], + '', + false + ); $methodMock->expects($this->once()) ->method('setChecks') ->with([ @@ -274,7 +292,7 @@ public function testSetSimpleProduct() $methodMock->expects($this->once())->method('getData')->willReturn($methodData); $paymentMock = $this->getMock( - 'Magento\Quote\Model\Quote\Payment', + \Magento\Quote\Model\Quote\Payment::class, ['importData', 'getMethod', 'getMethodInstance', 'getId'], [], '', @@ -284,7 +302,7 @@ public function testSetSimpleProduct() $paymentMock->expects($this->once())->method('getMethod')->willReturn($paymentMethod); $shippingAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getCountryId', 'setPaymentMethod'], [], '', @@ -300,7 +318,7 @@ public function testSetSimpleProduct() $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(false); $quoteMock->expects($this->exactly(4))->method('getShippingAddress')->willReturn($shippingAddressMock); - $methodInstance = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $methodInstance = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class); $paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance); $this->zeroTotalMock->expects($this->once()) @@ -326,7 +344,7 @@ public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet() $methodData = ['method' => 'data']; $quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getPayment', 'isVirtual', 'getShippingAddress'], [], '', @@ -334,7 +352,13 @@ public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet() ); $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock); - $methodMock = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $methodMock = $this->getMock( + \Magento\Quote\Model\Quote\Payment::class, + ['setChecks', 'getData'], + [], + '', + false + ); $methodMock->expects($this->once()) ->method('setChecks') ->with([ @@ -346,10 +370,16 @@ public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet() ->willReturnSelf(); $methodMock->expects($this->once())->method('getData')->willReturn($methodData); - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', ['importData'], [], '', false); + $paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, ['importData'], [], '', false); $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf(); - $shippingAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', ['getCountryId'], [], '', false); + $shippingAddressMock = $this->getMock( + \Magento\Quote\Model\Quote\Address::class, + ['getCountryId'], + [], + '', + false + ); $shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn(null); $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QueryResolverTest.php b/app/code/Magento/Quote/Test/Unit/Model/QueryResolverTest.php index 023e173c3db7e..a2075b1161fc2 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QueryResolverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QueryResolverTest.php @@ -25,8 +25,8 @@ class QueryResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock('Magento\Framework\App\ResourceConnection\ConfigInterface'); - $this->cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); + $this->configMock = $this->getMock(\Magento\Framework\App\ResourceConnection\ConfigInterface::class); + $this->cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); $this->quoteResolver = new \Magento\Quote\Model\QueryResolver( $this->configMock, $this->cacheMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/RelationTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/RelationTest.php index 9c10bcd72f9ed..006869460c4b5 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/RelationTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/RelationTest.php @@ -23,7 +23,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); $this->modelMock = $this->getMock( - 'Magento\Framework\Model\AbstractModel', + \Magento\Framework\Model\AbstractModel::class, [ 'getItemsCollection', 'getShippingRatesCollection', @@ -34,20 +34,20 @@ protected function setUp() '', false ); - $this->relation = $objectManager->getObject('Magento\Quote\Model\Quote\Address\Relation', []); + $this->relation = $objectManager->getObject(\Magento\Quote\Model\Quote\Address\Relation::class, []); } public function testProcessRelation() { $itemsCollection = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', + \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::class, [], [], '', false ); $shippingRatesCollection = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', + \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::class, [], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderAddressTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderAddressTest.php index 7d0428e2acc9e..1b0d7132d021d 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderAddressTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderAddressTest.php @@ -40,18 +40,24 @@ class ToOrderAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderAddressRepositoryMock = $this->getMock( - 'Magento\Sales\Model\Order\AddressRepository', + \Magento\Sales\Model\Order\AddressRepository::class, ['create'], [], '', false ); - $this->objectCopyMock = $this->getMock('Magento\Framework\DataObject\Copy', [], [], '', false); - $this->orderInterfaceMock = $this->getMock('Magento\Sales\Api\Data\OrderAddressInterface', [], [], '', false); - $this->dataObjectHelper = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->objectCopyMock = $this->getMock(\Magento\Framework\DataObject\Copy::class, [], [], '', false); + $this->orderInterfaceMock = $this->getMock( + \Magento\Sales\Api\Data\OrderAddressInterface::class, + [], + [], + '', + false + ); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $objectManager = new ObjectManager($this); $this->converter = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Address\ToOrderAddress', + \Magento\Quote\Model\Quote\Address\ToOrderAddress::class, [ 'orderAddressRepository' => $this->orderAddressRepositoryMock, 'objectCopyService' => $this->objectCopyMock, @@ -67,14 +73,14 @@ public function testConvert() /** * @var \Magento\Quote\Model\Quote\Address $object */ - $object = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $object = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with( 'sales_convert_quote_address', 'to_order_address', $object )->willReturn($orderData); $this->dataObjectHelper->expects($this->once())->method('populateWithArray') - ->with($this->orderInterfaceMock, ['test' => 'beer'], '\Magento\Sales\Api\Data\OrderAddressInterface') + ->with($this->orderInterfaceMock, ['test' => 'beer'], \Magento\Sales\Api\Data\OrderAddressInterface::class) ->willReturnSelf(); $this->orderAddressRepositoryMock->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderTest.php index 57ed0b69c9bc6..782644d072f31 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ToOrderTest.php @@ -45,21 +45,21 @@ class ToOrderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderDataFactoryMock = $this->getMock( - 'Magento\Sales\Api\Data\OrderInterfaceFactory', + \Magento\Sales\Api\Data\OrderInterfaceFactory::class, ['create'], [], '', false ); - $this->objectCopyMock = $this->getMock('Magento\Framework\DataObject\Copy', [], [], '', false); - $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + $this->objectCopyMock = $this->getMock(\Magento\Framework\DataObject\Copy::class, [], [], '', false); + $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->disableOriginalConstructor() ->getMock(); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $this->dataObjectHelper = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $objectManager = new ObjectManager($this); $this->converter = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Address\ToOrder', + \Magento\Quote\Model\Quote\Address\ToOrder::class, [ 'orderFactory' => $this->orderDataFactoryMock, 'objectCopyService' => $this->objectCopyMock, @@ -76,8 +76,8 @@ public function testConvert() $quoteId = 1; $storeId = 777; - $object = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $object = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $object->expects($this->exactly(5))->method('getQuote')->willReturn($quote); $quote->expects($this->once())->method('getId')->willReturn($quoteId); $quote->expects($this->once())->method('getStoreId')->willReturn($storeId); @@ -87,7 +87,7 @@ public function testConvert() $object )->willReturn($orderData); $this->dataObjectHelper->expects($this->once())->method('populateWithArray') - ->with($this->orderMock, ['test' => 'beer'], '\Magento\Sales\Api\Data\OrderInterface') + ->with($this->orderMock, ['test' => 'beer'], \Magento\Sales\Api\Data\OrderInterface::class) ->willReturnSelf(); $this->orderMock->expects($this->once())->method('setStoreId')->with($storeId)->willReturnSelf(); $this->orderMock->expects($this->once())->method('setQuoteId')->with($quoteId)->willReturnSelf(); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php index 31728e3c20ccb..8db55ff0be6df 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php @@ -17,7 +17,7 @@ class GrandTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Quote\Model\Quote\Address\Total\Grand'); + $this->model = $objectManager->getObject(\Magento\Quote\Model\Quote\Address\Total\Grand::class); } public function testCollect() @@ -28,7 +28,7 @@ public function testCollect() $grandTotalBase = 15.7; // 4 + 5 + 6.7 $totalMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address\Total', + \Magento\Quote\Model\Quote\Address\Total::class, ['getAllTotalAmounts', 'getAllBaseTotalAmounts', 'setGrandTotal', 'setBaseGrandTotal'], [], '', @@ -40,8 +40,8 @@ public function testCollect() $totalMock->expects($this->once())->method('setBaseGrandTotal')->with($grandTotalBase); $this->model->collect( - $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false), - $this->getMock('\Magento\Quote\Api\Data\ShippingAssignmentInterface'), + $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false), + $this->getMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class), $totalMock ); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php index ae905becfa6d5..7ae2206ca9e3e 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php @@ -45,29 +45,29 @@ class ShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->freeShipping = $this->getMockForAbstractClass( - 'Magento\Quote\Model\Quote\Address\FreeShippingInterface', + \Magento\Quote\Model\Quote\Address\FreeShippingInterface::class, [], '', false ); $this->priceCurrency = $this->getMockForAbstractClass( - 'Magento\Framework\Pricing\PriceCurrencyInterface', + \Magento\Framework\Pricing\PriceCurrencyInterface::class, [], '', false ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->shippingModel = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Address\Total\Shipping', + \Magento\Quote\Model\Quote\Address\Total\Shipping::class, [ 'freeShipping' => $this->freeShipping, 'priceCurrency' => $this->priceCurrency, ] ); - $this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->total = $this->getMock( - 'Magento\Quote\Model\Quote\Address\Total', + \Magento\Quote\Model\Quote\Address\Total::class, [ 'setShippingAmount', 'setBaseShippingAmount', @@ -80,13 +80,13 @@ protected function setUp() false ); $this->shippingAssignment = $this->getMockForAbstractClass( - 'Magento\Quote\Api\Data\ShippingAssignmentInterface', + \Magento\Quote\Api\Data\ShippingAssignmentInterface::class, [], '', false ); $this->address = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'setWeight', 'setFreeMethodWeight', @@ -104,9 +104,14 @@ protected function setUp() '', false ); - $this->shipping = $this->getMockForAbstractClass('Magento\Quote\Api\Data\ShippingInterface', [], '', false); + $this->shipping = $this->getMockForAbstractClass( + \Magento\Quote\Api\Data\ShippingInterface::class, + [], + '', + false + ); $this->cartItem = $this->getMockForAbstractClass( - 'Magento\Quote\Api\Data\CartItemInterface', + \Magento\Quote\Api\Data\CartItemInterface::class, [], '', false, @@ -124,13 +129,13 @@ protected function setUp() ] ); $this->rate = $this->getMock( - 'Magento\Quote\Model\Quote\Address\Rate', + \Magento\Quote\Model\Quote\Address\Rate::class, ['getPrice', 'getCode', 'getCarrierTitle', 'getMethodTitle'], [], '', false ); - $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); } public function testFetch() @@ -143,9 +148,9 @@ public function testFetch() 'title' => __('Shipping & Handling (%1)', $shippingDescription) ]; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $totalMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address\Total', + \Magento\Quote\Model\Quote\Address\Total::class, ['getShippingAmount', 'getShippingDescription'], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php index c9b17c67ca339..f44d6ec8ed9ae 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php @@ -9,6 +9,8 @@ * Class SubtotalTest * @package Magento\Quote\Model\Quote\Address\Total * TODO refactor me + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SubtotalTest extends \PHPUnit_Framework_TestCase { @@ -33,17 +35,19 @@ class SubtotalTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->subtotalModel = $this->objectManager->getObject('Magento\Quote\Model\Quote\Address\Total\Subtotal'); + $this->subtotalModel = $this->objectManager->getObject( + \Magento\Quote\Model\Quote\Address\Total\Subtotal::class + ); $this->stockRegistry = $this->getMock( - 'Magento\CatalogInventory\Model\StockRegistry', + \Magento\CatalogInventory\Model\StockRegistry::class, ['getStockItem', '__wakeup'], [], '', false ); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getIsInStock', '__wakeup'], [], '', @@ -77,15 +81,14 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri { $this->stockRegistry->expects($this->any())->method('getStockItem')->willReturn($this->stockItemMock); - $priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock(); + $priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock(); $convertedPrice = 1231313; // @TODO this is a wrong test and it does not check methods. Any digital value will be correct $priceCurrency->expects($this->any())->method('convert')->willReturn(1231313); - /** @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $quoteItem */ $quoteItem = $this->objectManager->getObject( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [ 'stockRegistry' => $this->stockRegistry, 'priceCurrency' => $priceCurrency, @@ -93,7 +96,7 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri ); /** @var \Magento\Quote\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject $address */ $address = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [], [], '', @@ -101,15 +104,15 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri ); /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $product->expects($this->any())->method('getPrice')->will($this->returnValue($originalPrice)); /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quote */ - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $store = $this->objectManager->getObject('Magento\Store\Model\Store'); + $quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $store = $this->objectManager->getObject(\Magento\Store\Model\Store::class); $store->setCurrentCurrency(''); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->any())->method('getWebsiteId')->willReturn(10); $product->expects($this->any())->method('getStore')->willReturn($store); $product->expects($this->any())->method('isVisibleInCatalog')->will($this->returnValue(true)); @@ -119,26 +122,26 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri $parentQuoteItem = false; if ($itemHasParent) { - $parentQuoteItem = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $parentQuoteItem = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $parentQuoteItem->expects($this->any())->method('getProduct')->will($this->returnValue($product)); } $quoteItem->setParentItem($parentQuoteItem); //This value will be overwritten $quoteItem->setConvertedPrice(10); - $priceModel = $this->getMock('\Magento\Catalog\Model\Product\Type\Price', [], [], '', false); + $priceModel = $this->getMock(\Magento\Catalog\Model\Product\Type\Price::class, [], [], '', false); $priceModel->expects($this->any())->method('getChildFinalPrice')->willReturn($price); $product->expects($this->any())->method('getPriceModel')->willReturn($priceModel); $product->expects($this->any())->method('getFinalPrice')->willReturn($price); - $shipping = $this->getMock('\Magento\Quote\Api\Data\ShippingInterface'); + $shipping = $this->getMock(\Magento\Quote\Api\Data\ShippingInterface::class); $shipping->expects($this->exactly(2))->method('getAddress')->willReturn($address); - $shippingAssignmentMock = $this->getMock('\Magento\Quote\Api\Data\ShippingAssignmentInterface'); + $shippingAssignmentMock = $this->getMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class); $shippingAssignmentMock->expects($this->exactly(2))->method('getShipping')->willReturn($shipping); $shippingAssignmentMock->expects($this->once())->method('getItems')->willReturn([$quoteItem]); $total = $this->getMock( - '\Magento\Quote\Model\Quote\Address\Total', + \Magento\Quote\Model\Quote\Address\Total::class, ['setBaseVirtualAmount', 'setVirtualAmount', 'setTotalQty'], [], '', @@ -164,8 +167,8 @@ public function testFetch() 'value' => 100 ]; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $totalMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Total', ['getSubtotal'], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $totalMock = $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, ['getSubtotal'], [], '', false); $totalMock->expects($this->once())->method('getSubtotal')->willReturn(100); $this->assertEquals($expectedResult, $this->subtotalModel->fetch($quoteMock, $totalMock)); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ValidatorTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ValidatorTest.php index e9181138b9533..a87f889e51d2c 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ValidatorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/ValidatorTest.php @@ -35,10 +35,10 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->countryFactoryMock = $this->getMock('\Magento\Directory\Model\CountryFactory', [], [], '', false); - $this->countryMock = $this->getMock('\Magento\Directory\Model\Country', [], [], '', false); + $this->countryFactoryMock = $this->getMock(\Magento\Directory\Model\CountryFactory::class, [], [], '', false); + $this->countryMock = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); $this->itemMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getCountryId', 'getEmail'], [], '', @@ -49,7 +49,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->countryMock)); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Address\Validator', + \Magento\Quote\Model\Quote\Address\Validator::class, [ 'countryFactory' => $this->countryFactoryMock, ] diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/AddressTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/AddressTest.php index da3c3ae6af13c..7a8ccb232ba06 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/AddressTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/AddressTest.php @@ -36,15 +36,15 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config', [], [], '', false); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false); $this->address = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Address', - [ - 'scopeConfig' => $this->scopeConfig - ] - ); - $this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + \Magento\Quote\Model\Quote\Address::class, + [ + 'scopeConfig' => $this->scopeConfig + ] + ); + $this->quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->address->setQuote($this->quote); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/ConfigTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/ConfigTest.php index 41266f1175379..1f824e873448c 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/ConfigTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/ConfigTest.php @@ -20,7 +20,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_attributeConfig = $this->getMock( - 'Magento\Catalog\Model\Attribute\Config', + \Magento\Catalog\Model\Attribute\Config::class, [], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/AbstractItemTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/AbstractItemTest.php index c0e623321778f..857267f2b8391 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/AbstractItemTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/AbstractItemTest.php @@ -22,7 +22,7 @@ class AbstractItemTest extends \PHPUnit_Framework_TestCase public function testGetTotalDiscountAmount($expectedDiscountAmount, $children, $calculated, $myDiscountAmount) { $abstractItemMock = $this->getMockForAbstractClass( - 'Magento\Quote\Model\Quote\Item\AbstractItem', + \Magento\Quote\Model\Quote\Item\AbstractItem::class, [], '', false, @@ -51,7 +51,7 @@ public function dataProviderGetTotalDiscountAmount() { $childOneDiscountAmount = 1000; $childOneItemMock = $this->getMockForAbstractClass( - 'Magento\Quote\Model\Quote\Item\AbstractItem', + \Magento\Quote\Model\Quote\Item\AbstractItem::class, [], '', false, @@ -65,7 +65,7 @@ public function dataProviderGetTotalDiscountAmount() $childTwoDiscountAmount = 50; $childTwoItemMock = $this->getMockForAbstractClass( - 'Magento\Quote\Model\Quote\Item\AbstractItem', + \Magento\Quote\Model\Quote\Item\AbstractItem::class, [], '', false, diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php index 07f9987a90252..f8b72e4df6b7c 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php @@ -38,22 +38,22 @@ class CompareTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->itemMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + $this->itemMock = $this->getMock( + \Magento\Quote\Model\Quote\Item::class, ['__wakeup', 'getProductId', 'getOptions'], [], '', false ); - $this->comparedMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + $this->comparedMock = $this->getMock( + \Magento\Quote\Model\Quote\Item::class, ['__wakeup', 'getProductId', 'getOptions'], [], '', false ); - $this->optionMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item\Option', + $this->optionMock = $this->getMock( + \Magento\Quote\Model\Quote\Item\Option::class, ['__wakeup', 'getCode', 'getValue'], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php index a3ccf8a40aebf..580d7c4b9d22d 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php @@ -17,6 +17,8 @@ /** * Tests for Magento\Quote\Model\Service\Quote\Processor + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ProcessorTest extends \PHPUnit_Framework_TestCase { @@ -63,7 +65,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteItemFactoryMock = $this->getMock( - 'Magento\Quote\Model\Quote\ItemFactory', + \Magento\Quote\Model\Quote\ItemFactory::class, ['create'], [], '', @@ -71,7 +73,7 @@ protected function setUp() ); $this->itemMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [ 'getId', 'setOptions', @@ -91,19 +93,19 @@ protected function setUp() ->will($this->returnValue($this->itemMock)); $this->storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManager', + \Magento\Store\Model\StoreManager::class, ['getStore'], [], '', false ); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup'], [], '', false); $this->storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnValue($this->storeMock)); $this->stateMock = $this->getMock( - 'Magento\Framework\App\State', + \Magento\Framework\App\State::class, [], [], '', @@ -117,14 +119,14 @@ protected function setUp() ); $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, ['getCustomOptions', '__wakeup', 'getParentProductId', 'getCartQty', 'getStickWithinParent'], [], '', false ); $this->objectMock = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, ['getResetCount', 'getId', 'getCustomPrice'], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php index ae7a46c6a831c..b9db00cd8cc5b 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php @@ -33,9 +33,9 @@ protected function setUp() */ public function testGetRelatedProductIds($optionValue, $productId, $expectedResult) { - $quoteItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $itemOptionMock = $this->getMock( - '\Magento\Quote\Model\Quote\Item\Option', + \Magento\Quote\Model\Quote\Item\Option::class, ['getValue', 'getProductId', '__wakeup'], [], '', @@ -79,7 +79,7 @@ public function getRelatedProductIdsDataProvider() */ public function testGetRelatedProductIdsNoOptions() { - $quoteItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $quoteItemMock->expects( $this->once() diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php index f341bacef4713..76c3766d1f248 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php @@ -7,6 +7,9 @@ namespace Magento\Quote\Test\Unit\Model\Quote\Item; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class RepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -60,18 +63,18 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->productRepositoryMock = $this->getMock('Magento\Catalog\Api\ProductRepositoryInterface'); + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->productRepositoryMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); $this->itemDataFactoryMock = - $this->getMock('Magento\Quote\Api\Data\CartItemInterfaceFactory', ['create'], [], '', false); - $this->dataMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); - $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->getMock(\Magento\Quote\Api\Data\CartItemInterfaceFactory::class, ['create'], [], '', false); + $this->dataMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $methods = ['getId', 'getSku', 'getQty', 'setData', '__wakeUp', 'getProduct', 'addProduct']; $this->quoteItemMock = - $this->getMock('Magento\Quote\Model\Quote\Item', $methods, [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Item::class, $methods, [], '', false); $this->customOptionProcessor = $this->getMock( - 'Magento\Catalog\Model\CustomOptions\CustomOptionProcessor', + \Magento\Catalog\Model\CustomOptions\CustomOptionProcessor::class, [], [], '', @@ -132,7 +135,7 @@ public function testSaveCouldNotAddProduct() { $this->markTestSkipped('MAGETWO-48531'); $cartId = 13; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $buyRequest->expects($this->once()) ->method('setData') ->with('qty', '12'); @@ -170,7 +173,7 @@ public function testSaveCouldNotSaveException() { $this->markTestSkipped('MAGETWO-48531'); $cartId = 13; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->dataMock->expects($this->exactly(2))->method('getQty')->will($this->returnValue(12)); $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); $this->quoteRepositoryMock->expects($this->once()) @@ -220,7 +223,7 @@ public function testSave() { $this->markTestSkipped('MAGETWO-48531'); $cartId = 13; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $buyRequest->expects($this->once()) ->method('setData') ->with('qty', '12'); @@ -263,7 +266,7 @@ public function testSaveWithCustomOption() { $this->markTestSkipped('MAGETWO-48531'); $cartId = 13; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->dataMock->expects($this->exactly(2))->method('getQty')->will($this->returnValue(12)); $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); $this->quoteRepositoryMock->expects($this->once()) @@ -330,7 +333,7 @@ public function testUpdateItemWithCouldNotSaveException() $this->markTestSkipped('MAGETWO-48531'); $cartId = 11; $itemId = 5; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->dataMock->expects($this->exactly(2))->method('getQty')->will($this->returnValue(12)); $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue($itemId)); $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); @@ -379,7 +382,7 @@ public function testUpdateItemQty() $this->markTestSkipped('MAGETWO-48531'); $cartId = 11; $itemId = 5; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $this->dataMock->expects($this->exactly(2))->method('getQty')->will($this->returnValue(12)); $this->dataMock->expects($this->once())->method('getItemId')->will($this->returnValue($itemId)); $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); @@ -429,15 +432,15 @@ public function testUpdateItemOptions() $this->markTestSkipped('MAGETWO-48531'); $cartId = 11; $itemId = 5; - $buyRequest = $this->getMock('Magento\Framework\DataObject', [], [], '', false); - $cartItemProcessorMock = $this->getMock('\Magento\Quote\Model\Quote\Item\CartItemProcessorInterface'); + $buyRequest = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); + $cartItemProcessorMock = $this->getMock(\Magento\Quote\Model\Quote\Item\CartItemProcessorInterface::class); $this->repository = new \Magento\Quote\Model\Quote\Item\Repository( $this->quoteRepositoryMock, $this->productRepositoryMock, $this->itemDataFactoryMock, ['simple' => $cartItemProcessorMock, 'custom_options' => $this->customOptionProcessor] ); - $requestMock = $this->getMock('\Magento\Framework\DataObject', ['setQty', 'getData'], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\DataObject::class, ['setQty', 'getData'], [], '', false); $cartItemProcessorMock->expects($this->once())->method('convertToBuyRequest')->willReturn($requestMock); $cartItemProcessorMock ->expects($this->once()) @@ -535,11 +538,11 @@ public function testDeleteWithCouldNotSaveException() public function testGetList() { $this->markTestSkipped('MAGETWO-48531'); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once())->method('getActive') ->with(33) ->will($this->returnValue($quoteMock)); - $itemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $quoteMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock])); $this->assertEquals([$itemMock], $this->repository->getList(33)); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ToOrderItemTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ToOrderItemTest.php index bf05b030f414d..c09900e6571a7 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ToOrderItemTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ToOrderItemTest.php @@ -48,48 +48,48 @@ class ToOrderItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->orderItemFactoryMock = $this->getMock( - 'Magento\Sales\Api\Data\OrderItemInterfaceFactory', + \Magento\Sales\Api\Data\OrderItemInterfaceFactory::class, ['create'], [], '', false ); $this->objectCopyServiceMock = $this->getMock( - 'Magento\Framework\DataObject\Copy', + \Magento\Framework\DataObject\Copy::class, [], [], '', false ); $this->quoteItemMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [], [], '', false ); $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [], [], '', false ); $this->productTypeMock = $this->getMock( - 'Magento\Catalog\Model\Product\Type\Simple', + \Magento\Catalog\Model\Product\Type\Simple::class, [], [], '', false ); $this->orderItemMock = $this->getMock( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, [], [], '', false ); - $dataObjectHelper = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $this->converter = new \Magento\Quote\Model\Quote\Item\ToOrderItem( $this->orderItemFactoryMock, @@ -125,7 +125,7 @@ public function testConvert() ->method('create') ->willReturn($this->orderItemMock); $this->assertInstanceOf( - 'Magento\Sales\Model\Order\Item', + \Magento\Sales\Model\Order\Item::class, $this->converter->convert($this->quoteItemMock, []) ); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php index 82a9a851bb130..fc86df0819e68 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php @@ -41,7 +41,7 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'getStockItem', '__wakeup', @@ -54,7 +54,7 @@ protected function setUp() ); $this->localeFormat = $this->getMock( - 'Magento\Framework\Locale\Format', + \Magento\Framework\Locale\Format::class, [ 'getNumber', 'getPriceFormat' ], @@ -64,7 +64,7 @@ protected function setUp() ); $this->itemMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [ 'updateItem', 'getProduct', @@ -85,7 +85,7 @@ protected function setUp() ); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, [ 'getIsQtyDecimal', '__wakeup' @@ -97,7 +97,7 @@ protected function setUp() $this->object = (new ObjectManager($this)) ->getObject( - 'Magento\Quote\Model\Quote\Item\Updater', + \Magento\Quote\Model\Quote\Item\Updater::class, [ 'localeFormat' => $this->localeFormat ] @@ -231,7 +231,7 @@ public function testUpdateCustomPrice() $customPrice = 9.99; $qty = 3; $buyRequestMock = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, [ 'setCustomPrice', 'setValue', @@ -297,7 +297,7 @@ public function testUpdateUnsetCustomPrice() { $qty = 3; $buyRequestMock = $this->getMock( - 'Magento\Framework\DataObject', + \Magento\Framework\DataObject::class, [ 'setCustomPrice', 'setValue', diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php index d1298ac7296be..7e07fcddf4aba 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php @@ -8,6 +8,9 @@ namespace Magento\Quote\Test\Unit\Model\Quote; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ItemTest extends \PHPUnit_Framework_TestCase { /** @@ -70,16 +73,16 @@ protected function setUp() { $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->localeFormat = $this->getMockBuilder('Magento\Framework\Locale\FormatInterface') + $this->localeFormat = $this->getMockBuilder(\Magento\Framework\Locale\FormatInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->modelContext = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->modelContext = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->setMethods(['getEventDispatcher']) ->getMock(); - $this->eventDispatcher = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); @@ -88,12 +91,12 @@ protected function setUp() ->method('getEventDispatcher') ->will($this->returnValue($this->eventDispatcher)); - $this->errorInfos = $this->getMockBuilder('Magento\Sales\Model\Status\ListStatus') + $this->errorInfos = $this->getMockBuilder(\Magento\Sales\Model\Status\ListStatus::class) ->disableOriginalConstructor() ->setMethods(['clear', 'addItem', 'getItems', 'removeItemsByParams']) ->getMock(); - $statusListFactory = $this->getMockBuilder('Magento\Sales\Model\Status\ListFactory') + $statusListFactory = $this->getMockBuilder(\Magento\Sales\Model\Status\ListFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -102,13 +105,13 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->errorInfos)); - $this->itemOptionFactory = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\OptionFactory') + $this->itemOptionFactory = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\OptionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->compareHelper = $this->getMock( - 'Magento\Quote\Model\Quote\Item\Compare', + \Magento\Quote\Model\Quote\Item\Compare::class, [], [], '', @@ -116,14 +119,14 @@ protected function setUp() ); $this->stockItemMock = $this->getMock( - 'Magento\CatalogInventory\Model\Stock\Item', + \Magento\CatalogInventory\Model\Stock\Item::class, ['getIsQtyDecimal', '__wakeup'], [], '', false ); - $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Model\StockRegistry') + $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); @@ -132,7 +135,7 @@ protected function setUp() ->will($this->returnValue($this->stockItemMock)); $this->model = $this->objectManagerHelper->getObject( - '\Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [ 'localeFormat' => $this->localeFormat, 'context' => $this->modelContext, @@ -146,7 +149,7 @@ protected function setUp() public function testGetAddress() { - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->setMethods(['getShippingAddress', 'getBillingAddress', 'getStoreId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -175,7 +178,7 @@ public function testSetAndQuote() { $idValue = "id_value"; - $quote = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->setMethods(['getId', 'getStoreId', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -226,7 +229,7 @@ public function testAddQtyExistingParentItemAndId() $existingQuantity = 2; $quantityToAdd = 3; - $parentItemMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + $parentItemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->setMethods(['addChild', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -272,7 +275,7 @@ public function testSetQtyQuoteIgnoreOldQuantity() ->with($quantityToAdd) ->will($this->returnValue($preparedQuantityToAdd)); - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->setMethods(['getIgnoreOldQty', 'getStoreId', '__wakeup']) ->getMock(); @@ -379,7 +382,7 @@ public function testSetProductWithQuoteAndStockItem() $storeId = 15; $customerGroupId = 11; - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class) ->disableOriginalConstructor() ->setMethods(['getStoreId', 'getCustomerGroupId', '__wakeup']) ->getMock(); @@ -420,7 +423,7 @@ private function generateProductMock( $productTaxClassId, $productCost ) { - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods( [ @@ -464,7 +467,7 @@ private function generateProductMock( $productMock->expects($this->any()) ->method('getCost') ->will($this->returnValue($productCost)); - $store = $this->getMock('Magento\Store\Model\Store', ['getWebsiteId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId'], [], '', false); $store->expects($this->any()) ->method('getWebsiteId') ->will($this->returnValue(10)); @@ -505,7 +508,7 @@ public function testRepresentProductStickWithinParentNotSameAsParentItem() self::PRODUCT_COST ); - $parentItemMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + $parentItemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->setMethods(['addChild', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -532,7 +535,7 @@ public function testRepresentProductItemOptionsNotInProductOptions() self::PRODUCT_COST ); - $parentItemMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + $parentItemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->setMethods(['addChild', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -575,7 +578,7 @@ public function testRepresentProductProductOptionsNotInItemOptions() self::PRODUCT_COST ); - $parentItemMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + $parentItemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->setMethods(['addChild', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -618,7 +621,7 @@ public function testRepresentProductTrue() self::PRODUCT_COST ); - $parentItemMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item') + $parentItemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->setMethods(['addChild', '__wakeup']) ->disableOriginalConstructor() ->getMock(); @@ -654,7 +657,8 @@ public function testRepresentProductTrue() */ public function testCompare() { - $itemMock = $this->getMock('Magento\Quote\Model\Quote\Item', + $itemMock = $this->getMock( + \Magento\Quote\Model\Quote\Item::class, [], [], '', @@ -848,7 +852,7 @@ public function testSetOptionsWithNull() private function createOptionMock($optionCode, $optionData = []) { - $optionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->setMethods(['setData', 'setItem', 'getCode', '__wakeup', 'isDeleted', 'getValue', 'getProduct']) ->disableOriginalConstructor() ->getMock(); @@ -872,7 +876,7 @@ public function testAddOptionArray() $optionCode = 1234; $optionData = ['product' => 'test', 'code' => $optionCode]; - $optionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->setMethods(['setData', 'setItem', 'getCode', '__wakeup', 'isDeleted']) ->disableOriginalConstructor() ->getMock(); @@ -911,7 +915,7 @@ public function testUpdateQtyOption() ); $typeInstanceMock = $this->getMockForAbstractClass( - 'Magento\Catalog\Model\Product\Type\AbstractType', + \Magento\Catalog\Model\Product\Type\AbstractType::class, [], '', false, @@ -923,7 +927,7 @@ public function testUpdateQtyOption() ->method('getTypeInstance') ->will($this->returnValue($typeInstanceMock)); - $optionMock = $this->getMockBuilder('Magento\Framework\DataObject') + $optionMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->disableOriginalConstructor() ->setMethods(['getProduct']) ->getMock(); @@ -944,7 +948,7 @@ public function testRemoveOption() { $optionCode = 1234; - $optionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->setMethods(['setItem', 'getCode', '__wakeup', 'isDeleted']) ->disableOriginalConstructor() ->getMock(); @@ -981,7 +985,7 @@ public function testGetOptionByCodeDeletedCode() { $optionCode = 1234; - $optionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->setMethods(['setItem', 'getCode', '__wakeup', 'isDeleted']) ->disableOriginalConstructor() ->getMock(); @@ -1005,7 +1009,7 @@ public function testGetOptionByCodeNotDeletedCode() { $optionCode = 1234; - $optionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->setMethods(['setItem', 'getCode', '__wakeup', 'isDeleted']) ->disableOriginalConstructor() ->getMock(); @@ -1043,7 +1047,7 @@ public function testGetBuyRequestOptionByCode() { $optionCode = "info_buyRequest"; $buyRequestQuantity = 23; - $optionMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Item\Option') + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) ->setMethods(['setItem', 'getCode', '__wakeup', 'getValue']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php index 4bd0595fe911c..5400293a9ece1 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php @@ -43,25 +43,25 @@ class ToOrderPaymentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentMock = $this->getMock( - 'Magento\Quote\Model\Quote\Payment', + $this->paymentMock = $this->getMock( + \Magento\Quote\Model\Quote\Payment::class, ['getCcNumber', 'getCcCid', 'getMethodInstance', 'getAdditionalInformation'], [], '', false ); - $this->objectCopyMock = $this->getMock('Magento\Framework\DataObject\Copy', [], [], '', false); - $this->orderPaymentRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Sales\Api\OrderPaymentRepositoryInterface', + $this->objectCopyMock = $this->getMock(\Magento\Framework\DataObject\Copy::class, [], [], '', false); + $this->orderPaymentRepositoryMock = $this->getMockForAbstractClass( + \Magento\Sales\Api\OrderPaymentRepositoryInterface::class, [], '', false, false ); - $this->dataObjectHelper = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $objectManager = new ObjectManager($this); - $this->converter = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Payment\ToOrderPayment', + $this->converter = $objectManager->getObject( + \Magento\Quote\Model\Quote\Payment\ToOrderPayment::class, [ 'orderPaymentRepository' => $this->orderPaymentRepositoryMock, 'objectCopyService' => $this->objectCopyMock, @@ -75,7 +75,7 @@ protected function setUp() */ public function testConvert() { - $methodInterface = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $methodInterface = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class); $paymentData = ['test' => 'test2']; $data = ['some_id' => 1]; @@ -102,8 +102,8 @@ public function testConvert() ->method('getCcCid') ->willReturn($ccCid); - $orderPayment = $this->getMockForAbstractClass( - 'Magento\Sales\Api\Data\OrderPaymentInterface', + $orderPayment = $this->getMockForAbstractClass( + \Magento\Sales\Api\Data\OrderPaymentInterface::class, [], '', false, @@ -125,7 +125,7 @@ public function testConvert() $this->orderPaymentRepositoryMock->expects($this->once())->method('create')->willReturn($orderPayment); $this->dataObjectHelper->expects($this->once()) ->method('populateWithArray') - ->with($orderPayment, array_merge($paymentData, $data), '\Magento\Sales\Api\Data\OrderPaymentInterface') + ->with($orderPayment, array_merge($paymentData, $data), \Magento\Sales\Api\Data\OrderPaymentInterface::class) ->willReturnSelf(); $this->assertSame($orderPayment, $this->converter->convert($this->paymentMock, $data)); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/PaymentTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/PaymentTest.php index 53d95bda04ed3..0cfbfa7ac3542 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/PaymentTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/PaymentTest.php @@ -20,7 +20,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject( - '\Magento\Quote\Model\Quote\Payment' + \Magento\Quote\Model\Quote\Payment::class ); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/RelationTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/RelationTest.php index bae70ac62043d..dae711863bd72 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/RelationTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/RelationTest.php @@ -25,11 +25,11 @@ class RelationTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\Quote\Relation' + \Magento\Quote\Model\Quote\Relation::class ); } @@ -39,7 +39,7 @@ protected function setUp() public function testProcessRelation() { $addressCollectionMock = $this->getMock( - 'Magento\Eav\Model\Entity\Collection\AbstractCollection', + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], [], '', @@ -49,9 +49,8 @@ public function testProcessRelation() $this->quoteMock->expects($this->once())->method('getAddressesCollection')->willReturn($addressCollectionMock); $addressCollectionMock->expects($this->once())->method('save'); - $itemsCollectionMock = $this->getMock( - 'Magento\Eav\Model\Entity\Collection\AbstractCollection', + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], [], '', @@ -62,7 +61,7 @@ public function testProcessRelation() $itemsCollectionMock->expects($this->once())->method('save'); $paymentCollectionMock = $this->getMock( - 'Magento\Eav\Model\Entity\Collection\AbstractCollection', + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], [], '', @@ -72,7 +71,7 @@ public function testProcessRelation() $this->quoteMock->expects($this->once())->method('getPaymentsCollection')->willReturn($paymentCollectionMock); $paymentCollectionMock->expects($this->once())->method('save'); - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $this->quoteMock->expects($this->once())->method('currentPaymentWasSet')->willReturn(true); $this->quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock); $paymentMock->expects($this->once())->method('save'); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/TotalsReaderTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/TotalsReaderTest.php index ce63f09dfec5d..414b7880d96d1 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/TotalsReaderTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/TotalsReaderTest.php @@ -38,16 +38,21 @@ class TotalsReaderTest extends \PHPUnit_Framework_TestCase */ protected $collectorMock; - protected function setUp() { $this->totalFactoryMock = - $this->getMock('Magento\Quote\Model\Quote\Address\TotalFactory', ['create'], [], '', false); - $this->collectionListMock = $this->getMock('Magento\Quote\Model\Quote\TotalsCollectorList', [], [], '', false); - $this->totalMock = $this->getMock('Magento\Quote\Model\Quote\Address\Total', ['setData'], [], '', false); - $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Address\TotalFactory::class, ['create'], [], '', false); + $this->collectionListMock = $this->getMock( + \Magento\Quote\Model\Quote\TotalsCollectorList::class, + [], + [], + '', + false + ); + $this->totalMock = $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, ['setData'], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->collectorMock = - $this->getMock('Magento\Quote\Model\Quote\Address\Total\AbstractTotal', [], [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Address\Total\AbstractTotal::class, [], [], '', false); $this->model = new \Magento\Quote\Model\Quote\TotalsReader( $this->totalFactoryMock, $this->collectionListMock @@ -59,7 +64,7 @@ public function testFetch() $total = []; $storeId = 1; $testedTotalMock = - $this->getMock('Magento\Quote\Model\Quote\Address\Total', ['setData', 'getCode'], [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, ['setData', 'getCode'], [], '', false); $expected = ['my_total_type' => $testedTotalMock]; $data = ['code' => 'my_total_type']; $this->totalMock->expects($this->once())->method('setData')->with([])->willReturnSelf(); @@ -110,9 +115,9 @@ public function testFetchSeveralCollectors() $total = []; $storeId = 1; $firstTotalMock = - $this->getMock('Magento\Quote\Model\Quote\Address\Total', ['setData', 'getCode'], [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, ['setData', 'getCode'], [], '', false); $secondTotalMock = - $this->getMock('Magento\Quote\Model\Quote\Address\Total', ['setData', 'getCode'], [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, ['setData', 'getCode'], [], '', false); $expected = ['first_total_type' => $firstTotalMock, 'second_total_type' => $secondTotalMock]; $data = [['code' => 'first_total_type'], ['code' => 'second_total_type']]; $this->totalMock->expects($this->once())->method('setData')->with([])->willReturnSelf(); @@ -144,7 +149,7 @@ public function testConvert() $total = []; $storeId = 1; $testedTotalMock = - $this->getMock('Magento\Quote\Model\Quote\Address\Total', ['setData', 'getCode'], [], '', false); + $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, ['setData', 'getCode'], [], '', false); $expected = ['my_total_type' => $testedTotalMock]; $this->totalMock->expects($this->once())->method('setData')->with([])->willReturnSelf(); $this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php index 3ac2883365df3..2ba9aaa751e4d 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php @@ -43,29 +43,29 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->addressRepositoryMock = $this->getMock( - '\Magento\Customer\Api\AddressRepositoryInterface', + \Magento\Customer\Api\AddressRepositoryInterface::class, [], [], '', false ); $this->quoteAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getCustomerId', 'load', 'getId', '__wakeup'], [], '', false ); $this->customerRepositoryMock = $this->getMock( - '\Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], [], '', false ); - $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->model = $this->objectManager->getObject( - '\Magento\Quote\Model\QuoteAddressValidator', + \Magento\Quote\Model\QuoteAddressValidator::class, [ 'addressRepository' => $this->addressRepositoryMock, 'customerRepository' => $this->customerRepositoryMock, @@ -81,8 +81,8 @@ protected function setUp() public function testValidateInvalidCustomer() { $customerId = 100; - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($customerId); $this->customerRepositoryMock->expects($this->once())->method('getById')->with($customerId) @@ -97,7 +97,7 @@ public function testValidateInvalidCustomer() public function testValidateInvalidAddress() { $this->markTestSkipped('MAGETWO-48531'); - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->customerRepositoryMock->expects($this->never())->method('getById'); $address->expects($this->atLeastOnce())->method('getId')->willReturn(101); @@ -114,7 +114,7 @@ public function testValidateNewAddress() { $this->customerRepositoryMock->expects($this->never())->method('getById'); $this->addressRepositoryMock->expects($this->never())->method('getById'); - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->assertTrue($this->model->validate($address)); } @@ -127,8 +127,8 @@ public function testValidateWithAddressOfOtherCustomer() $this->markTestSkipped('MAGETWO-48531'); $addressCustomer = 100; $addressId = 100; - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerRepositoryMock->expects($this->once())->method('getById')->with($addressCustomer) ->willReturn($customerMock); @@ -149,9 +149,9 @@ public function testValidateWithInvalidCustomerAddressId() { $this->markTestSkipped('MAGETWO-48531'); $customerAddressId = 42; - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); - $customerAddress = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $customerAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $address->expects($this->atLeastOnce())->method('getCustomerAddressId')->willReturn($customerAddressId); $this->customerSessionMock->expects($this->once())->method('getCustomerDataObject')->willReturn($customerMock); @@ -168,12 +168,12 @@ public function testValidateWithValidAddress() $addressId = 100; $customerAddressId = 42; - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); $address->expects($this->atLeastOnce())->method('getId')->willReturn($addressId); $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($addressCustomer); $address->expects($this->atLeastOnce())->method('getCustomerAddressId')->willReturn($customerAddressId); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); - $customerAddress = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $customerAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->customerRepositoryMock->expects($this->once())->method('getById')->willReturn($customerMock); $customerMock->expects($this->once())->method('getId')->willReturn($addressCustomer); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteIdMaskTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteIdMaskTest.php index 9a21cfcf68c46..2200ed2e39237 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteIdMaskTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteIdMaskTest.php @@ -22,7 +22,7 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->quoteIdMask = $helper->getObject( - 'Magento\Quote\Model\QuoteIdMask', + \Magento\Quote\Model\QuoteIdMask::class, ['randomDataGenerator' => new Random()] ); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php index 2664e7ef21ad7..8df85ec47af94 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php @@ -133,58 +133,70 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteValidator = $this->getMock('Magento\Quote\Model\QuoteValidator', [], [], '', false); - $this->eventManager = $this->getMockForAbstractClass('Magento\Framework\Event\ManagerInterface'); + $this->quoteValidator = $this->getMock(\Magento\Quote\Model\QuoteValidator::class, [], [], '', false); + $this->eventManager = $this->getMockForAbstractClass(\Magento\Framework\Event\ManagerInterface::class); $this->orderFactory = $this->getMock( - 'Magento\Sales\Api\Data\OrderInterfaceFactory', + \Magento\Sales\Api\Data\OrderInterfaceFactory::class, [ 'create' ], [], '', false ); $this->quoteAddressToOrder = $this->getMock( - 'Magento\Quote\Model\Quote\Address\ToOrder', + \Magento\Quote\Model\Quote\Address\ToOrder::class, [], [], '', false ); $this->quotePaymentToOrderPayment = $this->getMock( - 'Magento\Quote\Model\Quote\Payment\ToOrderPayment', + \Magento\Quote\Model\Quote\Payment\ToOrderPayment::class, [], [], '', false ); $this->quoteAddressToOrderAddress = $this->getMock( - 'Magento\Quote\Model\Quote\Address\ToOrderAddress', + \Magento\Quote\Model\Quote\Address\ToOrderAddress::class, [], [], '', false ); - $this->quoteItemToOrderItem = $this->getMock('Magento\Quote\Model\Quote\Item\ToOrderItem', [], [], '', false); - $this->orderManagement = $this->getMock('Magento\Sales\Api\OrderManagementInterface', [], [], '', false); - $this->customerManagement = $this->getMock('Magento\Quote\Model\CustomerManagement', [], [], '', false); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $this->quoteItemToOrderItem = $this->getMock( + \Magento\Quote\Model\Quote\Item\ToOrderItem::class, + [], + [], + '', + false + ); + $this->orderManagement = $this->getMock(\Magento\Sales\Api\OrderManagementInterface::class, [], [], '', false); + $this->customerManagement = $this->getMock(\Magento\Quote\Model\CustomerManagement::class, [], [], '', false); + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $this->userContextMock = $this->getMock('\Magento\Authorization\Model\UserContextInterface', [], [], '', false); + $this->userContextMock = $this->getMock( + \Magento\Authorization\Model\UserContextInterface::class, + [], + [], + '', + false + ); $this->customerRepositoryMock = $this->getMock( - '\Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, ['create', 'save', 'get', 'getById', 'getList', 'delete', 'deleteById'], [], '', false ); $this->customerFactoryMock = $this->getMock( - '\Magento\Customer\Model\CustomerFactory', + \Magento\Customer\Model\CustomerFactory::class, ['create'], [], '', false ); $this->storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, [], '', false, @@ -194,7 +206,7 @@ protected function setUp() ); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'getId', 'getCheckoutMethod', @@ -213,33 +225,33 @@ protected function setUp() ); $this->quoteAddressFactory = $this->getMock( - 'Magento\Quote\Model\Quote\AddressFactory', + \Magento\Quote\Model\Quote\AddressFactory::class, ['create'], [], '', false ); - $this->dataObjectHelperMock = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->dataObjectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); $this->checkoutSessionMock = $this->getMock( - 'Magento\Checkout\Model\Session', + \Magento\Checkout\Model\Session::class, ['setLastQuoteId', 'setLastSuccessQuoteId', 'setLastOrderId', 'setLastRealOrderId', 'setLastOrderStatus'], [], '', false ); - $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); $this->accountManagementMock = $this->getMock( - '\Magento\Customer\Api\AccountManagementInterface', + \Magento\Customer\Api\AccountManagementInterface::class, [], [], '', false ); - $this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', ['create'], [], '', false); + $this->quoteFactoryMock = $this->getMock(\Magento\Quote\Model\QuoteFactory::class, ['create'], [], '', false); $this->model = $objectManager->getObject( - '\Magento\Quote\Model\QuoteManagement', + \Magento\Quote\Model\QuoteManagement::class, [ 'eventManager' => $this->eventManager, 'quoteValidator' => $this->quoteValidator, @@ -265,7 +277,7 @@ protected function setUp() ); // Set the new dependency - $this->quoteIdMock = $this->getMock('Magento\Quote\Model\QuoteIdMask', [], [], '', false); + $this->quoteIdMock = $this->getMock(\Magento\Quote\Model\QuoteIdMask::class, [], [], '', false); $quoteIdFactoryMock = $this->getMock(\Magento\Quote\Model\QuoteIdMaskFactory::class, ['create'], [], '', false); $this->setPropertyValue($this->model, 'quoteIdMaskFactory', $quoteIdFactoryMock); @@ -276,9 +288,9 @@ public function testCreateEmptyCartAnonymous() $storeId = 345; $quoteId = 2311; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); - $quoteAddress = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $quoteMock->expects($this->any())->method('setBillingAddress')->with($quoteAddress)->willReturnSelf(); $quoteMock->expects($this->any())->method('setShippingAddress')->with($quoteAddress)->willReturnSelf(); @@ -303,7 +315,7 @@ public function testCreateEmptyCartForCustomer() $quoteId = 2311; $userId = 567; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock ->expects($this->once()) @@ -329,7 +341,7 @@ public function testCreateEmptyCartForCustomerReturnExistsQuote() $storeId = 345; $userId = 567; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock ->expects($this->once()) @@ -355,8 +367,8 @@ public function testAssignCustomerFromAnotherStore() $customerId = 455; $storeId = 5; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->quoteRepositoryMock ->expects($this->once()) @@ -371,7 +383,7 @@ public function testAssignCustomerFromAnotherStore() ->willReturn($customerMock); $customerModelMock = $this->getMock( - '\Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['load', 'getSharedStoreIds'], [], '', @@ -403,13 +415,13 @@ public function testAssignCustomerToNonanonymousCart() $storeId = 5; $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getCustomerId', 'setCustomer', 'setCustomerIsGuest'], [], '', false ); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->quoteRepositoryMock ->expects($this->once()) @@ -424,7 +436,7 @@ public function testAssignCustomerToNonanonymousCart() ->willReturn($customerMock); $customerModelMock = $this->getMock( - '\Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['load', 'getSharedStoreIds'], [], '', @@ -458,13 +470,13 @@ public function testAssignCustomerNoSuchCustomer() $storeId = 5; $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getCustomerId', 'setCustomer', 'setCustomerIsGuest'], [], '', false ); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->quoteRepositoryMock ->expects($this->once()) @@ -479,7 +491,7 @@ public function testAssignCustomerNoSuchCustomer() ->willReturn($customerMock); $customerModelMock = $this->getMock( - '\Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['load', 'getSharedStoreIds'], [], '', @@ -521,13 +533,13 @@ public function testAssignCustomer() $this->quoteIdMock->expects($this->once())->method('getId')->willReturn(10); $this->quoteIdMock->expects($this->once())->method('delete'); $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['getCustomerId', 'setCustomer', 'setCustomerIsGuest'], [], '', false ); - $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->quoteRepositoryMock ->expects($this->once()) @@ -542,7 +554,7 @@ public function testAssignCustomer() ->willReturn($customerMock); $customerModelMock = $this->getMock( - '\Magento\Customer\Model\Customer', + \Magento\Customer\Model\Customer::class, ['load', 'getSharedStoreIds'], [], '', @@ -583,17 +595,27 @@ public function testSubmit() $isVirtual = false; $customerId = 1; $quoteId = 1; - $quoteItem = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); - - $billingAddress = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); - $shippingAddress = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); - $payment = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - - $baseOrder = $this->getMock('Magento\Sales\Api\Data\OrderInterface', [], [], '', false); - $convertedBillingAddress = $this->getMock('Magento\Sales\Api\Data\OrderAddressInterface', [], [], '', false); - $convertedShippingAddress = $this->getMock('Magento\Sales\Api\Data\OrderAddressInterface', [], [], '', false); - $convertedPayment = $this->getMock('Magento\Sales\Api\Data\OrderPaymentInterface', [], [], '', false); - $convertedQuoteItem = $this->getMock('Magento\Sales\Api\Data\OrderItemInterface', [], [], '', false); + $quoteItem = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $billingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $shippingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $payment = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); + $baseOrder = $this->getMock(\Magento\Sales\Api\Data\OrderInterface::class, [], [], '', false); + $convertedBillingAddress = $this->getMock( + \Magento\Sales\Api\Data\OrderAddressInterface::class, + [], + [], + '', + false + ); + $convertedShippingAddress = $this->getMock( + \Magento\Sales\Api\Data\OrderAddressInterface::class, + [], + [], + '', + false + ); + $convertedPayment = $this->getMock(\Magento\Sales\Api\Data\OrderPaymentInterface::class, [], [], '', false); + $convertedQuoteItem = $this->getMock(\Magento\Sales\Api\Data\OrderItemInterface::class, [], [], '', false); $addresses = [$convertedShippingAddress, $convertedBillingAddress]; $quoteItems = [$quoteItem]; @@ -610,10 +632,7 @@ public function testSubmit() $shippingAddress ); - $this->quoteValidator->expects($this->once()) - ->method('validateBeforeSubmit') - ->with($quote); - + $this->quoteValidator->expects($this->once())->method('validateBeforeSubmit')->with($quote); $this->quoteAddressToOrder->expects($this->once()) ->method('convert') ->with($shippingAddress, $orderData) @@ -638,15 +657,11 @@ public function testSubmit() ] ) ->willReturn($convertedBillingAddress); - $this->quoteItemToOrderItem->expects($this->once()) - ->method('convert') + $this->quoteItemToOrderItem->expects($this->once())->method('convert') ->with($quoteItem, ['parent_item' => null]) ->willReturn($convertedQuoteItem); - $this->quotePaymentToOrderPayment->expects($this->once()) - ->method('convert') - ->with($payment) + $this->quotePaymentToOrderPayment->expects($this->once())->method('convert')->with($payment) ->willReturn($convertedPayment); - $shippingAddress->expects($this->once())->method('getShippingMethod')->willReturn('free'); $order = $this->prepareOrderFactory( @@ -663,16 +678,13 @@ public function testSubmit() ->method('place') ->with($order) ->willReturn($order); - $this->eventManager->expects($this->at(0)) ->method('dispatch') ->with('sales_model_service_quote_submit_before', ['order' => $order, 'quote' => $quote]); $this->eventManager->expects($this->at(1)) ->method('dispatch') ->with('sales_model_service_quote_submit_success', ['order' => $order, 'quote' => $quote]); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quote); - $this->assertEquals($order, $this->model->submit($quote, $orderData)); } @@ -695,7 +707,7 @@ public function testPlaceOrderIfCustomerIsGuest() $this->quoteMock->expects($this->once())->method('setCustomerId')->with(null)->willReturnSelf(); $this->quoteMock->expects($this->once())->method('setCustomerEmail')->with($email)->willReturnSelf(); - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', ['getEmail'], [], '', false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, ['getEmail'], [], '', false); $addressMock->expects($this->once())->method('getEmail')->willReturn($email); $this->quoteMock->expects($this->once())->method('getBillingAddress')->with()->willReturn($addressMock); @@ -706,7 +718,7 @@ public function testPlaceOrderIfCustomerIsGuest() /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ $service = $this->getMock( - '\Magento\Quote\Model\QuoteManagement', + \Magento\Quote\Model\QuoteManagement::class, ['submit'], [ 'eventManager' => $this->eventManager, @@ -732,7 +744,7 @@ public function testPlaceOrderIfCustomerIsGuest() ] ); $orderMock = $this->getMock( - '\Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', @@ -764,7 +776,7 @@ public function testPlaceOrder() /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ $service = $this->getMock( - '\Magento\Quote\Model\QuoteManagement', + \Magento\Quote\Model\QuoteManagement::class, ['submit'], [ 'eventManager' => $this->eventManager, @@ -790,7 +802,7 @@ public function testPlaceOrder() ] ); $orderMock = $this->getMock( - '\Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, [], [], '', @@ -802,7 +814,7 @@ public function testPlaceOrder() ->with($cartId) ->willReturn($this->quoteMock); - $quotePayment = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $quotePayment = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $quotePayment->expects($this->once()) ->method('setQuote'); $quotePayment->expects($this->once()) @@ -832,7 +844,13 @@ public function testPlaceOrder() $this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId); $this->checkoutSessionMock->expects($this->once())->method('setLastOrderStatus')->with($orderStatus); - $paymentMethod = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $paymentMethod = $this->getMock( + \Magento\Quote\Model\Quote\Payment::class, + ['setChecks', 'getData'], + [], + '', + false + ); $paymentMethod->expects($this->once())->method('setChecks'); $paymentMethod->expects($this->once())->method('getData')->willReturn(['additional_data' => []]); @@ -861,7 +879,7 @@ protected function getQuote( \Magento\Quote\Model\Quote\Address $shippingAddress = null ) { $quote = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'setIsActive', 'getCustomerEmail', @@ -907,7 +925,7 @@ protected function getQuote( ->method('getPayment') ->willReturn($payment); - $customer = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); $customer->expects($this->once()) ->method('getId') ->willReturn($customerId); @@ -945,7 +963,7 @@ protected function prepareOrderFactory( $customerId = null ) { $order = $this->getMock( - 'Magento\Sales\Model\Order', + \Magento\Sales\Model\Order::class, ['setShippingAddress', 'getAddressesCollection', 'getAddresses', 'getBillingAddress', 'addAddresses', 'setBillingAddress', 'setAddresses', 'setPayment', 'setItems', 'setQuoteId'], [], @@ -984,7 +1002,7 @@ protected function prepareOrderFactory( public function testGetCartForCustomer() { $customerId = 100; - $cartMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $cartMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActiveForCustomer') ->with($customerId) diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepository/Plugin/AuthorizationTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepository/Plugin/AuthorizationTest.php index b04207c72601e..5d00745f4ab57 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepository/Plugin/AuthorizationTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepository/Plugin/AuthorizationTest.php @@ -25,7 +25,7 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->userContextMock = $this->getMock('Magento\Authorization\Model\UserContextInterface'); + $this->userContextMock = $this->getMock(\Magento\Authorization\Model\UserContextInterface::class); $this->authorization = new Authorization($this->userContextMock); } @@ -36,8 +36,8 @@ protected function setUp() public function testAfterGetActiveThrowsExceptionIfQuoteIsNotAllowedForCurrentUserContext() { // Quote without customer ID - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', ['getCustomerId'], [], '', false); - $quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getCustomerId'], [], '', false); + $quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->userContextMock->expects($this->any()) ->method('getUserType') ->willReturn(UserContextInterface::USER_TYPE_CUSTOMER); @@ -48,8 +48,8 @@ public function testAfterGetActiveThrowsExceptionIfQuoteIsNotAllowedForCurrentUs public function testAfterGetActiveReturnsQuoteIfQuoteIsAllowedForCurrentUserContext() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->userContextMock->expects($this->any()) ->method('getUserType') ->willReturn(UserContextInterface::USER_TYPE_GUEST); @@ -63,8 +63,8 @@ public function testAfterGetActiveReturnsQuoteIfQuoteIsAllowedForCurrentUserCont public function testAfterGetActiveForCustomerThrowsExceptionIfQuoteIsNotAllowedForCurrentUserContext() { // Quote without customer ID - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', ['getCustomerId'], [], '', false); - $quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, ['getCustomerId'], [], '', false); + $quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->userContextMock->expects($this->any())->method('getUserType')->willReturn( UserContextInterface::USER_TYPE_CUSTOMER ); @@ -75,8 +75,8 @@ public function testAfterGetActiveForCustomerThrowsExceptionIfQuoteIsNotAllowedF public function testAfterGetActiveForCustomerReturnsQuoteIfQuoteIsAllowedForCurrentUserContext() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->userContextMock->expects($this->any()) ->method('getUserType') ->willReturn(UserContextInterface::USER_TYPE_GUEST); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php index db0e186a50329..c46c99b93014e 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php @@ -12,6 +12,9 @@ use Magento\Framework\Api\SortOrder; use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase { /** @@ -58,10 +61,10 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', ['create'], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->quoteFactoryMock = $this->getMock(\Magento\Quote\Model\QuoteFactory::class, ['create'], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'load', 'loadByCustomer', @@ -77,9 +80,9 @@ protected function setUp() '', false ); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->searchResultsDataFactory = $this->getMock( - '\Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory', + \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory::class, ['create'], [], '', @@ -87,10 +90,10 @@ protected function setUp() ); $this->quoteCollectionMock = - $this->getMock('Magento\Quote\Model\ResourceModel\Quote\Collection', [], [], '', false); + $this->getMock(\Magento\Quote\Model\ResourceModel\Quote\Collection::class, [], [], '', false); $this->extensionAttributesJoinProcessorMock = $this->getMock( - 'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, [], [], '', @@ -98,7 +101,7 @@ protected function setUp() ); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\QuoteRepository', + \Magento\Quote\Model\QuoteRepository::class, [ 'quoteFactory' => $this->quoteFactoryMock, 'storeManager' => $this->storeManagerMock, @@ -331,10 +334,10 @@ public function testDelete() public function testGetListSuccess($direction, $expectedDirection) { $this->markTestSkipped('MAGETWO-48531'); - $searchResult = $this->getMock('\Magento\Quote\Api\Data\CartSearchResultsInterface', [], [], '', false); - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); - $cartMock = $this->getMock('Magento\Payment\Model\Cart', [], [], '', false); - $filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); + $searchResult = $this->getMock(\Magento\Quote\Api\Data\CartSearchResultsInterface::class, [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); + $cartMock = $this->getMock(\Magento\Payment\Model\Cart::class, [], [], '', false); + $filterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); $pageSize = 10; $this->searchResultsDataFactory @@ -346,7 +349,7 @@ public function testGetListSuccess($direction, $expectedDirection) ->expects($this->once()) ->method('setSearchCriteria'); - $filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false); + $filterGroupMock = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); $searchCriteriaMock ->expects($this->any()) ->method('getFilterGroups') @@ -361,7 +364,7 @@ public function testGetListSuccess($direction, $expectedDirection) //back in getList() $this->quoteCollectionMock->expects($this->once())->method('getSize')->willReturn($pageSize); $searchResult->expects($this->once())->method('setTotalCount')->with($pageSize); - $sortOrderMock = $this->getMockBuilder('Magento\Framework\Api\SortOrder') + $sortOrderMock = $this->getMockBuilder(\Magento\Framework\Api\SortOrder::class) ->setMethods(['getField', 'getDirection']) ->disableOriginalConstructor() ->getMock(); @@ -383,14 +386,14 @@ public function testGetListSuccess($direction, $expectedDirection) $this->extensionAttributesJoinProcessorMock->expects($this->once()) ->method('process') ->with( - $this->isInstanceOf('\Magento\Quote\Model\ResourceModel\Quote\Collection') + $this->isInstanceOf(\Magento\Quote\Model\ResourceModel\Quote\Collection::class) ); $this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]); $searchResult->expects($this->once())->method('setItems')->with([$cartMock]); $this->model = $this->getMock( - 'Magento\Quote\Model\QuoteRepository', + \Magento\Quote\Model\QuoteRepository::class, ['getQuoteCollection'], [ 'quoteFactory' => $this->quoteFactoryMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php index 7da2feffe464e..7bb93cf35a8a9 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php @@ -143,14 +143,14 @@ class QuoteTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteAddressFactoryMock = $this->getMock( - 'Magento\Quote\Model\Quote\AddressFactory', + \Magento\Quote\Model\Quote\AddressFactory::class, ['create'], [], '', false ); $this->quoteAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'isDeleted', 'getCollection', 'getId', 'getCustomerAddressId', '__wakeup', 'getAddressType', 'getDeleteImmediately', 'validateMinimumAmount', 'setData' @@ -160,21 +160,21 @@ protected function setUp() false ); $this->quoteAddressCollectionMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Address\Collection', + \Magento\Quote\Model\ResourceModel\Quote\Address\Collection::class, [], [], '', false ); $this->extensibleDataObjectConverterMock = $this->getMock( - 'Magento\Framework\Api\ExtensibleDataObjectConverter', + \Magento\Framework\Api\ExtensibleDataObjectConverter::class, ['toFlatArray'], [], '', false ); $this->customerRepositoryMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\CustomerRepositoryInterface', + \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false, @@ -183,14 +183,20 @@ protected function setUp() ['getById'] ); $this->objectCopyServiceMock = $this->getMock( - 'Magento\Framework\DataObject\Copy', + \Magento\Framework\DataObject\Copy::class, ['copyFieldsetToTarget'], [], '', false ); - $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); - $this->objectFactoryMock = $this->getMock('\Magento\Framework\DataObject\Factory', ['create'], [], '', false); + $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->objectFactoryMock = $this->getMock( + \Magento\Framework\DataObject\Factory::class, + ['create'], + [], + '', + false + ); $this->quoteAddressFactoryMock->expects( $this->any() )->method( @@ -205,69 +211,70 @@ protected function setUp() )->will( $this->returnValue($this->quoteAddressCollectionMock) ); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class) ->disableOriginalConstructor() ->getMock(); - $this->resourceMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote') + $this->resourceMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->customerFactoryMock = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory') + $this->customerFactoryMock = $this->getMockBuilder(\Magento\Customer\Model\CustomerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->groupRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\GroupRepositoryInterface') + $this->groupRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\GroupRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any()) ->method('getEventDispatcher') ->will($this->returnValue($this->eventManagerMock)); $this->quoteItemCollectionFactoryMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory', + \Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory::class, ['create'], [], '', false ); $this->quotePaymentCollectionFactoryMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Payment\CollectionFactory', + \Magento\Quote\Model\ResourceModel\Quote\Payment\CollectionFactory::class, ['create'], [], '', false ); $this->paymentFactoryMock = $this->getMock( - 'Magento\Quote\Model\Quote\PaymentFactory', + \Magento\Quote\Model\Quote\PaymentFactory::class, ['create'], [], '', false ); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->addressRepositoryMock = $this->getMockForAbstractClass('Magento\Customer\Api\AddressRepositoryInterface', + $this->addressRepositoryMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\AddressRepositoryInterface::class, [], '', false ); - $this->criteriaBuilderMock = $this->getMockBuilder('Magento\Framework\Api\SearchCriteriaBuilder') + $this->criteriaBuilderMock = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteriaBuilder::class) ->disableOriginalConstructor() ->getMock(); - $this->filterBuilderMock = $this->getMockBuilder('Magento\Framework\Api\FilterBuilder') + $this->filterBuilderMock = $this->getMockBuilder(\Magento\Framework\Api\FilterBuilder::class) ->disableOriginalConstructor() ->getMock(); $this->extensionAttributesJoinProcessorMock = $this->getMock( - 'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface', + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, [], [], '', @@ -276,7 +283,7 @@ protected function setUp() $this->quote = (new ObjectManager($this)) ->getObject( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'quoteAddressFactory' => $this->quoteAddressFactoryMock, 'storeManager' => $this->storeManagerMock, @@ -374,7 +381,7 @@ public function dataProviderForTestIsMultipleShippingAddresses() protected function getAddressMock($type) { $shippingAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getAddressType', '__wakeup'], [], '', @@ -388,7 +395,7 @@ protected function getAddressMock($type) public function testGetStoreIdNoId() { - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $storeMock->expects($this->once()) @@ -414,7 +421,7 @@ public function testGetStore() { $storeId = 1; - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $this->storeManagerMock->expects($this->once()) @@ -424,14 +431,14 @@ public function testGetStore() $this->quote->setStoreId($storeId); $result = $this->quote->getStore(); - $this->assertInstanceOf('Magento\Store\Model\Store', $result); + $this->assertInstanceOf(\Magento\Store\Model\Store::class, $result); } public function testSetStore() { $storeId = 1; - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $storeMock->expects($this->once()) @@ -439,7 +446,7 @@ public function testSetStore() ->will($this->returnValue($storeId)); $result = $this->quote->setStore($storeMock); - $this->assertInstanceOf('Magento\Quote\Model\Quote', $result); + $this->assertInstanceOf(\Magento\Quote\Model\Quote::class, $result); } public function testGetSharedWebsiteStoreIds() @@ -447,7 +454,7 @@ public function testGetSharedWebsiteStoreIds() $sharedIds = null; $storeIds = [1, 2, 3]; - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->disableOriginalConstructor() ->getMock(); $websiteMock->expects($this->once()) @@ -466,14 +473,14 @@ public function testGetSharedStoreIds() $storeIds = [1, 2, 3]; $storeId = 1; - $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + $websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->disableOriginalConstructor() ->getMock(); $websiteMock->expects($this->once()) ->method('getStoreIds') ->will($this->returnValue($storeIds)); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $storeMock->expects($this->once()) @@ -503,7 +510,7 @@ public function testLoadActive() ->method('dispatch'); $result = $this->quote->loadActive($quoteId); - $this->assertInstanceOf('Magento\Quote\Model\Quote', $result); + $this->assertInstanceOf(\Magento\Quote\Model\Quote::class, $result); } public function testloadByIdWithoutStore() @@ -518,7 +525,7 @@ public function testloadByIdWithoutStore() ->method('dispatch'); $result = $this->quote->loadByIdWithoutStore($quoteId); - $this->assertInstanceOf('Magento\Quote\Model\Quote', $result); + $this->assertInstanceOf(\Magento\Quote\Model\Quote::class, $result); } /** @@ -528,7 +535,7 @@ public function testSetCustomerAddressData() { $customerId = 1; $addressMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AddressInterface', + \Magento\Customer\Api\Data\AddressInterface::class, [], '', false, @@ -542,9 +549,14 @@ public function testSetCustomerAddressData() $addresses = [$addressMock]; - $customerMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\CustomerInterface', [], '', false); + $customerMock = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\CustomerInterface::class, + [], + '', + false + ); $customerResultMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false @@ -557,7 +569,7 @@ public function testSetCustomerAddressData() ->will($this->returnValue($addresses)); $result = $this->quote->setCustomerAddressData([$addressMock]); - $this->assertInstanceOf('Magento\Quote\Model\Quote', $result); + $this->assertInstanceOf(\Magento\Quote\Model\Quote::class, $result); $this->assertEquals($customerResultMock, $this->quote->getCustomer()); } @@ -565,7 +577,7 @@ public function testGetCustomerTaxClassId() { $groupId = 1; $taxClassId = 1; - $groupMock = $this->getMockForAbstractClass('Magento\Customer\Api\Data\GroupInterface', [], '', false); + $groupMock = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\GroupInterface::class, [], '', false); $groupMock->expects($this->once()) ->method('getTaxClassId') ->willReturn($taxClassId); @@ -745,7 +757,7 @@ public function testRemoveAddress() $this->quote->setId($id); $result = $this->quote->removeAddress($id); - $this->assertInstanceOf('Magento\Quote\Model\Quote', $result); + $this->assertInstanceOf(\Magento\Quote\Model\Quote::class, $result); } public function testRemoveAllAddresses() @@ -788,7 +800,7 @@ public function testRemoveAllAddresses() $this->quote->setId($id); $result = $this->quote->removeAllAddresses(); - $this->assertInstanceOf('Magento\Quote\Model\Quote', $result); + $this->assertInstanceOf(\Magento\Quote\Model\Quote::class, $result); } /** @@ -803,7 +815,7 @@ public function testAddProductNoCandidates() { $expectedResult = 'test_string'; $requestMock = $this->getMock( - '\Magento\Framework\DataObject' + \Magento\Framework\DataObject::class ); $this->objectFactoryMock->expects($this->once()) ->method('create') @@ -811,7 +823,7 @@ public function testAddProductNoCandidates() ->will($this->returnValue($requestMock)); $typeInstanceMock = $this->getMock( - 'Magento\Catalog\Model\Product\Type\Simple', + \Magento\Catalog\Model\Product\Type\Simple::class, [ 'prepareForCartAdvanced' ], @@ -833,7 +845,7 @@ public function testAddProductNoCandidates() public function testAddProductItemPreparation() { $itemMock = $this->getMock( - '\Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, [], [], '', @@ -842,7 +854,7 @@ public function testAddProductItemPreparation() $expectedResult = $itemMock; $requestMock = $this->getMock( - '\Magento\Framework\DataObject' + \Magento\Framework\DataObject::class ); $this->objectFactoryMock->expects($this->once()) ->method('create') @@ -850,7 +862,7 @@ public function testAddProductItemPreparation() ->will($this->returnValue($requestMock)); $typeInstanceMock = $this->getMock( - 'Magento\Catalog\Model\Product\Type\Simple', + \Magento\Catalog\Model\Product\Type\Simple::class, [ 'prepareForCartAdvanced' ], @@ -860,7 +872,7 @@ public function testAddProductItemPreparation() ); $productMock = $this->getMock( - 'Magento\Catalog\Model\Product', + \Magento\Catalog\Model\Product::class, [ 'getParentProductId', 'setStickWithinParent', @@ -872,7 +884,7 @@ public function testAddProductItemPreparation() ); $collectionMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Item\Collection', + \Magento\Quote\Model\ResourceModel\Quote\Item\Collection::class, [], [], '', @@ -959,7 +971,7 @@ public function testGetPaymentIsNotDeleted() { $this->quote->setId(1); $payment = $this->getMock( - 'Magento\Quote\Model\Quote\Payment', + \Magento\Quote\Model\Quote\Payment::class, ['setQuote', 'isDeleted', '__wakeup'], [], '', @@ -971,7 +983,7 @@ public function testGetPaymentIsNotDeleted() ->method('isDeleted') ->willReturn(false); $quotePaymentCollectionMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Payment\Collection', + \Magento\Quote\Model\ResourceModel\Quote\Payment\Collection::class, ['setQuoteFilter', 'getFirstItem'], [], '', @@ -988,14 +1000,14 @@ public function testGetPaymentIsNotDeleted() ->method('create') ->willReturn($quotePaymentCollectionMock); - $this->assertInstanceOf('\Magento\Quote\Model\Quote\Payment', $this->quote->getPayment()); + $this->assertInstanceOf(\Magento\Quote\Model\Quote\Payment::class, $this->quote->getPayment()); } public function testGetPaymentIsDeleted() { $this->quote->setId(1); $payment = $this->getMock( - 'Magento\Quote\Model\Quote\Payment', + \Magento\Quote\Model\Quote\Payment::class, ['setQuote', 'isDeleted', 'getId', '__wakeup'], [], '', @@ -1010,7 +1022,7 @@ public function testGetPaymentIsDeleted() ->method('getId') ->willReturn(1); $quotePaymentCollectionMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Payment\Collection', + \Magento\Quote\Model\ResourceModel\Quote\Payment\Collection::class, ['setQuoteFilter', 'getFirstItem'], [], '', @@ -1031,19 +1043,19 @@ public function testGetPaymentIsDeleted() ->method('create') ->willReturn($payment); - $this->assertInstanceOf('\Magento\Quote\Model\Quote\Payment', $this->quote->getPayment()); + $this->assertInstanceOf(\Magento\Quote\Model\Quote\Payment::class, $this->quote->getPayment()); } public function testAddItem() { - $item = $this->getMock('Magento\Quote\Model\Quote\Item', ['setQuote', 'getId'], [], '', false); + $item = $this->getMock(\Magento\Quote\Model\Quote\Item::class, ['setQuote', 'getId'], [], '', false); $item->expects($this->once()) ->method('setQuote'); $item->expects($this->once()) ->method('getId') ->willReturn(false); $itemsMock = $this->getMock( - 'Magento\Eav\Model\Entity\Collection\AbstractCollection', + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, ['setQuote', 'addItem'], [], '', @@ -1071,7 +1083,7 @@ public function testAddItem() public function testBeforeSaveIsVirtualQuote(array $productTypes, $expected) { $storeId = 1; - $currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + $currencyMock = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) ->disableOriginalConstructor() ->getMock(); $currencyMock->expects($this->any()) @@ -1080,7 +1092,7 @@ public function testBeforeSaveIsVirtualQuote(array $productTypes, $expected) $currencyMock->expects($this->any()) ->method('getRate') ->will($this->returnValue('test_rate')); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); $storeMock->expects($this->once()) @@ -1097,7 +1109,7 @@ public function testBeforeSaveIsVirtualQuote(array $productTypes, $expected) $this->quote->setStoreId($storeId); $collectionMock = $this->getMock( - 'Magento\Quote\Model\ResourceModel\Quote\Item\Collection', + \Magento\Quote\Model\ResourceModel\Quote\Item\Collection::class, [], [], '', @@ -1105,11 +1117,11 @@ public function testBeforeSaveIsVirtualQuote(array $productTypes, $expected) ); $items = []; foreach ($productTypes as $type) { - $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $productMock->expects($this->any())->method('getIsVirtual')->willReturn($type); $itemMock = $this->getMock( - 'Magento\Quote\Model\Quote\Item', + \Magento\Quote\Model\Quote\Item::class, ['isDeleted', 'getParentItemId', 'getProduct'], [], '', @@ -1154,7 +1166,7 @@ public function dataProviderForTestBeforeSaveIsVirtualQuote() public function testGetItemsCollection() { - $itemCollectionMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote\Collection') + $itemCollectionMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Collection::class) ->disableOriginalConstructor() ->setMethods(['setQuote']) ->getMock(); @@ -1165,7 +1177,7 @@ public function testGetItemsCollection() $this->extensionAttributesJoinProcessorMock->expects($this->once()) ->method('process') ->with( - $this->isInstanceOf('Magento\Quote\Model\ResourceModel\Quote\Collection') + $this->isInstanceOf(\Magento\Quote\Model\ResourceModel\Quote\Collection::class) ); $itemCollectionMock->expects($this->once())->method('setQuote')->with($this->quote); @@ -1174,7 +1186,7 @@ public function testGetItemsCollection() public function testGetAllItems() { - $itemOneMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote\Item') + $itemOneMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Item::class) ->setMethods(['isDeleted']) ->disableOriginalConstructor() ->getMock(); @@ -1182,7 +1194,7 @@ public function testGetAllItems() ->method('isDeleted') ->willReturn(false); - $itemTwoMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote\Item') + $itemTwoMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Item::class) ->setMethods(['isDeleted']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteValidatorTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteValidatorTest.php index 41d607ecbd0ce..b018ee074d2c3 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteValidatorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteValidatorTest.php @@ -30,7 +30,7 @@ protected function setUp() $this->quoteValidator = new \Magento\Quote\Model\QuoteValidator(); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'getShippingAddress', 'getBillingAddress', @@ -109,7 +109,7 @@ public function testCheckQuoteAmountAmountGreaterThanAvailable() */ public function testValidateBeforeSubmitThrowsExceptionIfShippingAddressIsInvalid() { - $shippingAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $shippingAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->quoteMock->expects($this->any())->method('getShippingAddress')->willReturn($shippingAddressMock); $this->quoteMock->expects($this->any())->method('isVirtual')->willReturn(false); $shippingAddressMock->expects($this->any())->method('validate')->willReturn(['Invalid Shipping Address']); @@ -125,7 +125,7 @@ public function testValidateBeforeSubmitThrowsExceptionIfShippingRateIsNotSelect { $shippingMethod = 'checkmo'; $shippingAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'validate', 'getShippingMethod', @@ -151,7 +151,7 @@ public function testValidateBeforeSubmitThrowsExceptionIfShippingRateIsNotSelect */ public function testValidateBeforeSubmitThrowsExceptionIfBillingAddressIsNotValid() { - $billingAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $billingAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $this->quoteMock->expects($this->any())->method('getBillingAddress')->willReturn($billingAddressMock); $this->quoteMock->expects($this->any())->method('isVirtual')->willReturn(true); $billingAddressMock->expects($this->any())->method('validate')->willReturn(['Invalid Billing Address']); @@ -165,8 +165,8 @@ public function testValidateBeforeSubmitThrowsExceptionIfBillingAddressIsNotVali */ public function testValidateBeforeSubmitThrowsExceptionIfPaymentMethodIsNotSelected() { - $paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); - $billingAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); + $billingAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $billingAddressMock->expects($this->any())->method('validate')->willReturn(true); $this->quoteMock->expects($this->any())->method('getBillingAddress')->willReturn($billingAddressMock); diff --git a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/Item/CollectionTest.php b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/Item/CollectionTest.php index a948072e96d5f..59dab75405398 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/Item/CollectionTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/Item/CollectionTest.php @@ -58,26 +58,38 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactory', [], [], '', false); + $this->entityFactoryMock = $this->getMock( + \Magento\Framework\Data\Collection\EntityFactory::class, + [], + [], + '', + false + ); $this->fetchStrategyMock = $this->getMockForAbstractClass( - 'Magento\Framework\Data\Collection\Db\FetchStrategyInterface' + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class ); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); - $this->selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); - $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $this->connectionMock->expects($this->atLeastOnce()) ->method('select') ->will($this->returnValue($this->selectMock)); - $this->resourceMock = $this->getMock('Magento\Framework\Model\ResourceModel\Db\AbstractDb', [], [], '', false); + $this->resourceMock = $this->getMock( + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, + [], + [], + '', + false + ); $this->resourceMock->expects($this->any())->method('getConnection')->will( $this->returnValue($this->connectionMock) ); $objectManager = new ObjectManager($this); $this->collection = $objectManager->getObject( - 'Magento\Quote\Model\ResourceModel\Quote\Item\Collection', + \Magento\Quote\Model\ResourceModel\Quote\Item\Collection::class, [ 'entityFactory' => $this->entityFactoryMock, 'fetchStrategy' => $this->fetchStrategyMock, @@ -90,7 +102,7 @@ protected function setUp() public function testInstanceOf() { $this->assertInstanceOf( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Collection', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Collection::class, $this->collection ); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/ItemTest.php b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/ItemTest.php index 4a710ef723810..2e39e03ebb00e 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/ItemTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/ItemTest.php @@ -57,10 +57,10 @@ class ItemTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->quoteItemMock = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); + $this->resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ 'describeTable', 'insert', @@ -76,27 +76,27 @@ protected function setUp() false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', false ); $this->relationCompositeMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class, [], [], '', false ); $this->objectRelationProcessorMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, [], [], '', false ); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $contextMock->expects($this->once()) ->method('getObjectRelationProcessor') @@ -104,7 +104,7 @@ protected function setUp() $objectManager = new ObjectManagerHelper($this); $this->model = $objectManager->getObject( - 'Magento\Quote\Model\ResourceModel\Quote\Item', + \Magento\Quote\Model\ResourceModel\Quote\Item::class, [ 'context' => $contextMock, 'entitySnapshot' => $this->entitySnapshotMock, @@ -115,7 +115,10 @@ protected function setUp() public function testInstanceOf() { - $this->assertInstanceOf('Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb', $this->model); + $this->assertInstanceOf( + \Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb::class, + $this->model + ); } public function testSaveNotModifiedItem() diff --git a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/QuoteAddressTest.php b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/QuoteAddressTest.php index 4d2ca4785ef90..bd0a7eb56b6e5 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/QuoteAddressTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/Quote/QuoteAddressTest.php @@ -53,42 +53,42 @@ class QuoteAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->addressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['__wakeup', 'getOrderId', 'hasDataChanges', 'beforeSave', 'afterSave', 'validateBeforeSave', 'getOrder'], [], '', false ); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['__wakeup', 'getId'], [], '', false ); $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\ResourceConnection', + \Magento\Framework\App\ResourceConnection::class, [], [], '', false ); $this->connectionMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false ); $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, [], [], '', false ); $this->relationCompositeMock = $this->getMock( - 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite', + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class, [], [], '', @@ -106,7 +106,7 @@ protected function setUp() $this->connectionMock->expects($this->any()) ->method('lastInsertId'); $this->addressResource = $objectManager->getObject( - 'Magento\Quote\Model\ResourceModel\Quote\Address', + \Magento\Quote\Model\ResourceModel\Quote\Address::class, [ 'resource' => $this->appResourceMock, 'entitySnapshot' => $this->entitySnapshotMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php index 968ef83c81685..09125c0328725 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php @@ -10,6 +10,9 @@ namespace Magento\Quote\Test\Unit\Model; use \Magento\Quote\Model\ShippingAddressManagement; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase { /** @@ -50,11 +53,11 @@ class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->quoteAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'setSameAsBilling', 'setCollectShippingRates', @@ -70,15 +73,21 @@ protected function setUp() false ); $this->validatorMock = $this->getMock( - 'Magento\Quote\Model\QuoteAddressValidator', [], [], '', false + \Magento\Quote\Model\QuoteAddressValidator::class, [], [], '', false + ); + $this->totalsCollectorMock = $this->getMock( + \Magento\Quote\Model\Quote\TotalsCollector::class, + [], + [], + '', + false ); - $this->totalsCollectorMock = $this->getMock('Magento\Quote\Model\Quote\TotalsCollector', [], [], '', false); $this->service = $this->objectManager->getObject( - '\Magento\Quote\Model\ShippingAddressManagement', + \Magento\Quote\Model\ShippingAddressManagement::class, [ 'quoteRepository' => $this->quoteRepositoryMock, 'addressValidator' => $this->validatorMock, - 'logger' => $this->getMock('\Psr\Log\LoggerInterface'), + 'logger' => $this->getMock(\Psr\Log\LoggerInterface::class), 'scopeConfig' => $this->scopeConfigMock, 'totalsCollector' => $this->totalsCollectorMock ] @@ -91,7 +100,7 @@ protected function setUp() */ public function testSetAddressValidationFailed() { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') ->with('cart654') @@ -107,7 +116,7 @@ public function testSetAddress() { $this->markTestSkipped('MAGETWO-48531'); $addressId = 1; - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') ->with('cart867') @@ -143,7 +152,7 @@ public function testSetAddress() */ public function testSetAddressForVirtualProduct() { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') ->with('cart867') @@ -170,7 +179,7 @@ public function testSetAddressWithInabilityToSaveQuote() new \Exception('Unable to save address. Please check input data.') ); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->totalsCollectorMock ->expects($this->once()) ->method('collectAddressTotals') @@ -197,7 +206,7 @@ public function testSetAddressWithViolationOfMinimumAmount() $storeId = 12; $this->quoteAddressMock->expects($this->once())->method('save'); - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cart123') ->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); @@ -215,12 +224,12 @@ public function testSetAddressWithViolationOfMinimumAmount() public function testGetAddress() { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cartId')->will( $this->returnValue($quoteMock) ); - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($addressMock)); $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(false)); $this->assertEquals($addressMock, $this->service->get('cartId')); @@ -232,7 +241,7 @@ public function testGetAddress() */ public function testGetAddressOfQuoteWithVirtualProducts() { - $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with('cartId')->will( $this->returnValue($quoteMock) ); diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php index 8be6c8befe20b..00d13003c8153 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php @@ -12,6 +12,9 @@ use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ShippingMethodManagementTest extends \PHPUnit_Framework_TestCase { /** @@ -57,9 +60,9 @@ class ShippingMethodManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->methodDataFactoryMock = $this->getMock( - '\Magento\Quote\Api\Data\ShippingMethodInterfaceFactory', + \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory::class, [ 'create' ], @@ -68,9 +71,9 @@ protected function setUp() false ); - $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'getShippingAddress', 'isVirtual', @@ -86,7 +89,7 @@ protected function setUp() false ); $this->shippingAddressMock = $this->getMock( - '\Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'getCountryId', 'getShippingMethod', @@ -105,7 +108,7 @@ protected function setUp() false ); $this->converterMock = $this->getMock( - '\Magento\Quote\Model\Cart\ShippingMethodConverter', + \Magento\Quote\Model\Cart\ShippingMethodConverter::class, [], [], '', @@ -113,7 +116,7 @@ protected function setUp() ); $this->model = $this->objectManager->getObject( - 'Magento\Quote\Model\ShippingMethodManagement', + \Magento\Quote\Model\ShippingMethodManagement::class, [ 'quoteRepository' => $this->quoteRepositoryMock, 'methodDataFactory' => $this->methodDataFactoryMock, @@ -155,14 +158,14 @@ public function testGetMethod() ->method('getShippingMethod')->will($this->returnValue('one_two')); $this->shippingAddressMock->expects($this->once())->method('collectShippingRates')->willReturnSelf(); - $shippingRateMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', [], [], '', false); + $shippingRateMock = $this->getMock(\Magento\Quote\Model\Quote\Address\Rate::class, [], [], '', false); $this->shippingAddressMock->expects($this->once()) ->method('getShippingRateByCode') ->with('one_two') ->willReturn($shippingRateMock); - $this->shippingMethodMock = $this->getMock('\Magento\Quote\Api\Data\ShippingMethodInterface'); + $this->shippingMethodMock = $this->getMock(\Magento\Quote\Api\Data\ShippingMethodInterface::class); $this->converterMock->expects($this->once()) ->method('modelToDataObject') ->with($shippingRateMock, $currencyCode) @@ -244,7 +247,7 @@ public function testGetList() ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(345)); $this->shippingAddressMock->expects($this->once())->method('collectShippingRates'); - $shippingRateMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', [], [], '', false); + $shippingRateMock = $this->getMock(\Magento\Quote\Model\Quote\Address\Rate::class, [], [], '', false); $this->shippingAddressMock->expects($this->once()) ->method('getGroupedAllShippingRates') ->will($this->returnValue([[$shippingRateMock]])); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php b/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php index 1f05e619fdfca..4a36cd8bb985b 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php @@ -29,12 +29,12 @@ class ParamOverriderCartIdTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->userContext = $this->getMockBuilder('Magento\Authorization\Model\UserContextInterface') + $this->userContext = $this->getMockBuilder(\Magento\Authorization\Model\UserContextInterface::class) ->getMockForAbstractClass(); - $this->cartManagement = $this->getMockBuilder('Magento\Quote\Api\CartManagementInterface') + $this->cartManagement = $this->getMockBuilder(\Magento\Quote\Api\CartManagementInterface::class) ->getMockForAbstractClass(); $this->model = (new ObjectManager($this))->getObject( - 'Magento\Quote\Model\Webapi\ParamOverriderCartId', + \Magento\Quote\Model\Webapi\ParamOverriderCartId::class, [ 'userContext' => $this->userContext, 'cartManagement' => $this->cartManagement, @@ -54,7 +54,7 @@ public function testGetOverriddenValueIsCustomerAndCartExists() ->method('getUserId') ->will($this->returnValue($customerId)); - $cart = $this->getMockBuilder('Magento\Quote\Api\Data\CartInterface') + $cart = $this->getMockBuilder(\Magento\Quote\Api\Data\CartInterface::class) ->getMockForAbstractClass(); $this->cartManagement->expects($this->once()) ->method('getCartForCustomer') diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php index 44afe3322f3ae..6970376c4d5b8 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php @@ -42,24 +42,24 @@ class CustomerQuoteObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\Customer\Model\Config\Share') + $this->configMock = $this->getMockBuilder(\Magento\Customer\Model\Config\Share::class) ->disableOriginalConstructor() ->getMock(); - $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); - $this->eventMock = $this->getMockBuilder('Magento\Framework\Event') + $this->eventMock = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() ->setMethods(['getCustomerDataObject']) ->getMock(); $this->observerMock->expects($this->any())->method('getEvent')->will($this->returnValue($this->eventMock)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerQuote = $objectManager->getObject( - 'Magento\Quote\Observer\Backend\CustomerQuoteObserver', + $this->customerQuote = $objectManager->getObject( + \Magento\Quote\Observer\Backend\CustomerQuoteObserver::class, [ 'storeManager' => $this->storeManagerMock, 'config' => $this->configMock, @@ -70,13 +70,13 @@ protected function setUp() public function testDispatchNoCustomerGroupChange() { - $customerDataObjectMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerDataObjectMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); $customerDataObjectMock->expects($this->any()) ->method('getGroupId') ->will($this->returnValue(1)); - $origCustomerDataObjectMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $origCustomerDataObjectMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); $origCustomerDataObjectMock->expects($this->any()) @@ -105,7 +105,7 @@ public function testDispatch($isWebsiteScope, $websites) $this->configMock->expects($this->once()) ->method('isWebsiteScope') ->will($this->returnValue($isWebsiteScope)); - $customerDataObjectMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface') + $customerDataObjectMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() ->getMock(); $customerDataObjectMock->expects($this->any()) @@ -129,8 +129,8 @@ public function testDispatch($isWebsiteScope, $websites) ->method('getCustomerDataObject') ->will($this->returnValue($customerDataObjectMock)); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote $quoteMock */ - $quoteMock = $this->getMockBuilder( - 'Magento\Quote\Model\Quote' + $quoteMock = $this->getMockBuilder( + \Magento\Quote\Model\Quote::class )->setMethods( [ 'setWebsite', diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php index fedcd43bfdd50..d38e212060645 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php @@ -10,6 +10,8 @@ /** * Class CollectTotalsTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CollectTotalsObserverTest extends \PHPUnit_Framework_TestCase { @@ -86,7 +88,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->storeId = 1; $this->customerMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\CustomerInterface', + \Magento\Customer\Api\Data\CustomerInterface::class, [], '', false, @@ -94,24 +96,24 @@ protected function setUp() true, ['getStoreId', 'getCustomAttribute', 'getId', '__wakeup'] ); - $this->customerAddressMock = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); - $this->customerVatMock = $this->getMock('Magento\Customer\Model\Vat', [], [], '', false); + $this->customerAddressMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->customerVatMock = $this->getMock(\Magento\Customer\Model\Vat::class, [], [], '', false); $this->customerDataFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['mergeDataObjectWithArray', 'create'], [], '', false ); $this->vatValidatorMock = $this->getMock( - 'Magento\Quote\Observer\Frontend\Quote\Address\VatValidator', + \Magento\Quote\Observer\Frontend\Quote\Address\VatValidator::class, [], [], '', false ); $this->observerMock = $this->getMock( - '\Magento\Framework\Event\Observer', + \Magento\Framework\Event\Observer::class, ['getShippingAssignment', 'getQuote'], [], '', @@ -119,7 +121,7 @@ protected function setUp() ); $this->quoteAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, ['getCountryId', 'getVatId', 'getQuote', 'setPrevQuoteCustomerGroupId', '__wakeup'], [], '', @@ -128,7 +130,7 @@ protected function setUp() ); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['setCustomerGroupId', 'getCustomerGroupId', 'getCustomer', '__wakeup', 'setCustomer'], [], '', @@ -136,7 +138,7 @@ protected function setUp() ); $this->groupManagementMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\GroupManagementInterface', + \Magento\Customer\Api\GroupManagementInterface::class, [], '', false, @@ -149,7 +151,7 @@ protected function setUp() ); $this->groupInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\GroupInterface', + \Magento\Customer\Api\Data\GroupInterface::class, [], '', false, @@ -158,8 +160,8 @@ protected function setUp() ['getId'] ); - $shippingAssignmentMock = $this->getMock('\Magento\Quote\Api\Data\ShippingAssignmentInterface'); - $shippingMock = $this->getMock('\Magento\Quote\Api\Data\ShippingInterface'); + $shippingAssignmentMock = $this->getMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class); + $shippingMock = $this->getMock(\Magento\Quote\Api\Data\ShippingInterface::class); $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock); $shippingMock->expects($this->once())->method('getAddress')->willReturn($this->quoteAddressMock); @@ -222,7 +224,7 @@ public function testDispatchWithCustomerCountryNotInEUAndNotLoggedCustomerInGrou $this->returnValue(false) ); - $groupMock = $this->getMockBuilder('Magento\Customer\Api\Data\GroupInterface') + $groupMock = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class) ->disableOriginalConstructor() ->getMock(); $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue(null)); diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/VatValidatorTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/VatValidatorTest.php index d3686db77b8db..41e80c8e87a6e 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/VatValidatorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/VatValidatorTest.php @@ -44,8 +44,8 @@ class VatValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerAddressMock = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); - $this->customerVatMock = $this->getMock('Magento\Customer\Model\Vat', [], [], '', false); + $this->customerAddressMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->customerVatMock = $this->getMock(\Magento\Customer\Model\Vat::class, [], [], '', false); $this->customerVatMock->expects($this->any()) ->method('getMerchantCountryCode') ->willReturn('merchantCountryCode'); @@ -53,10 +53,10 @@ protected function setUp() ->method('getMerchantVatNumber') ->willReturn('merchantVatNumber'); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->quoteAddressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'getCountryId', 'getVatId', diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Webapi/SubmitObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Webapi/SubmitObserverTest.php index e054dfc3d31a8..dc73b2e6ec7e5 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Webapi/SubmitObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Webapi/SubmitObserverTest.php @@ -44,17 +44,17 @@ class SubmitObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $this->orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); - $this->paymentMock = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $this->orderMock = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); + $this->paymentMock = $this->getMock(\Magento\Quote\Model\Quote\Payment::class, [], [], '', false); $this->orderSenderMock = - $this->getMock('Magento\Sales\Model\Order\Email\Sender\OrderSender', [], [], '', false); - $eventMock = $this->getMockBuilder('Magento\Framework\Event') + $this->getMock(\Magento\Sales\Model\Order\Email\Sender\OrderSender::class, [], [], '', false); + $eventMock = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() ->setMethods(['getQuote', 'getOrder']) ->getMock(); - $this->observerMock = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); + $this->observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); $this->observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock); $eventMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock); $eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock); From e99627038fdcdf22769d7ab2e90b47400dc88dcb Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 12:29:29 +0300 Subject: [PATCH 18/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../System/Storage/Media/Synchronize.php | 2 +- .../System/Config/System/Storage.php | 2 +- .../System/Config/System/Storage/Status.php | 2 +- .../Config/System/Storage/Synchronize.php | 2 +- .../MediaStorage/Test/Unit/App/MediaTest.php | 36 ++++-- .../Test/Unit/Helper/File/MediaTest.php | 8 +- .../Unit/Helper/File/Storage/DatabaseTest.php | 43 +++---- .../Test/Unit/Helper/File/StorageTest.php | 8 +- .../Asset/Plugin/CleanMergedJsCssTest.php | 11 +- .../Source/Storage/Media/DatabaseTest.php | 2 +- .../Unit/Model/File/Storage/ConfigTest.php | 8 +- .../File/Storage/Directory/DatabaseTest.php | 18 +-- .../Unit/Model/File/Storage/MediaTest.php | 8 +- .../Unit/Model/File/Storage/RequestTest.php | 2 +- .../File/Storage/SynchronizationTest.php | 8 +- .../ResourceModel/File/Storage/FileTest.php | 6 +- .../Block/Checkout/Addresses.php | 2 +- .../Multishipping/Controller/Checkout.php | 19 +-- .../Controller/Checkout/Address.php | 4 +- .../Checkout/Address/EditShippingPost.php | 2 +- .../Checkout/Address/SaveBilling.php | 2 +- .../Checkout/Address/SetBilling.php | 2 +- .../Controller/Checkout/Login.php | 2 +- .../Controller/Checkout/Overview.php | 2 +- .../Controller/Checkout/OverviewPost.php | 8 +- .../Controller/Checkout/Register.php | 2 +- .../Block/Checkout/Address/SelectTest.php | 29 +++-- .../Test/Unit/Block/Checkout/OverviewTest.php | 37 ++++-- .../Unit/Block/Checkout/Payment/InfoTest.php | 9 +- .../Test/Unit/Block/Checkout/ShippingTest.php | 46 +++++--- .../Test/Unit/Block/Checkout/StateTest.php | 5 +- .../Test/Unit/Block/Checkout/SuccessTest.php | 13 ++- .../Checkout/Address/EditAddressTest.php | 30 ++--- .../Checkout/Address/EditBillingTest.php | 40 ++++--- .../Checkout/Address/EditShippingTest.php | 38 +++--- .../Checkout/Address/NewBillingTest.php | 28 +++-- .../Checkout/Address/NewShippingTest.php | 38 +++--- .../Checkout/Address/ShippingSavedTest.php | 43 ++++--- .../Unit/Controller/Checkout/PluginTest.php | 6 +- .../Test/Unit/Helper/DataTest.php | 6 +- .../Model/Cart/Controller/CartPluginTest.php | 12 +- .../Type/Multishipping/PluginTest.php | 4 +- .../Model/Checkout/Type/MultishippingTest.php | 110 ++++++++++++------ .../Method/Specification/EnabledTest.php | 4 +- .../Newsletter/Block/Adminhtml/Problem.php | 4 +- .../Newsletter/Block/Adminhtml/Queue/Edit.php | 12 +- .../Newsletter/Block/Adminhtml/Template.php | 4 +- .../Block/Adminhtml/Template/Edit.php | 27 ++--- .../Block/Adminhtml/Template/Grid.php | 4 +- .../Controller/Adminhtml/Problem/Grid.php | 4 +- .../Controller/Adminhtml/Queue/Cancel.php | 2 +- .../Controller/Adminhtml/Queue/Edit.php | 6 +- .../Controller/Adminhtml/Queue/Pause.php | 2 +- .../Controller/Adminhtml/Queue/Preview.php | 2 +- .../Controller/Adminhtml/Queue/Resume.php | 2 +- .../Controller/Adminhtml/Queue/Save.php | 4 +- .../Controller/Adminhtml/Queue/Sending.php | 2 +- .../Controller/Adminhtml/Queue/Start.php | 4 +- .../Adminhtml/Subscriber/MassDelete.php | 2 +- .../Adminhtml/Subscriber/MassUnsubscribe.php | 2 +- .../Controller/Adminhtml/Template/Delete.php | 2 +- .../Controller/Adminhtml/Template/Edit.php | 2 +- .../Controller/Adminhtml/Template/Grid.php | 4 +- .../Controller/Adminhtml/Template/Index.php | 2 +- .../Controller/Adminhtml/Template/Preview.php | 2 +- .../Controller/Adminhtml/Template/Save.php | 4 +- .../Controller/Subscriber/NewAction.php | 5 +- app/code/Magento/Newsletter/Model/Problem.php | 2 +- app/code/Magento/Newsletter/Model/Queue.php | 2 +- .../ResourceModel/Problem/Collection.php | 4 +- .../Model/ResourceModel/Queue/Collection.php | 2 +- .../ResourceModel/Subscriber/Collection.php | 5 +- .../ResourceModel/Template/Collection.php | 5 +- .../Magento/Newsletter/Model/Subscriber.php | 2 +- .../Magento/Newsletter/Model/Template.php | 2 +- .../Block/Adminhtml/Queue/PreviewTest.php | 41 ++++--- .../Block/Adminhtml/Template/PreviewTest.php | 19 ++- .../Test/Unit/Controller/Manage/SaveTest.php | 17 +-- .../Unit/Model/Plugin/CustomerPluginTest.php | 18 +-- .../Unit/Model/Queue/TransportBuilderTest.php | 25 ++-- .../Newsletter/Test/Unit/Model/QueueTest.php | 29 ++--- .../Test/Unit/Model/SubscriberTest.php | 39 ++++--- .../Test/Unit/Model/Template/FilterTest.php | 43 ++++--- .../Test/Unit/Model/TemplateTest.php | 38 +++--- .../Magento/Reports/Block/Adminhtml/Grid.php | 2 +- .../Adminhtml/Product/Downloads/Grid.php | 2 +- .../Block/Adminhtml/Product/Viewed/Grid.php | 4 +- .../Adminhtml/Sales/Bestsellers/Grid.php | 4 +- .../Block/Adminhtml/Sales/Coupons/Grid.php | 6 +- .../Block/Adminhtml/Sales/Invoiced/Grid.php | 6 +- .../Block/Adminhtml/Sales/Refunded/Grid.php | 6 +- .../Block/Adminhtml/Sales/Sales/Grid.php | 6 +- .../Block/Adminhtml/Sales/Shipping/Grid.php | 6 +- .../Block/Adminhtml/Sales/Tax/Grid.php | 6 +- .../Adminhtml/Shopcart/Abandoned/Grid.php | 2 +- .../Adminhtml/Shopcart/Customer/Grid.php | 2 +- .../Block/Adminhtml/Shopcart/Product/Grid.php | 2 +- .../Reports/Block/Adminhtml/Wishlist.php | 2 +- .../Adminhtml/Report/AbstractReport.php | 8 +- .../Adminhtml/Report/Product/Downloads.php | 2 +- .../Report/Product/ExportDownloadsCsv.php | 2 +- .../Report/Product/ExportDownloadsExcel.php | 2 +- .../Report/Product/ExportViewedCsv.php | 2 +- .../Report/Product/ExportViewedExcel.php | 2 +- .../Adminhtml/Report/Product/Viewed.php | 2 +- .../Report/Review/ExportProductDetailCsv.php | 2 +- .../Review/ExportProductDetailExcel.php | 2 +- .../Adminhtml/Report/Review/ProductDetail.php | 2 +- .../Report/Sales/ExportBestsellersCsv.php | 2 +- .../Report/Sales/ExportBestsellersExcel.php | 2 +- .../Report/Sales/ExportCouponsCsv.php | 2 +- .../Report/Sales/ExportCouponsExcel.php | 2 +- .../Report/Sales/ExportInvoicedCsv.php | 2 +- .../Report/Sales/ExportInvoicedExcel.php | 2 +- .../Report/Sales/ExportRefundedCsv.php | 2 +- .../Report/Sales/ExportRefundedExcel.php | 2 +- .../Adminhtml/Report/Sales/ExportSalesCsv.php | 2 +- .../Report/Sales/ExportSalesExcel.php | 2 +- .../Report/Sales/ExportShippingCsv.php | 2 +- .../Report/Sales/ExportShippingExcel.php | 2 +- .../Adminhtml/Report/Sales/ExportTaxCsv.php | 2 +- .../Adminhtml/Report/Sales/ExportTaxExcel.php | 2 +- .../Adminhtml/Report/Shopcart/Abandoned.php | 2 +- .../Adminhtml/Report/Shopcart/Customer.php | 2 +- .../Report/Shopcart/ExportAbandonedCsv.php | 2 +- .../Report/Shopcart/ExportAbandonedExcel.php | 2 +- .../Report/Shopcart/ExportCustomerCsv.php | 2 +- .../Report/Shopcart/ExportCustomerExcel.php | 2 +- .../Report/Shopcart/ExportProductCsv.php | 2 +- .../Report/Shopcart/ExportProductExcel.php | 2 +- .../Adminhtml/Report/Shopcart/Product.php | 2 +- .../Adminhtml/Report/Statistics.php | 2 +- .../Report/Statistics/RefreshLifetime.php | 2 +- .../Report/Statistics/RefreshRecent.php | 6 +- app/code/Magento/Reports/Model/Event.php | 2 +- app/code/Magento/Reports/Model/Event/Type.php | 2 +- .../Reports/Model/Product/Index/Compared.php | 2 +- .../Reports/Model/Product/Index/Factory.php | 4 +- .../Reports/Model/Product/Index/Viewed.php | 2 +- .../Accounts/Collection/Initial.php | 2 +- .../Customer/Orders/Collection/Initial.php | 2 +- .../Customer/Totals/Collection/Initial.php | 2 +- .../Model/ResourceModel/Event/Collection.php | 2 +- .../ResourceModel/Event/Type/Collection.php | 2 +- .../Product/Sold/Collection/Initial.php | 2 +- .../ResourceModel/Quote/CollectionFactory.php | 2 +- .../ResourceModel/Quote/Item/Collection.php | 3 +- .../Model/ResourceModel/Review/Collection.php | 2 +- .../ResourceModel/Wishlist/Collection.php | 2 +- .../Wishlist/Product/Collection.php | 2 +- .../Sales/Grid/Column/Renderer/DateTest.php | 27 +++-- .../Test/Unit/Block/Product/ViewedTest.php | 6 +- .../Report/AbstractControllerTest.php | 20 ++-- .../Report/Customer/AccountsTest.php | 2 +- .../Adminhtml/Report/Customer/OrdersTest.php | 2 +- .../Adminhtml/Report/Customer/TotalsTest.php | 2 +- .../Report/Product/DownloadsTest.php | 19 +-- .../Report/Product/ExportDownloadsCsvTest.php | 6 +- .../Product/ExportDownloadsExcelTest.php | 6 +- .../Report/Product/ExportLowstockCsvTest.php | 4 +- .../Product/ExportLowstockExcelTest.php | 4 +- .../Report/Product/ExportSoldCsvTest.php | 4 +- .../Report/Product/ExportSoldExcelTest.php | 4 +- .../Report/Product/ExportViewedCsvTest.php | 10 +- .../Report/Product/ExportViewedExcelTest.php | 10 +- .../Adminhtml/Report/Product/LowstockTest.php | 6 +- .../Adminhtml/Report/Product/SoldTest.php | 6 +- .../Adminhtml/Report/Product/ViewedTest.php | 31 ++--- .../Reports/Test/Unit/Helper/DataTest.php | 8 +- .../Test/Unit/Model/Plugin/LogTest.php | 10 +- .../Unit/Model/Product/Index/ComparedTest.php | 30 ++--- .../ResourceModel/Event/CollectionTest.php | 20 ++-- .../Unit/Model/ResourceModel/EventTest.php | 26 ++--- .../Unit/Model/ResourceModel/HelperTest.php | 6 +- .../ResourceModel/Order/CollectionTest.php | 35 +++--- .../ResourceModel/Quote/CollectionTest.php | 22 ++-- .../Collection/AbstractCollectionTest.php | 18 ++- .../ResourceModel/Report/CollectionTest.php | 13 ++- .../Report/Product/ViewedTest.php | 30 ++--- .../Report/Quote/CollectionTest.php | 64 +++++----- ...ogProductCompareAddProductObserverTest.php | 31 ++--- .../CatalogProductViewObserverTest.php | 41 ++++--- .../Observer/CustomerLoginObserverTest.php | 31 +++-- .../Observer/CustomerLogoutObserverTest.php | 20 ++-- 184 files changed, 1033 insertions(+), 820 deletions(-) diff --git a/app/code/Magento/MediaStorage/Block/System/Config/System/Storage/Media/Synchronize.php b/app/code/Magento/MediaStorage/Block/System/Config/System/Storage/Media/Synchronize.php index b3479864fde19..5dbb452c675dd 100644 --- a/app/code/Magento/MediaStorage/Block/System/Config/System/Storage/Media/Synchronize.php +++ b/app/code/Magento/MediaStorage/Block/System/Config/System/Storage/Media/Synchronize.php @@ -87,7 +87,7 @@ public function getAjaxStatusUpdateUrl() public function getButtonHtml() { $button = $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button' + \Magento\Backend\Block\Widget\Button::class )->setData( [ 'id' => 'synchronize_button', diff --git a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage.php b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage.php index b64f8604864a6..edc7647763370 100644 --- a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage.php +++ b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage.php @@ -20,7 +20,7 @@ abstract class Storage extends \Magento\Backend\App\Action */ protected function _getSyncSingleton() { - return $this->_objectManager->get('Magento\MediaStorage\Model\File\Storage'); + return $this->_objectManager->get(\Magento\MediaStorage\Model\File\Storage::class); } /** diff --git a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php index 9e454e3d57335..3fb7dc1b5e46f 100644 --- a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php +++ b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php @@ -81,7 +81,7 @@ public function execute() ) && $flagData['timeout_reached']) ) { $this->_objectManager->get( - 'Psr\Log\LoggerInterface' + \Psr\Log\LoggerInterface::class )->critical( new \Magento\Framework\Exception\LocalizedException( __('The timeout limit for response from synchronize process was reached.') diff --git a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Synchronize.php b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Synchronize.php index b9a147bb8fc1e..f18d0f23da4db 100644 --- a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Synchronize.php +++ b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Synchronize.php @@ -44,7 +44,7 @@ public function execute() try { $this->_getSyncSingleton()->synchronize($storage); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $flag->passError($e); } diff --git a/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php b/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php index 7ebaf15e0bb45..d9c7dde74dcda 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php @@ -7,6 +7,10 @@ use Magento\Framework\App\Filesystem\DirectoryList; +/** + * Class MediaTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MediaTest extends \PHPUnit_Framework_TestCase { const MEDIA_DIRECTORY = 'mediaDirectory'; @@ -63,10 +67,16 @@ protected function setUp() $this->closure = function () { return true; }; - $this->configMock = $this->getMock('Magento\MediaStorage\Model\File\Storage\Config', [], [], '', false); - $this->sync = $this->getMock('Magento\MediaStorage\Model\File\Storage\Synchronization', [], [], '', false); + $this->configMock = $this->getMock(\Magento\MediaStorage\Model\File\Storage\Config::class, [], [], '', false); + $this->sync = $this->getMock( + \Magento\MediaStorage\Model\File\Storage\Synchronization::class, + [], + [], + '', + false + ); $this->configFactoryMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\ConfigFactory', + \Magento\MediaStorage\Model\File\Storage\ConfigFactory::class, ['create'], [], '', @@ -76,7 +86,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->configMock)); $this->syncFactoryMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\SynchronizationFactory', + \Magento\MediaStorage\Model\File\Storage\SynchronizationFactory::class, ['create'], [], '', @@ -86,15 +96,23 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->sync)); - $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->directoryMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->directoryMock = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class + ); $this->filesystemMock->expects($this->any()) ->method('getDirectoryWrite') ->with(DirectoryList::MEDIA) ->will($this->returnValue($this->directoryMock)); - $this->responseMock = $this->getMock('Magento\MediaStorage\Model\File\Storage\Response', [], [], '', false); + $this->responseMock = $this->getMock( + \Magento\MediaStorage\Model\File\Storage\Response::class, + [], + [], + '', + false + ); $this->model = new \Magento\MediaStorage\App\Media( $this->configFactoryMock, @@ -214,8 +232,8 @@ public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized() */ public function testCatchException($isDeveloper, $setBodyCalls) { - $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); - $exception = $this->getMock('Exception', [], [], '', false); + $bootstrap = $this->getMock(\Magento\Framework\App\Bootstrap::class, [], [], '', false); + $exception = $this->getMock(\Exception::class, [], [], '', false); $this->responseMock->expects($this->once()) ->method('setHttpResponseCode') ->with(404); diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php index 5f2292567080d..7b29ca0ef1697 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php @@ -26,24 +26,24 @@ class MediaTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->dirMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $this->dirMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); $filesystemMock->expects($this->any()) ->method('getDirectoryRead') ->with(DirectoryList::MEDIA) ->will($this->returnValue($this->dirMock)); - $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + $dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); $dateMock->expects($this->any()) ->method('date') ->will($this->returnValue(self::UPDATE_TIME)); $this->helper = $this->objectManager->getObject( - 'Magento\MediaStorage\Helper\File\Media', + \Magento\MediaStorage\Helper\File\Media::class, ['filesystem' => $filesystemMock, 'date' => $dateMock] ); } diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php index 1f8826718ad5d..4b96c18e681f6 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php @@ -32,19 +32,20 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dbStorageFactoryMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\DatabaseFactory') - ->disableOriginalConstructor() + $this->dbStorageFactoryMock = $this->getMockBuilder( + \Magento\MediaStorage\Model\File\Storage\DatabaseFactory::class + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $className = 'Magento\MediaStorage\Helper\File\Storage\Database'; + $className = \Magento\MediaStorage\Helper\File\Storage\Database::class; $arguments = $this->objectManager->getConstructArguments( $className, ['dbStorageFactory' => $this->dbStorageFactoryMock] ); /** @var \Magento\Framework\App\Helper\Context $context */ $context = $arguments['context']; - $mediaDirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $mediaDirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $mediaDirMock->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnValue('media-dir')); @@ -84,7 +85,7 @@ public function checkDbUsageDataProvider() public function testGetStorageDatabaseModel() { - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->once()) @@ -101,13 +102,13 @@ public function testGetStorageFileModel() public function testGetResourceStorageModel() { - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($dbModelMock)); - $resourceModelMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $resourceModelMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMockForAbstractClass(); @@ -130,7 +131,7 @@ public function testSaveFile($storage, $callNum) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -162,7 +163,7 @@ public function testRenameFile($storage, $callNum) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -186,7 +187,7 @@ public function testCopyFile($storage, $callNum) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -211,7 +212,7 @@ public function testFileExists($storage, $callNum, $expected) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -245,7 +246,7 @@ public function testGetUniqueFilename($storage, $callNum, $expected) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -285,7 +286,7 @@ public function testSaveFileToFileSystem($expected, $storage, $callNum, $id = 0, ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -342,13 +343,13 @@ public function testDeleteFolder($storage, $callNum) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) ->method('create') ->will($this->returnValue($dbModelMock)); - $resourceModelMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $resourceModelMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['deleteFolder', '__wakeup']) ->getMockForAbstractClass(); @@ -373,7 +374,7 @@ public function testDeleteFile($storage, $callNum) ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) @@ -400,13 +401,13 @@ public function testSaveUploadedFile($result, $expected, $expectedFullPath, $sto ->method('getValue') ->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default') ->will($this->returnValue($storage)); - $dbModelMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $dbModelMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->getMock(); $this->dbStorageFactoryMock->expects($this->exactly($callNum)) ->method('create') ->will($this->returnValue($dbModelMock)); - $dirWriteMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $dirWriteMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->disableOriginalConstructor() ->getMock(); $this->filesystemMock->expects($this->exactly($callDirWrite)) @@ -459,11 +460,11 @@ public function saveUploadedFileDataProvider() public function testGetMediaBaseDir() { - $mediaDirMock = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $mediaDirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $mediaDirMock->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnValue('media-dir')); - $filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); $filesystemMock->expects($this->once()) @@ -472,7 +473,7 @@ public function testGetMediaBaseDir() ->will($this->returnValue($mediaDirMock)); $this->helper = $this->objectManager->getObject( - 'Magento\MediaStorage\Helper\File\Storage\Database', + \Magento\MediaStorage\Helper\File\Storage\Database::class, [ 'filesystem' => $filesystemMock, 'fileStorage' => $this->fileStorageMock, diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php index a15671f49933c..580a64f10d0d1 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php @@ -32,7 +32,7 @@ class StorageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $className = 'Magento\MediaStorage\Helper\File\Storage'; + $className = \Magento\MediaStorage\Helper\File\Storage::class; $arguments = $this->objectManager->getConstructArguments($className); /** @var \Magento\Framework\App\Helper\Context $context */ $context = $arguments['context']; @@ -88,7 +88,7 @@ public function isInternalStorageDataProvider() public function testGetStorageModel() { - $storageModelMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + $storageModelMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->getMock(); $this->storageMock->expects($this->once()) @@ -119,14 +119,14 @@ public function testProcessStorageFile($expected, $storage, $callNum, $callSaveF ->with($filename) ->will($this->returnValue($relativePath)); - $storageModelMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + $storageModelMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods(['loadByFileName', '__wakeup']) ->getMock(); $this->storageMock->expects($this->exactly($callNum)) ->method('getStorageModel') ->will($this->returnValue($storageModelMock)); - $fileMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Storage\Database') + $fileMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) ->disableOriginalConstructor() ->setMethods(['getId', '__wakeup']) ->getMock(); diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/Asset/Plugin/CleanMergedJsCssTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/Asset/Plugin/CleanMergedJsCssTest.php index ae087a152529d..aa6578ebc7eff 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/Asset/Plugin/CleanMergedJsCssTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/Asset/Plugin/CleanMergedJsCssTest.php @@ -35,9 +35,10 @@ class CleanMergedJsCssTest extends \Magento\Framework\TestFramework\Unit\BaseTes protected function setUp() { parent::setUp(); - $this->filesystemMock = $this->basicMock('\Magento\Framework\Filesystem'); - $this->databaseMock = $this->basicMock('\Magento\MediaStorage\Helper\File\Storage\Database'); - $this->model = $this->objectManager->getObject('Magento\MediaStorage\Model\Asset\Plugin\CleanMergedJsCss', + $this->filesystemMock = $this->basicMock(\Magento\Framework\Filesystem::class); + $this->databaseMock = $this->basicMock(\Magento\MediaStorage\Helper\File\Storage\Database::class); + $this->model = $this->objectManager->getObject( + \Magento\MediaStorage\Model\Asset\Plugin\CleanMergedJsCss::class, [ 'database' => $this->databaseMock, 'filesystem' => $this->filesystemMock, @@ -53,7 +54,7 @@ public function testAroundCleanMergedJsCss() $readDir = 'read directory'; $mergedDir = $readDir . '/' . \Magento\Framework\View\Asset\Merged::getRelativeDir(); - $readDirectoryMock = $this->basicMock('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $readDirectoryMock = $this->basicMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $readDirectoryMock->expects($this->any())->method('getAbsolutePath')->willReturn($readDir); $this->databaseMock->expects($this->once()) @@ -65,7 +66,7 @@ public function testAroundCleanMergedJsCss() ->willReturn($readDirectoryMock); $this->model->aroundCleanMergedJsCss( - $this->basicMock('\Magento\Framework\View\Asset\MergeService'), + $this->basicMock(\Magento\Framework\View\Asset\MergeService::class), $callable ); diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php index d031daa6f27da..bf4d0ee9ab1a2 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php @@ -27,7 +27,7 @@ class DatabaseTest 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); $this->deploymentConfig->expects( $this->any() )->method( diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/ConfigTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/ConfigTest.php index 3a905ecef7e6b..41b8623461332 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/ConfigTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/ConfigTest.php @@ -15,11 +15,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testSave() { $config = []; - $fileStorageMock = $this->getMock('Magento\MediaStorage\Model\File\Storage', [], [], '', false); + $fileStorageMock = $this->getMock(\Magento\MediaStorage\Model\File\Storage::class, [], [], '', false); $fileStorageMock->expects($this->once())->method('getScriptConfig')->will($this->returnValue($config)); $file = $this->getMock( - 'Magento\Framework\Filesystem\File\Write', + \Magento\Framework\Filesystem\File\Write::class, ['lock', 'write', 'unlock', 'close'], [], '', @@ -30,7 +30,7 @@ public function testSave() $file->expects($this->once())->method('unlock'); $file->expects($this->once())->method('close'); $directory = $this->getMock( - 'Magento\Framework\Filesystem\Direcoty\Write', + \Magento\Framework\Filesystem\Direcoty\Write::class, ['openFile', 'getRelativePath'], [], '', @@ -39,7 +39,7 @@ public function testSave() $directory->expects($this->once())->method('getRelativePath')->will($this->returnArgument(0)); $directory->expects($this->once())->method('openFile')->with('cacheFile')->will($this->returnValue($file)); $filesystem = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryWrite'], [], '', diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/Directory/DatabaseTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/Directory/DatabaseTest.php index 1c9b4eaad83a6..20a993f45c490 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/Directory/DatabaseTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/Directory/DatabaseTest.php @@ -72,44 +72,44 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); $this->helperStorageDatabase = $this->getMock( - 'Magento\MediaStorage\Helper\File\Storage\Database', + \Magento\MediaStorage\Helper\File\Storage\Database::class, [], [], '', false ); $this->dateModelMock = $this->getMock( - 'Magento\Framework\Stdlib\DateTime\DateTime', + \Magento\Framework\Stdlib\DateTime\DateTime::class, [], [], '', false ); $this->directoryMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\Directory\Database', + \Magento\MediaStorage\Model\File\Storage\Directory\Database::class, ['setPath', 'setName', '__wakeup', 'save', 'getParentId'], [], '', false ); $this->directoryFactoryMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\Directory\DatabaseFactory', + \Magento\MediaStorage\Model\File\Storage\Directory\DatabaseFactory::class, ['create'], [], '', false ); $this->resourceDirectoryDatabaseMock = $this->getMock( - 'Magento\MediaStorage\Model\ResourceModel\File\Storage\Directory\Database', + \Magento\MediaStorage\Model\ResourceModel\File\Storage\Directory\Database::class, [], [], '', false ); - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->directoryFactoryMock->expects( $this->any() @@ -119,7 +119,7 @@ protected function setUp() $this->returnValue($this->directoryMock) ); - $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->configMock->expects( $this->any() )->method( diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/MediaTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/MediaTest.php index c4376c3338944..a3e61bb596d3a 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/MediaTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/MediaTest.php @@ -37,17 +37,17 @@ class MediaTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->_loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->_storageHelperMock = $this->getMock( - 'Magento\MediaStorage\Helper\File\Storage\Database', + \Magento\MediaStorage\Helper\File\Storage\Database::class, [], [], '', false ); - $this->_mediaHelperMock = $this->getMock('Magento\MediaStorage\Helper\File\Media', [], [], '', false); + $this->_mediaHelperMock = $this->getMock(\Magento\MediaStorage\Helper\File\Media::class, [], [], '', false); $this->_fileUtilityMock = $this->getMock( - 'Magento\MediaStorage\Model\ResourceModel\File\Storage\File', + \Magento\MediaStorage\Model\ResourceModel\File\Storage\File::class, [], [], '', diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/RequestTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/RequestTest.php index 36958687c00da..829deff2faa9e 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/RequestTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/RequestTest.php @@ -25,7 +25,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { $path = '..PathInfo'; - $this->_requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->_requestMock->expects($this->once())->method('getPathInfo')->will($this->returnValue($path)); $this->_model = new \Magento\MediaStorage\Model\File\Storage\Request($this->_requestMock); } diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/SynchronizationTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/SynchronizationTest.php index 9d13a1c97e78c..99eee9b70566b 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/SynchronizationTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/SynchronizationTest.php @@ -13,14 +13,14 @@ public function testSynchronize() $relativeFileName = 'config.xml'; $storageFactoryMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\DatabaseFactory', + \Magento\MediaStorage\Model\File\Storage\DatabaseFactory::class, ['create', '_wakeup'], [], '', false ); $storageMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\Database', + \Magento\MediaStorage\Model\File\Storage\Database::class, ['getContent', 'getId', 'loadByFilename', '__wakeup'], [], '', @@ -33,7 +33,7 @@ public function testSynchronize() $storageMock->expects($this->once())->method('loadByFilename'); $file = $this->getMock( - 'Magento\Framework\Filesystem\File\Write', + \Magento\Framework\Filesystem\File\Write::class, ['lock', 'write', 'unlock', 'close'], [], '', @@ -43,7 +43,7 @@ public function testSynchronize() $file->expects($this->once())->method('write')->with($content); $file->expects($this->once())->method('unlock'); $file->expects($this->once())->method('close'); - $directory = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $directory = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $directory->expects($this->once()) ->method('openFile') ->with($relativeFileName) diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php index d3b8c76346365..fa2cc3198e38c 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php @@ -37,16 +37,16 @@ class FileTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); $this->filesystemMock = $this->getMock( - 'Magento\Framework\Filesystem', + \Magento\Framework\Filesystem::class, ['getDirectoryRead'], [], '', false ); $this->directoryReadMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Read', + \Magento\Framework\Filesystem\Directory\Read::class, ['isDirectory', 'readRecursively'], [], '', diff --git a/app/code/Magento/Multishipping/Block/Checkout/Addresses.php b/app/code/Magento/Multishipping/Block/Checkout/Addresses.php index eb33e55df5407..5a919124052dc 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Addresses.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Addresses.php @@ -109,7 +109,7 @@ public function getItems() */ public function getAddressesHtmlSelect($item, $index) { - $select = $this->getLayout()->createBlock('Magento\Framework\View\Element\Html\Select') + $select = $this->getLayout()->createBlock(\Magento\Framework\View\Element\Html\Select::class) ->setName('ship[' . $index . '][' . $item->getQuoteItemId() . '][address]') ->setId('ship_' . $index . '_' . $item->getQuoteItemId() . '_address') ->setValue($item->getCustomerAddressId()) diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index 058e79874c00f..37d07a3f1c6ad 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -12,6 +12,7 @@ /** * Multishipping checkout controller * @SuppressWarnings(PHPMD.NumberOfChildren) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ abstract class Checkout extends \Magento\Checkout\Controller\Action implements \Magento\Checkout\Controller\Express\RedirectLoginInterface @@ -45,7 +46,7 @@ public function __construct( */ protected function _getCheckout() { - return $this->_objectManager->get('Magento\Multishipping\Model\Checkout\Type\Multishipping'); + return $this->_objectManager->get(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class); } /** @@ -55,7 +56,7 @@ protected function _getCheckout() */ protected function _getState() { - return $this->_objectManager->get('Magento\Multishipping\Model\Checkout\Type\Multishipping\State'); + return $this->_objectManager->get(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class); } /** @@ -65,7 +66,7 @@ protected function _getState() */ protected function _getHelper() { - return $this->_objectManager->get('Magento\Multishipping\Helper\Url'); + return $this->_objectManager->get(\Magento\Multishipping\Helper\Url::class); } /** @@ -75,7 +76,7 @@ protected function _getHelper() */ protected function _getCheckoutSession() { - return $this->_objectManager->get('Magento\Checkout\Model\Session'); + return $this->_objectManager->get(\Magento\Checkout\Model\Session::class); } /** @@ -113,12 +114,14 @@ public function dispatch(RequestInterface $request) } if (!in_array($action, ['login', 'register'])) { - $customerSession = $this->_objectManager->get('Magento\Customer\Model\Session'); + $customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class); if (!$customerSession->authenticate($this->_getHelper()->getMSLoginUrl())) { $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); } - if (!$this->_objectManager->get('Magento\Multishipping\Helper\Data')->isMultishippingCheckoutAvailable()) { + if (!$this->_objectManager->get( + \Magento\Multishipping\Helper\Data::class + )->isMultishippingCheckoutAvailable()) { $error = $this->_getCheckout()->getMinimumAmountError(); $this->messageManager->addError($error); $this->getResponse()->setRedirect($this->_getHelper()->getCartUrl()); @@ -181,7 +184,9 @@ protected function _validateMinimumAmount() */ public function getCustomerBeforeAuthUrl() { - return $this->_objectManager->create('Magento\Framework\UrlInterface')->getUrl('*/*', ['_secure' => true]); + return $this->_objectManager->create( + \Magento\Framework\UrlInterface::class + )->getUrl('*/*', ['_secure' => true]); } /** diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address.php b/app/code/Magento/Multishipping/Controller/Checkout/Address.php index f5b6d0a3c62c1..76ac86ef51539 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address.php @@ -28,7 +28,7 @@ public function dispatch(\Magento\Framework\App\RequestInterface $request) */ protected function _getCheckout() { - return $this->_objectManager->get('Magento\Multishipping\Model\Checkout\Type\Multishipping'); + return $this->_objectManager->get(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class); } /** @@ -38,6 +38,6 @@ protected function _getCheckout() */ protected function _getState() { - return $this->_objectManager->get('Magento\Multishipping\Model\Checkout\Type\Multishipping\State'); + return $this->_objectManager->get(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class); } } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShippingPost.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShippingPost.php index 6b89745375f14..0c415ac4e7db0 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShippingPost.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShippingPost.php @@ -15,7 +15,7 @@ public function execute() { if ($addressId = $this->getRequest()->getParam('id')) { $this->_objectManager->create( - 'Magento\Multishipping\Model\Checkout\Type\Multishipping' + \Magento\Multishipping\Model\Checkout\Type\Multishipping::class )->updateQuoteCustomerShippingAddress( $addressId ); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/SaveBilling.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/SaveBilling.php index 269f708e0d400..3c0b89373c8c6 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/SaveBilling.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/SaveBilling.php @@ -15,7 +15,7 @@ public function execute() { if ($addressId = $this->getRequest()->getParam('id')) { $this->_objectManager->create( - 'Magento\Multishipping\Model\Checkout\Type\Multishipping' + \Magento\Multishipping\Model\Checkout\Type\Multishipping::class )->setQuoteCustomerBillingAddress( $addressId ); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/SetBilling.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/SetBilling.php index c71b4acd30ed1..17f708497f02f 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/SetBilling.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/SetBilling.php @@ -15,7 +15,7 @@ public function execute() { if ($addressId = $this->getRequest()->getParam('id')) { $this->_objectManager->create( - 'Magento\Multishipping\Model\Checkout\Type\Multishipping' + \Magento\Multishipping\Model\Checkout\Type\Multishipping::class )->setQuoteCustomerBillingAddress( $addressId ); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Login.php b/app/code/Magento/Multishipping/Controller/Checkout/Login.php index ca222faa8e589..57877a3f6ff45 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Login.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Login.php @@ -15,7 +15,7 @@ class Login extends \Magento\Multishipping\Controller\Checkout */ public function execute() { - if ($this->_objectManager->get('Magento\Customer\Model\Session')->isLoggedIn()) { + if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { $this->_redirect('*/*/'); return; } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Overview.php b/app/code/Magento/Multishipping/Controller/Checkout/Overview.php index 0527781bb48e1..c3c286f0a3e56 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Overview.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Overview.php @@ -41,7 +41,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); $this->_redirect('*/*/billing'); } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addException($e, __('We cannot open the overview page.')); $this->_redirect('*/*/billing'); } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/OverviewPost.php b/app/code/Magento/Multishipping/Controller/Checkout/OverviewPost.php index d1334ca4319ef..a36259a081c36 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/OverviewPost.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/OverviewPost.php @@ -12,6 +12,8 @@ /** * Class OverviewPost + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OverviewPost extends \Magento\Multishipping\Controller\Checkout { @@ -106,7 +108,7 @@ public function execute() $this->_redirect('*/*/billing'); } catch (\Magento\Checkout\Exception $e) { $this->_objectManager->get( - 'Magento\Checkout\Helper\Data' + \Magento\Checkout\Helper\Data::class )->sendPaymentFailedEmail( $this->_getCheckout()->getQuote(), $e->getMessage(), @@ -117,7 +119,7 @@ public function execute() $this->_redirect('*/cart'); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->_objectManager->get( - 'Magento\Checkout\Helper\Data' + \Magento\Checkout\Helper\Data::class )->sendPaymentFailedEmail( $this->_getCheckout()->getQuote(), $e->getMessage(), @@ -129,7 +131,7 @@ public function execute() $this->logger->critical($e); try { $this->_objectManager->get( - 'Magento\Checkout\Helper\Data' + \Magento\Checkout\Helper\Data::class )->sendPaymentFailedEmail( $this->_getCheckout()->getQuote(), $e->getMessage(), diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Register.php b/app/code/Magento/Multishipping/Controller/Checkout/Register.php index 8bd2abb14d99f..7a499d2ae1209 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Register.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Register.php @@ -15,7 +15,7 @@ class Register extends \Magento\Multishipping\Controller\Checkout */ public function execute() { - if ($this->_objectManager->get('Magento\Customer\Model\Session')->isLoggedIn()) { + if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { $this->getResponse()->setRedirect($this->_getHelper()->getMSCheckoutUrl()); return; } diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php index 3f1beb8b3961e..b33609cb9aeaf 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php @@ -11,6 +11,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SelectTest extends \PHPUnit_Framework_TestCase { /** @@ -67,16 +70,17 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); $this->multishippingMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); - $this->addressMock = $this->getMock('Magento\Customer\Api\Data\AddressInterface'); - $this->customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); - $this->filterBuilderMock = $this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); + $this->addressMock = $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class); + $this->customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $this->filterBuilderMock = $this->getMock(\Magento\Framework\Api\FilterBuilder::class, [], [], '', false); $this->searchCriteriaBuilderMock = - $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); - $this->addressRepositoryMock = $this->getMock('Magento\Customer\Api\AddressRepositoryInterface'); - $this->filterMock = $this->getMock('Magento\Framework\Api\Filter', [], [], '', false); - $this->searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); - $this->block = $this->objectManager->getObject('Magento\Multishipping\Block\Checkout\Address\Select', [ + $this->getMock(\Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false); + $this->addressRepositoryMock = $this->getMock(\Magento\Customer\Api\AddressRepositoryInterface::class); + $this->filterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $this->searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); + $this->block = $this->objectManager->getObject( + \Magento\Multishipping\Block\Checkout\Address\Select::class, [ 'multishipping' => $this->multishippingMock, 'addressRepository' => $this->addressRepositoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, @@ -121,7 +125,7 @@ public function isDefaultAddressDataProvider() public function testGetAddress() { - $searchResultMock = $this->getMock('Magento\Customer\Api\Data\AddressSearchResultsInterface'); + $searchResultMock = $this->getMock(\Magento\Customer\Api\Data\AddressSearchResultsInterface::class); $this->multishippingMock->expects($this->once())->method('getCustomer')->willReturn($this->customerMock); $this->customerMock->expects($this->once())->method('getId')->willReturn(1); $this->filterBuilderMock->expects($this->once())->method('setField')->with('parent_id')->willReturnSelf(); @@ -149,7 +153,8 @@ public function testGetAddress() public function testGetAlreadyExistingAddress() { - $this->block = $this->objectManager->getObject('Magento\Multishipping\Block\Checkout\Address\Select', [ + $this->block = $this->objectManager->getObject( + \Magento\Multishipping\Block\Checkout\Address\Select::class, [ 'addressRepository' => $this->addressRepositoryMock, 'filterBuilder' => $this->filterBuilderMock, 'data' => [ @@ -167,7 +172,7 @@ public function testGetAlreadyExistingAddress() public function testGetAddressWhenItNotExistInCustomer() { - $searchResultMock = $this->getMock('Magento\Customer\Api\Data\AddressSearchResultsInterface'); + $searchResultMock = $this->getMock(\Magento\Customer\Api\Data\AddressSearchResultsInterface::class); $this->multishippingMock->expects($this->once())->method('getCustomer')->willReturn($this->customerMock); $this->customerMock->expects($this->once())->method('getId')->willReturn(1); $this->filterBuilderMock->expects($this->once())->method('setField')->with('parent_id')->willReturnSelf(); diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/OverviewTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/OverviewTest.php index b30f79f2c62ab..fc2169f38e4af 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/OverviewTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/OverviewTest.php @@ -12,6 +12,9 @@ use Magento\Multishipping\Block\Checkout\Overview; use Magento\Quote\Model\Quote\Address; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class OverviewTest extends \PHPUnit_Framework_TestCase { /** @@ -54,7 +57,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->addressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + \Magento\Quote\Model\Quote\Address::class, [ 'getShippingMethod', 'getShippingRateByCode', @@ -68,13 +71,20 @@ protected function setUp() false); $this->priceCurrencyMock = - $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface', [], [], '', false); - $this->totalsReaderMock = $this->getMock('Magento\Quote\Model\Quote\TotalsReader', [], [], '', false); - $this->totalsCollectorMock = $this->getMock('Magento\Quote\Model\Quote\TotalsCollector', [], [], '', false); + $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class, [], [], '', false); + $this->totalsReaderMock = $this->getMock(\Magento\Quote\Model\Quote\TotalsReader::class, [], [], '', false); + $this->totalsCollectorMock = $this->getMock( + \Magento\Quote\Model\Quote\TotalsCollector::class, + [], + [], + '', + false + ); $this->checkoutMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); - $this->quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $this->model = $objectManager->getObject('Magento\Multishipping\Block\Checkout\Overview', + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $this->model = $objectManager->getObject( + \Magento\Multishipping\Block\Checkout\Overview::class, [ 'priceCurrency' => $this->priceCurrencyMock, 'totalsCollector' => $this->totalsCollectorMock, @@ -86,7 +96,7 @@ protected function setUp() public function testGetShippingRateByCode() { - $rateMock = $this->getMock('Magento\Quote\Model\Quote\Address\Rate', [], [], '', false); + $rateMock = $this->getMock(\Magento\Quote\Model\Quote\Address\Rate::class, [], [], '', false); $this->addressMock->expects($this->once()) ->method('getShippingMethod')->will($this->returnValue('shipping method')); $this->addressMock->expects($this->once()) @@ -117,7 +127,8 @@ public function testGetShippingAddressItems() public function testGetShippingAddressTotals() { - $totalMock = $this->getMock('\Magento\Sales\Model\Order\Total', + $totalMock = $this->getMock( + \Magento\Sales\Model\Order\Total::class, ['getCode', 'setTitle', '__wakeup'], [], '', @@ -133,7 +144,8 @@ public function testGetShippingAddressTotals() public function testGetShippingAddressTotalsWithNotBillingAddress() { - $totalMock = $this->getMock('\Magento\Sales\Model\Order\Total', + $totalMock = $this->getMock( + \Magento\Sales\Model\Order\Total::class, ['getCode', 'setTitle', '__wakeup'], [], '', @@ -153,7 +165,8 @@ public function testGetShippingAddressTotalsWithNotBillingAddress() */ protected function getTotalsMock($address) { - $totalMock = $this->getMock('\Magento\Sales\Model\Order\Total', + $totalMock = $this->getMock( + \Magento\Sales\Model\Order\Total::class, [ 'getCode', 'setTitle', @@ -162,7 +175,7 @@ protected function getTotalsMock($address) [], '', false); - $totalsAddressMock = $this->getMock('Magento\Quote\Model\Quote\Address\Total', [], [], '', false); + $totalsAddressMock = $this->getMock(\Magento\Quote\Model\Quote\Address\Total::class, [], [], '', false); $this->checkoutMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock); $this->totalsCollectorMock ->expects($this->once()) diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Payment/InfoTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Payment/InfoTest.php index 877fa6a229638..9b20cb8eda47c 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Payment/InfoTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Payment/InfoTest.php @@ -26,9 +26,10 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->multiShippingMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->model = $objectManager->getObject('Magento\Multishipping\Block\Checkout\Payment\Info', + $this->model = $objectManager->getObject( + \Magento\Multishipping\Block\Checkout\Payment\Info::class, [ 'multishipping' => $this->multiShippingMock, ] @@ -37,8 +38,8 @@ protected function setUp() public function testGetPaymentInfo() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $paymentInfoMock = $this->getMock('Magento\Payment\Model\Info', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $paymentInfoMock = $this->getMock(\Magento\Payment\Model\Info::class, [], [], '', false); $this->multiShippingMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentInfoMock); diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php index 6d7787ac8e825..43b384a7484bc 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php @@ -42,14 +42,20 @@ class ShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $this->scopeConfigMock = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + [], + [], + '', + false + ); $this->multiShippingMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); $this->priceCurrencyMock = - $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface', [], [], '', false); - $this->taxHelperMock = $this->getMock('Magento\Tax\Helper\Data', [], [], '', false); - $this->model = $objectManager->getObject( - 'Magento\Multishipping\Block\Checkout\Shipping', + $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class, [], [], '', false); + $this->taxHelperMock = $this->getMock(\Magento\Tax\Helper\Data::class, [], [], '', false); + $this->model = $objectManager->getObject( + \Magento\Multishipping\Block\Checkout\Shipping::class, [ 'multishipping' => $this->multiShippingMock, 'scopeConfig' => $this->scopeConfigMock, @@ -61,7 +67,7 @@ protected function setUp() public function testGetAddresses() { - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $this->multiShippingMock->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once()) ->method('getAllShippingAddresses')->will($this->returnValue(['expected array'])); @@ -70,8 +76,8 @@ public function testGetAddresses() public function testGetAddressShippingMethod() { - $addressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + $addressMock = $this->getMock( + \Magento\Quote\Model\Quote\Address::class, ['getShippingMethod', '__wakeup'], [], '', @@ -84,8 +90,8 @@ public function testGetAddressShippingMethod() public function testGetShippingRates() { - $addressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + $addressMock = $this->getMock( + \Magento\Quote\Model\Quote\Address::class, ['getGroupedAllShippingRates', '__wakeup'], [], '', @@ -102,7 +108,10 @@ public function testGetCarrierName() $carrierCode = 'some carrier code'; $name = 'some name'; $this->scopeConfigMock->expects($this->once())->method('getValue')->with('carriers/' . $carrierCode . '/title', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue($name)); + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will($this->returnValue($name + ) + ); $this->assertEquals($name, $this->model->getCarrierName($carrierCode)); } @@ -111,22 +120,25 @@ public function testGetCarrierNameWithEmptyName() { $carrierCode = 'some carrier code'; $this->scopeConfigMock->expects($this->once())->method('getValue')->with('carriers/' . $carrierCode . '/title', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue(null)); + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will($this->returnValue(null + ) + ); $this->assertEquals($carrierCode, $this->model->getCarrierName($carrierCode)); } public function testGetShippingPrice() { - $addressMock = $this->getMock( - 'Magento\Quote\Model\Quote\Address', + $addressMock = $this->getMock( + \Magento\Quote\Model\Quote\Address::class, ['getQuote', '__wakeup'], [], '', false ); - $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $price = 100; $flag = true; $shippingPrice = 11.11; diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/StateTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/StateTest.php index bb2a064dbf67b..c800cea37d5b6 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/StateTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/StateTest.php @@ -27,8 +27,9 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->mShippingStateMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping\State', [], [], '', false); - $this->model = $objectManager->getObject('Magento\Multishipping\Block\Checkout\State', + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, [], [], '', false); + $this->model = $objectManager->getObject( + \Magento\Multishipping\Block\Checkout\State::class, [ 'multishippingState' => $this->mShippingStateMock, ] diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/SuccessTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/SuccessTest.php index 16b403355517b..f02b282b3938e 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/SuccessTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/SuccessTest.php @@ -34,8 +34,8 @@ class SuccessTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMock( - 'Magento\Framework\Session\SessionManagerInterface', + $this->sessionMock = $this->getMock( + \Magento\Framework\Session\SessionManagerInterface::class, [ 'getOrderIds', 'start', 'writeClose', 'isSessionExists', 'getSessionId', 'getName', 'setName', 'destroy', 'clearStorage', 'getCookieDomain', 'getCookiePath', 'getCookieLifetime', 'setSessionId', @@ -46,14 +46,15 @@ protected function setUp() '', false ); - $this->contextMock = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->contextMock = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->contextMock->expects($this->once())->method('getSession')->will($this->returnValue($this->sessionMock)); $this->contextMock->expects($this->once()) ->method('getStoreManager')->will($this->returnValue($this->storeManagerMock)); - $this->model = $objectManager->getObject('Magento\Multishipping\Block\Checkout\Success', + $this->model = $objectManager->getObject( + \Magento\Multishipping\Block\Checkout\Success::class, [ 'context' => $this->contextMock ]); @@ -83,7 +84,7 @@ public function testGetOrderIds() public function testGetContinueUrl() { - $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('Expected Result')); diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditAddressTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditAddressTest.php index be39c5af4f6df..b0c451d2a33e2 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditAddressTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditAddressTest.php @@ -10,6 +10,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EditAddressTest extends \PHPUnit_Framework_TestCase { /** @@ -61,21 +64,21 @@ class EditAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->configMock = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $this->checkoutMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); - $this->titleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); + $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $response = $this->getMockBuilder('\Magento\Framework\App\ResponseInterface') + $response = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $contextMock->expects($this->atLeastOnce()) ->method('getRequest') ->will($this->returnValue($this->request)); @@ -85,14 +88,15 @@ protected function setUp() $contextMock->expects($this->any())->method('getView')->willReturn($this->viewMock); $methods = ['setTitle', 'getTitle', 'setSuccessUrl', 'setBackUrl', 'setErrorUrl', '__wakeUp']; $this->addressFormMock = - $this->getMock('Magento\Customer\Block\Address\Edit', $methods, [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); + $this->getMock(\Magento\Customer\Block\Address\Edit::class, $methods, [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class); $contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock); - $this->pageMock = $this->getMock('Magento\Framework\View\Result\Page', [], [], '', false); + $this->pageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); $this->pageMock->expects($this->any())->method('getConfig')->willReturn($this->configMock); $this->configMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->pageMock); - $this->controller = $objectManager->getObject('Magento\Multishipping\Controller\Checkout\Address\EditAddress', + $this->controller = $objectManager->getObject( + \Magento\Multishipping\Controller\Checkout\Address\EditAddress::class, ['context' => $contextMock]); } @@ -111,7 +115,7 @@ public function testExecute() ->method('setTitle') ->with('Edit Address') ->willReturnSelf(); - $helperMock = $this->getMock('Magento\Multishipping\Helper\Data', [], [], '', false); + $helperMock = $this->getMock(\Magento\Multishipping\Helper\Data::class, [], [], '', false); $helperMock->expects($this->any())->method('__')->willReturn('Edit Address'); $valueMap = [ ['*/*/selectBilling', null, 'success/url'], diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditBillingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditBillingTest.php index 2b8a09f173863..8892fe04b86c8 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditBillingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditBillingTest.php @@ -10,6 +10,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EditBillingTest extends \PHPUnit_Framework_TestCase { /** @@ -75,29 +78,29 @@ class EditBillingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->configMock = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $this->checkoutMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); - $this->titleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); + $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->stateMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping\State', [], [], '', false); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, [], [], '', false); $valueMap = [ - ['Magento\Multishipping\Model\Checkout\Type\Multishipping\State', $this->stateMock], - ['Magento\Multishipping\Model\Checkout\Type\Multishipping', $this->checkoutMock] + [\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, $this->stateMock], + [\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, $this->checkoutMock] ]; $this->objectManagerMock->expects($this->any())->method('get')->willReturnMap($valueMap); - $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $response = $this->getMockBuilder('\Magento\Framework\App\ResponseInterface') + $response = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $contextMock->expects($this->atLeastOnce()) ->method('getRequest') ->will($this->returnValue($this->request)); @@ -108,14 +111,15 @@ protected function setUp() $contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); $methods = ['setTitle', 'getTitle', 'setSuccessUrl', 'setBackUrl', 'setErrorUrl', '__wakeUp']; $this->addressFormMock = - $this->getMock('Magento\Customer\Block\Address\Edit', $methods, [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); + $this->getMock(\Magento\Customer\Block\Address\Edit::class, $methods, [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class); $contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock); - $this->pageMock = $this->getMock('Magento\Framework\View\Result\Page', [], [], '', false); + $this->pageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); $this->pageMock->expects($this->any())->method('getConfig')->willReturn($this->configMock); $this->configMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->pageMock); - $this->controller = $objectManager->getObject('Magento\Multishipping\Controller\Checkout\Address\EditBilling', + $this->controller = $objectManager->getObject( + \Magento\Multishipping\Controller\Checkout\Address\EditBilling::class, ['context' => $contextMock]); } @@ -124,7 +128,7 @@ public function testExecute() $this->stateMock ->expects($this->once()) ->method('setActiveStep') - ->with( \Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_BILLING); + ->with(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_BILLING); $this->request->expects($this->once())->method('getParam')->with('id')->willReturn(1); $this->viewMock->expects($this->once())->method('loadLayout')->willReturnSelf(); $this->viewMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock); @@ -138,7 +142,7 @@ public function testExecute() ->method('setTitle') ->with('Edit Billing Address') ->willReturnSelf(); - $helperMock = $this->getMock('Magento\Multishipping\Helper\Data', [], [], '', false); + $helperMock = $this->getMock(\Magento\Multishipping\Helper\Data::class, [], [], '', false); $helperMock->expects($this->any())->method('__')->willReturn('Edit Billing Address'); $this->addressFormMock->expects($this->once())->method('setSuccessUrl')->with('success/url')->willReturnSelf(); $this->addressFormMock->expects($this->once())->method('setErrorUrl')->with('error/url')->willReturnSelf(); diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditShippingTest.php index 1b6494f70d019..bd0f0b6f119bf 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditShippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/EditShippingTest.php @@ -10,6 +10,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EditShippingTest extends \PHPUnit_Framework_TestCase { /** @@ -75,29 +78,29 @@ class EditShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->configMock = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $this->checkoutMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); - $this->titleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); + $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->stateMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping\State', [], [], '', false); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, [], [], '', false); $valueMap = [ - ['Magento\Multishipping\Model\Checkout\Type\Multishipping\State', $this->stateMock], - ['Magento\Multishipping\Model\Checkout\Type\Multishipping', $this->checkoutMock] + [\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, $this->stateMock], + [\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, $this->checkoutMock] ]; $this->objectManagerMock->expects($this->any())->method('get')->willReturnMap($valueMap); - $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $response = $this->getMockBuilder('\Magento\Framework\App\ResponseInterface') + $response = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $contextMock->expects($this->atLeastOnce()) ->method('getRequest') ->will($this->returnValue($this->request)); @@ -108,14 +111,15 @@ protected function setUp() $contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); $methods = ['setTitle', 'getTitle', 'setSuccessUrl', 'setBackUrl', 'setErrorUrl', '__wakeUp']; $this->addressFormMock = - $this->getMock('Magento\Customer\Block\Address\Edit', $methods, [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); + $this->getMock(\Magento\Customer\Block\Address\Edit::class, $methods, [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class); $contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock); - $this->pageMock = $this->getMock('Magento\Framework\View\Result\Page', [], [], '', false); + $this->pageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); $this->pageMock->expects($this->any())->method('getConfig')->willReturn($this->configMock); $this->configMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->pageMock); - $this->controller = $objectManager->getObject('Magento\Multishipping\Controller\Checkout\Address\EditShipping', + $this->controller = $objectManager->getObject( + \Magento\Multishipping\Controller\Checkout\Address\EditShipping::class, ['context' => $contextMock]); } @@ -138,7 +142,7 @@ public function testExecute() ->method('setTitle') ->with('Edit Shipping Address') ->willReturnSelf(); - $helperMock = $this->getMock('Magento\Multishipping\Helper\Data', [], [], '', false); + $helperMock = $this->getMock(\Magento\Multishipping\Helper\Data::class, [], [], '', false); $helperMock->expects($this->any())->method('__')->willReturn('Edit Shipping Address'); $this->addressFormMock->expects($this->once())->method('setSuccessUrl')->with('success/url')->willReturnSelf(); $this->addressFormMock->expects($this->once())->method('setErrorUrl')->with('error/url')->willReturnSelf(); diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewBillingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewBillingTest.php index abfca45e860f9..398061b4f1491 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewBillingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewBillingTest.php @@ -10,6 +10,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class NewBillingTest extends \PHPUnit_Framework_TestCase { /** @@ -56,19 +59,19 @@ class NewBillingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->configMock = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); - $this->titleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $this->configMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); + $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $response = $this->getMockBuilder('\Magento\Framework\App\ResponseInterface') + $response = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $contextMock->expects($this->atLeastOnce()) ->method('getRequest') ->will($this->returnValue($request)); @@ -78,14 +81,15 @@ protected function setUp() $contextMock->expects($this->any())->method('getView')->willReturn($this->viewMock); $methods = ['setTitle', 'getTitle', 'setSuccessUrl', 'setErrorUrl', 'setBackUrl', '__wakeUp']; $this->addressFormMock = - $this->getMock('Magento\Customer\Block\Address\Edit', $methods, [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); + $this->getMock(\Magento\Customer\Block\Address\Edit::class, $methods, [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class); $contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock); - $this->pageMock = $this->getMock('Magento\Framework\View\Result\Page', [], [], '', false); + $this->pageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); $this->pageMock->expects($this->any())->method('getConfig')->willReturn($this->configMock); $this->configMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->pageMock); - $this->controller = $objectManager->getObject('Magento\Multishipping\Controller\Checkout\Address\NewBilling', + $this->controller = $objectManager->getObject( + \Magento\Multishipping\Controller\Checkout\Address\NewBilling::class, ['context' => $contextMock]); } @@ -103,7 +107,7 @@ public function testExecute() ->method('setTitle') ->with('Create Billing Address') ->willReturnSelf(); - $helperMock = $this->getMock('Magento\Multishipping\Helper\Data', [], [], '', false); + $helperMock = $this->getMock(\Magento\Multishipping\Helper\Data::class, [], [], '', false); $helperMock->expects($this->any())->method('__')->willReturn('Create Billing Address'); $valueMap = [ ['*/*/selectBilling', null, 'success/url'], diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php index 714f59a978b68..139114536748e 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php @@ -10,6 +10,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class NewShippingTest extends \PHPUnit_Framework_TestCase { /** @@ -70,29 +73,29 @@ class NewShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->configMock = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $this->configMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); $this->checkoutMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping', [], [], '', false); - $this->titleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false); - $this->layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $this->viewMock = $this->getMock('Magento\Framework\App\ViewInterface'); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); + $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->stateMock = - $this->getMock('Magento\Multishipping\Model\Checkout\Type\Multishipping\State', [], [], '', false); + $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, [], [], '', false); $valueMap = [ - ['Magento\Multishipping\Model\Checkout\Type\Multishipping\State', $this->stateMock], - ['Magento\Multishipping\Model\Checkout\Type\Multishipping', $this->checkoutMock] + [\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class, $this->stateMock], + [\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, $this->checkoutMock] ]; $this->objectManagerMock->expects($this->any())->method('get')->willReturnMap($valueMap); - $request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + $request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $response = $this->getMockBuilder('\Magento\Framework\App\ResponseInterface') + $response = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); $contextMock->expects($this->atLeastOnce()) ->method('getRequest') ->will($this->returnValue($request)); @@ -103,14 +106,15 @@ protected function setUp() $contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); $methods = ['setTitle', 'getTitle', 'setSuccessUrl', 'setBackUrl', 'setErrorUrl', '__wakeUp']; $this->addressFormMock = - $this->getMock('Magento\Customer\Block\Address\Edit', $methods, [], '', false); - $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); + $this->getMock(\Magento\Customer\Block\Address\Edit::class, $methods, [], '', false); + $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class); $contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock); - $this->pageMock = $this->getMock('Magento\Framework\View\Result\Page', [], [], '', false); + $this->pageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); $this->pageMock->expects($this->any())->method('getConfig')->willReturn($this->configMock); $this->configMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->pageMock); - $this->controller = $objectManager->getObject('Magento\Multishipping\Controller\Checkout\Address\NewShipping', + $this->controller = $objectManager->getObject( + \Magento\Multishipping\Controller\Checkout\Address\NewShipping::class, ['context' => $contextMock]); } @@ -138,7 +142,7 @@ public function testExecute($backUrl, $shippingAddress, $url) ->method('setTitle') ->with('Create Shipping Address') ->willReturnSelf(); - $helperMock = $this->getMock('Magento\Multishipping\Helper\Data', [], [], '', false); + $helperMock = $this->getMock(\Magento\Multishipping\Helper\Data::class, [], [], '', false); $helperMock->expects($this->any())->method('__')->willReturn('Create Shipping Address'); $this->addressFormMock->expects($this->once())->method('setSuccessUrl')->with('success/url')->willReturnSelf(); $this->addressFormMock->expects($this->once())->method('setErrorUrl')->with('error/url')->willReturnSelf(); diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php index 81dde56d33217..2121f3cfe8c72 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php @@ -9,6 +9,7 @@ /** * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ShippingSavedTest extends \PHPUnit_Framework_TestCase { @@ -55,29 +56,35 @@ class ShippingSavedTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->checkoutMock = $this->getMock( - 'Magento\Multishipping\Model\Checkout\Type\Multishipping', + \Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false ); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerMock->expects($this->any()) ->method('get') - ->with('Magento\Multishipping\Model\Checkout\Type\Multishipping') + ->with(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class) ->willReturn($this->checkoutMock); - $this->contextMock = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); - $requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $responseMock = $this->getMock('Magento\Framework\App\ResponseInterface'); - $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); + $this->contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); + $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class); + $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($requestMock); $this->contextMock->expects($this->any())->method('getResponse')->willReturn($responseMock); $this->contextMock->expects($this->any())->method('getRedirect')->willReturn($this->redirectMock); - $this->addressRepositoryMock = $this->getMock('Magento\Customer\Api\AddressRepositoryInterface'); - $this->filterBuilderMock = $this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false); - $this->criteriaBuilderMock = $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); + $this->addressRepositoryMock = $this->getMock(\Magento\Customer\Api\AddressRepositoryInterface::class); + $this->filterBuilderMock = $this->getMock(\Magento\Framework\Api\FilterBuilder::class, [], [], '', false); + $this->criteriaBuilderMock = $this->getMock( + \Magento\Framework\Api\SearchCriteriaBuilder::class, + [], + [], + '', + false + ); $this->controller = new \Magento\Multishipping\Controller\Checkout\Address\ShippingSaved( $this->contextMock, $this->addressRepositoryMock, @@ -89,13 +96,13 @@ protected function setUp() public function testExecuteResetsCheckoutIfCustomerHasAddedNewShippingAddressAndItIsTheOnlyAddressHeHas() { $customerId = 1; - $customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerMock->expects($this->any())->method('getId')->willReturn($customerId); $this->checkoutMock->expects($this->any())->method('getCustomer')->willReturn($customerMock); $this->mockCustomerAddressRepository( $customerId, - [$this->getMock('Magento\Customer\Api\Data\AddressInterface')] + [$this->getMock(\Magento\Customer\Api\Data\AddressInterface::class)] ); // check that checkout is reset @@ -106,15 +113,15 @@ public function testExecuteResetsCheckoutIfCustomerHasAddedNewShippingAddressAnd public function testExecuteDoesNotResetCheckoutIfCustomerHasMoreThanOneAddress() { $customerId = 1; - $customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); + $customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerMock->expects($this->any())->method('getId')->willReturn($customerId); $this->checkoutMock->expects($this->any())->method('getCustomer')->willReturn($customerMock); $this->mockCustomerAddressRepository( $customerId, [ - $this->getMock('Magento\Customer\Api\Data\AddressInterface'), - $this->getMock('Magento\Customer\Api\Data\AddressInterface'), + $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class), + $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class), ] ); @@ -131,17 +138,17 @@ public function testExecuteDoesNotResetCheckoutIfCustomerHasMoreThanOneAddress() */ private function mockCustomerAddressRepository($customerId, array $addresses) { - $filterMock = $this->getMock('Magento\Framework\Api\Filter', [], [], '', false); + $filterMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); $this->filterBuilderMock->expects($this->once())->method('setField')->with('parent_id')->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setValue')->with($customerId)->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setConditionType')->with('eq')->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); - $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $this->criteriaBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock])->willReturnSelf(); $this->criteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); - $searchResultMock = $this->getMock('Magento\Customer\Api\Data\AddressSearchResultsInterface'); + $searchResultMock = $this->getMock(\Magento\Customer\Api\Data\AddressSearchResultsInterface::class); $this->addressRepositoryMock->expects($this->once()) ->method('getList') ->with($searchCriteriaMock) diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php index 01416790d1c75..f863f9d5c0766 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php @@ -27,9 +27,9 @@ class PluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cartMock = $this->getMock('Magento\Checkout\Model\Cart', [], [], '', false); + $this->cartMock = $this->getMock(\Magento\Checkout\Model\Cart::class, [], [], '', false); $this->quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, ['__wakeUp', 'setIsMultiShipping'], [], '', @@ -41,7 +41,7 @@ protected function setUp() public function testExecuteTurnsOffMultishippingModeOnQuote() { - $subject = $this->getMock('Magento\Checkout\Controller\Index\Index', [], [], '', false); + $subject = $this->getMock(\Magento\Checkout\Controller\Index\Index::class, [], [], '', false); $this->quoteMock->expects($this->once())->method('setIsMultiShipping')->with(0); $this->object->beforeExecute($subject); } diff --git a/app/code/Magento/Multishipping/Test/Unit/Helper/DataTest.php b/app/code/Magento/Multishipping/Test/Unit/Helper/DataTest.php index d6abf2533a3f8..5538df0400d4e 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Helper/DataTest.php @@ -40,11 +40,11 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $arguments = $objectManager->getConstructArguments('Magento\Multishipping\Helper\Data'); - $this->helper = $objectManager->getObject('Magento\Multishipping\Helper\Data', $arguments); + $arguments = $objectManager->getConstructArguments(\Magento\Multishipping\Helper\Data::class); + $this->helper = $objectManager->getObject(\Magento\Multishipping\Helper\Data::class, $arguments); $this->checkoutSessionMock = $arguments['checkoutSession']; /** @var \Magento\Framework\App\Helper\Context $context */ $context = $arguments['context']; diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php index 5b6ba1b447a39..a0c476f24be36 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php @@ -24,8 +24,8 @@ class CartPluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cartRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); + $this->cartRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); $this->model = new \Magento\Multishipping\Model\Cart\Controller\CartPlugin( $this->cartRepositoryMock, $this->checkoutSessionMock @@ -36,7 +36,7 @@ public function testBeforeDispatch() { $addressId = 100; $quoteMock = $this->getMock( - '\Magento\Quote\Model\Quote', + \Magento\Quote\Model\Quote::class, [ 'isMultipleShippingAddresses', 'getAllShippingAddresses', @@ -51,7 +51,7 @@ public function testBeforeDispatch() ); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); $addressMock->expects($this->once())->method('getId')->willReturn($addressId); $quoteMock->expects($this->once())->method('isMultipleShippingAddresses')->willReturn(true); @@ -64,8 +64,8 @@ public function testBeforeDispatch() $this->cartRepositoryMock->expects($this->once())->method('save')->with($quoteMock); $this->model->beforeDispatch( - $this->getMock('\Magento\Checkout\Controller\Cart', [], [], '', false), - $this->getMock('\Magento\Framework\App\RequestInterface') + $this->getMock(\Magento\Checkout\Controller\Cart::class, [], [], '', false), + $this->getMock(\Magento\Framework\App\RequestInterface::class) ); } } diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php index cfa89df9d4de1..75ee606fe88f6 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php @@ -28,13 +28,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->checkoutSessionMock = $this->getMock( - 'Magento\Checkout\Model\Session', + \Magento\Checkout\Model\Session::class, ['getCheckoutState', 'setCheckoutState'], [], '', false ); - $this->cartMock = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); + $this->cartMock = $this->getMock(\Magento\Checkout\Model\Cart::class, [], [], '', false); $this->model = new \Magento\Multishipping\Model\Checkout\Type\Multishipping\Plugin($this->checkoutSessionMock); } diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php index 929b8fadc604b..5cbf7c20c7c63 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Multishipping\Test\Unit\Model\Checkout\Type; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MultishippingTest extends \PHPUnit_Framework_TestCase { /** @@ -59,50 +62,77 @@ class MultishippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); - $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); - $orderFactoryMock = $this->getMock('\Magento\Sales\Model\OrderFactory', [], [], '', false); - $eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface', [], [], '', false); - $scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); - $sessionMock = $this->getMock('\Magento\Framework\Session\Generic', [], [], '', false); - $addressFactoryMock = $this->getMock('\Magento\Quote\Model\Quote\AddressFactory', [], [], '', false); - $toOrderMock = $this->getMock('\Magento\Quote\Model\Quote\Address\ToOrder', [], [], '', false); - $toOrderAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address\ToOrderAddress', [], [], '', false); - $toOrderPaymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment\ToOrderPayment', [], [], '', false); - $toOrderItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item\ToOrderItem', [], [], '', false); - $storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); - $paymentSpecMock = $this->getMock('\Magento\Payment\Model\Method\SpecificationInterface', [], [], '', false); - $this->helperMock = $this->getMock('\Magento\Multishipping\Helper\Data', [], [], '', false); - $orderSenderMock = $this->getMock('\Magento\Sales\Model\Order\Email\Sender\OrderSender', [], [], '', false); - $priceMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface', [], [], '', false); - $quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface'); - $this->filterBuilderMock = $this->getMock('\Magento\Framework\Api\FilterBuilder', [], [], '', false); + $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $orderFactoryMock = $this->getMock(\Magento\Sales\Model\OrderFactory::class, [], [], '', false); + $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); + $sessionMock = $this->getMock(\Magento\Framework\Session\Generic::class, [], [], '', false); + $addressFactoryMock = $this->getMock(\Magento\Quote\Model\Quote\AddressFactory::class, [], [], '', false); + $toOrderMock = $this->getMock(\Magento\Quote\Model\Quote\Address\ToOrder::class, [], [], '', false); + $toOrderAddressMock = $this->getMock( + \Magento\Quote\Model\Quote\Address\ToOrderAddress::class, + [], + [], + '', + false + ); + $toOrderPaymentMock = $this->getMock( + \Magento\Quote\Model\Quote\Payment\ToOrderPayment::class, + [], + [], + '', + false + ); + $toOrderItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item\ToOrderItem::class, [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $paymentSpecMock = $this->getMock( + \Magento\Payment\Model\Method\SpecificationInterface::class, + [], + [], + '', + false + ); + $this->helperMock = $this->getMock(\Magento\Multishipping\Helper\Data::class, [], [], '', false); + $orderSenderMock = $this->getMock( + \Magento\Sales\Model\Order\Email\Sender\OrderSender::class, + [], + [], + '', + false + ); + $priceMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class, [], [], '', false); + $quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->filterBuilderMock = $this->getMock(\Magento\Framework\Api\FilterBuilder::class, [], [], '', false); $this->searchCriteriaBuilderMock = $this->getMock( - '\Magento\Framework\Api\SearchCriteriaBuilder', + \Magento\Framework\Api\SearchCriteriaBuilder::class, [], [], '', false ); $this->addressRepositoryMock = $this->getMock( - '\Magento\Customer\Api\AddressRepositoryInterface', + \Magento\Customer\Api\AddressRepositoryInterface::class, [], [], '', false ); - - /** - * This is used to get past _init() which is called in construct. - */ + /** This is used to get past _init() which is called in construct. */ $data['checkout_session'] = $this->checkoutSessionMock; - $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $this->customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $this->customerMock->expects($this->atLeastOnce())->method('getId')->willReturn(null); $this->checkoutSessionMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($this->quoteMock); $this->customerSessionMock->expects($this->atLeastOnce())->method('getCustomerDataObject') ->willReturn($this->customerMock); - $this->totalsCollectorMock = $this->getMock('Magento\Quote\Model\Quote\TotalsCollector', [], [], '', false); + $this->totalsCollectorMock = $this->getMock( + \Magento\Quote\Model\Quote\TotalsCollector::class, + [], + [], + '', + false + ); $this->model = new \Magento\Multishipping\Model\Checkout\Type\Multishipping( $this->checkoutSessionMock, $this->customerSessionMock, @@ -154,14 +184,20 @@ public function testSetShippingItemsInformation() $this->filterBuilderMock->expects($this->atLeastOnce())->method('setConditionType')->willReturnSelf(); $this->filterBuilderMock->expects($this->atLeastOnce())->method('create')->willReturnSelf(); - $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); + $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('addFilters')->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('create') ->willReturn($searchCriteriaMock); - $resultMock = $this->getMock('\Magento\Customer\Api\Data\AddressSearchResultsInterface', [], [], '', false); + $resultMock = $this->getMock( + \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, + [], + [], + '', + false + ); $this->addressRepositoryMock->expects($this->atLeastOnce())->method('getList')->willReturn($resultMock); - $addressItemMock = $this->getMock('\Magento\Customer\Api\Data\AddressInterface', [], [], '', false); + $addressItemMock = $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class, [], [], '', false); $resultMock->expects($this->atLeastOnce())->method('getItems')->willReturn([$addressItemMock]); $addressItemMock->expects($this->atLeastOnce())->method('getId')->willReturn(null); @@ -184,11 +220,11 @@ public function testSetShippingItemsInformationForAddressLeak() ]; $customerAddressId = 42; - $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock = $this->getMock(\Magento\Customer\Model\Data\Address::class, [], [], '', false); $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); $customerAddresses = [$customerAddressMock]; - $quoteItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', [], [], '', false); + $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); $this->quoteMock->expects($this->once())->method('getItemById')->willReturn($quoteItemMock); $this->quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([]); @@ -204,7 +240,7 @@ public function testupdateQuoteCustomerShippingAddress() $addressId = 42; $customerAddressId = 42; - $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock = $this->getMock(\Magento\Customer\Model\Data\Address::class, [], [], '', false); $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); $customerAddresses = [$customerAddressMock]; $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); @@ -223,7 +259,7 @@ public function testupdateQuoteCustomerShippingAddressForAddressLeak() $addressId = 43; $customerAddressId = 42; - $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock = $this->getMock(\Magento\Customer\Model\Data\Address::class, [], [], '', false); $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); $customerAddresses = [$customerAddressMock]; $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); @@ -236,7 +272,7 @@ public function testSetQuoteCustomerBillingAddress() $addressId = 42; $customerAddressId = 42; - $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock = $this->getMock(\Magento\Customer\Model\Data\Address::class, [], [], '', false); $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); $customerAddresses = [$customerAddressMock]; $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); @@ -253,7 +289,7 @@ public function testSetQuoteCustomerBillingAddressForAddressLeak() $addressId = 43; $customerAddressId = 42; - $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock = $this->getMock(\Magento\Customer\Model\Data\Address::class, [], [], '', false); $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); $customerAddresses = [$customerAddressMock]; $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); @@ -263,7 +299,7 @@ public function testSetQuoteCustomerBillingAddressForAddressLeak() public function testGetQuoteShippingAddressesItems() { - $quoteItem = $this->getMock('Magento\Quote\Model\Quote\Address\Item', [], [], '', false); + $quoteItem = $this->getMock(\Magento\Quote\Model\Quote\Address\Item::class, [], [], '', false); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock); $this->quoteMock->expects($this->once())->method('getShippingAddressesItems')->willReturn($quoteItem); $this->model->getQuoteShippingAddressesItems(); diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/EnabledTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/EnabledTest.php index c00d96f887e6a..48e4cde475ebd 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/EnabledTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/EnabledTest.php @@ -26,7 +26,7 @@ class EnabledTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentConfigMock = $this->getMock('\Magento\Payment\Model\Config', [], [], '', false); + $this->paymentConfigMock = $this->getMock(\Magento\Payment\Model\Config::class, [], [], '', false); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } @@ -51,7 +51,7 @@ public function testIsSatisfiedBy($methodsInfo, $result) ); $configSpecification = $this->objectManager->getObject( - 'Magento\Multishipping\Model\Payment\Method\Specification\Enabled', + \Magento\Multishipping\Model\Payment\Method\Specification\Enabled::class, ['paymentConfig' => $this->paymentConfigMock] ); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php b/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php index 33702d8ec34f7..4280a82546a2d 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php @@ -59,7 +59,7 @@ protected function _prepareLayout() $this->setChild( 'deleteButton', $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, 'del.button' )->setData( ['label' => __('Delete Selected Problems'), 'onclick' => 'problemController.deleteSelected();'] @@ -69,7 +69,7 @@ protected function _prepareLayout() $this->setChild( 'unsubscribeButton', $this->getLayout()->createBlock( - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, 'unsubscribe.button' )->setData( ['label' => __('Unsubscribe Selected'), 'onclick' => 'problemController.unsubscribe();'] diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php index f71b1f76d7ff4..f4808f00cd345 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php @@ -70,7 +70,7 @@ protected function _beforeToHtml() { $this->setChild( 'form', - $this->getLayout()->createBlock('Magento\Newsletter\Block\Adminhtml\Queue\Edit\Form', 'form') + $this->getLayout()->createBlock(\Magento\Newsletter\Block\Adminhtml\Queue\Edit\Form::class, 'form') ); return parent::_beforeToHtml(); } @@ -99,7 +99,7 @@ protected function _prepareLayout() { $this->getToolbar()->addChild( 'back_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'onclick' => "window.location.href = '" . $this->getUrl( @@ -111,19 +111,19 @@ protected function _prepareLayout() $this->getToolbar()->addChild( 'reset_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Reset'), 'class' => 'reset', 'onclick' => 'window.location = window.location'] ); $this->getToolbar()->addChild( 'preview_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Preview Template'), 'onclick' => 'queueControl.preview();', 'class' => 'preview'] ); $this->getToolbar()->addChild( 'save_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save Newsletter'), 'class' => 'save primary', @@ -135,7 +135,7 @@ protected function _prepareLayout() $this->getToolbar()->addChild( 'save_and_resume', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save and Resume'), 'class' => 'save', diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template.php index b50a53c9b5592..4a9e06c2a88d0 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template.php @@ -25,7 +25,7 @@ protected function _prepareLayout() { $this->getToolbar()->addChild( 'add_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Add New Template'), 'onclick' => "window.location='" . $this->getCreateUrl() . "'", @@ -36,7 +36,7 @@ protected function _prepareLayout() $this->setChild( 'grid', $this->getLayout()->createBlock( - 'Magento\Newsletter\Block\Adminhtml\Template\Grid', + \Magento\Newsletter\Block\Adminhtml\Template\Grid::class, 'newsletter.template.grid' ) ); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php index 03297c9c45181..5f0664f72866a 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php @@ -72,8 +72,7 @@ protected function _prepareLayout() // } $this->getToolbar()->addChild( - 'back_button', - 'Magento\Backend\Block\Widget\Button', + 'back_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'", @@ -82,8 +81,7 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( - 'reset_button', - 'Magento\Backend\Block\Widget\Button', + 'reset_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Reset'), 'onclick' => 'window.location.href = window.location.href', @@ -93,8 +91,7 @@ protected function _prepareLayout() if (!$this->isTextType()) { $this->getToolbar()->addChild( - 'to_plain_button', - 'Magento\Backend\Block\Widget\Button', + 'to_plain_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Convert to Plain Text'), 'data_attribute' => [ @@ -106,8 +103,7 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( - 'to_html_button', - 'Magento\Backend\Block\Widget\Button', + 'to_html_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Return HTML Version'), 'data_attribute' => [ @@ -121,8 +117,7 @@ protected function _prepareLayout() } $this->getToolbar()->addChild( - 'preview_button', - 'Magento\Backend\Block\Widget\Button', + 'preview_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Preview Template'), 'data_attribute' => [ @@ -134,8 +129,7 @@ protected function _prepareLayout() if ($this->getEditMode()) { $this->getToolbar()->addChild( - 'delete_button', - 'Magento\Backend\Block\Widget\Button', + 'delete_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Delete Template'), 'data_attribute' => [ @@ -146,8 +140,7 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( - 'save_as_button', - 'Magento\Backend\Block\Widget\Button', + 'save_as_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save As'), 'data_attribute' => [ @@ -159,8 +152,7 @@ protected function _prepareLayout() } $this->getToolbar()->addChild( - 'save_button', - 'Magento\Backend\Block\Widget\Button', + 'save_button', \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save Template'), 'data_attribute' => [ @@ -208,7 +200,8 @@ public function getHeaderText() */ public function getForm() { - return $this->getLayout()->createBlock('Magento\Newsletter\Block\Adminhtml\Template\Edit\Form')->toHtml(); + return $this->getLayout()->createBlock( + \Magento\Newsletter\Block\Adminhtml\Template\Edit\Form::class)->toHtml(); } /** diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php index 92cab662fbfd3..817ef89a41ffb 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php @@ -115,7 +115,7 @@ protected function _prepareColumns() [ 'header' => __('Sender'), 'index' => 'template_sender_email', - 'renderer' => 'Magento\Newsletter\Block\Adminhtml\Template\Grid\Renderer\Sender', + 'renderer' => \Magento\Newsletter\Block\Adminhtml\Template\Grid\Renderer\Sender::class, 'header_css_class' => 'col-sender', 'column_css_class' => 'col-sender' ] @@ -144,7 +144,7 @@ protected function _prepareColumns() 'sortable' => false, 'filter' => false, 'no_link' => true, - 'renderer' => 'Magento\Newsletter\Block\Adminhtml\Template\Grid\Renderer\Action', + 'renderer' => \Magento\Newsletter\Block\Adminhtml\Template\Grid\Renderer\Action::class, 'header_css_class' => 'col-actions', 'column_css_class' => 'col-actions' ] diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Problem/Grid.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Problem/Grid.php index 7b48decab9c05..512e8cc97b4e7 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Problem/Grid.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Problem/Grid.php @@ -19,7 +19,7 @@ public function execute() $problems = (array)$this->getRequest()->getParam('problem', []); if (count($problems) > 0) { $collection = - $this->_objectManager->create('Magento\Newsletter\Model\ResourceModel\Problem\Collection'); + $this->_objectManager->create(\Magento\Newsletter\Model\ResourceModel\Problem\Collection::class); $collection->addSubscriberInfo()->addFieldToFilter( $collection->getResource()->getIdFieldName(), ['in' => $problems] @@ -35,7 +35,7 @@ public function execute() $problems = (array)$this->getRequest()->getParam('problem', []); if (count($problems) > 0) { $collection = - $this->_objectManager->create('Magento\Newsletter\Model\ResourceModel\Problem\Collection'); + $this->_objectManager->create(\Magento\Newsletter\Model\ResourceModel\Problem\Collection::class); $collection->addFieldToFilter( $collection->getResource()->getIdFieldName(), ['in' => $problems] diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Cancel.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Cancel.php index a6894b5835c04..82e82a2c40e1a 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Cancel.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Cancel.php @@ -16,7 +16,7 @@ class Cancel extends \Magento\Newsletter\Controller\Adminhtml\Queue public function execute() { $queue = $this->_objectManager->get( - 'Magento\Newsletter\Model\Queue' + \Magento\Newsletter\Model\Queue::class )->load( $this->getRequest()->getParam('id') ); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Edit.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Edit.php index 6c86dd13d541e..a2a4406bfba78 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Edit.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Edit.php @@ -32,7 +32,9 @@ public function __construct(\Magento\Backend\App\Action\Context $context, \Magen */ public function execute() { - $this->_coreRegistry->register('current_queue', $this->_objectManager->get('Magento\Newsletter\Model\Queue')); + $this->_coreRegistry->register('current_queue', $this->_objectManager->get( + \Magento\Newsletter\Model\Queue::class + )); $id = $this->getRequest()->getParam('id'); $templateId = $this->getRequest()->getParam('template_id'); @@ -40,7 +42,7 @@ public function execute() if ($id) { $queue = $this->_coreRegistry->registry('current_queue')->load($id); } elseif ($templateId) { - $template = $this->_objectManager->create('Magento\Newsletter\Model\Template')->load($templateId); + $template = $this->_objectManager->create(\Magento\Newsletter\Model\Template::class)->load($templateId); $queue = $this->_coreRegistry->registry('current_queue')->setTemplateId($template->getId()); } diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Pause.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Pause.php index b33bb6219e1dd..43c9e55d97b68 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Pause.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Pause.php @@ -16,7 +16,7 @@ class Pause extends \Magento\Newsletter\Controller\Adminhtml\Queue public function execute() { $queue = $this->_objectManager->get( - 'Magento\Newsletter\Model\Queue' + \Magento\Newsletter\Model\Queue::class )->load( $this->getRequest()->getParam('id') ); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Preview.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Preview.php index a11d1abc82b9b..fdf2d8bf89fb1 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Preview.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Preview.php @@ -28,7 +28,7 @@ public function execute() // set default value for selected store /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManager'); + $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManager::class); $defaultStore = $storeManager->getDefaultStoreView(); if (!$defaultStore) { $allStores = $storeManager->getStores(); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Resume.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Resume.php index 07364ef21117e..31ac1d89f7ce5 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Resume.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Resume.php @@ -16,7 +16,7 @@ class Resume extends \Magento\Newsletter\Controller\Adminhtml\Queue public function execute() { $queue = $this->_objectManager->get( - 'Magento\Newsletter\Model\Queue' + \Magento\Newsletter\Model\Queue::class )->load( $this->getRequest()->getParam('id') ); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Save.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Save.php index 4acef96088aff..b7614f1657b27 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Save.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Save.php @@ -22,12 +22,12 @@ public function execute() { try { /* @var $queue \Magento\Newsletter\Model\Queue */ - $queue = $this->_objectManager->create('Magento\Newsletter\Model\Queue'); + $queue = $this->_objectManager->create(\Magento\Newsletter\Model\Queue::class); $templateId = $this->getRequest()->getParam('template_id'); if ($templateId) { /* @var $template \Magento\Newsletter\Model\Template */ - $template = $this->_objectManager->create('Magento\Newsletter\Model\Template')->load($templateId); + $template = $this->_objectManager->create(\Magento\Newsletter\Model\Template::class)->load($templateId); if (!$template->getId() || $template->getIsSystem()) { throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the newsletter template and try again.')); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Sending.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Sending.php index 66573735092a0..d919ab3c7e993 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Sending.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Sending.php @@ -20,7 +20,7 @@ public function execute() $countOfSubscritions = 20; $collection = $this->_objectManager->create( - 'Magento\Newsletter\Model\ResourceModel\Queue\Collection' + \Magento\Newsletter\Model\ResourceModel\Queue\Collection::class )->setPageSize( $countOfQueue )->setCurPage( diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Start.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Start.php index 8b72ef9308199..28ca6b4463ecc 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Start.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue/Start.php @@ -16,7 +16,7 @@ class Start extends \Magento\Newsletter\Controller\Adminhtml\Queue public function execute() { $queue = $this->_objectManager->create( - 'Magento\Newsletter\Model\Queue' + \Magento\Newsletter\Model\Queue::class )->load( $this->getRequest()->getParam('id') ); @@ -31,7 +31,7 @@ public function execute() } $queue->setQueueStartAt( - $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->gmtDate() + $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\DateTime::class)->gmtDate() )->setQueueStatus( \Magento\Newsletter\Model\Queue::STATUS_SENDING )->save(); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassDelete.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassDelete.php index 35d91a1e28508..f97c8a2b64914 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassDelete.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassDelete.php @@ -22,7 +22,7 @@ public function execute() try { foreach ($subscribersIds as $subscriberId) { $subscriber = $this->_objectManager->create( - 'Magento\Newsletter\Model\Subscriber' + \Magento\Newsletter\Model\Subscriber::class )->load( $subscriberId ); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassUnsubscribe.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassUnsubscribe.php index eb6950cc55ffc..04ebff9922db5 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassUnsubscribe.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber/MassUnsubscribe.php @@ -22,7 +22,7 @@ public function execute() try { foreach ($subscribersIds as $subscriberId) { $subscriber = $this->_objectManager->create( - 'Magento\Newsletter\Model\Subscriber' + \Magento\Newsletter\Model\Subscriber::class )->load( $subscriberId ); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Delete.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Delete.php index 8317d032174b0..8c63c508642a7 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Delete.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Delete.php @@ -16,7 +16,7 @@ class Delete extends \Magento\Newsletter\Controller\Adminhtml\Template public function execute() { $template = $this->_objectManager->create( - 'Magento\Newsletter\Model\Template' + \Magento\Newsletter\Model\Template::class )->load( $this->getRequest()->getParam('id') ); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Edit.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Edit.php index 9189688cb045f..1c10f9bc42b83 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Edit.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Edit.php @@ -32,7 +32,7 @@ public function __construct(\Magento\Backend\App\Action\Context $context, \Magen */ public function execute() { - $model = $this->_objectManager->create('Magento\Newsletter\Model\Template'); + $model = $this->_objectManager->create(\Magento\Newsletter\Model\Template::class); $id = $this->getRequest()->getParam('id'); if ($id) { $model->load($id); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Grid.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Grid.php index 1147c181452a5..6e3dbfb664d8c 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Grid.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Grid.php @@ -16,7 +16,9 @@ class Grid extends \Magento\Newsletter\Controller\Adminhtml\Template public function execute() { $this->_view->loadLayout(); - $grid = $this->_view->getLayout()->createBlock('Magento\Newsletter\Block\Adminhtml\Template\Grid')->toHtml(); + $grid = $this->_view->getLayout()->createBlock( + \Magento\Newsletter\Block\Adminhtml\Template\Grid::class + )->toHtml(); $this->getResponse()->setBody($grid); } } diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Index.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Index.php index 28c2494668b69..3376c1e4e4db0 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Index.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Index.php @@ -23,7 +23,7 @@ public function execute() $this->_setActiveMenu('Magento_Newsletter::newsletter_template'); $this->_addBreadcrumb(__('Newsletter Templates'), __('Newsletter Templates')); $this->_addContent( - $this->_view->getLayout()->createBlock('Magento\Newsletter\Block\Adminhtml\Template', 'template') + $this->_view->getLayout()->createBlock(\Magento\Newsletter\Block\Adminhtml\Template::class, 'template') ); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Newsletter Templates')); $this->_view->renderLayout(); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Preview.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Preview.php index 80579ddb49395..da2fc7e808bee 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Preview.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Preview.php @@ -28,7 +28,7 @@ public function execute() // set default value for selected store /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManager'); + $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManager::class); $defaultStore = $storeManager->getDefaultStoreView(); if (!$defaultStore) { $allStores = $storeManager->getStores(); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Save.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Save.php index ee09d6da776bc..526c18305a170 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Save.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template/Save.php @@ -22,7 +22,7 @@ public function execute() if (!$request->isPost()) { $this->getResponse()->setRedirect($this->getUrl('*/template')); } - $template = $this->_objectManager->create('Magento\Newsletter\Model\Template'); + $template = $this->_objectManager->create(\Magento\Newsletter\Model\Template::class); $id = (int)$request->getParam('id'); if ($id) { @@ -45,7 +45,7 @@ public function execute() )->setTemplateStyles( $request->getParam('styles') )->setModifiedAt( - $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->gmtDate() + $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\DateTime::class)->gmtDate() ); if (!$template->getId()) { diff --git a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php index 1077bb3fd5d75..f9bea0b19c29c 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php @@ -13,6 +13,9 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Newsletter\Model\SubscriberFactory; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class NewAction extends \Magento\Newsletter\Controller\Subscriber { /** @@ -75,7 +78,7 @@ protected function validateEmailAvailable($email) */ protected function validateGuestSubscription() { - if ($this->_objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface') + if ($this->_objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getValue( \Magento\Newsletter\Model\Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG, \Magento\Store\Model\ScopeInterface::SCOPE_STORE diff --git a/app/code/Magento/Newsletter/Model/Problem.php b/app/code/Magento/Newsletter/Model/Problem.php index db5047d60efb5..43fec3ca3f6f0 100644 --- a/app/code/Magento/Newsletter/Model/Problem.php +++ b/app/code/Magento/Newsletter/Model/Problem.php @@ -66,7 +66,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Newsletter\Model\ResourceModel\Problem'); + $this->_init(\Magento\Newsletter\Model\ResourceModel\Problem::class); } /** diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 53fc97d8bc1f7..c78c0ee5903bd 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -158,7 +158,7 @@ public function __construct( protected function _construct() { parent::_construct(); - $this->_init('Magento\Newsletter\Model\ResourceModel\Queue'); + $this->_init(\Magento\Newsletter\Model\ResourceModel\Queue::class); } /** diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php index aea3f599006d7..649c92773f3ce 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php @@ -12,6 +12,7 @@ * Newsletter problems collection * * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { @@ -87,7 +88,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Newsletter\Model\Problem', 'Magento\Newsletter\Model\ResourceModel\Problem'); + $this->_init(\Magento\Newsletter\Model\Problem::class, \Magento\Newsletter\Model\ResourceModel\Problem::class); } /** @@ -103,6 +104,7 @@ protected function _setIsLoaded($flag = true) } return parent::_setIsLoaded($flag); } + /** * Adds subscribers info * diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php index 7f082d7664df4..1975df50abd1c 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php @@ -63,7 +63,7 @@ public function __construct( protected function _construct() { $this->_map['fields']['queue_id'] = 'main_table.queue_id'; - $this->_init('Magento\Newsletter\Model\Queue', 'Magento\Newsletter\Model\ResourceModel\Queue'); + $this->_init(\Magento\Newsletter\Model\Queue::class, \Magento\Newsletter\Model\ResourceModel\Queue::class); } /** diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php index 9913f94b1720b..f336036bd1852 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php @@ -87,7 +87,10 @@ public function __construct( protected function _construct() { parent::_construct(); - $this->_init('Magento\Newsletter\Model\Subscriber', 'Magento\Newsletter\Model\ResourceModel\Subscriber'); + $this->_init( + \Magento\Newsletter\Model\Subscriber::class, + \Magento\Newsletter\Model\ResourceModel\Subscriber::class + ); $this->_queueLinkTable = $this->getTable('newsletter_queue_link'); $this->_storeTable = $this->getTable('store'); diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php index 0e87e5792326d..7bac4bb8ff9fa 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php @@ -19,7 +19,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Newsletter\Model\Template', 'Magento\Newsletter\Model\ResourceModel\Template'); + $this->_init( + \Magento\Newsletter\Model\Template::class, + \Magento\Newsletter\Model\ResourceModel\Template::class + ); } /** diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index ef43df4104b93..4520b0de5b36f 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -171,7 +171,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Newsletter\Model\ResourceModel\Subscriber'); + $this->_init(\Magento\Newsletter\Model\ResourceModel\Subscriber::class); } /** diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 53f7e5e5852f7..7b454921b0ddc 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -127,7 +127,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Newsletter\Model\ResourceModel\Template'); + $this->_init(\Magento\Newsletter\Model\ResourceModel\Template::class); } /** diff --git a/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php index ad90c5a6d9159..17b8f6de3ed3c 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Newsletter\Test\Unit\Block\Adminhtml\Queue; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class PreviewTest extends \PHPUnit_Framework_TestCase { /** @@ -44,45 +47,51 @@ class PreviewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock('Magento\Backend\Block\Template\Context', [], [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $context = $this->getMock(\Magento\Backend\Block\Template\Context::class, [], [], '', false); + $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); $context->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager)); - $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); $context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request)); $this->storeManager = $this->getMock( - 'Magento\Store\Model\StoreManager', + \Magento\Store\Model\StoreManager::class, ['getStores', 'getDefaultStoreView'], [], '', false ); $context->expects($this->once())->method('getStoreManager')->will($this->returnValue($this->storeManager)); - $appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); $context->expects($this->once())->method('getAppState')->will($this->returnValue($appState)); - $backendSession = $this->getMockBuilder('Magento\Backend\Model\Session') + $backendSession = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->disableOriginalConstructor() ->getMock(); $context->expects($this->once())->method('getBackendSession')->willReturn($backendSession); - $templateFactory = $this->getMock('Magento\Newsletter\Model\TemplateFactory', ['create'], [], '', false); - $this->template = $this->getMock('Magento\Newsletter\Model\Template', [], [], '', false); + $templateFactory = $this->getMock(\Magento\Newsletter\Model\TemplateFactory::class, ['create'], [], '', false); + $this->template = $this->getMock(\Magento\Newsletter\Model\Template::class, [], [], '', false); $templateFactory->expects($this->once())->method('create')->will($this->returnValue($this->template)); - $subscriberFactory = $this->getMock('Magento\Newsletter\Model\SubscriberFactory', ['create'], [], '', false); - $this->subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); + $subscriberFactory = $this->getMock( + \Magento\Newsletter\Model\SubscriberFactory::class, + ['create'], + [], + '', + false + ); + $this->subscriber = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); $subscriberFactory->expects($this->once())->method('create')->will($this->returnValue($this->subscriber)); - $queueFactory = $this->getMock('Magento\Newsletter\Model\QueueFactory', ['create'], [], '', false); - $this->queue = $this->getMock('Magento\Newsletter\Model\Queue', ['load'], [], '', false); + $queueFactory = $this->getMock(\Magento\Newsletter\Model\QueueFactory::class, ['create'], [], '', false); + $this->queue = $this->getMock(\Magento\Newsletter\Model\Queue::class, ['load'], [], '', false); $queueFactory->expects($this->any())->method('create')->will($this->returnValue($this->queue)); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->preview = $this->objectManager->getObject( - 'Magento\Newsletter\Block\Adminhtml\Queue\Preview', + \Magento\Newsletter\Block\Adminhtml\Queue\Preview::class, [ 'context' => $context, 'templateFactory' => $templateFactory, @@ -95,7 +104,7 @@ protected function setUp() public function testToHtmlEmpty() { /** @var \Magento\Store\Model\Store $store */ - $store = $this->getMock('Magento\Store\Model\Store', ['getId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId'], [], '', false); $this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue($store)); $result = $this->preview->toHtml(); $this->assertEquals('', $result); @@ -113,7 +122,7 @@ public function testToHtmlWithId() $this->template->expects($this->any())->method('isPlain')->will($this->returnValue(true)); /** @var \Magento\Store\Model\Store $store */ $this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue(null)); - $store = $this->getMock('Magento\Store\Model\Store', ['getId'], [], '', false); + $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId'], [], '', false); $this->storeManager->expects($this->once())->method('getStores')->will($this->returnValue([0 => $store])); $result = $this->preview->toHtml(); $this->assertEquals('
', $result);
diff --git a/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
index b35d74bb1d9b8..f5aab0a39e814 100644
--- a/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
+++ b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
@@ -33,11 +33,11 @@ class PreviewTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false);
-        $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false);
-        $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
+        $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false);
+        $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false);
+        $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);
         $this->template = $this->getMock(
-            'Magento\Newsletter\Model\Template',
+            \Magento\Newsletter\Model\Template::class,
             [
                 'setTemplateType',
                 'setTemplateText',
@@ -52,10 +52,10 @@ protected function setUp()
             '',
             false
         );
-        $templateFactory = $this->getMock('Magento\Newsletter\Model\TemplateFactory', ['create'], [], '', false);
+        $templateFactory = $this->getMock(\Magento\Newsletter\Model\TemplateFactory::class, ['create'], [], '', false);
         $templateFactory->expects($this->once())->method('create')->willReturn($this->template);
         $this->subscriberFactory = $this->getMock(
-            'Magento\Newsletter\Model\SubscriberFactory',
+            \Magento\Newsletter\Model\SubscriberFactory::class,
             ['create'],
             [],
             '',
@@ -64,7 +64,7 @@ protected function setUp()
 
         $this->objectManagerHelper = new ObjectManagerHelper($this);
         $this->preview = $this->objectManagerHelper->getObject(
-            'Magento\Newsletter\Block\Adminhtml\Template\Preview',
+            \Magento\Newsletter\Block\Adminhtml\Template\Preview::class,
             [
                 'appState' => $this->appState,
                 'storeManager' => $this->storeManager,
@@ -118,12 +118,11 @@ public function testToHtmlForNewTemplate()
         $this->template->expects($this->atLeastOnce())->method('emulateDesign')->with(1);
         $this->template->expects($this->atLeastOnce())->method('revertDesign');
 
-        $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
+        $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false);
         $store->expects($this->atLeastOnce())->method('getId')->willReturn(1);
 
         $this->storeManager->expects($this->atLeastOnce())->method('getStores')->willReturn([$store]);
 
-
         $this->appState->expects($this->atLeastOnce())->method('emulateAreaCode')
             ->with(
                 \Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA,
@@ -151,7 +150,7 @@ public function testToHtmlWithSubscriber()
                 ['subscriber', null, 3]
             ]
         );
-        $subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false);
+        $subscriber = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false);
         $subscriber->expects($this->atLeastOnce())->method('load')->with(3)->willReturnSelf();
         $this->subscriberFactory->expects($this->atLeastOnce())->method('create')->willReturn($subscriber);
 
diff --git a/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php b/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php
index 62042abb4692d..7219dab989d5c 100644
--- a/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php
+++ b/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php
@@ -57,34 +57,35 @@ class SaveTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
+        $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
             ->disableOriginalConstructor()
             ->getMock();
-        $this->responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')
+        $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class)
             ->disableOriginalConstructor()
             ->getMock();
-        $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface')
+        $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
             ->disableOriginalConstructor()
             ->getMock();
-        $this->redirectMock = $this->getMockBuilder('Magento\Framework\App\Response\RedirectInterface')
+        $this->redirectMock = $this->getMockBuilder(\Magento\Framework\App\Response\RedirectInterface::class)
             ->disableOriginalConstructor()
             ->getMock();
-        $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session')
+        $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class)
             ->disableOriginalConstructor()
             ->getMock();
         $this->customerSessionMock->expects($this->any())
             ->method('isLoggedIn')
             ->will($this->returnValue(true));
-        $this->formKeyValidatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator')
+        $this->formKeyValidatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class)
             ->disableOriginalConstructor()
             ->getMock();
         $this->customerRepositoryMock =
-            $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface')
+            $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class)
                 ->disableOriginalConstructor()
                 ->getMock();
         $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
 
-        $this->action = $objectManager->getObject('Magento\Newsletter\Controller\Manage\Save', [
+        $this->action = $objectManager->getObject(
+            \Magento\Newsletter\Controller\Manage\Save::class, [
                 'request' => $this->requestMock,
                 'response' => $this->responseMock,
                 'messageManager' => $this->messageManagerMock,
diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php
index 5a89e77644e30..02464425e70b0 100644
--- a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php
+++ b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php
@@ -29,11 +29,11 @@ class CustomerPluginTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->subscriberFactory = $this->getMockBuilder('\Magento\Newsletter\Model\SubscriberFactory')
+        $this->subscriberFactory = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class)
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
-        $this->subscriber = $this->getMockBuilder('\Magento\Newsletter\Model\Subscriber')
+        $this->subscriber = $this->getMockBuilder(\Magento\Newsletter\Model\Subscriber::class)
             ->setMethods(['loadByEmail', 'getId', 'delete', 'updateSubscription'])
             ->disableOriginalConstructor()
             ->getMock();
@@ -42,7 +42,7 @@ protected function setUp()
         $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
 
         $this->plugin = $this->objectManager->getObject(
-            'Magento\Newsletter\Model\Plugin\CustomerPlugin',
+            \Magento\Newsletter\Model\Plugin\CustomerPlugin::class,
             [
                 'subscriberFactory' => $this->subscriberFactory
             ]
@@ -52,8 +52,8 @@ protected function setUp()
     public function testAfterSave()
     {
         $customerId = 1;
-        $subject = $this->getMock('\Magento\Customer\Api\CustomerRepositoryInterface');
-        $customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface');
+        $subject = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class);
+        $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class);
         $customer->expects($this->once())->method('getId')->willReturn($customerId);
         $this->subscriber->expects($this->once())->method('updateSubscription')->with($customerId)->willReturnSelf();
 
@@ -65,8 +65,8 @@ public function testAroundDelete()
         $deleteCustomer = function () {
             return true;
         };
-        $subject = $this->getMock('\Magento\Customer\Api\CustomerRepositoryInterface');
-        $customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface');
+        $subject = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class);
+        $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class);
         $customer->expects($this->once())->method('getEmail')->willReturn('test@test.com');
         $this->subscriber->expects($this->once())->method('loadByEmail')->with('test@test.com')->willReturnSelf();
         $this->subscriber->expects($this->once())->method('getId')->willReturn(1);
@@ -81,8 +81,8 @@ public function testAroundDeleteById()
         $deleteCustomerById = function () {
             return true;
         };
-        $subject = $this->getMock('\Magento\Customer\Api\CustomerRepositoryInterface');
-        $customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface');
+        $subject = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class);
+        $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class);
         $subject->expects($this->once())->method('getById')->willReturn($customer);
         $customer->expects($this->once())->method('getEmail')->willReturn('test@test.com');
         $this->subscriber->expects($this->once())->method('loadByEmail')->with('test@test.com')->willReturnSelf();
diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/Queue/TransportBuilderTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/Queue/TransportBuilderTest.php
index 5429c8c82d10e..7b730fc33b56f 100644
--- a/app/code/Magento/Newsletter/Test/Unit/Model/Queue/TransportBuilderTest.php
+++ b/app/code/Magento/Newsletter/Test/Unit/Model/Queue/TransportBuilderTest.php
@@ -13,7 +13,7 @@ class TransportBuilderTest extends \PHPUnit_Framework_TestCase
     /**
      * @var string
      */
-    protected $builderClassName = '\Magento\Newsletter\Model\Queue\TransportBuilder';
+    protected $builderClassName = \Magento\Newsletter\Model\Queue\TransportBuilder::class;
 
     /**
      * @var \Magento\Newsletter\Model\Queue\TransportBuilder
@@ -51,12 +51,13 @@ class TransportBuilderTest extends \PHPUnit_Framework_TestCase
     public function setUp()
     {
         $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
-        $this->templateFactoryMock = $this->getMock('Magento\Framework\Mail\Template\FactoryInterface');
-        $this->messageMock = $this->getMock('Magento\Framework\Mail\Message');
-        $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
-        $this->senderResolverMock = $this->getMock('Magento\Framework\Mail\Template\SenderResolverInterface');
-        $this->mailTransportFactoryMock = $this->getMockBuilder('Magento\Framework\Mail\TransportInterfaceFactory')
-            ->disableOriginalConstructor()
+        $this->templateFactoryMock = $this->getMock(\Magento\Framework\Mail\Template\FactoryInterface::class);
+        $this->messageMock = $this->getMock(\Magento\Framework\Mail\Message::class);
+        $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class);
+        $this->senderResolverMock = $this->getMock(\Magento\Framework\Mail\Template\SenderResolverInterface::class);
+        $this->mailTransportFactoryMock = $this->getMockBuilder(
+            \Magento\Framework\Mail\TransportInterfaceFactory::class
+        )->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
         $this->builder = $objectManagerHelper->getObject(
@@ -83,7 +84,7 @@ public function testGetTransport(
         $messageType = MessageInterface::TYPE_HTML,
         $bodyText = '

Html message

' ) { - $filter = $this->getMock('Magento\Email\Model\Template\Filter', [], [], '', false); + $filter = $this->getMock(\Magento\Email\Model\Template\Filter::class, [], [], '', false); $data = [ 'template_subject' => 'Email Subject', 'template_text' => $bodyText, @@ -93,7 +94,7 @@ public function testGetTransport( ]; $vars = ['reason' => 'Reason', 'customer' => 'Customer']; $options = ['area' => 'frontend', 'store' => 1]; - $template = $this->getMock('\Magento\Email\Model\Template', [], [], '', false); + $template = $this->getMock(\Magento\Email\Model\Template::class, [], [], '', false); $template->expects($this->once())->method('setVars')->with($this->equalTo($vars))->will($this->returnSelf()); $template->expects( $this->once() @@ -152,7 +153,7 @@ public function testGetTransport( $this->returnSelf() ); - $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); + $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class); $this->mailTransportFactoryMock->expects( $this->at(0) @@ -169,7 +170,7 @@ public function testGetTransport( )->method( 'create' )->with( - $this->equalTo('Magento\Framework\Mail\Message') + $this->equalTo(\Magento\Framework\Mail\Message::class) )->will( $this->returnValue($transport) ); @@ -186,6 +187,6 @@ public function testGetTransport( $result = $this->builder->getTransport(); - $this->assertInstanceOf('Magento\Framework\Mail\TransportInterface', $result); + $this->assertInstanceOf(\Magento\Framework\Mail\TransportInterface::class, $result); } } diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php index b110bf7f3023e..907eb7446386d 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Newsletter\Test\Unit\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class QueueTest extends \PHPUnit_Framework_TestCase { /** @@ -59,35 +62,35 @@ class QueueTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->templateFilter = $this->getMockBuilder('\Magento\Newsletter\Model\Template\Filter') + $this->templateFilter = $this->getMockBuilder(\Magento\Newsletter\Model\Template\Filter::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->date = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\DateTime') + $this->date = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); - $this->templateFactory = $this->getMockBuilder('\Magento\Newsletter\Model\TemplateFactory') + $this->templateFactory = $this->getMockBuilder(\Magento\Newsletter\Model\TemplateFactory::class) ->disableOriginalConstructor() ->setMethods(['create', 'load']) ->getMock(); - $this->problemFactory = $this->getMockBuilder('\Magento\Newsletter\Model\ProblemFactory') + $this->problemFactory = $this->getMockBuilder(\Magento\Newsletter\Model\ProblemFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->transportBuilder = $this->getMockBuilder('\Magento\Newsletter\Model\Queue\TransportBuilder') + $this->transportBuilder = $this->getMockBuilder(\Magento\Newsletter\Model\Queue\TransportBuilder::class) ->disableOriginalConstructor() ->setMethods( ['setTemplateData', 'setTemplateOptions', 'setTemplateVars', 'setFrom', 'addTo', 'getTransport'] ) ->getMock(); $this->subscribersCollection = - $this->getMockBuilder('\Magento\Newsletter\Model\ResourceModel\Subscriber\Collection') + $this->getMockBuilder(\Magento\Newsletter\Model\ResourceModel\Subscriber\Collection::class) ->disableOriginalConstructor() ->getMock(); - $this->resource = $this->getMockBuilder('\Magento\Newsletter\Model\ResourceModel\Queue') + $this->resource = $this->getMockBuilder(\Magento\Newsletter\Model\ResourceModel\Queue::class) ->disableOriginalConstructor() ->getMock(); $this->subscribersCollectionFactory = $this->getMockBuilder( - '\Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory' + \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory::class ) ->disableOriginalConstructor() ->setMethods(['create']) @@ -99,7 +102,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->queue = $this->objectManager->getObject( - '\Magento\Newsletter\Model\Queue', + \Magento\Newsletter\Model\Queue::class, [ 'templateFilter' => $this->templateFilter, 'date' => $this->date, @@ -136,15 +139,15 @@ public function testSendPerSubscriber2() { $this->queue->setQueueStatus(1); $this->queue->setQueueStartAt(1); - $collection = $this->getMockBuilder('\Magento\Framework\Data\Collection') + $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->setMethods(['getItems']) ->getMock(); - $item = $this->getMockBuilder('\Magento\Newsletter\Model\Subscriber') + $item = $this->getMockBuilder(\Magento\Newsletter\Model\Subscriber::class) ->disableOriginalConstructor() ->setMethods(['getStoreId', 'getSubscriberEmail', 'getSubscriberFullName', 'received']) ->getMock(); - $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); + $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class); $this->subscribersCollection->expects($this->once())->method('getQueueJoinedFlag')->willReturn(false); $this->subscribersCollection->expects($this->once())->method('useQueue')->with($this->queue)->willReturnSelf(); $this->subscribersCollection->expects($this->once())->method('getSize')->willReturn(5); @@ -186,7 +189,7 @@ public function testGetDataForSave() public function testGetTemplate() { - $template = $this->getMockBuilder('\Magento\Newsletter\Model\Template') + $template = $this->getMockBuilder(\Magento\Newsletter\Model\Template::class) ->disableOriginalConstructor() ->getMock(); $this->queue->setTemplateId(2); diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php index 39f06d20f2e69..789a8bdcd4397 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Newsletter\Test\Unit\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SubscriberTest extends \PHPUnit_Framework_TestCase { /** @@ -64,10 +67,10 @@ class SubscriberTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->newsletterData = $this->getMock('Magento\Newsletter\Helper\Data', [], [], '', false); - $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->newsletterData = $this->getMock(\Magento\Newsletter\Helper\Data::class, [], [], '', false); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->transportBuilder = $this->getMock( - 'Magento\Framework\Mail\Template\TransportBuilder', + \Magento\Framework\Mail\Template\TransportBuilder::class, [ 'setTemplateIdentifier', 'setTemplateOptions', @@ -80,9 +83,9 @@ protected function setUp() '', false ); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->customerSession = $this->getMock( - 'Magento\Customer\Model\Session', + \Magento\Customer\Model\Session::class, [ 'isLoggedIn', 'getCustomerDataObject', @@ -92,11 +95,11 @@ protected function setUp() '', false ); - $this->customerRepository = $this->getMock('Magento\Customer\Api\CustomerRepositoryInterface'); - $this->customerAccountManagement = $this->getMock('Magento\Customer\Api\AccountManagementInterface'); - $this->inlineTranslation = $this->getMock('Magento\Framework\Translate\Inline\StateInterface'); + $this->customerRepository = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->customerAccountManagement = $this->getMock(\Magento\Customer\Api\AccountManagementInterface::class); + $this->inlineTranslation = $this->getMock(\Magento\Framework\Translate\Inline\StateInterface::class); $this->resource = $this->getMock( - 'Magento\Newsletter\Model\ResourceModel\Subscriber', + \Magento\Newsletter\Model\ResourceModel\Subscriber::class, [ 'loadByEmail', 'getIdFieldName', @@ -111,7 +114,7 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->subscriber = $this->objectManager->getObject( - 'Magento\Newsletter\Model\Subscriber', + \Magento\Newsletter\Model\Subscriber::class, [ 'newsletterData' => $this->newsletterData, 'scopeConfig' => $this->scopeConfig, @@ -138,7 +141,7 @@ public function testSubscribe() ); $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); $this->customerSession->expects($this->any())->method('isLoggedIn')->willReturn(true); - $customerDataModel = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $customerDataModel = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerSession->expects($this->any())->method('getCustomerDataObject')->willReturn($customerDataModel); $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1); $customerDataModel->expects($this->any())->method('getEmail')->willReturn($email); @@ -163,7 +166,7 @@ public function testSubscribeNotLoggedIn() ); $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); $this->customerSession->expects($this->any())->method('isLoggedIn')->willReturn(false); - $customerDataModel = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $customerDataModel = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerSession->expects($this->any())->method('getCustomerDataObject')->willReturn($customerDataModel); $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1); $customerDataModel->expects($this->any())->method('getEmail')->willReturn($email); @@ -179,7 +182,7 @@ public function testSubscribeNotLoggedIn() public function testUpdateSubscription() { $customerId = 1; - $customerDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $this->customerRepository->expects($this->atLeastOnce()) ->method('getById') @@ -208,7 +211,7 @@ public function testUpdateSubscription() public function testUnsubscribeCustomerById() { $customerId = 1; - $customerDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $this->customerRepository->expects($this->atLeastOnce()) ->method('getById') @@ -234,7 +237,7 @@ public function testUnsubscribeCustomerById() public function testSubscribeCustomerById() { $customerId = 1; - $customerDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); $this->customerRepository->expects($this->atLeastOnce()) ->method('getById') @@ -304,7 +307,7 @@ public function testConfirmWrongCode() public function testReceived() { - $queue = $this->getMockBuilder('\Magento\Newsletter\Model\Queue') + $queue = $this->getMockBuilder(\Magento\Newsletter\Model\Queue::class) ->disableOriginalConstructor() ->getMock(); $this->resource->expects($this->once())->method('received')->with($this->subscriber, $queue)->willReturnSelf(); @@ -314,11 +317,11 @@ public function testReceived() protected function sendEmailCheck() { - $storeModel = $this->getMockBuilder('\Magento\Store\Model\Store') + $storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); - $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); + $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class); $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->willReturnSelf(); $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf(); diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/Template/FilterTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/Template/FilterTest.php index e267ddd3d7b5d..36adf86829c2c 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/Template/FilterTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/Template/FilterTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Newsletter\Test\Unit\Model\Template; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class FilterTest extends \PHPUnit_Framework_TestCase { /** @@ -25,30 +28,36 @@ class FilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $scopeConfig = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface', + \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false ); $this->storeManager = $this->getMockForAbstractClass( - '\Magento\Store\Model\StoreManagerInterface', + \Magento\Store\Model\StoreManagerInterface::class, + [], + '', + false + ); + $logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class, [], '', false); + $layout = $this->getMockForAbstractClass(\Magento\Framework\View\LayoutInterface::class, [], '', false); + $urlModel = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class, [], '', false); + $string = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class, [], [], '', false); + $escaper = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $assetRepo = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $coreVariableFactory = $this->getMock( + \Magento\Variable\Model\VariableFactory::class, + ['create'], [], '', false ); - $logger = $this->getMockForAbstractClass('\Psr\Log\LoggerInterface', [], '', false); - $layout = $this->getMockForAbstractClass('\Magento\Framework\View\LayoutInterface', [], '', false); - $urlModel = $this->getMockForAbstractClass('\Magento\Framework\UrlInterface', [], '', false); - $string = $this->getMock('\Magento\Framework\Stdlib\StringUtils', [], [], '', false); - $escaper = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); - $assetRepo = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); - $coreVariableFactory = $this->getMock('\Magento\Variable\Model\VariableFactory', ['create'], [], '', false); - $layoutFactory = $this->getMock('\Magento\Framework\View\LayoutFactory', ['create'], [], '', false); - $this->appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false); - $emogrifier = $this->getMock('\Pelago\Emogrifier', [], [], '', false); - $configVariables = $this->getMock('\Magento\Email\Model\Source\Variables', [], [], '', false); - $widgetResource = $this->getMock('\Magento\Widget\Model\ResourceModel\Widget', [], [], '', false); - $widget = $this->getMock('\Magento\Widget\Model\Widget', [], [], '', false); + $layoutFactory = $this->getMock(\Magento\Framework\View\LayoutFactory::class, ['create'], [], '', false); + $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $emogrifier = $this->getMock(\Pelago\Emogrifier::class, [], [], '', false); + $configVariables = $this->getMock(\Magento\Email\Model\Source\Variables::class, [], [], '', false); + $widgetResource = $this->getMock(\Magento\Widget\Model\ResourceModel\Widget::class, [], [], '', false); + $widget = $this->getMock(\Magento\Widget\Model\Widget::class, [], [], '', false); $this->filter = new \Magento\Newsletter\Model\Template\Filter( $string, @@ -72,12 +81,12 @@ protected function setUp() public function testWidgetDirective() { - $subscriber = $this->getMock('\Magento\Newsletter\Model\Subscriber', [], [], '', false); + $subscriber = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); $this->filter->setVariables(['subscriber' => $subscriber]); $construction = '{{widget type="\Magento\Cms\Block\Widget\Page\Link" page_id="1"}}'; - $store = $this->getMockForAbstractClass('Magento\Store\Api\Data\StoreInterface', [], '', false); + $store = $this->getMockForAbstractClass(\Magento\Store\Api\Data\StoreInterface::class, [], '', false); $store->expects($this->once()) ->method('getId') ->willReturn(1); diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php index 9aacaa5d2fac4..e51d5e0fdb3a7 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php @@ -90,27 +90,27 @@ class TemplateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->design = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + $this->design = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->appEmulation = $this->getMockBuilder('Magento\Store\Model\App\Emulation') + $this->appEmulation = $this->getMockBuilder(\Magento\Store\Model\App\Emulation::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->setMethods(['getFrontendName', 'getId']) ->disableOriginalConstructor() ->getMock(); @@ -127,39 +127,39 @@ protected function setUp() ->method('getStore') ->will($this->returnValue($this->store)); - $this->assetRepo = $this->getMockBuilder('Magento\Framework\View\Asset\Repository') + $this->assetRepo = $this->getMockBuilder(\Magento\Framework\View\Asset\Repository::class) ->disableOriginalConstructor() ->getMock(); - $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->emailConfig = $this->getMockBuilder('Magento\Email\Model\Template\Config') + $this->emailConfig = $this->getMockBuilder(\Magento\Email\Model\Template\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->templateFactory = $this->getMockBuilder('Magento\Email\Model\TemplateFactory') + $this->templateFactory = $this->getMockBuilder(\Magento\Email\Model\TemplateFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->filterManager = $this->getMockBuilder('Magento\Framework\Filter\FilterManager') + $this->filterManager = $this->getMockBuilder(\Magento\Framework\Filter\FilterManager::class) ->disableOriginalConstructor() ->getMock(); - $this->urlModel = $this->getMockBuilder('Magento\Framework\Url') + $this->urlModel = $this->getMockBuilder(\Magento\Framework\Url::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->filterFactory = $this->getMockBuilder('Magento\Newsletter\Model\Template\FilterFactory') + $this->filterFactory = $this->getMockBuilder(\Magento\Newsletter\Model\Template\FilterFactory::class) ->disableOriginalConstructor() ->getMock(); } @@ -172,7 +172,7 @@ protected function setUp() */ protected function getModelMock(array $mockedMethods = []) { - return $this->getMockBuilder('Magento\Newsletter\Model\Template') + return $this->getMockBuilder(\Magento\Newsletter\Model\Template::class) ->setMethods(array_merge($mockedMethods, ['__wakeup', '__sleep', '_init'])) ->setConstructorArgs( [ @@ -207,7 +207,7 @@ public function testGetProcessedTemplateSubject() $templateSubject = 'templateSubject'; $model->setTemplateSubject($templateSubject); - $filterTemplate = $this->getMockBuilder('Magento\Framework\Filter\Template') + $filterTemplate = $this->getMockBuilder(\Magento\Framework\Filter\Template::class) ->setMethods(['setVariables', 'setStoreId', 'filter']) ->disableOriginalConstructor() ->getMock(); @@ -245,7 +245,7 @@ public function testGetProcessedTemplateSubject() */ public function testGetProcessedTemplate($variables, $templateType, $storeId, $expectedVariables, $expectedResult) { - $filterTemplate = $this->getMockBuilder('Magento\Newsletter\Model\Template\Filter') + $filterTemplate = $this->getMockBuilder(\Magento\Newsletter\Model\Template\Filter::class) ->setMethods([ 'setUseSessionInUrl', 'setPlainTemplateMode', @@ -283,7 +283,7 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e // The following block of code tests to ensure that the store id of the subscriber will be used, if the // 'subscriber' variable is set. - $subscriber = $this->getMockBuilder('Magento\Newsletter\Model\Subscriber') + $subscriber = $this->getMockBuilder(\Magento\Newsletter\Model\Subscriber::class) ->setMethods([ 'getStoreId', ]) diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php index e227052a4e2dc..e1d8115f94f32 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php @@ -373,7 +373,7 @@ protected function _prepareFilterButtons() { $this->addChild( 'refresh_button', - 'Magento\Backend\Block\Widget\Button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Refresh'), 'onclick' => "{$this->getJsObjectName()}.doFilter();", 'class' => 'task'] ); } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php index d6f5dfd825d88..06045d1f2f56a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php @@ -121,7 +121,7 @@ protected function _prepareColumns() 'filter' => false, 'index' => 'purchases', 'type' => 'number', - 'renderer' => 'Magento\Reports\Block\Adminhtml\Product\Downloads\Renderer\Purchases', + 'renderer' => \Magento\Reports\Block\Adminhtml\Product\Downloads\Renderer\Purchases::class, 'header_css_class' => 'col-purchases', 'column_css_class' => 'col-purchases' ] diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php index b49971cb905dd..4fa70d2b692c2 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php @@ -25,7 +25,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid * * @var string */ - protected $_resourceCollectionName = 'Magento\Reports\Model\ResourceModel\Report\Product\Viewed\Collection'; + protected $_resourceCollectionName = \Magento\Reports\Model\ResourceModel\Report\Product\Viewed\Collection::class; /** * Init grid parameters @@ -53,7 +53,7 @@ protected function _prepareColumns() 'width' => 100, 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'html_decorators' => ['nobr'], 'header_css_class' => 'col-period', diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php index 976f6139a72f3..07a7c1a08c2a7 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php @@ -36,7 +36,7 @@ protected function _construct() */ public function getResourceCollectionName() { - return 'Magento\Sales\Model\ResourceModel\Report\Bestsellers\Collection'; + return \Magento\Sales\Model\ResourceModel\Report\Bestsellers\Collection::class; } /** @@ -51,7 +51,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'html_decorators' => ['nobr'], 'header_css_class' => 'col-period', diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php index 7362e381aba74..45e679e69c37b 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php @@ -37,9 +37,9 @@ protected function _construct() public function getResourceCollectionName() { if ($this->getFilterData()->getData('report_type') == 'updated_at_order') { - return 'Magento\SalesRule\Model\ResourceModel\Report\Updatedat\Collection'; + return \Magento\SalesRule\Model\ResourceModel\Report\Updatedat\Collection::class; } else { - return 'Magento\SalesRule\Model\ResourceModel\Report\Collection'; + return \Magento\SalesRule\Model\ResourceModel\Report\Collection::class; } } @@ -56,7 +56,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'subtotals_label' => __('Subtotal'), 'html_decorators' => ['nobr'], diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php index 9e8efb8a2c96f..50e164ce166ef 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php @@ -37,8 +37,8 @@ protected function _construct() public function getResourceCollectionName() { return ($this->getFilterData()->getData('report_type')) == 'created_at_invoice' - ? 'Magento\Sales\Model\ResourceModel\Report\Invoiced\Collection\Invoiced' - : 'Magento\Sales\Model\ResourceModel\Report\Invoiced\Collection\Order'; + ? \Magento\Sales\Model\ResourceModel\Report\Invoiced\Collection\Invoiced::class + : \Magento\Sales\Model\ResourceModel\Report\Invoiced\Collection\Order::class; } /** @@ -53,7 +53,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'html_decorators' => ['nobr'], 'header_css_class' => 'col-period', diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php index 2a6ac0f96e803..d7de298111cb7 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php @@ -37,8 +37,8 @@ protected function _construct() public function getResourceCollectionName() { return $this->getFilterData()->getData('report_type') == 'created_at_refunded' - ? 'Magento\Sales\Model\ResourceModel\Report\Refunded\Collection\Refunded' - : 'Magento\Sales\Model\ResourceModel\Report\Refunded\Collection\Order'; + ? \Magento\Sales\Model\ResourceModel\Report\Refunded\Collection\Refunded::class + : \Magento\Sales\Model\ResourceModel\Report\Refunded\Collection\Order::class; } /** @@ -53,7 +53,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'html_decorators' => ['nobr'], 'header_css_class' => 'col-period', diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php index 0b78b61c4d2cb..39dc98511717c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php @@ -37,8 +37,8 @@ protected function _construct() public function getResourceCollectionName() { return $this->getFilterData()->getData('report_type') == 'updated_at_order' - ? 'Magento\Sales\Model\ResourceModel\Report\Order\Updatedat\Collection' - : 'Magento\Sales\Model\ResourceModel\Report\Order\Collection'; + ? \Magento\Sales\Model\ResourceModel\Report\Order\Updatedat\Collection::class + : \Magento\Sales\Model\ResourceModel\Report\Order\Collection::class; } /** @@ -55,7 +55,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'html_decorators' => ['nobr'], 'header_css_class' => 'col-period', diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php index b4ce6c4066456..8338877f4759a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php @@ -38,8 +38,8 @@ protected function _construct() public function getResourceCollectionName() { return $this->getFilterData()->getData('report_type') == 'created_at_shipment' - ? 'Magento\Sales\Model\ResourceModel\Report\Shipping\Collection\Shipment' - : 'Magento\Sales\Model\ResourceModel\Report\Shipping\Collection\Order'; + ? \Magento\Sales\Model\ResourceModel\Report\Shipping\Collection\Shipment::class + : \Magento\Sales\Model\ResourceModel\Report\Shipping\Collection\Order::class; } /** @@ -54,7 +54,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'subtotals_label' => __('Subtotal'), 'html_decorators' => ['nobr'], diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php index d8f3b137e3180..b55a05b7df7ab 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php @@ -69,8 +69,8 @@ protected function _construct() public function getResourceCollectionName() { return $this->getFilterData()->getData('report_type') == 'updated_at_order' - ? 'Magento\Tax\Model\ResourceModel\Report\Updatedat\Collection' - : 'Magento\Tax\Model\ResourceModel\Report\Collection'; + ? \Magento\Tax\Model\ResourceModel\Report\Updatedat\Collection::class + : \Magento\Tax\Model\ResourceModel\Report\Collection::class; } /** @@ -85,7 +85,7 @@ protected function _prepareColumns() 'index' => 'period', 'sortable' => false, 'period_type' => $this->getPeriodType(), - 'renderer' => 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', + 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'subtotals_label' => __('Subtotal'), 'html_decorators' => ['nobr'], diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php index 6c514ce4a0005..c6b66565c8d8b 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php @@ -161,7 +161,7 @@ protected function _prepareColumns() 'currency_code' => $currencyCode, 'index' => 'subtotal', 'sortable' => false, - 'renderer' => 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency', + 'renderer' => \Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency::class, 'rate' => $this->getRate($currencyCode), 'header_css_class' => 'col-subtotal', 'column_css_class' => 'col-subtotal' diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php index 24915a0a6d4cf..ae203b37ee0b2 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php @@ -104,7 +104,7 @@ protected function _prepareColumns() 'align' => 'right', 'currency_code' => $currencyCode, 'index' => 'total', - 'renderer' => 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency', + 'renderer' => \Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency::class, 'rate' => $this->getRate($currencyCode) ] ); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php index 2bd635493779f..75d1ae7ac5c48 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php @@ -101,7 +101,7 @@ protected function _prepareColumns() 'currency_code' => $currencyCode, 'index' => 'price', 'sortable' => false, - 'renderer' => 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency', + 'renderer' => \Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency::class, 'rate' => $this->getRate($currencyCode), 'header_css_class' => 'col-price', 'column_css_class' => 'col-price' diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php index 45dcc02b433e0..b4ebd37a6e957 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php @@ -50,7 +50,7 @@ protected function _beforeToHtml() { $this->setChild( 'grid', - $this->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Wishlist\Grid', 'report.grid') + $this->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Wishlist\Grid::class, 'report.grid') ); $collection = $this->_wishlistFactory->create(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php index 4a112df124167..bb7265a1a1a62 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php @@ -63,7 +63,7 @@ public function __construct( protected function _getSession() { if ($this->_adminSession === null) { - $this->_adminSession = $this->_objectManager->get('Magento\Backend\Model\Auth\Session'); + $this->_adminSession = $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class); } return $this->_adminSession; } @@ -93,7 +93,7 @@ public function _initReportAction($blocks) } $requestData = $this->_objectManager->get( - 'Magento\Backend\Helper\Data' + \Magento\Backend\Helper\Data::class )->prepareFilterString( $this->getRequest()->getParam('filter') ); @@ -131,7 +131,9 @@ public function _initReportAction($blocks) */ protected function _showLastExecutionTime($flagCode, $refreshCode) { - $flag = $this->_objectManager->create('Magento\Reports\Model\Flag')->setReportFlagCode($flagCode)->loadSelf(); + $flag = $this->_objectManager->create(\Magento\Reports\Model\Flag::class) + ->setReportFlagCode($flagCode) + ->loadSelf(); $updatedAt = 'undefined'; if ($flag->hasData()) { $updatedAt = $this->timezone->formatDate( diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php index 46f0661ee72a4..8635c0fbfc91f 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php @@ -28,7 +28,7 @@ public function execute() __('Downloads'), __('Downloads') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Product\Downloads') + $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Product\Downloads::class) ); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Downloads Report')); $this->_view->renderLayout(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsCsv.php index 80ec4843146c0..ab45869506b9b 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsCsv.php @@ -26,7 +26,7 @@ public function execute() { $fileName = 'products_downloads.csv'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Product\Downloads\Grid' + \Magento\Reports\Block\Adminhtml\Product\Downloads\Grid::class )->setSaveParametersInSession( true )->getCsv(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsExcel.php index 9e3bd4c6406de..fb7bfab47aace 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsExcel.php @@ -26,7 +26,7 @@ public function execute() { $fileName = 'products_downloads.xml'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Product\Downloads\Grid' + \Magento\Reports\Block\Adminhtml\Product\Downloads\Grid::class )->setSaveParametersInSession( true )->getExcel( diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedCsv.php index 748c73cae8c40..1c9dd4b35ed9f 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedCsv.php @@ -26,7 +26,7 @@ class ExportViewedCsv extends \Magento\Reports\Controller\Adminhtml\Report\Produ public function execute() { $fileName = 'products_mostviewed.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Product\Viewed\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Product\Viewed\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedExcel.php index af20058e9edab..7958775b535ac 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportViewedExcel.php @@ -26,7 +26,7 @@ class ExportViewedExcel extends \Magento\Reports\Controller\Adminhtml\Report\Pro public function execute() { $fileName = 'products_mostviewed.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Product\Viewed\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Product\Viewed\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create( $fileName, diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php index c11fe70335262..6565a5794c658 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php @@ -47,7 +47,7 @@ public function execute() $this->messageManager->addError( __('An error occurred while showing the product views report. Please review the log and try again.') ); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->_redirect('reports/*/viewed/'); return; } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailCsv.php index 54854d2325282..5ef4ece6f6e63 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailCsv.php @@ -20,7 +20,7 @@ public function execute() { $fileName = 'review_product_detail.csv'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Review\Detail\Grid' + \Magento\Reports\Block\Adminhtml\Review\Detail\Grid::class )->getCsv(); return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailExcel.php index 4b12bfa9ec4a7..ccc4ef6096530 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ExportProductDetailExcel.php @@ -20,7 +20,7 @@ public function execute() { $fileName = 'review_product_detail.xml'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Review\Detail\Grid' + \Magento\Reports\Block\Adminhtml\Review\Detail\Grid::class )->getExcel( $fileName ); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ProductDetail.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ProductDetail.php index c12ef0fb71797..081203325b003 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ProductDetail.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/ProductDetail.php @@ -24,7 +24,7 @@ public function execute() __('Product Reviews'), __('Product Reviews') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Review\Detail') + $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Review\Detail::class) ); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Details')); $this->_view->renderLayout(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersCsv.php index 6cb7867c90b9a..4068a0393e3fb 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersCsv.php @@ -19,7 +19,7 @@ class ExportBestsellersCsv extends \Magento\Reports\Controller\Adminhtml\Report\ public function execute() { $fileName = 'bestsellers.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Bestsellers\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Bestsellers\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersExcel.php index 514dbeb02d546..68dc386b86a67 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportBestsellersExcel.php @@ -19,7 +19,7 @@ class ExportBestsellersExcel extends \Magento\Reports\Controller\Adminhtml\Repor public function execute() { $fileName = 'bestsellers.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Bestsellers\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Bestsellers\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsCsv.php index 9bab4809285f3..0402d173d7f9f 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsCsv.php @@ -19,7 +19,7 @@ class ExportCouponsCsv extends \Magento\Reports\Controller\Adminhtml\Report\Sale public function execute() { $fileName = 'coupons.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsExcel.php index cdb04866617fd..c6023bc32d96b 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportCouponsExcel.php @@ -19,7 +19,7 @@ class ExportCouponsExcel extends \Magento\Reports\Controller\Adminhtml\Report\Sa public function execute() { $fileName = 'coupons.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedCsv.php index dab200bc3757d..16f18da2ecd4d 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedCsv.php @@ -19,7 +19,7 @@ class ExportInvoicedCsv extends \Magento\Reports\Controller\Adminhtml\Report\Sal public function execute() { $fileName = 'invoiced.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Invoiced\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Invoiced\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedExcel.php index 9c9f8b7488a2b..5eb08203ee549 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportInvoicedExcel.php @@ -19,7 +19,7 @@ class ExportInvoicedExcel extends \Magento\Reports\Controller\Adminhtml\Report\S public function execute() { $fileName = 'invoiced.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Invoiced\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Invoiced\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedCsv.php index ab7f3eed9dd8d..c93bce51f5582 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedCsv.php @@ -19,7 +19,7 @@ class ExportRefundedCsv extends \Magento\Reports\Controller\Adminhtml\Report\Sal public function execute() { $fileName = 'refunded.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Refunded\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Refunded\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedExcel.php index 71ef3f2470c05..fd571d8a68a2a 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportRefundedExcel.php @@ -19,7 +19,7 @@ class ExportRefundedExcel extends \Magento\Reports\Controller\Adminhtml\Report\S public function execute() { $fileName = 'refunded.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Refunded\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Refunded\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesCsv.php index b384de50a4aae..ed0fde22ebf60 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesCsv.php @@ -19,7 +19,7 @@ class ExportSalesCsv extends \Magento\Reports\Controller\Adminhtml\Report\Sales public function execute() { $fileName = 'sales.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Sales\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Sales\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesExcel.php index 67ef18badd52b..26c3d3286f583 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportSalesExcel.php @@ -19,7 +19,7 @@ class ExportSalesExcel extends \Magento\Reports\Controller\Adminhtml\Report\Sale public function execute() { $fileName = 'sales.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Sales\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Sales\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingCsv.php index 4e964dfb4f78c..517e56838faf0 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingCsv.php @@ -19,7 +19,7 @@ class ExportShippingCsv extends \Magento\Reports\Controller\Adminhtml\Report\Sal public function execute() { $fileName = 'shipping.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Shipping\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Shipping\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingExcel.php index eeb56fe587661..77e45d3776779 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportShippingExcel.php @@ -19,7 +19,7 @@ class ExportShippingExcel extends \Magento\Reports\Controller\Adminhtml\Report\S public function execute() { $fileName = 'shipping.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Shipping\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Shipping\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxCsv.php index aa64ae7ffdec4..b6a7a9701a662 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxCsv.php @@ -19,7 +19,7 @@ class ExportTaxCsv extends \Magento\Reports\Controller\Adminhtml\Report\Sales public function execute() { $fileName = 'tax.csv'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Tax\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Tax\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getCsvFile(), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxExcel.php index a55291fde4c04..0d58ec6034bfc 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/ExportTaxExcel.php @@ -19,7 +19,7 @@ class ExportTaxExcel extends \Magento\Reports\Controller\Adminhtml\Report\Sales public function execute() { $fileName = 'tax.xml'; - $grid = $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Sales\Tax\Grid'); + $grid = $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Sales\Tax\Grid::class); $this->_initReportAction($grid); return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName), DirectoryList::VAR_DIR); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php index 2cf599663f307..271c7a016f72b 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php @@ -21,7 +21,7 @@ public function execute() __('Abandoned Carts'), __('Abandoned Carts') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Abandoned') + $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Shopcart\Abandoned::class) ); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Abandoned Carts')); $this->_view->renderLayout(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Customer.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Customer.php index 745d10280a3d9..f5c9816b16f98 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Customer.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Customer.php @@ -21,7 +21,7 @@ public function execute() __('Customers Report'), __('Customers Report') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Customer') + $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Shopcart\Customer::class) ); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Customer Shopping Carts')); $this->_view->renderLayout(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedCsv.php index 2e1c99c09411a..8be4bde3fbe91 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedCsv.php @@ -20,7 +20,7 @@ public function execute() { $fileName = 'shopcart_abandoned.csv'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid' + \Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid::class )->getCsvFile(); return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedExcel.php index 3398eb745fe1a..b3520391c3111 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportAbandonedExcel.php @@ -20,7 +20,7 @@ public function execute() { $fileName = 'shopcart_abandoned.xml'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid' + \Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid::class )->getExcelFile( $fileName ); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerCsv.php index c0a1230fc2cef..6b2dc465cc3ca 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerCsv.php @@ -19,7 +19,7 @@ public function execute() { $fileName = 'shopcart_customer.csv'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Shopcart\Customer\Grid' + \Magento\Reports\Block\Adminhtml\Shopcart\Customer\Grid::class )->getCsvFile(); return $this->_fileFactory->create($fileName, $content); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerExcel.php index 7c94bebd89761..6bc0a460881f8 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportCustomerExcel.php @@ -19,7 +19,7 @@ public function execute() { $fileName = 'shopcart_customer.xml'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Shopcart\Customer\Grid' + \Magento\Reports\Block\Adminhtml\Shopcart\Customer\Grid::class )->getExcelFile( $fileName ); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductCsv.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductCsv.php index c894c6f700e5b..15c28b6d39d1d 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductCsv.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductCsv.php @@ -20,7 +20,7 @@ public function execute() { $fileName = 'shopcart_product.csv'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid' + \Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid::class )->getCsvFile(); return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductExcel.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductExcel.php index b80d2501f32d6..55d8715528d57 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductExcel.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/ExportProductExcel.php @@ -20,7 +20,7 @@ public function execute() { $fileName = 'shopcart_product.xml'; $content = $this->_view->getLayout()->createBlock( - 'Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid' + \Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid::class )->getExcelFile( $fileName ); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php index b02b7d01dde22..9ab49da51aa67 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php @@ -21,7 +21,7 @@ public function execute() __('Products Report'), __('Products Report') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Product') + $this->_view->getLayout()->createBlock(\Magento\Reports\Block\Adminhtml\Shopcart\Product::class) ); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Products in Carts')); $this->_view->renderLayout(); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php index d5498d73e08ee..e096abef9156f 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php @@ -104,7 +104,7 @@ protected function _getCollectionNames() protected function _getSession() { if ($this->_adminSession === null) { - $this->_adminSession = $this->_objectManager->get('Magento\Backend\Model\Auth\Session'); + $this->_adminSession = $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class); } return $this->_adminSession; } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshLifetime.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshLifetime.php index f4bacdf945320..a6c9b2d512d40 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshLifetime.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshLifetime.php @@ -26,7 +26,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t refresh lifetime statistics.')); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } if ($this->_getSession()->isFirstPageAfterLogin()) { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php index 935c6751a3ca8..1a57e433d8572 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php @@ -19,7 +19,9 @@ public function execute() try { $collectionsNames = $this->_getCollectionNames(); /** @var \DateTime $currentDate */ - $currentDate = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface')->date(); + $currentDate = $this->_objectManager->get( + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class + )->date(); $date = $currentDate->modify('-25 hours'); foreach ($collectionsNames as $collectionName) { $this->_objectManager->create($collectionName)->aggregate($date); @@ -29,7 +31,7 @@ public function execute() $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t refresh recent statistics.')); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); } if ($this->_getSession()->isFirstPageAfterLogin()) { diff --git a/app/code/Magento/Reports/Model/Event.php b/app/code/Magento/Reports/Model/Event.php index 9e75595f79bd2..8c7f52fd88fff 100644 --- a/app/code/Magento/Reports/Model/Event.php +++ b/app/code/Magento/Reports/Model/Event.php @@ -79,7 +79,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Reports\Model\ResourceModel\Event'); + $this->_init(\Magento\Reports\Model\ResourceModel\Event::class); } /** diff --git a/app/code/Magento/Reports/Model/Event/Type.php b/app/code/Magento/Reports/Model/Event/Type.php index d0bcd0f0bc588..7d12bab105fee 100644 --- a/app/code/Magento/Reports/Model/Event/Type.php +++ b/app/code/Magento/Reports/Model/Event/Type.php @@ -24,6 +24,6 @@ class Type extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\Reports\Model\ResourceModel\Event\Type'); + $this->_init(\Magento\Reports\Model\ResourceModel\Event\Type::class); } } diff --git a/app/code/Magento/Reports/Model/Product/Index/Compared.php b/app/code/Magento/Reports/Model/Product/Index/Compared.php index 7c3b3b22ad2ad..e4a7f4a59ad63 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Compared.php +++ b/app/code/Magento/Reports/Model/Product/Index/Compared.php @@ -88,7 +88,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Reports\Model\ResourceModel\Product\Index\Compared'); + $this->_init(\Magento\Reports\Model\ResourceModel\Product\Index\Compared::class); } /** diff --git a/app/code/Magento/Reports/Model/Product/Index/Factory.php b/app/code/Magento/Reports/Model/Product/Index/Factory.php index ff9efbf9b58de..1dfeb8b0659d6 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Factory.php +++ b/app/code/Magento/Reports/Model/Product/Index/Factory.php @@ -15,8 +15,8 @@ class Factory * @var array */ protected $_typeClasses = [ - self::TYPE_COMPARED => 'Magento\Reports\Model\Product\Index\Compared', - self::TYPE_VIEWED => 'Magento\Reports\Model\Product\Index\Viewed', + self::TYPE_COMPARED => \Magento\Reports\Model\Product\Index\Compared::class, + self::TYPE_VIEWED => \Magento\Reports\Model\Product\Index\Viewed::class, ]; /** diff --git a/app/code/Magento/Reports/Model/Product/Index/Viewed.php b/app/code/Magento/Reports/Model/Product/Index/Viewed.php index e4e421edb6097..8c1ffeb4e489a 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Viewed.php +++ b/app/code/Magento/Reports/Model/Product/Index/Viewed.php @@ -36,7 +36,7 @@ class Viewed extends \Magento\Reports\Model\Product\Index\AbstractIndex */ protected function _construct() { - $this->_init('Magento\Reports\Model\ResourceModel\Product\Index\Viewed'); + $this->_init(\Magento\Reports\Model\ResourceModel\Product\Index\Viewed::class); } /** diff --git a/app/code/Magento/Reports/Model/ResourceModel/Accounts/Collection/Initial.php b/app/code/Magento/Reports/Model/ResourceModel/Accounts/Collection/Initial.php index 6818555da8c91..68d67c964c93e 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Accounts/Collection/Initial.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Accounts/Collection/Initial.php @@ -17,5 +17,5 @@ class Initial extends \Magento\Reports\Model\ResourceModel\Report\Collection * Report sub-collection class name * @var string */ - protected $_reportCollection = 'Magento\Reports\Model\ResourceModel\Accounts\Collection'; + protected $_reportCollection = \Magento\Reports\Model\ResourceModel\Accounts\Collection::class; } diff --git a/app/code/Magento/Reports/Model/ResourceModel/Customer/Orders/Collection/Initial.php b/app/code/Magento/Reports/Model/ResourceModel/Customer/Orders/Collection/Initial.php index f4917929756bf..ec7fef4f7d414 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Customer/Orders/Collection/Initial.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Customer/Orders/Collection/Initial.php @@ -17,5 +17,5 @@ class Initial extends \Magento\Reports\Model\ResourceModel\Report\Collection * Report sub-collection class name * @var string */ - protected $_reportCollection = 'Magento\Reports\Model\ResourceModel\Customer\Orders\Collection'; + protected $_reportCollection = \Magento\Reports\Model\ResourceModel\Customer\Orders\Collection::class; } diff --git a/app/code/Magento/Reports/Model/ResourceModel/Customer/Totals/Collection/Initial.php b/app/code/Magento/Reports/Model/ResourceModel/Customer/Totals/Collection/Initial.php index d9defdb07a701..c76dfcfa1d884 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Customer/Totals/Collection/Initial.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Customer/Totals/Collection/Initial.php @@ -18,5 +18,5 @@ class Initial extends \Magento\Reports\Model\ResourceModel\Report\Collection * * @var string */ - protected $_reportCollection = 'Magento\Reports\Model\ResourceModel\Customer\Totals\Collection'; + protected $_reportCollection = \Magento\Reports\Model\ResourceModel\Customer\Totals\Collection::class; } diff --git a/app/code/Magento/Reports/Model/ResourceModel/Event/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Event/Collection.php index 3405a309fbde9..0a45adfbfdfc2 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Event/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Event/Collection.php @@ -27,7 +27,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Reports\Model\Event', 'Magento\Reports\Model\ResourceModel\Event'); + $this->_init(\Magento\Reports\Model\Event::class, \Magento\Reports\Model\ResourceModel\Event::class); } /** diff --git a/app/code/Magento/Reports/Model/ResourceModel/Event/Type/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Event/Type/Collection.php index bcd25991989d1..8e082bb36cc67 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Event/Type/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Event/Type/Collection.php @@ -20,7 +20,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magento\Reports\Model\Event\Type', 'Magento\Reports\Model\ResourceModel\Event\Type'); + $this->_init(\Magento\Reports\Model\Event\Type::class, \Magento\Reports\Model\ResourceModel\Event\Type::class); } /** diff --git a/app/code/Magento/Reports/Model/ResourceModel/Product/Sold/Collection/Initial.php b/app/code/Magento/Reports/Model/ResourceModel/Product/Sold/Collection/Initial.php index e92879a04d933..00c55b2161d4f 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Product/Sold/Collection/Initial.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Product/Sold/Collection/Initial.php @@ -18,5 +18,5 @@ class Initial extends \Magento\Reports\Model\ResourceModel\Report\Collection * * @var string */ - protected $_reportCollection = 'Magento\Reports\Model\ResourceModel\Product\Sold\Collection'; + protected $_reportCollection = \Magento\Reports\Model\ResourceModel\Product\Sold\Collection::class; } diff --git a/app/code/Magento/Reports/Model/ResourceModel/Quote/CollectionFactory.php b/app/code/Magento/Reports/Model/ResourceModel/Quote/CollectionFactory.php index e8579bbe5137c..e791412f4f4f2 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Quote/CollectionFactory.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Quote/CollectionFactory.php @@ -34,7 +34,7 @@ class CollectionFactory implements \Magento\Reports\Model\ResourceModel\Quote\Co */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, - $instanceName = 'Magento\Reports\Model\ResourceModel\\Quote\\Collection' + $instanceName = \Magento\Reports\Model\ResourceModel\Quote\Collection::class ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; diff --git a/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php index 871d51eea9e23..caad6a8b606d2 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php @@ -86,10 +86,9 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Quote\Model\Quote\Item', 'Magento\Quote\Model\ResourceModel\Quote\Item'); + $this->_init(\Magento\Quote\Model\Quote\Item::class, \Magento\Quote\Model\ResourceModel\Quote\Item::class); } - /** * Prepare select query for products in carts report * diff --git a/app/code/Magento/Reports/Model/ResourceModel/Review/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Review/Collection.php index 987be0c185023..c97699bcc79e7 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Review/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Review/Collection.php @@ -20,7 +20,7 @@ class Collection extends \Magento\Review\Model\ResourceModel\Review\Collection */ protected function _construct() { - $this->_init('Magento\Review\Model\Review', 'Magento\Review\Model\ResourceModel\Review'); + $this->_init(\Magento\Review\Model\Review::class, \Magento\Review\Model\ResourceModel\Review::class); } /** diff --git a/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Collection.php index ae33f09019518..b566687ef993e 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Collection.php @@ -54,7 +54,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Wishlist\Model\Wishlist', 'Magento\Wishlist\Model\ResourceModel\Wishlist'); + $this->_init(\Magento\Wishlist\Model\Wishlist::class, \Magento\Wishlist\Model\ResourceModel\Wishlist::class); $this->setWishlistTable($this->getTable('wishlist')); } diff --git a/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Product/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Product/Collection.php index cbd7858584c84..b2c0a99a6afe0 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Product/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Wishlist/Product/Collection.php @@ -20,7 +20,7 @@ class Collection extends \Magento\Wishlist\Model\ResourceModel\Item\Collection */ public function _construct() { - $this->_init('Magento\Wishlist\Model\Wishlist', 'Magento\Wishlist\Model\ResourceModel\Wishlist'); + $this->_init(\Magento\Wishlist\Model\Wishlist::class, \Magento\Wishlist\Model\ResourceModel\Wishlist::class); } /** diff --git a/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Sales/Grid/Column/Renderer/DateTest.php b/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Sales/Grid/Column/Renderer/DateTest.php index a3603e506b9dd..a74cac42812e6 100644 --- a/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Sales/Grid/Column/Renderer/DateTest.php +++ b/app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Sales/Grid/Column/Renderer/DateTest.php @@ -63,7 +63,7 @@ function ($value) use ($locale) { */ private function mockGridDateColumnConfig($objectDataIndex, $periodType) { - $columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + $columnMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class) ->disableOriginalConstructor() ->setMethods(['getIndex', 'getPeriodType']) ->getMock(); @@ -78,7 +78,7 @@ private function mockGridDateColumnConfig($objectDataIndex, $periodType) */ protected function setUp() { - $this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->localeDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMock(); $this->localeDate @@ -86,7 +86,7 @@ protected function setUp() ->method('date') ->willReturnArgument(0); - $this->contextMock = $this->getMockBuilder('Magento\Backend\Block\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\Block\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock @@ -94,17 +94,20 @@ protected function setUp() ->method('getLocaleDate') ->willReturn($this->localeDate); - $this->resolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + $this->resolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); - $this->dateTimeFormatter = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface'); + $this->dateTimeFormatter = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->date = $objectManager->getObject('Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', [ - 'context' => $this->contextMock, - 'localeResolver' => $this->resolverMock, - 'dateTimeFormatter' => $this->dateTimeFormatter, - ]); + $this->date = $objectManager->getObject( + \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, + [ + 'context' => $this->contextMock, + 'localeResolver' => $this->resolverMock, + 'dateTimeFormatter' => $this->dateTimeFormatter, + ] + ); $this->globalStateLocaleBackup = \Locale::getDefault(); } @@ -134,7 +137,7 @@ public function testRender($data, $locale, $index, $period, $result) $this->mockGridDateRendererBehaviorWithLocale($locale); $this->mockGridDateColumnConfig($index, $period); - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods(['getData']) ->getMock(); $objectMock->expects($this->once())->method('getData')->willReturn($data); @@ -199,7 +202,7 @@ public function testDateIsRenderedIndependentOfSystemDefaultLocale() $this->mockGridDateRendererBehaviorWithLocale($locale); $this->mockGridDateColumnConfig('period', 'day'); - $objectMock = $this->getMockBuilder('Magento\Framework\DataObject') + $objectMock = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods(['getData']) ->getMock(); $objectMock->expects($this->any())->method('getData')->willReturn('2014-06-25'); diff --git a/app/code/Magento/Reports/Test/Unit/Block/Product/ViewedTest.php b/app/code/Magento/Reports/Test/Unit/Block/Product/ViewedTest.php index f729a67da9539..2f95cf4b3c259 100644 --- a/app/code/Magento/Reports/Test/Unit/Block/Product/ViewedTest.php +++ b/app/code/Magento/Reports/Test/Unit/Block/Product/ViewedTest.php @@ -15,7 +15,7 @@ class ViewedTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $objectManager->getObject('Magento\Reports\Block\Product\Viewed'); + $this->block = $objectManager->getObject(\Magento\Reports\Block\Product\Viewed::class); } protected function tearDown() @@ -27,10 +27,10 @@ public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); - $collection = new \ReflectionProperty('Magento\Reports\Block\Product\Viewed', '_collection'); + $collection = new \ReflectionProperty(\Magento\Reports\Block\Product\Viewed::class, '_collection'); $collection->setAccessible(true); $collection->setValue($this->block, [$product]); diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/AbstractControllerTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/AbstractControllerTest.php index a4c5135d6f8bb..20b3cb6c57211 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/AbstractControllerTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/AbstractControllerTest.php @@ -67,37 +67,37 @@ abstract class AbstractControllerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->requestMock = $this->getMockForAbstractClassBuilder( - 'Magento\Framework\App\RequestInterface', + \Magento\Framework\App\RequestInterface::class, ['isDispatched', 'initForward', 'setDispatched', 'isForwarded'] ); $this->breadcrumbsBlockMock = $this->getMockForAbstractClassBuilder( - 'Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, ['addLink'] ); $this->menuBlockMock = $this->getMockForAbstractClassBuilder( - 'Magento\Framework\View\Element\BlockInterface', + \Magento\Framework\View\Element\BlockInterface::class, ['setActive', 'getMenuModel'] ); $this->viewMock = $this->getMockForAbstractClassBuilder( - 'Magento\Framework\App\ViewInterface' + \Magento\Framework\App\ViewInterface::class ); - $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $this->layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->switcherBlockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + $this->switcherBlockMock = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + $this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->menuModelMock = $this->getMockBuilder('Magento\Backend\Model\Menu') + $this->menuModelMock = $this->getMockBuilder(\Magento\Backend\Model\Menu::class) ->disableOriginalConstructor() ->getMock(); - $this->abstractBlockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') + $this->abstractBlockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) ->setMethods(['getCsvFile', 'getExcelFile', 'setSaveParametersInSession', 'getCsv', 'getExcel']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/AccountsTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/AccountsTest.php index acfedafb81a93..027890da8a15f 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/AccountsTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/AccountsTest.php @@ -35,7 +35,7 @@ protected function setUp() */ public function testExecute() { - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $titleMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/OrdersTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/OrdersTest.php index 791ac8cada605..0e31a2aee37c9 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/OrdersTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/OrdersTest.php @@ -35,7 +35,7 @@ protected function setUp() */ public function testExecute() { - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $titleMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/TotalsTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/TotalsTest.php index 29e2dadb610e8..d7091d4c42258 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/TotalsTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Customer/TotalsTest.php @@ -35,7 +35,7 @@ protected function setUp() */ public function testExecute() { - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); $titleMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/DownloadsTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/DownloadsTest.php index a1090e882446b..53b5cff617ffd 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/DownloadsTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/DownloadsTest.php @@ -29,16 +29,19 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->downloads = $objectManager->getObject('Magento\Reports\Controller\Adminhtml\Report\Product\Downloads', [ - 'context' => $this->contextMock, - 'fileFactory' => $this->fileFactoryMock, - 'dateFilter' => $this->dateMock, - ]); + $this->downloads = $objectManager->getObject( + \Magento\Reports\Controller\Adminhtml\Report\Product\Downloads::class, + [ + 'context' => $this->contextMock, + 'fileFactory' => $this->fileFactoryMock, + 'dateFilter' => $this->dateMock, + ] + ); } /** @@ -46,7 +49,7 @@ protected function setUp() */ public function testExecute() { - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); @@ -83,7 +86,7 @@ public function testExecute() $this->layoutMock ->expects($this->once()) ->method('createBlock') - ->with('Magento\Reports\Block\Adminhtml\Product\Downloads') + ->with(\Magento\Reports\Block\Adminhtml\Product\Downloads::class) ->willReturn($this->abstractBlockMock); $this->downloads->execute(); diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsCsvTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsCsvTest.php index a924bbc1435cd..c6c3608aa0d32 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsCsvTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsCsvTest.php @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportDownloadsCsv = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportDownloadsCsv', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportDownloadsCsv::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -62,7 +62,7 @@ public function testExecute() $this->layoutMock ->expects($this->once()) ->method('createBlock') - ->with('Magento\Reports\Block\Adminhtml\Product\Downloads\Grid') + ->with(\Magento\Reports\Block\Adminhtml\Product\Downloads\Grid::class) ->willReturn($this->abstractBlockMock); $this->fileFactoryMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsExcelTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsExcelTest.php index dc25ab285f107..62809603e0d2c 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsExcelTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportDownloadsExcelTest.php @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportDownloadsExcel = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportDownloadsExcel', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportDownloadsExcel::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -64,7 +64,7 @@ public function testExecute() $this->layoutMock ->expects($this->once()) ->method('createBlock') - ->with('Magento\Reports\Block\Adminhtml\Product\Downloads\Grid') + ->with(\Magento\Reports\Block\Adminhtml\Product\Downloads\Grid::class) ->willReturn($this->abstractBlockMock); $this->fileFactoryMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockCsvTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockCsvTest.php index 937ffb8fe9fee..5e520d2de9c05 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockCsvTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockCsvTest.php @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportLowstockCsv = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportLowstockCsv', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportLowstockCsv::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockExcelTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockExcelTest.php index 40be824ff1a48..1b83fa9ff662e 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockExcelTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportLowstockExcelTest.php @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportLowstockExcel = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportLowstockExcel', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportLowstockExcel::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldCsvTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldCsvTest.php index 75121c6268a98..f2101baaeeaa0 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldCsvTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldCsvTest.php @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportSoldCsv = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportSoldCsv', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportSoldCsv::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldExcelTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldExcelTest.php index fb3b3b03eb68a..60e0c889ce1a9 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldExcelTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportSoldExcelTest.php @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportSoldExcel = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportSoldExcel', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportSoldExcel::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedCsvTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedCsvTest.php index e5fd8ee2221b6..c71834da60575 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedCsvTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedCsvTest.php @@ -37,15 +37,15 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock @@ -57,7 +57,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportViewedCsv = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportViewedCsv', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportViewedCsv::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -82,7 +82,7 @@ public function testExecute() $this->layoutMock ->expects($this->once()) ->method('createBlock') - ->with('Magento\Reports\Block\Adminhtml\Product\Viewed\Grid') + ->with(\Magento\Reports\Block\Adminhtml\Product\Viewed\Grid::class) ->willReturn($this->abstractBlockMock); $this->fileFactoryMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedExcelTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedExcelTest.php index 5be6a987ef117..3d22dd4eeebd7 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedExcelTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ExportViewedExcelTest.php @@ -37,15 +37,15 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock @@ -57,7 +57,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->exportViewedExcel = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\ExportViewedExcel', + \Magento\Reports\Controller\Adminhtml\Report\Product\ExportViewedExcel::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -83,7 +83,7 @@ public function testExecute() $this->layoutMock ->expects($this->once()) ->method('createBlock') - ->with('Magento\Reports\Block\Adminhtml\Product\Viewed\Grid') + ->with(\Magento\Reports\Block\Adminhtml\Product\Viewed\Grid::class) ->willReturn($this->abstractBlockMock); $this->fileFactoryMock diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/LowstockTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/LowstockTest.php index a4ca359be97fa..96d95b6064c99 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/LowstockTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/LowstockTest.php @@ -29,13 +29,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->lowstock = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\Lowstock', + \Magento\Reports\Controller\Adminhtml\Report\Product\Lowstock::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -49,7 +49,7 @@ protected function setUp() */ public function testExecute() { - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/SoldTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/SoldTest.php index b27128b86c0a5..d6ec8e7f217d6 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/SoldTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/SoldTest.php @@ -29,13 +29,13 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->sold = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\Sold', + \Magento\Reports\Controller\Adminhtml\Report\Product\Sold::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -49,7 +49,7 @@ protected function setUp() */ public function testExecute() { - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ViewedTest.php b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ViewedTest.php index 5fcbc32146bbb..b6c3cf705a920 100644 --- a/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ViewedTest.php +++ b/app/code/Magento/Reports/Test/Unit/Controller/Adminhtml/Report/Product/ViewedTest.php @@ -10,6 +10,9 @@ use Magento\Framework\DataObject; use Magento\Framework\Phrase; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ViewedTest extends \Magento\Reports\Test\Unit\Controller\Adminhtml\Report\AbstractControllerTest { /** @@ -44,11 +47,11 @@ protected function setUp() { parent::setUp(); - $this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date') + $this->dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\Filter\Date::class) ->disableOriginalConstructor() ->getMock(); - $flagMock = $this->getMockBuilder('Magento\Reports\Model\Flag') + $flagMock = $this->getMockBuilder(\Magento\Reports\Model\Flag::class) ->disableOriginalConstructor() ->getMock(); $flagMock @@ -60,28 +63,28 @@ protected function setUp() ->method('loadSelf') ->willReturnSelf(); - $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + $this->helperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock ->expects($this->any()) ->method('create') - ->with('Magento\Reports\Model\Flag') + ->with(\Magento\Reports\Model\Flag::class) ->willReturn($flagMock); - $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $flagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + $flagMock = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) ->disableOriginalConstructor() ->getMock(); - $responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface') + $responseMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods(['setRedirect', 'sendResponse']) ->getMock(); @@ -94,7 +97,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->viewed = $objectManager->getObject( - 'Magento\Reports\Controller\Adminhtml\Report\Product\Viewed', + \Magento\Reports\Controller\Adminhtml\Report\Product\Viewed::class, [ 'context' => $this->contextMock, 'fileFactory' => $this->fileFactoryMock, @@ -113,7 +116,7 @@ public function testExecute() ->method('get') ->willReturn($this->helperMock); - $titleMock = $this->getMockBuilder('Magento\Framework\View\Page\Title') + $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class) ->disableOriginalConstructor() ->getMock(); @@ -164,11 +167,11 @@ public function testExecuteWithException() 'Please review the log and try again.' ); - $logMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $logMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); - $sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + $sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->setMethods(['setIsUrlNotice']) ->disableOriginalConstructor() ->getMock(); @@ -179,8 +182,8 @@ public function testExecuteWithException() ->will( $this->returnValueMap( [ - ['Psr\Log\LoggerInterface', $logMock], - ['Magento\Backend\Model\Auth\Session', $sessionMock] + [\Psr\Log\LoggerInterface::class, $logMock], + [\Magento\Backend\Model\Auth\Session::class, $sessionMock] ] ) ); diff --git a/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php b/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php index bb4ba304a2287..c76c071f7926d 100644 --- a/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php @@ -30,10 +30,10 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->itemFactoryMock = $this->getMockBuilder('Magento\Reports\Model\ItemFactory') + $this->itemFactoryMock = $this->getMockBuilder(\Magento\Reports\Model\ItemFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); @@ -67,12 +67,12 @@ public function testGetIntervals($from, $to, $period, $results) */ public function testPrepareIntervalsCollection($from, $to, $period, $results) { - $collection = $this->getMockBuilder('Magento\Framework\Data\Collection') + $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->setMethods(['addItem']) ->getMock(); - $item = $this->getMockBuilder('Magento\Reports\Model\Item') + $item = $this->getMockBuilder(\Magento\Reports\Model\Item::class) ->disableOriginalConstructor() ->setMethods(['setPeriod', 'setIsEmpty']) ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php b/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php index 011e00413c65e..5fa44ef2aeff6 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php @@ -45,20 +45,20 @@ class LogTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $this->eventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor() ->getMock(); - $this->comparedMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + $this->comparedMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Compared::class) ->disableOriginalConstructor() ->getMock(); - $this->viewedMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Viewed') + $this->viewedMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Viewed::class) ->disableOriginalConstructor() ->getMock(); - $this->logResourceMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Visitor') + $this->logResourceMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Visitor::class) ->disableOriginalConstructor() ->getMock(); - $this->subjectMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Visitor') + $this->subjectMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Visitor::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php b/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php index 7e72a2c38b778..bf308ce1bc2fd 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php @@ -8,6 +8,9 @@ use Magento\Reports\Model\Product\Index\Compared; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ComparedTest extends \PHPUnit_Framework_TestCase { /** @@ -69,41 +72,42 @@ class ComparedTest extends \PHPUnit_Framework_TestCase * @var \Magento\Framework\Data\Collection\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $dbMock; + /** * {@inheritDoc} */ protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class) ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->visitorMock = $this->getMockBuilder('Magento\Customer\Model\Visitor') + $this->visitorMock = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->genericMock = $this->getMockBuilder('Magento\Framework\Session\Generic') + $this->genericMock = $this->getMockBuilder(\Magento\Framework\Session\Generic::class) ->disableOriginalConstructor() ->getMock(); - $this->visibilityMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Visibility') + $this->visibilityMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Visibility::class) ->disableOriginalConstructor() ->getMock(); - $this->dateTimeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime') + $this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class) ->getMock(); - $this->catalogProductHelperMock = $this->getMockBuilder('Magento\Catalog\Helper\Product\Compare') + $this->catalogProductHelperMock = $this->getMockBuilder(\Magento\Catalog\Helper\Product\Compare::class) ->disableOriginalConstructor() ->getMock(); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->disableOriginalConstructor() ->setMethods(['getIdFieldName', '_construct', 'getConnection']) ->getMockForAbstractClass(); - $this->dbMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $this->dbMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMock(); @@ -127,13 +131,13 @@ protected function setUp() */ public function testGetExcludeProductIds() { - $collection = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection') + $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection::class) ->disableOriginalConstructor() ->setMethods(['getEntityId']) ->getMock(); $collection->expects($this->once())->method('getEntityId')->willReturn(1); - $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['getId']) ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Event/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Event/CollectionTest.php index ea5ea219fccf8..80dadc5e398a8 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Event/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Event/CollectionTest.php @@ -55,16 +55,18 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactoryInterface') + $this->entityFactoryMock = $this->getMockBuilder( + \Magento\Framework\Data\Collection\EntityFactoryInterface::class + )->getMock(); + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') - ->getMock(); - $this->fetchStrategyMock = $this->getMockBuilder('Magento\Framework\Data\Collection\Db\FetchStrategyInterface') - ->getMock(); - $this->managerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->fetchStrategyMock = $this->getMockBuilder( + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class + )->getMock(); + $this->managerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->getMock(); - $this->selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods(['where', 'from']) ->disableOriginalConstructor() ->getMock(); @@ -75,14 +77,14 @@ protected function setUp() ->method('where') ->willReturnSelf(); - $this->dbMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $this->dbMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); $this->dbMock->expects($this->any()) ->method('select') ->willReturn($this->selectMock); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['getConnection', 'getCurrentStoreIds', '_construct', 'getMainTable', 'getTable']) ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/EventTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/EventTest.php index 49f8052b30f3c..5508d94d3d10b 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/EventTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/EventTest.php @@ -50,17 +50,17 @@ class EventTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); @@ -69,10 +69,10 @@ protected function setUp() ->method('getStore') ->willReturn($this->storeMock); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->getMock(); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $this->resourceMock @@ -97,7 +97,7 @@ protected function setUp() */ public function testUpdateCustomerTypeWithoutType() { - $eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $eventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor() ->getMock(); $this->connectionMock @@ -113,7 +113,7 @@ public function testUpdateCustomerTypeWithoutType() */ public function testUpdateCustomerTypeWithType() { - $eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $eventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor() ->getMock(); $this->connectionMock @@ -132,7 +132,7 @@ public function testApplyLogToCollection() $derivedSelect = 'SELECT * FROM table'; $idFieldName = 'IdFieldName'; - $collectionSelectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $collectionSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->setMethods(['joinInner', 'order']) ->getMock(); @@ -150,7 +150,7 @@ public function testApplyLogToCollection() ->method('order') ->willReturnSelf(); - $collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + $collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMock(); $collectionMock @@ -166,7 +166,7 @@ public function testApplyLogToCollection() ->method('getSelect') ->willReturn($collectionSelectMock); - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->setMethods(['from', 'where', 'group', 'joinInner', '__toString']) ->getMock(); @@ -205,11 +205,11 @@ public function testApplyLogToCollection() */ public function testClean() { - $eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $eventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor() ->getMock(); - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->setMethods(['select', 'from', 'joinLeft', 'where', 'limit', 'fetchCol']) ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/HelperTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/HelperTest.php index 0f7b68add150c..8911975d1e1f6 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/HelperTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/HelperTest.php @@ -30,11 +30,11 @@ class HelperTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->getMock(); $this->resourceMock @@ -76,7 +76,7 @@ public function testUpdateReportRatingPos($type, $result) $column = 'column'; $aggregationTable = 'aggregationTable'; - $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $selectMock diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php index d3a309daf2681..692ccaf42f1f7 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php @@ -93,36 +93,37 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactory') + $this->entityFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\EntityFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMock(); - $this->fetchStrategyMock = $this->getMockBuilder('Magento\Framework\Data\Collection\Db\FetchStrategyInterface') + $this->fetchStrategyMock = $this->getMockBuilder( + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class + )->getMock(); + $this->managerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->getMock(); - $this->managerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') - ->getMock(); - $snapshotClassName = 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot'; + $snapshotClassName = \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class; $this->entitySnapshotMock = $this->getMockBuilder($snapshotClassName) ->disableOriginalConstructor() ->getMock(); - $this->helperMock = $this->getMockBuilder('Magento\Framework\DB\Helper') + $this->helperMock = $this->getMockBuilder(\Magento\Framework\DB\Helper::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->getMock(); - $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); - $this->configMock = $this->getMockBuilder('Magento\Sales\Model\Order\Config') + $this->configMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\OrderFactory') + $this->orderFactoryMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\OrderFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $this->selectMock @@ -146,7 +147,7 @@ protected function setUp() ->method('getPart') ->willReturn([]); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->setMethods(['select', 'getIfNullSql', 'getDateFormatSql', 'prepareSqlCondition', 'getCheckSql']) ->disableOriginalConstructor() ->getMock(); @@ -155,7 +156,7 @@ protected function setUp() ->method('select') ->willReturn($this->selectMock); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->getMock(); $this->resourceMock @@ -220,7 +221,7 @@ public function testPrepareSummary($useAggregatedData, $mainTable, $isFilter, $g ) ->willReturn($useAggregatedData); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\Order') + $orderMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Report\Order::class) ->disableOriginalConstructor() ->getMock(); @@ -354,7 +355,7 @@ public function testCalculateSales($isFilter, $useAggregatedData, $mainTable) ) ->willReturn($useAggregatedData); - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Quote/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Quote/CollectionTest.php index fa4f67f09f2d5..d1757d53ed55b 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Quote/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Quote/CollectionTest.php @@ -49,7 +49,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); $this->selectMock->expects($this->any()) @@ -57,13 +57,13 @@ protected function setUp() ->withAnyParameters() ->willReturnSelf(); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\Pdo\Mysql') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) ->disableOriginalConstructor() ->getMock(); $this->connectionMock->expects($this->any()) ->method('select') ->willReturn($this->selectMock); - $this->resourceMock = $this->getMockBuilder('Magento\Quote\Model\ResourceModel\Quote') + $this->resourceMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote::class) ->disableOriginalConstructor() ->getMock(); $this->resourceMock->expects($this->any()) @@ -75,18 +75,18 @@ protected function setUp() $this->resourceMock->expects($this->any()) ->method('getTable') ->willReturn('test_table'); - $this->customerResourceMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer') + $this->customerResourceMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer::class) ->disableOriginalConstructor() ->getMock(); - $this->fetchStrategyMock = $this->getMockBuilder('Magento\Framework\Data\Collection\Db\FetchStrategy\Query') - ->disableOriginalConstructor() - ->getMock(); + $this->fetchStrategyMock = $this->getMockBuilder( + \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class + )->disableOriginalConstructor()->getMock(); - $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactory') + $this->entityFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\EntityFactory::class) ->disableOriginalConstructor() ->getMock(); - $snapshotClassName = 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot'; + $snapshotClassName = \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class; $this->entitySnapshotMock = $this->getMockBuilder($snapshotClassName) ->disableOriginalConstructor() ->setMethods(['registerSnapshot']) @@ -94,7 +94,7 @@ protected function setUp() $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $helper->getObject( - 'Magento\Reports\Model\ResourceModel\Quote\Collection', + \Magento\Reports\Model\ResourceModel\Quote\Collection::class, [ 'customerResource' => $this->customerResourceMock, 'resource' => $this->resourceMock, @@ -154,7 +154,7 @@ public function testResolveCustomerNames() ->withAnyParameters() ->willReturn($customerId); - $itemMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + $itemMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Collection/AbstractCollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Collection/AbstractCollectionTest.php index 8ccd519be86b5..fdacb261794b1 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Collection/AbstractCollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Collection/AbstractCollectionTest.php @@ -17,13 +17,19 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $entityFactory = $this->getMock('\Magento\Framework\Data\Collection\EntityFactory', [], [], '', false); - $logger = $this->getMock('\Psr\Log\LoggerInterface', [], [], '', false); - $fetchStrategy = $this->getMock('\Magento\Framework\Data\Collection\Db\FetchStrategy\Query', [], [], '', false); - $eventManager = $this->getMock('\Magento\Framework\Event\Manager', [], [], '', false); - $connection = $this->getMock('\Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); + $logger = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); + $fetchStrategy = $this->getMock( + \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class, + [], + [], + '', + false + ); + $eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); + $connection = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); - $resource = $this->getMockBuilder('\Magento\Framework\Model\ResourceModel\Db\AbstractDb') + $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() ->setMethods(['getConnection']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/CollectionTest.php index aa2121e745e69..069bb5e5edf33 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/CollectionTest.php @@ -35,13 +35,14 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactory') + $this->entityFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\EntityFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); - $this->factoryMock = $this->getMockBuilder('Magento\Reports\Model\ResourceModel\Report\Collection\Factory') - ->disableOriginalConstructor() + $this->factoryMock = $this->getMockBuilder( + \Magento\Reports\Model\ResourceModel\Report\Collection\Factory::class + )->disableOriginalConstructor() ->getMock(); $this->timezoneMock @@ -116,7 +117,7 @@ public function testGetReports($period, $fromDate, $toDate, $size) $this->collection->setInterval($fromDate, $toDate); $reports = $this->collection->getReports(); foreach ($reports as $report) { - $this->assertInstanceOf('\Magento\Framework\DataObject', $report); + $this->assertInstanceOf(\Magento\Framework\DataObject::class, $report); $reportData = $report->getData(); $this->assertTrue(empty($reportData['children'])); $this->assertTrue($reportData['is_empty']); @@ -130,7 +131,7 @@ public function testGetReports($period, $fromDate, $toDate, $size) public function testLoadData() { $this->assertInstanceOf( - '\Magento\Reports\Model\ResourceModel\Report\Collection', + \Magento\Reports\Model\ResourceModel\Report\Collection::class, $this->collection->loadData() ); } diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php index 3712db3157ae5..c431472ca04a7 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php @@ -91,10 +91,10 @@ class ViewedTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->zendDbMock = $this->getMockBuilder('Zend_Db_Statement_Interface')->getMock(); + $this->zendDbMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock(); $this->zendDbMock->expects($this->any())->method('fetchColumn')->willReturn([]); - $this->selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->setMethods( [ @@ -118,11 +118,11 @@ protected function setUp() $this->selectMock->expects($this->any())->method('insertFromSelect')->willReturnSelf(); $this->selectMock->expects($this->any())->method('__toString')->willReturn('string'); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface')->getMock(); + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock(); $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock); $this->connectionMock->expects($this->any())->method('query')->willReturn($this->zendDbMock); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); @@ -134,47 +134,49 @@ function ($arg) { ) ); - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\Context::class) ->disableOriginalConstructor() ->getMock(); $this->contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock); - $dateTime = $this->getMockBuilder('DateTime')->getMock(); + $dateTime = $this->getMockBuilder(\DateTime::class)->getMock(); - $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')->getMock(); + $this->timezoneMock = $this->getMockBuilder( + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class + )->getMock(); $this->timezoneMock->expects($this->any())->method('scopeDate')->willReturn($dateTime); - $this->flagMock = $this->getMockBuilder('Magento\Reports\Model\Flag') + $this->flagMock = $this->getMockBuilder(\Magento\Reports\Model\Flag::class) ->disableOriginalConstructor() ->setMethods(['setReportFlagCode', 'unsetData', 'loadSelf', 'setFlagData', 'setLastUpdate', 'save']) ->getMock(); - $this->flagFactoryMock = $this->getMockBuilder('Magento\Reports\Model\FlagFactory') + $this->flagFactoryMock = $this->getMockBuilder(\Magento\Reports\Model\FlagFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->flagFactoryMock->expects($this->any())->method('create')->willReturn($this->flagMock); - $this->backendMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend') + $this->backendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class) ->disableOriginalConstructor() ->getMock(); - $this->attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $this->attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->getMock(); $this->attributeMock->expects($this->any())->method('getBackend')->willReturn($this->backendMock); - $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product') + $this->productMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product::class) ->disableOriginalConstructor() ->getMock(); $this->productMock->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock); - $this->helperMock = $this->getMockBuilder('Magento\Reports\Model\ResourceModel\Helper') + $this->helperMock = $this->getMockBuilder(\Magento\Reports\Model\ResourceModel\Helper::class) ->disableOriginalConstructor() ->getMock(); $this->viewed = (new ObjectManager($this))->getObject( - 'Magento\Reports\Model\ResourceModel\Report\Product\Viewed', + \Magento\Reports\Model\ResourceModel\Report\Product\Viewed::class, [ 'context' => $this->contextMock, 'localeDate' => $this->timezoneMock, diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Quote/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Quote/CollectionTest.php index 61787632c9599..7d208d6d4b675 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Quote/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Quote/CollectionTest.php @@ -9,6 +9,9 @@ use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use \Magento\Reports\Model\ResourceModel\Quote\Collection as Collection; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CollectionTest extends \PHPUnit_Framework_TestCase { /** @@ -24,16 +27,16 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); } public function testGetSelectCountSql() { /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ $constructArgs = $this->objectManager - ->getConstructArguments('Magento\Reports\Model\ResourceModel\Quote\Collection'); + ->getConstructArguments(\Magento\Reports\Model\ResourceModel\Quote\Collection::class); $collection = $this->getMock( - 'Magento\Reports\Model\ResourceModel\Quote\Collection', + \Magento\Reports\Model\ResourceModel\Quote\Collection::class, ['getSelect'], $constructArgs, '', @@ -53,9 +56,9 @@ public function testPrepareActiveCartItems() { /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ $constructArgs = $this->objectManager - ->getConstructArguments('Magento\Reports\Model\ResourceModel\Quote\Item\Collection'); + ->getConstructArguments(\Magento\Reports\Model\ResourceModel\Quote\Item\Collection::class); $collection = $this->getMock( - 'Magento\Reports\Model\ResourceModel\Quote\Item\Collection', + \Magento\Reports\Model\ResourceModel\Quote\Item\Collection::class, ['getSelect', 'getTable'], $constructArgs, '', @@ -77,28 +80,37 @@ public function testLoadWithFilter() { /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ $constructArgs = $this->objectManager - ->getConstructArguments('Magento\Reports\Model\ResourceModel\Quote\Item\Collection'); - $constructArgs['eventManager'] = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); - $resourceMock = $this->getMock('\Magento\Quote\Model\ResourceModel\Quote', [], [], '', false); - $resourceMock - ->expects($this->any()) - ->method('getConnection') - ->willReturn($this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false)); + ->getConstructArguments(\Magento\Reports\Model\ResourceModel\Quote\Item\Collection::class); + $constructArgs['eventManager'] = $this->getMock( + \Magento\Framework\Event\ManagerInterface::class, + [], + [], + '', + false + ); + $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); + $resourceMock = $this->getMock(\Magento\Quote\Model\ResourceModel\Quote::class, [], [], '', false); + $resourceMock->expects($this->any())->method('getConnection') + ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false)); $constructArgs['resource'] = $resourceMock; $productResourceMock = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Product\Collection', + \Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], [], '', false ); $constructArgs['productResource'] = $productResourceMock; - $orderResourceMock = $this->getMock('\Magento\Sales\Model\ResourceModel\Order\Collection', [], [], '', false); + $orderResourceMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Collection::class, + [], + [], + '', + false + ); $constructArgs['orderResource'] = $orderResourceMock; - $collection = $this->getMock( - 'Magento\Reports\Model\ResourceModel\Quote\Item\Collection', + \Magento\Reports\Model\ResourceModel\Quote\Item\Collection::class, [ '_beforeLoad', '_renderFilters', @@ -123,31 +135,27 @@ public function testLoadWithFilter() $collection->expects($this->once())->method('printLogQuery')->willReturnSelf(); $collection->expects($this->once())->method('getData')->willReturn(null); $collection->expects($this->once())->method('_setIsLoaded')->willReturnSelf(); - //productLoad() $productAttributeMock = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [], [], '', false ); $priceAttributeMock = $this->getMock( - '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', + \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [], [], '', false ); - $productResourceMock->expects($this->once()) - ->method('getConnection') - ->willReturn($connectionMock); - $productResourceMock->expects($this->any()) - ->method('getAttribute') + $productResourceMock->expects($this->once())->method('getConnection')->willReturn($connectionMock); + $productResourceMock->expects($this->any())->method('getAttribute') ->willReturnMap([['name', $productAttributeMock], ['price', $priceAttributeMock]]); $productResourceMock->expects($this->once())->method('getSelect')->willReturn($this->selectMock); $eavEntity = $this->getMock( - 'Magento\Eav\Model\Entity\AbstractEntity', + \Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', @@ -155,20 +163,16 @@ public function testLoadWithFilter() ); $eavEntity->expects($this->once())->method('getLinkField')->willReturn('entity_id'); $productResourceMock->expects($this->once())->method('getEntity')->willReturn($eavEntity); - $this->selectMock->expects($this->once())->method('reset')->willReturnSelf(); $this->selectMock->expects($this->once())->method('from')->willReturnSelf(); $this->selectMock->expects($this->once())->method('useStraightJoin')->willReturnSelf(); $this->selectMock->expects($this->exactly(2))->method('joinInner')->willReturnSelf(); $collection->expects($this->once())->method('getOrdersData')->willReturn([]); - $productAttributeMock->expects($this->once())->method('getBackend')->willReturnSelf(); $priceAttributeMock->expects($this->once())->method('getBackend')->willReturnSelf(); $connectionMock->expects($this->once())->method('fetchAssoc')->willReturn([1, 2, 3]); - //_afterLoad() $collection->expects($this->once())->method('getItems')->willReturn([]); - $collection->loadWithFilter(); } } diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php index 15519568452d1..d4c671b52a65c 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Reports\Test\Unit\Observer; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CatalogProductCompareAddProductObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -54,14 +57,14 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor()->getMock(); - $this->customerVisitorMock = $this->getMockBuilder('Magento\Customer\Model\Visitor') + $this->customerVisitorMock = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class) ->disableOriginalConstructor()->getMock(); - $reportEventFactory = $this->getMockBuilder('Magento\Reports\Model\EventFactory') + $reportEventFactory = $this->getMockBuilder(\Magento\Reports\Model\EventFactory::class) ->setMethods(['create'])->disableOriginalConstructor()->getMock(); - $this->reportEventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $this->reportEventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor()->getMock(); $reportEventFactory->expects($this->any()) @@ -69,19 +72,21 @@ protected function setUp() ->willReturn($this->reportEventMock); /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject $storeManager */ - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor()->getMock(); $storeManager->expects($this->any()) ->method('getStore') ->willReturn($this->storeMock); - $this->productCompModelMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + $this->productCompModelMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Compared::class) ->disableOriginalConstructor() ->getMock(); - $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') + $this->productCompFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ComparedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -89,13 +94,13 @@ protected function setUp() ->method('create') ->willReturn($this->productCompModelMock); - $this->eventSaverMock = $this->getMockBuilder('\Magento\Reports\Observer\EventSaver') + $this->eventSaverMock = $this->getMockBuilder(\Magento\Reports\Observer\EventSaver::class) ->disableOriginalConstructor() ->setMethods(['save']) ->getMock(); $this->observer = $objectManager->getObject( - 'Magento\Reports\Observer\CatalogProductCompareAddProductObserver', + \Magento\Reports\Observer\CatalogProductCompareAddProductObserver::class, [ 'productCompFactory' => $this->productCompFactoryMock, 'customerSession' => $this->customerSessionMock, @@ -162,13 +167,13 @@ public function catalogProductCompareAddProductDataProvider() */ protected function getObserverMock($productId) { - $eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); - $eventMock = $this->getMockBuilder('Magento\Framework\Event') + $eventMock = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() ->setMethods(['getProduct'])->getMock(); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php index 9af77378d3740..3a0ad161c9be0 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Reports\Test\Unit\Observer; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CatalogProductViewObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -64,24 +67,26 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor()->getMock(); - $this->customerVisitorMock = $this->getMockBuilder('Magento\Customer\Model\Visitor') + $this->customerVisitorMock = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class) ->disableOriginalConstructor()->getMock(); - $this->productIndexFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ViewedFactory') + $this->productIndexFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ViewedFactory::class + ) ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); - $this->productIndexMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Viewed') + $this->productIndexMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Viewed::class) ->disableOriginalConstructor()->getMock(); $this->productIndexFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->productIndexMock); - $reportEventFactory = $this->getMockBuilder('Magento\Reports\Model\EventFactory') + $reportEventFactory = $this->getMockBuilder(\Magento\Reports\Model\EventFactory::class) ->setMethods(['create'])->disableOriginalConstructor()->getMock(); - $this->reportEventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $this->reportEventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor()->getMock(); $reportEventFactory->expects($this->any()) @@ -89,19 +94,21 @@ protected function setUp() ->willReturn($this->reportEventMock); /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject $storeManager */ - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor()->getMock(); $storeManager->expects($this->any()) ->method('getStore') ->willReturn($this->storeMock); - $this->productCompModelMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + $this->productCompModelMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Compared::class) ->disableOriginalConstructor() ->getMock(); - $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') + $this->productCompFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ComparedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -109,18 +116,20 @@ protected function setUp() ->method('create') ->willReturn($this->productCompModelMock); - $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') + $this->productCompFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ComparedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->eventSaverMock = $this->getMockBuilder('\Magento\Reports\Observer\EventSaver') + $this->eventSaverMock = $this->getMockBuilder(\Magento\Reports\Observer\EventSaver::class) ->disableOriginalConstructor() ->setMethods(['save']) ->getMock(); $this->observer = $objectManager->getObject( - 'Magento\Reports\Observer\CatalogProductViewObserver', + \Magento\Reports\Observer\CatalogProductViewObserver::class, [ 'storeManager' => $storeManager, 'productIndxFactory' => $this->productIndexFactoryMock, @@ -239,13 +248,13 @@ protected function prepareReportEventModel($expectedEventData) */ protected function getObserverMock($productId) { - $eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); - $eventMock = $this->getMockBuilder('Magento\Framework\Event') + $eventMock = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() ->setMethods(['getProduct'])->getMock(); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php index de5031a368d51..4b8f57b4dc513 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Reports\Test\Unit\Observer; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CustomerLoginObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -54,35 +57,39 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor()->getMock(); - $this->customerVisitorMock = $this->getMockBuilder('Magento\Customer\Model\Visitor') + $this->customerVisitorMock = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class) ->disableOriginalConstructor()->getMock(); - $this->productIndexFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ViewedFactory') + $this->productIndexFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ViewedFactory::class + ) ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); - $this->productIndexMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Viewed') + $this->productIndexMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Viewed::class) ->disableOriginalConstructor()->getMock(); $this->productIndexFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->productIndexMock); - $reportEventFactory = $this->getMockBuilder('Magento\Reports\Model\EventFactory') + $reportEventFactory = $this->getMockBuilder(\Magento\Reports\Model\EventFactory::class) ->setMethods(['create'])->disableOriginalConstructor()->getMock(); - $this->reportEventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + $this->reportEventMock = $this->getMockBuilder(\Magento\Reports\Model\Event::class) ->disableOriginalConstructor()->getMock(); $reportEventFactory->expects($this->any()) ->method('create') ->willReturn($this->reportEventMock); - $this->productCompModelMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + $this->productCompModelMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Compared::class) ->disableOriginalConstructor() ->getMock(); - $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') + $this->productCompFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ComparedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -91,7 +98,7 @@ protected function setUp() ->willReturn($this->productCompModelMock); $this->observer = $objectManager->getObject( - 'Magento\Reports\Observer\CustomerLoginObserver', + \Magento\Reports\Observer\CustomerLoginObserver::class, [ 'event' => $reportEventFactory, 'productCompFactory' => $this->productCompFactoryMock, @@ -154,13 +161,13 @@ public function testCustomerLoginLoggedInFalse() */ protected function getObserverMock($productId) { - $eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); - $eventMock = $this->getMockBuilder('Magento\Framework\Event') + $eventMock = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() ->setMethods(['getProduct'])->getMock(); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php index 27d868f430902..ab59ff47b7466 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php @@ -39,21 +39,25 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->productIndexFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ViewedFactory') + $this->productIndexFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ViewedFactory::class + ) ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); - $this->productIndexMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Viewed') + $this->productIndexMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Viewed::class) ->disableOriginalConstructor()->getMock(); $this->productIndexFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->productIndexMock); - $this->productCompModelMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + $this->productCompModelMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Compared::class) ->disableOriginalConstructor() ->getMock(); - $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') + $this->productCompFactoryMock = $this->getMockBuilder( + \Magento\Reports\Model\Product\Index\ComparedFactory::class + ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -62,7 +66,7 @@ protected function setUp() ->willReturn($this->productCompModelMock); $this->observer = $objectManager->getObject( - 'Magento\Reports\Observer\CustomerLogoutObserver', + \Magento\Reports\Observer\CustomerLogoutObserver::class, [ 'productIndxFactory' => $this->productIndexFactoryMock, 'productCompFactory' => $this->productCompFactoryMock, @@ -92,13 +96,13 @@ public function testCustomerLogout() */ protected function getObserverMock($productId) { - $eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + $eventObserverMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) ->disableOriginalConstructor() ->getMock(); - $eventMock = $this->getMockBuilder('Magento\Framework\Event') + $eventMock = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() ->setMethods(['getProduct'])->getMock(); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); From 2b94e47a97ee4def29527d304369eb55ee0634ce Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Apr 2016 15:13:44 +0300 Subject: [PATCH 19/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Magento/Test/Integrity/_files/blacklist/reference.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 3179ca0a7a217..b7492fa0c0dc9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -110,3 +110,5 @@ DoubleColon \Magento\Framework\ObjectManager\Code\Generator\Sample \Magento\Config\Block\Tooltip \Magento\Framework\Model\Name +\Magento\Test\Di\WrappedClass +\Magento\Test\Di\WrappedClass\Logger From 5bb14100ad3a0a38a5798e3e40e31864bcfcda00 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 18 Jul 2016 17:16:45 +0300 Subject: [PATCH 20/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Test/Unit/Model/MenuBuilderTest.php | 8 ++--- .../Test/Unit/Model/Session/QuoteTest.php | 4 +-- .../Product/Helper/Form/Gallery/Content.php | 4 +-- .../CustomOptions/CustomOptionProcessor.php | 2 +- .../Magento/Catalog/Model/Product/Copier.php | 2 +- .../Model/Product/Option/Repository.php | 2 +- .../Catalog/Model/ProductOptionProcessor.php | 2 +- .../Indexer/Product/Flat/ProcessorTest.php | 8 ++--- .../Product/Attribute/Source/BooleanTest.php | 2 +- .../Test/Unit/Model/Product/CopierTest.php | 4 +-- .../Unit/Model/ProductOptionProcessorTest.php | 2 +- .../Catalog/Url/Rewrite/SuffixTest.php | 18 +++++----- .../Test/Unit/Pricing/Price/BasePriceTest.php | 2 +- .../Test/Unit/Model/Stock/ItemTest.php | 2 +- .../Test/Unit/Model/StockTest.php | 14 ++++---- .../CatalogRule/Model/ResourceModel/Rule.php | 2 +- .../Model/ResourceModel/Rule/Collection.php | 2 +- .../CatalogRule/Test/Unit/Model/RuleTest.php | 12 +++---- .../Model/ProductUrlRewriteGenerator.php | 2 +- .../Test/Unit/Model/RuleTest.php | 12 +++---- .../Customer/Controller/Account/EditPost.php | 2 +- .../Customer/Controller/Address/FormPost.php | 4 ++- .../Customer/Model/Customer/DataProvider.php | 2 +- .../Customer/Model/Metadata/Form/File.php | 2 +- .../Customer/Model/Metadata/Form/Image.php | 2 +- .../Unit/Controller/Account/EditPostTest.php | 2 +- .../Unit/Controller/Account/LogoutTest.php | 4 +-- .../Unit/Controller/Address/DeleteTest.php | 34 +++++++++--------- .../Unit/Controller/Address/FormPostTest.php | 2 +- .../Adminhtml/File/Address/UploadTest.php | 30 ++++++++-------- .../Adminhtml/File/Customer/UploadTest.php | 30 ++++++++-------- .../Controller/Adminhtml/Group/SaveTest.php | 2 +- .../Plugin/SessionCheckerTest.php | 8 ++--- .../Test/Unit/Model/AccountManagementTest.php | 10 +++--- .../Unit/Model/Customer/DataProviderTest.php | 34 +++++++++--------- .../Customer/NotificationStorageTest.php | 3 +- .../Unit/Model/Customer/Source/GroupTest.php | 2 +- .../Test/Unit/Model/FileProcessorTest.php | 14 ++++---- .../Test/Unit/Model/FileUploaderTest.php | 16 ++++----- .../Model/Plugin/CustomerNotificationTest.php | 16 +++++---- .../Currency/Import/YahooFinanceTest.php | 12 +++---- .../Test/Unit/Model/CurrencyTest.php | 2 +- .../Test/Unit/Model/Link/BuilderTest.php | 2 +- .../Test/Unit/Model/Sample/BuilderTest.php | 2 +- .../Magento/GiftMessage/Setup/UpgradeData.php | 2 +- app/code/Magento/Persistent/Model/Session.php | 2 +- .../Test/Unit/Model/SessionTest.php | 2 +- .../Unit/Observer/RefreshCustomerDataTest.php | 10 +++--- .../Quote/Test/Unit/Model/QuoteTest.php | 4 +-- .../SalesRule/Model/ResourceModel/Rule.php | 2 +- .../Model/ResourceModel/Rule/Collection.php | 2 +- .../Unit/Model/ResourceModel/RuleTest.php | 8 ++--- .../SalesRule/Test/Unit/Model/RuleTest.php | 12 +++---- app/code/Magento/Store/Model/Store.php | 2 +- .../Controller/Store/SwitchActionTest.php | 30 ++++++++-------- .../Store/Test/Unit/Model/StoreTest.php | 2 +- .../Edit/Options/AbstractSwatchTest.php | 2 +- .../Plugin/Catalog/CacheInvalidateTest.php | 8 ++--- .../Test/Unit/Model/Plugin/OrderSaveTest.php | 2 +- .../Test/Unit/Model/Inline/ParserTest.php | 19 +++++----- .../Controller/Rest/RequestValidatorTest.php | 12 +++---- .../Adminhtml/Widget/LoadOptionsTest.php | 8 ++--- .../Wishlist/Block/Customer/Sidebar.php | 2 +- .../Test/Unit/Block/Customer/SidebarTest.php | 16 ++++----- .../Test/Unit/Model/Rss/WishlistTest.php | 10 +++--- .../ConfigurableProductTest.php | 16 ++++----- .../ConfiguredPrice/DownloadableTest.php | 26 +++++++------- .../Pricing/Render/ConfiguredPriceBoxTest.php | 18 +++++----- .../Customer/Api/AccountManagementTest.php | 2 +- .../Customer/Api/CustomerRepositoryTest.php | 6 ++-- .../Service/V1/CreditMemoCreateRefundTest.php | 2 +- .../Adminhtml/Product/Modal/AddAttribute.php | 2 +- .../Adminhtml/Product/Modal/NewAttribute.php | 2 +- .../Test/TestCase/AddProductVideoTest.php | 4 +-- .../Test/TestCase/DeleteProductVideoTest.php | 4 +-- .../Test/TestCase/UpdateProductVideoTest.php | 4 +-- .../TestCase/AbstractController.php | 4 +-- .../Block/Product/ProductList/RelatedTest.php | 4 +-- .../Product/Attribute/Backend/SkuTest.php | 2 +- .../ResourceModel/Product/CollectionTest.php | 10 +++--- .../Product/Indexer/Eav/SourceTest.php | 4 +-- .../Email/Model/_files/email_template.php | 2 +- .../Search/_files/date_attribute.php | 8 ++--- .../Search/_files/date_attribute_rollback.php | 8 ++--- .../Pricing/Price/FinalPriceTest.php | 6 ++-- .../Newsletter/Model/SubscriberTest.php | 2 +- .../Magento/Newsletter/_files/subscribers.php | 2 +- .../Theme/Model/Config/ValidatorTest.php | 20 ++++++----- .../Framework/ObjectManager/DiConfigTest.php | 2 +- .../ExtensionAttributesGeneratorTest.php | 2 +- ...ensionAttributesInterfaceGeneratorTest.php | 4 +-- .../App/Test/Unit/DocRootLocatorTest.php | 6 ++-- .../Code/Test/Unit/GeneratedFilesTest.php | 7 ++-- .../EntityManager/Test/Unit/MapperTest.php | 18 ++++++---- .../Test/Unit/TypeResolverTest.php | 3 +- .../Framework/Reflection/TypeProcessor.php | 2 +- .../Webapi/ServiceInputProcessor.php | 2 +- .../Test/Unit/ServiceInputProcessorTest.php | 2 +- .../src/Magento/Setup/Model/PackagesData.php | 2 +- .../Magento/Setup/Model/PhpReadinessCheck.php | 8 ++--- .../ModuleEnableDisableCommandTest.php | 2 +- .../Test/Unit/Controller/EnvironmentTest.php | 8 ++--- .../Test/Unit/Model/BasePackageInfoTest.php | 4 +-- .../Test/Unit/Model/Cron/JobSetCacheTest.php | 36 ++++++++++++------- .../Setup/Test/Unit/Model/Cron/StatusTest.php | 5 +-- .../Test/Unit/Model/PackagesAuthTest.php | 14 ++++---- .../Test/Unit/Model/PackagesDataTest.php | 25 ++++++------- .../Test/Unit/Model/PayloadValidatorTest.php | 2 +- .../Unit/Model/UpdaterTaskCreatorTest.php | 20 +++++++---- 109 files changed, 435 insertions(+), 397 deletions(-) diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php index 677c7f77e0be4..fc519ded8e860 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php @@ -19,18 +19,18 @@ class MenuBuilderTest extends \PHPUnit_Framework_TestCase */ public function testAfterGetResult($isPub, $times) { - $docRootLocator = $this->getMock('\Magento\Framework\App\DocRootLocator', [], [], '', false); + $docRootLocator = $this->getMock(\Magento\Framework\App\DocRootLocator::class, [], [], '', false); $docRootLocator->expects($this->once())->method('isPub')->willReturn($isPub); $model = new MenuBuilder($docRootLocator); /** @var \Magento\Backend\Model\Menu $menu */ - $menu = $this->getMock('\Magento\Backend\Model\Menu', [], [], '', false); + $menu = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); $menu->expects($this->exactly($times))->method('remove')->willReturn(true); /** @var \Magento\Backend\Model\Menu\Builder $menuBuilder */ - $menuBuilder = $this->getMock('\Magento\Backend\Model\Menu\Builder', [], [], '', false); + $menuBuilder = $this->getMock(\Magento\Backend\Model\Menu\Builder::class, [], [], '', false); $this->assertInstanceOf( - '\Magento\Backend\Model\Menu', + \Magento\Backend\Model\Menu::class, $model->afterGetResult($menuBuilder, $menu) ); } diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index 13c9697cb69e5..fd80821a7e34b 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -451,10 +451,10 @@ public function getQuoteDataProvider() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php index 80b6d3806e527..fcf805f72ce90 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php @@ -257,7 +257,7 @@ private function getImageHelper() { if ($this->imageHelper === null) { $this->imageHelper = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Helper\Image'); + ->get(\Magento\Catalog\Helper\Image::class); } return $this->imageHelper; } @@ -270,7 +270,7 @@ private function getAssetRepo() { if ($this->assetRepo === null) { $this->assetRepo = \Magento\Framework\App\ObjectManager::getInstance() - ->get('\Magento\Framework\View\Asset\Repository'); + ->get(\Magento\Framework\View\Asset\Repository::class); } return $this->assetRepo; diff --git a/app/code/Magento/Catalog/Model/CustomOptions/CustomOptionProcessor.php b/app/code/Magento/Catalog/Model/CustomOptions/CustomOptionProcessor.php index 0e37b56f10003..5b55f9cb66cfe 100644 --- a/app/code/Magento/Catalog/Model/CustomOptions/CustomOptionProcessor.php +++ b/app/code/Magento/Catalog/Model/CustomOptions/CustomOptionProcessor.php @@ -175,7 +175,7 @@ private function getUrlBuilder() { if ($this->urlBuilder === null) { $this->urlBuilder = \Magento\Framework\App\ObjectManager::getInstance() - ->get('\Magento\Catalog\Model\Product\Option\UrlBuilder'); + ->get(\Magento\Catalog\Model\Product\Option\UrlBuilder::class); } return $this->urlBuilder; } diff --git a/app/code/Magento/Catalog/Model/Product/Copier.php b/app/code/Magento/Catalog/Model/Product/Copier.php index 4cb3f843aa3f4..a4a37ad5b20f5 100644 --- a/app/code/Magento/Catalog/Model/Product/Copier.php +++ b/app/code/Magento/Catalog/Model/Product/Copier.php @@ -110,7 +110,7 @@ private function getMetadataPool() { if (null === $this->metadataPool) { $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\MetadataPool'); + ->get(\Magento\Framework\EntityManager\MetadataPool::class); } return $this->metadataPool; } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Repository.php b/app/code/Magento/Catalog/Model/Product/Option/Repository.php index efbc8f34f0dfe..d48bed8e3ccd0 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Repository.php @@ -242,7 +242,7 @@ private function getHydratorPool() { if (null === $this->hydratorPool) { $this->hydratorPool = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Framework\EntityManager\HydratorPool'); + ->get(\Magento\Framework\EntityManager\HydratorPool::class); } return $this->hydratorPool; } diff --git a/app/code/Magento/Catalog/Model/ProductOptionProcessor.php b/app/code/Magento/Catalog/Model/ProductOptionProcessor.php index a22286c47701b..4514eeb51bf54 100644 --- a/app/code/Magento/Catalog/Model/ProductOptionProcessor.php +++ b/app/code/Magento/Catalog/Model/ProductOptionProcessor.php @@ -134,7 +134,7 @@ private function getUrlBuilder() { if ($this->urlBuilder === null) { $this->urlBuilder = \Magento\Framework\App\ObjectManager::getInstance() - ->get('\Magento\Catalog\Model\Product\Option\UrlBuilder'); + ->get(\Magento\Catalog\Model\Product\Option\UrlBuilder::class); } return $this->urlBuilder; } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php index 7cbb769e2b62a..5e65fb2e4b43a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php @@ -123,7 +123,7 @@ public function testReindexRow( ->method('isFlatEnabled') ->willReturn($isFlatEnabled); - $indexerMock = $this->getMockBuilder('Magento\Indexer\Model\Indexer') + $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class) ->disableOriginalConstructor() ->getMock(); @@ -157,7 +157,7 @@ public function testReindexRowForce() ->method('isFlatEnabled') ->willReturn(true); - $indexerMock = $this->getMockBuilder('Magento\Indexer\Model\Indexer') + $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class) ->disableOriginalConstructor() ->getMock(); @@ -192,7 +192,7 @@ public function testReindexList( ->method('isFlatEnabled') ->willReturn($isFlatEnabled); - $indexerMock = $this->getMockBuilder('Magento\Indexer\Model\Indexer') + $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class) ->disableOriginalConstructor() ->getMock(); @@ -226,7 +226,7 @@ public function testReindexListForce() ->method('isFlatEnabled') ->willReturn(true); - $indexerMock = $this->getMockBuilder('Magento\Indexer\Model\Indexer') + $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php index a3356964b456d..a2f32d92f02d6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php @@ -22,7 +22,7 @@ class BooleanTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->attributeFactoryMock = $this->getMock( - 'Magento\Eav\Model\ResourceModel\Entity\AttributeFactory', + \Magento\Eav\Model\ResourceModel\Entity\AttributeFactory::class, [], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php index edd966bf0a99b..7f4fcd93e0a4a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php @@ -60,10 +60,10 @@ protected function setUp() $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $this->productMock->expects($this->any())->method('getEntityId')->willReturn(1); - $this->metadata = $this->getMockBuilder('Magento\Framework\EntityManager\EntityMetadata') + $this->metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class) ->disableOriginalConstructor() ->getMock(); - $metadataPool = $this->getMockBuilder('Magento\Framework\EntityManager\MetadataPool') + $metadataPool = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); $metadataPool->expects($this->any())->method('getMetadata')->willReturn($this->metadata); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php index 2fa29399547f3..b8a274afa38b1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php @@ -82,7 +82,7 @@ protected function setUp() $this->customOptionFactory ); - $urlBuilder = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option\UrlBuilder') + $urlBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\UrlBuilder::class) ->disableOriginalConstructor() ->setMethods(['getUrl']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php index 7ceb21436b56a..2bbdcb68c22ea 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php @@ -59,37 +59,37 @@ class SuffixTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->eventDispatcher = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); $this->eventDispatcher->method('dispatch')->willReturnSelf(); - $this->context = $this->getMockBuilder('\Magento\Framework\Model\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->setMethods(['getEventDispatcher']) ->getMock(); $this->context->method('getEventDispatcher')->willReturn($this->eventDispatcher); - $this->registry = $this->getMock('\Magento\Framework\Registry'); - $this->config = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); - $this->cacheTypeList = $this->getMockBuilder('\Magento\Framework\App\Cache\TypeList') + $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->config = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->cacheTypeList = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeList::class) ->disableOriginalConstructor() ->setMethods(['invalidate']) ->getMock(); - $this->urlRewriteHelper = $this->getMockBuilder('\Magento\UrlRewrite\Helper\UrlRewrite') + $this->urlRewriteHelper = $this->getMockBuilder(\Magento\UrlRewrite\Helper\UrlRewrite::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManager') + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class) ->disableOriginalConstructor() ->setMethods(['getStores']) ->getMock(); $this->storeManager->method('getStores')->willReturn([]); - $this->appResource =$this->getMockBuilder('\Magento\Framework\App\ResourceConnection') + $this->appResource =$this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); - $this->urlFinder =$this->getMockBuilder('\Magento\UrlRewrite\Model\UrlFinderInterface') + $this->urlFinder =$this->getMockBuilder(\Magento\UrlRewrite\Model\UrlFinderInterface::class) ->setMethods(['findAllByData', 'findOneByData']) ->getMock(); $this->urlFinder->method('findAllByData')->willReturn([]); diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php index 0196b599d8b60..3cb1749dc4add 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php @@ -123,7 +123,7 @@ public function testGetAmount() { $amount = 20.; - $priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) ->getMockForAbstractClass(); $this->priceInfoMock->expects($this->once()) diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index ce6665b79f074..11bb5cf82328a 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -79,7 +79,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eventDispatcher = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php index 48c532bba7045..369b9ec2b5269 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php @@ -53,35 +53,35 @@ class StockTest extends \PHPUnit_Framework_TestCase public function setUp() { /** @var PHPUnit_Framework_MockObject_MockObject */ - $this->eventDispatcher = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->setMethods(['dispatch']) ->getMock(); - $this->context = $this->getMockBuilder('\Magento\Framework\Model\Context') + $this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class) ->disableOriginalConstructor() ->setMethods(['getEventDispatcher']) ->getMock(); $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventDispatcher); - $this->registry = $this->getMockBuilder('\Magento\Framework\Registry') + $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->extensionFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + $this->extensionFactory = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->customAttributeFactory = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + $this->customAttributeFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resource = $this->getMockBuilder('\Magento\Framework\Model\ResourceModel\AbstractResource') + $this->resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->disableOriginalConstructor() ->setMethods(['getIdFieldName']) ->getMockForAbstractClass(); - $this->resourceCollection = $this->getMockBuilder('\Magento\Framework\Data\Collection\AbstractDb') + $this->resourceCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php index ba590ed20d470..5fdaf912e5fe3 100644 --- a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php +++ b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php @@ -263,7 +263,7 @@ private function getAssociatedEntitiesMap() { if (!$this->_associatedEntitiesMap) { $this->_associatedEntitiesMap = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\CatalogRule\Model\ResourceModel\Rule\AssociatedEntityMap') + ->get(\Magento\CatalogRule\Model\ResourceModel\Rule\AssociatedEntityMap::class) ->getData(); } return $this->_associatedEntitiesMap; diff --git a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php index 4e08ec509dc1d..4ff2a9d538f19 100644 --- a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php +++ b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php @@ -138,7 +138,7 @@ private function getAssociatedEntitiesMap() { if (!$this->_associatedEntitiesMap) { $this->_associatedEntitiesMap = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\CatalogRule\Model\ResourceModel\Rule\AssociatedEntityMap') + ->get(\Magento\CatalogRule\Model\ResourceModel\Rule\AssociatedEntityMap::class) ->getData(); } return $this->_associatedEntitiesMap; diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php index 0ab39cd6254d0..a624b87ebbe13 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php @@ -132,12 +132,12 @@ protected function setUp() $this->prepareObjectManager([ [ - 'Magento\Framework\Api\ExtensionAttributesFactory', - $this->getMock('Magento\Framework\Api\ExtensionAttributesFactory', [], [], '', false) + \Magento\Framework\Api\ExtensionAttributesFactory::class, + $this->getMock(\Magento\Framework\Api\ExtensionAttributesFactory::class, [], [], '', false) ], [ - 'Magento\Framework\Api\AttributeValueFactory', - $this->getMock('Magento\Framework\Api\AttributeValueFactory', [], [], '', false) + \Magento\Framework\Api\AttributeValueFactory::class, + $this->getMock(\Magento\Framework\Api\AttributeValueFactory::class, [], [], '', false) ], ]); @@ -381,12 +381,12 @@ public function testGetConditionsFieldSetId() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php index 6539a955313af..db39a201d9c05 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php @@ -86,7 +86,7 @@ private function getAnchorUrlRewriteGenerator() { if ($this->anchorUrlRewriteGenerator === null) { $this->anchorUrlRewriteGenerator = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator'); + ->get(\Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator::class); } return $this->anchorUrlRewriteGenerator; } diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php index 279a823851b01..afcc540a37545 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php @@ -31,12 +31,12 @@ protected function setUp() $this->prepareObjectManager([ [ - 'Magento\Framework\Api\ExtensionAttributesFactory', - $this->getMock('Magento\Framework\Api\ExtensionAttributesFactory', [], [], '', false) + \Magento\Framework\Api\ExtensionAttributesFactory::class, + $this->getMock(\Magento\Framework\Api\ExtensionAttributesFactory::class, [], [], '', false) ], [ - 'Magento\Framework\Api\AttributeValueFactory', - $this->getMock('Magento\Framework\Api\AttributeValueFactory', [], [], '', false) + \Magento\Framework\Api\AttributeValueFactory::class, + $this->getMock(\Magento\Framework\Api\AttributeValueFactory::class, [], [], '', false) ], ]); @@ -68,12 +68,12 @@ public function testGetActionsInstance() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php index b2f6384524147..00d089209c579 100644 --- a/app/code/Magento/Customer/Controller/Account/EditPost.php +++ b/app/code/Magento/Customer/Controller/Account/EditPost.php @@ -322,7 +322,7 @@ private function processChangeEmailRequest(\Magento\Customer\Api\Data\CustomerIn private function getCustomerMapper() { if ($this->customerMapper === null) { - $this->customerMapper = ObjectManager::getInstance()->get('Magento\Customer\Model\Customer\Mapper'); + $this->customerMapper = ObjectManager::getInstance()->get(\Magento\Customer\Model\Customer\Mapper::class); } return $this->customerMapper; } diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index 2cd1e3d3be8a1..e1920f728b3b2 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -229,7 +229,9 @@ public function execute() private function getCustomerAddressMapper() { if ($this->customerAddressMapper === null) { - $this->customerAddressMapper = ObjectManager::getInstance()->get('Magento\Customer\Model\Address\Mapper'); + $this->customerAddressMapper = ObjectManager::getInstance()->get( + \Magento\Customer\Model\Address\Mapper::class + ); } return $this->customerAddressMapper; } diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 4890422f6d8d5..e4b4fdd0149db 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -460,7 +460,7 @@ private function getFileProcessorFactory() { if ($this->fileProcessorFactory === null) { $this->fileProcessorFactory = ObjectManager::getInstance() - ->get('Magento\Customer\Model\FileProcessorFactory'); + ->get(\Magento\Customer\Model\FileProcessorFactory::class); } return $this->fileProcessorFactory; } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php index 69b19bc37373d..f3e722a75c6e2 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/File.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php @@ -404,7 +404,7 @@ protected function getFileProcessorFactory() { if ($this->fileProcessorFactory === null) { $this->fileProcessorFactory = ObjectManager::getInstance() - ->get('Magento\Customer\Model\FileProcessorFactory'); + ->get(\Magento\Customer\Model\FileProcessorFactory::class); } return $this->fileProcessorFactory; } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Image.php b/app/code/Magento/Customer/Model/Metadata/Form/Image.php index 993cd83826627..4a03d1b384261 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Image.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Image.php @@ -163,7 +163,7 @@ private function getImageContentFactory() { if ($this->imageContentFactory === null) { $this->imageContentFactory = ObjectManager::getInstance() - ->get('Magento\Framework\Api\Data\ImageContentInterfaceFactory'); + ->get(\Magento\Framework\Api\Data\ImageContentInterfaceFactory::class); } return $this->imageContentFactory; } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php index f7d39e2346de8..667ea67ddd419 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php @@ -138,7 +138,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->customerMapperMock = $this->getMockBuilder('Magento\Customer\Model\Customer\Mapper') + $this->customerMapperMock = $this->getMockBuilder(\Magento\Customer\Model\Customer\Mapper::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php index 58331d1d03622..51df92317e05d 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php @@ -44,10 +44,10 @@ class LogoutTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Action\Context') + $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getId', 'logout', 'setBeforeAuthUrl', 'setLastCustomerId']) ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php index 1f5d92791269a..6dcc9c2f310a6 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php @@ -45,54 +45,54 @@ class DeleteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->validatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class) ->disableOriginalConstructor() ->getMock(); - $formFactoryMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\FormFactory') + $formFactoryMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\FormFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->addressRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\AddressRepositoryInterface') + $this->addressRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\AddressRepositoryInterface::class) ->getMockForAbstractClass(); - $addressInterfaceFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterfaceFactory') + $addressInterfaceFactoryMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $regionInterfaceFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\RegionInterfaceFactory') + $regionInterfaceFactoryMock = $this->getMockBuilder(\Magento\Customer\Api\Data\RegionInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor') + $dataObjectProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class) ->disableOriginalConstructor() ->getMock(); - $dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + $dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $forwardFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\ForwardFactory') + $forwardFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\ForwardFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $pageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + $pageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->getMockForAbstractClass(); - $this->address = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $this->address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->getMockForAbstractClass(); - $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->getMockForAbstractClass(); - $this->resultRedirectFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') + $this->resultRedirectFactory = + $this->getMockBuilder(\Magento\Framework\Controller\Result\RedirectFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') + $this->resultRedirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManagerHelper($this); - $this->context = $objectManager->getObject( - 'Magento\Framework\App\Action\Context', + $this->context = $objectManager->getObject(\Magento\Framework\App\Action\Context::class, [ 'request' => $this->request, 'messageManager' => $this->messageManager, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php index a2b9f4e7635c7..2f7083e59e388 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php @@ -202,7 +202,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->customerAddressMapper = $this->getMockBuilder('Magento\Customer\Model\Address\Mapper') + $this->customerAddressMapper = $this->getMockBuilder(\Magento\Customer\Model\Address\Mapper::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php index 2853a39982367..79ae5210d8840 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php @@ -43,11 +43,11 @@ class UploadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); @@ -55,15 +55,15 @@ protected function setUp() ->method('getResultFactory') ->willReturn($this->resultFactory); - $this->fileUploaderFactory = $this->getMockBuilder('Magento\Customer\Model\FileUploaderFactory') + $this->fileUploaderFactory = $this->getMockBuilder(\Magento\Customer\Model\FileUploaderFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->addressMetadataService = $this->getMockBuilder('Magento\Customer\Api\AddressMetadataInterface') + $this->addressMetadataService = $this->getMockBuilder(\Magento\Customer\Api\AddressMetadataInterface::class) ->getMockForAbstractClass(); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMockForAbstractClass(); $this->controller = new Upload( @@ -82,7 +82,7 @@ public function testExecuteEmptyFiles() ->with($exception) ->willReturnSelf(); - $resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); $resultJson->expects($this->once()) @@ -98,7 +98,7 @@ public function testExecuteEmptyFiles() ->with(ResultFactory::TYPE_JSON) ->willReturn($resultJson); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Json', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Json::class, $this->controller->execute()); } public function testExecute() @@ -127,7 +127,7 @@ public function testExecute() 'url' => $resultFileUrl, ]; - $attributeMetadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMetadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); $this->addressMetadataService->expects($this->once()) @@ -135,7 +135,7 @@ public function testExecute() ->with($attributeCode) ->willReturn($attributeMetadataMock); - $fileUploader = $this->getMockBuilder('Magento\Customer\Model\FileUploader') + $fileUploader = $this->getMockBuilder(\Magento\Customer\Model\FileUploader::class) ->disableOriginalConstructor() ->getMock(); $fileUploader->expects($this->once()) @@ -154,7 +154,7 @@ public function testExecute() ]) ->willReturn($fileUploader); - $resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); $resultJson->expects($this->once()) @@ -167,7 +167,7 @@ public function testExecute() ->with(ResultFactory::TYPE_JSON) ->willReturn($resultJson); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Json', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Json::class, $this->controller->execute()); } public function testExecuteWithErrors() @@ -189,7 +189,7 @@ public function testExecuteWithErrors() 'error2', ]; - $attributeMetadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMetadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); $this->addressMetadataService->expects($this->once()) @@ -197,7 +197,7 @@ public function testExecuteWithErrors() ->with($attributeCode) ->willReturn($attributeMetadataMock); - $fileUploader = $this->getMockBuilder('Magento\Customer\Model\FileUploader') + $fileUploader = $this->getMockBuilder(\Magento\Customer\Model\FileUploader::class) ->disableOriginalConstructor() ->getMock(); $fileUploader->expects($this->once()) @@ -213,7 +213,7 @@ public function testExecuteWithErrors() ]) ->willReturn($fileUploader); - $resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); $resultJson->expects($this->once()) @@ -229,6 +229,6 @@ public function testExecuteWithErrors() ->with(ResultFactory::TYPE_JSON) ->willReturn($resultJson); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Json', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Json::class, $this->controller->execute()); } } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php index 29ac801bb5885..180713fe87af9 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php @@ -43,11 +43,11 @@ class UploadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + $this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); @@ -55,15 +55,15 @@ protected function setUp() ->method('getResultFactory') ->willReturn($this->resultFactory); - $this->fileUploaderFactory = $this->getMockBuilder('Magento\Customer\Model\FileUploaderFactory') + $this->fileUploaderFactory = $this->getMockBuilder(\Magento\Customer\Model\FileUploaderFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->customerMetadataService = $this->getMockBuilder('Magento\Customer\Api\CustomerMetadataInterface') + $this->customerMetadataService = $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class) ->getMockForAbstractClass(); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface') + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) ->getMockForAbstractClass(); $this->controller = new Upload( @@ -82,7 +82,7 @@ public function testExecuteEmptyFiles() ->with($exception) ->willReturnSelf(); - $resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); $resultJson->expects($this->once()) @@ -98,7 +98,7 @@ public function testExecuteEmptyFiles() ->with(ResultFactory::TYPE_JSON) ->willReturn($resultJson); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Json', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Json::class, $this->controller->execute()); } public function testExecute() @@ -125,7 +125,7 @@ public function testExecute() 'url' => $resultFileUrl, ]; - $attributeMetadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMetadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); $this->customerMetadataService->expects($this->once()) @@ -133,7 +133,7 @@ public function testExecute() ->with($attributeCode) ->willReturn($attributeMetadataMock); - $fileUploader = $this->getMockBuilder('Magento\Customer\Model\FileUploader') + $fileUploader = $this->getMockBuilder(\Magento\Customer\Model\FileUploader::class) ->disableOriginalConstructor() ->getMock(); $fileUploader->expects($this->once()) @@ -152,7 +152,7 @@ public function testExecute() ]) ->willReturn($fileUploader); - $resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); $resultJson->expects($this->once()) @@ -165,7 +165,7 @@ public function testExecute() ->with(ResultFactory::TYPE_JSON) ->willReturn($resultJson); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Json', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Json::class, $this->controller->execute()); } public function testExecuteWithErrors() @@ -185,7 +185,7 @@ public function testExecuteWithErrors() 'error2', ]; - $attributeMetadataMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $attributeMetadataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); $this->customerMetadataService->expects($this->once()) @@ -193,7 +193,7 @@ public function testExecuteWithErrors() ->with($attributeCode) ->willReturn($attributeMetadataMock); - $fileUploader = $this->getMockBuilder('Magento\Customer\Model\FileUploader') + $fileUploader = $this->getMockBuilder(\Magento\Customer\Model\FileUploader::class) ->disableOriginalConstructor() ->getMock(); $fileUploader->expects($this->once()) @@ -209,7 +209,7 @@ public function testExecuteWithErrors() ]) ->willReturn($fileUploader); - $resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + $resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() ->getMock(); $resultJson->expects($this->once()) @@ -225,6 +225,6 @@ public function testExecuteWithErrors() ->with(ResultFactory::TYPE_JSON) ->willReturn($resultJson); - $this->assertInstanceOf('Magento\Framework\Controller\Result\Json', $this->controller->execute()); + $this->assertInstanceOf(\Magento\Framework\Controller\Result\Json::class, $this->controller->execute()); } } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php index e66ea71873b5b..b11fcdcf2137f 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php @@ -178,7 +178,7 @@ public function testExecuteWithTaxClassAndException() ->with('Exception'); $this->dataObjectProcessorMock->expects($this->once()) ->method('buildOutputDataArray') - ->with($this->group, '\Magento\Customer\Api\Data\GroupInterface') + ->with($this->group, \Magento\Customer\Api\Data\GroupInterface::class) ->willReturn(['code' => $code]); $this->session->expects($this->once()) ->method('setCustomerGroupData') diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php index c2d22bb166c17..01a875c75a8c2 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php @@ -36,16 +36,16 @@ class SessionCheckerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->cookieManager = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\PhpCookieManager') + $this->cookieManager = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class) ->disableOriginalConstructor() ->getMock(); - $this->metadataFactory = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory') + $this->metadataFactory = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->metadata = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadata') + $this->metadata = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieMetadata::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionManager = $this->getMockBuilder('Magento\Framework\Session\SessionManager') + $this->sessionManager = $this->getMockBuilder(\Magento\Framework\Session\SessionManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php index de208842e6798..892598cf3e756 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php @@ -1612,15 +1612,15 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses() $hash = '4nj54lkj5jfi03j49f8bgujfgsd'; //Handle store - $store = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock(); $store->expects($this->any()) ->method('getWebsiteId') ->willReturn($websiteId); //Handle address - existing and non-existing. Non-Existing should return null when call getId method - $existingAddress = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $existingAddress = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); - $nonExistingAddress = $this->getMockBuilder('Magento\Customer\Api\Data\AddressInterface') + $nonExistingAddress = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) ->disableOriginalConstructor() ->getMock(); //Ensure that existing address is not in use @@ -1642,7 +1642,7 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses() ->method("setId") ->with(null); //Handle Customer calls - $customer = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMock(); + $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $customer ->expects($this->atLeastOnce()) ->method('getWebsiteId') @@ -1665,7 +1665,7 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses() ->method('getById') ->with($customerId) ->willReturn($customer); - $customerSecure = $this->getMockBuilder('Magento\Customer\Model\Data\CustomerSecure') + $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index d68dcd5134264..5e022dd8feddb 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -82,11 +82,11 @@ protected function setUp() ->setMethods(['getCustomerFormData', 'unsCustomerFormData']) ->getMockForAbstractClass(); - $this->fileProcessor = $this->getMockBuilder('Magento\Customer\Model\FileProcessor') + $this->fileProcessor = $this->getMockBuilder(\Magento\Customer\Model\FileProcessor::class) ->disableOriginalConstructor() ->getMock(); - $this->fileProcessorFactory = $this->getMockBuilder('Magento\Customer\Model\FileProcessorFactory') + $this->fileProcessorFactory = $this->getMockBuilder(\Magento\Customer\Model\FileProcessorFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -615,7 +615,7 @@ public function testGetDataWithCustomAttributeImage() ], ]; - $attributeMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->exactly(2)) @@ -625,14 +625,14 @@ public function testGetDataWithCustomAttributeImage() ->method('getAttributeCode') ->willReturn('img1'); - $entityTypeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $entityTypeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); $entityTypeMock->expects($this->once()) ->method('getEntityTypeCode') ->willReturn(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); - $customerMock = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customerMock = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $customerMock->expects($this->once()) @@ -654,7 +654,7 @@ public function testGetDataWithCustomAttributeImage() ->method('getEntityType') ->willReturn($entityTypeMock); - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $collectionMock->expects($this->once()) @@ -691,7 +691,7 @@ public function testGetDataWithCustomAttributeImage() $objectManager = new ObjectManager($this); $dataProvider = $objectManager->getObject( - '\Magento\Customer\Model\Customer\DataProvider', + \Magento\Customer\Model\Customer\DataProvider::class, [ 'name' => 'test-name', 'primaryFieldName' => 'primary-field-name', @@ -731,7 +731,7 @@ public function testGetDataWithCustomAttributeImageNoData() ], ]; - $attributeMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + $attributeMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) ->disableOriginalConstructor() ->getMock(); $attributeMock->expects($this->once()) @@ -741,14 +741,14 @@ public function testGetDataWithCustomAttributeImageNoData() ->method('getAttributeCode') ->willReturn('img1'); - $entityTypeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $entityTypeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); $entityTypeMock->expects($this->once()) ->method('getEntityTypeCode') ->willReturn(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); - $customerMock = $this->getMockBuilder('Magento\Customer\Model\Customer') + $customerMock = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); $customerMock->expects($this->once()) @@ -769,7 +769,7 @@ public function testGetDataWithCustomAttributeImageNoData() ->method('getEntityType') ->willReturn($entityTypeMock); - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $collectionMock->expects($this->once()) @@ -786,7 +786,7 @@ public function testGetDataWithCustomAttributeImageNoData() $objectManager = new ObjectManager($this); $dataProvider = $objectManager->getObject( - '\Magento\Customer\Model\Customer\DataProvider', + \Magento\Customer\Model\Customer\DataProvider::class, [ 'name' => 'test-name', 'primaryFieldName' => 'primary-field-name', @@ -819,7 +819,7 @@ public function testGetAttributesMetaWithCustomAttributeImage() $attributeCode = 'img1'; - $collectionMock = $this->getMockBuilder('Magento\Customer\Model\ResourceModel\Customer\Collection') + $collectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() ->getMock(); $collectionMock->expects($this->once()) @@ -830,7 +830,7 @@ public function testGetAttributesMetaWithCustomAttributeImage() ->method('create') ->willReturn($collectionMock); - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->setMethods([ 'getAttributeCode', 'getFrontendInput', @@ -852,7 +852,7 @@ function ($origName) { } ); - $typeCustomerMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $typeCustomerMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); $typeCustomerMock->expects($this->once()) @@ -862,7 +862,7 @@ function ($origName) { ->method('getEntityTypeCode') ->willReturn(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); - $typeAddressMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + $typeAddressMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class) ->disableOriginalConstructor() ->getMock(); $typeAddressMock->expects($this->once()) @@ -905,7 +905,7 @@ function ($origName) { $objectManager = new ObjectManager($this); $dataProvider = $objectManager->getObject( - '\Magento\Customer\Model\Customer\DataProvider', + \Magento\Customer\Model\Customer\DataProvider::class, [ 'name' => 'test-name', 'primaryFieldName' => 'primary-field-name', diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php index 4e145d0f2898d..0d2b32f747a80 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php @@ -32,7 +32,8 @@ class NotificationStorageTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->cache = $this->getMockBuilder('Magento\Framework\Cache\FrontendInterface')->getMockForAbstractClass(); + $this->cache = $this->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class) + ->getMockForAbstractClass(); $this->model = new NotificationStorage($this->cache); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php index 4672d774c185b..d9ca3bdc1ba8e 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php @@ -90,7 +90,7 @@ public function testToOptionArray() ->with($this->searchCriteriaMock) ->willReturn($this->searchResultMock); - $groupTest = $this->getMockBuilder('\Magento\Customer\Api\Data\GroupInterface') + $groupTest = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class) ->disableOriginalConstructor() ->setMethods(['getCode', 'getId']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php index b25aa7c4dc89f..94cd992717881 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php @@ -39,10 +39,10 @@ class FileProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mediaDirectory = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + $this->mediaDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMockForAbstractClass(); - $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); $this->filesystem->expects($this->any()) @@ -50,15 +50,15 @@ protected function setUp() ->with(DirectoryList::MEDIA) ->willReturn($this->mediaDirectory); - $this->uploaderFactory = $this->getMockBuilder('Magento\MediaStorage\Model\File\UploaderFactory') + $this->uploaderFactory = $this->getMockBuilder(\Magento\MediaStorage\Model\File\UploaderFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') + $this->urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->getMockForAbstractClass(); - $this->urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface') + $this->urlEncoder = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class) ->getMockForAbstractClass(); } @@ -177,7 +177,7 @@ public function testSaveTemporaryFile() 'path' => 'filepath', ]; - $uploaderMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Uploader') + $uploaderMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class) ->disableOriginalConstructor() ->getMock(); $uploaderMock->expects($this->once()) @@ -232,7 +232,7 @@ public function testSaveTemporaryFileWithError() $absolutePath = '/absolute/filepath'; - $uploaderMock = $this->getMockBuilder('Magento\MediaStorage\Model\File\Uploader') + $uploaderMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class) ->disableOriginalConstructor() ->getMock(); $uploaderMock->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php index a902151860f8f..610f059f23baa 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php @@ -38,22 +38,22 @@ class FileUploaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerMetadataService = $this->getMockBuilder('Magento\Customer\Api\CustomerMetadataInterface') + $this->customerMetadataService = $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class) ->getMockForAbstractClass(); - $this->addressMetadataService = $this->getMockBuilder('Magento\Customer\Api\AddressMetadataInterface') + $this->addressMetadataService = $this->getMockBuilder(\Magento\Customer\Api\AddressMetadataInterface::class) ->getMockForAbstractClass(); - $this->elementFactory = $this->getMockBuilder('Magento\Customer\Model\Metadata\ElementFactory') + $this->elementFactory = $this->getMockBuilder(\Magento\Customer\Model\Metadata\ElementFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->fileProcessorFactory = $this->getMockBuilder('Magento\Customer\Model\FileProcessorFactory') + $this->fileProcessorFactory = $this->getMockBuilder(\Magento\Customer\Model\FileProcessorFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->attributeMetadata = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + $this->attributeMetadata = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); } @@ -90,7 +90,7 @@ public function testValidate() ], ]; - $formElement = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form\Image') + $formElement = $this->getMockBuilder(\Magento\Customer\Model\Metadata\Form\Image::class) ->disableOriginalConstructor() ->getMock(); $formElement->expects($this->once()) @@ -139,7 +139,7 @@ public function testUpload() 'url' => $resultFileUrl, ]; - $fileProcessor = $this->getMockBuilder('Magento\Customer\Model\FileProcessor') + $fileProcessor = $this->getMockBuilder(\Magento\Customer\Model\FileProcessor::class) ->disableOriginalConstructor() ->getMock(); $fileProcessor->expects($this->once()) @@ -163,7 +163,7 @@ public function testUpload() ]) ->willReturn($fileProcessor); - $validationRuleMock = $this->getMockBuilder('Magento\Customer\Api\Data\ValidationRuleInterface') + $validationRuleMock = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class) ->getMockForAbstractClass(); $validationRuleMock->expects($this->once()) ->method('getName') diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php index bd0600899edcb..b8da1b863aad4 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php @@ -33,21 +33,22 @@ class CustomerNotificationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->getMock(); - $this->notificationStorage = $this->getMockBuilder('Magento\Customer\Model\Customer\NotificationStorage') + $this->notificationStorage = $this->getMockBuilder(\Magento\Customer\Model\Customer\NotificationStorage::class) ->disableOriginalConstructor() ->getMock(); - $this->customerRepository = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + $this->customerRepository = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); - $this->abstractAction = $this->getMockBuilder('Magento\Backend\App\AbstractAction') + $this->abstractAction = $this->getMockBuilder(\Magento\Backend\App\AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['isPost']) ->getMockForAbstractClass(); - $this->appState = $this->getMockBuilder('Magento\Framework\App\State')->disableOriginalConstructor()->getMock(); + $this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class) + ->disableOriginalConstructor()->getMock(); $this->plugin = new CustomerNotification( $this->session, $this->notificationStorage, @@ -64,7 +65,8 @@ public function testBeforeDispatch() ->method('getAreaCode') ->willReturn(\Magento\Framework\App\Area::AREA_FRONTEND); $this->request->expects($this->any())->method('isPost')->willReturn(true); - $customerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')->getMockForAbstractClass(); + $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) + ->getMockForAbstractClass(); $customerMock->expects($this->any())->method('getGroupId')->willReturn($customerGroupId); $this->customerRepository->expects($this->any()) ->method('getById') diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php index 4add2ca82d19b..f536db4aa2e1d 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php @@ -27,21 +27,21 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->currencyFactoryMock = $this->getMockBuilder('Magento\Directory\Model\CurrencyFactory') + $this->currencyFactoryMock = $this->getMockBuilder(\Magento\Directory\Model\CurrencyFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->httpClientFactoryMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClientFactory') + $this->httpClientFactoryMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClientFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $scopeMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + $scopeMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $this->model = $objectManagerHelper->getObject( - 'Magento\Directory\Model\Currency\Import\YahooFinance', + \Magento\Directory\Model\Currency\Import\YahooFinance::class, [ 'currencyFactory' => $this->currencyFactoryMock, 'scopeConfig' => $scopeMock, @@ -62,12 +62,12 @@ public function testFetchRates() . "&env=store://datatables.org/alltableswithkeys for UAH."; /** @var \Magento\Directory\Model\Currency|\PHPUnit_Framework_MockObject_MockObject $currencyMock */ - $currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + $currencyMock = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); /** @var \Magento\Framework\HTTP\ZendClient|\PHPUnit_Framework_MockObject_MockObject $currencyMock */ - $httpClientMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClient') + $httpClientMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClient::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php index 913576481469f..223cf3976c9dc 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php @@ -64,7 +64,7 @@ public function testGetCurrencySymbol() */ public function testGetOutputFormat($withCurrency, $noCurrency, $expected) { - $currencyMock = $this->getMockBuilder('\Magento\Framework\Currency') + $currencyMock = $this->getMockBuilder(\Magento\Framework\Currency::class) ->disableOriginalConstructor() ->getMock(); $currencyMock->expects($this->at(0)) diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php index 97c3eb438a8d9..bb3aab7bbdf68 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php @@ -60,7 +60,7 @@ protected function setUp() \Magento\Framework\Api\DataObjectHelper::class )->disableOriginalConstructor()->getMock(); - $this->mockComponentFactory = $this->getMockBuilder('\Magento\Downloadable\Model\LinkFactory') + $this->mockComponentFactory = $this->getMockBuilder(\Magento\Downloadable\Model\LinkFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php index 1c0a4df238c1f..1bddb17f0555f 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php @@ -60,7 +60,7 @@ protected function setUp() \Magento\Framework\Api\DataObjectHelper::class )->disableOriginalConstructor()->getMock(); - $this->mockComponentFactory = $this->getMockBuilder('\Magento\Downloadable\Model\SampleFactory') + $this->mockComponentFactory = $this->getMockBuilder(\Magento\Downloadable\Model\SampleFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/GiftMessage/Setup/UpgradeData.php b/app/code/Magento/GiftMessage/Setup/UpgradeData.php index 9ceba69074875..60e2eed8944d6 100644 --- a/app/code/Magento/GiftMessage/Setup/UpgradeData.php +++ b/app/code/Magento/GiftMessage/Setup/UpgradeData.php @@ -64,7 +64,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $entityTypeId, $attribute['attribute_id'], 'source_model', - 'Magento\Catalog\Model\Product\Attribute\Source\Boolean' + \Magento\Catalog\Model\Product\Attribute\Source\Boolean::class ); } diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 2f9c96b3e1485..48362971b6b84 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -406,7 +406,7 @@ private function getRequest() { if ($this->request == null) { $this->request = \Magento\Framework\App\ObjectManager::getInstance() - ->get('\Magento\Framework\App\Request\Http'); + ->get(\Magento\Framework\App\Request\Http::class); } return $this->request; } diff --git a/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php b/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php index a3cd461f19a4c..9ba388d287b64 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php @@ -70,7 +70,7 @@ protected function setUp() 'cookieManager' => $this->cookieManagerMock, 'context' => $context, 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, - 'request' => $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false, false), + 'request' => $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false, false), 'resource' => $resourceMock, ] ); diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php index fa5990da27f34..b660c44817913 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php @@ -36,16 +36,16 @@ class RefreshCustomerDataTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->cookieManager = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\PhpCookieManager') + $this->cookieManager = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class) ->disableOriginalConstructor() ->getMock(); - $this->metadataFactory = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory') + $this->metadataFactory = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->metadata = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadata') + $this->metadata = $this->getMockBuilder(\Magento\Framework\Stdlib\Cookie\CookieMetadata::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionManager = $this->getMockBuilder('Magento\Framework\Session\SessionManager') + $this->sessionManager = $this->getMockBuilder(\Magento\Framework\Session\SessionManager::class) ->disableOriginalConstructor() ->getMock(); @@ -60,7 +60,7 @@ public function setUp() */ public function testBeforeStart($result, $callCount) { - $observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $frontendSessionCookieName = 'mage-cache-sessid'; $this->cookieManager->expects($this->once()) ->method('getCookie') diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php index 5d297c7f186d8..5165f299d45a9 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php @@ -286,7 +286,7 @@ protected function setUp() false ); $this->customerDataFactoryMock = $this->getMock( - 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create'], [], '', @@ -574,7 +574,7 @@ public function testSetCustomerAddressData() false ); $requestMock = $this->getMock( - '\Magento\Framework\DataObject' + \Magento\Framework\DataObject::class ); $this->extensibleDataObjectConverterMock->expects($this->any()) diff --git a/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php b/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php index f0dc9f3e41876..78cc3e1c39c27 100644 --- a/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php +++ b/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php @@ -388,7 +388,7 @@ private function getAssociatedEntitiesMap() { if (!$this->_associatedEntitiesMap) { $this->_associatedEntitiesMap = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\SalesRule\Model\ResourceModel\Rule\AssociatedEntityMap') + ->get(\Magento\SalesRule\Model\ResourceModel\Rule\AssociatedEntityMap::class) ->getData(); } return $this->_associatedEntitiesMap; diff --git a/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php b/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php index 891a080fab42f..cbc7b4385ec55 100644 --- a/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php +++ b/app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php @@ -325,7 +325,7 @@ private function getAssociatedEntitiesMap() { if (!$this->_associatedEntitiesMap) { $this->_associatedEntitiesMap = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\SalesRule\Model\ResourceModel\Rule\AssociatedEntityMap') + ->get(\Magento\SalesRule\Model\ResourceModel\Rule\AssociatedEntityMap::class) ->getData(); } return $this->_associatedEntitiesMap; diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/ResourceModel/RuleTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/ResourceModel/RuleTest.php index 4e7a8df547f2b..5c60007543916 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/ResourceModel/RuleTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/ResourceModel/RuleTest.php @@ -117,7 +117,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $associatedEntitiesMap = $this->getMock('Magento\Framework\DataObject', [], [], '', false); + $associatedEntitiesMap = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); $associatedEntitiesMap->expects($this->once()) ->method('getData') ->willReturn( @@ -137,7 +137,7 @@ protected function setUp() $this->prepareObjectManager([ [ - 'Magento\SalesRule\Model\ResourceModel\Rule\AssociatedEntityMap', + \Magento\SalesRule\Model\ResourceModel\Rule\AssociatedEntityMap::class, $associatedEntitiesMap ], ]); @@ -190,12 +190,12 @@ public function testDelete() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php index 6b00608e0f8fe..f3d16c188fdf9 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php @@ -59,12 +59,12 @@ protected function setUp() $this->prepareObjectManager([ [ - 'Magento\Framework\Api\ExtensionAttributesFactory', - $this->getMock('Magento\Framework\Api\ExtensionAttributesFactory', [], [], '', false) + \Magento\Framework\Api\ExtensionAttributesFactory::class, + $this->getMock(\Magento\Framework\Api\ExtensionAttributesFactory::class, [], [], '', false) ], [ - 'Magento\Framework\Api\AttributeValueFactory', - $this->getMock('Magento\Framework\Api\AttributeValueFactory', [], [], '', false) + \Magento\Framework\Api\AttributeValueFactory::class, + $this->getMock(\Magento\Framework\Api\AttributeValueFactory::class, [], [], '', false) ], ]); @@ -185,12 +185,12 @@ public function testGetActionsFieldSetId() */ private function prepareObjectManager($map) { - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf(); $objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnValueMap($map)); - $reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager'); + $reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class); $reflectionProperty = $reflectionClass->getProperty('_instance'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($objectManagerMock); diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index 9aab9765fced7..270b621407d46 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -1327,7 +1327,7 @@ private function getUrlModifier() { if ($this->urlModifier === null) { $this->urlModifier = \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Framework\Url\ModifierInterface' + \Magento\Framework\Url\ModifierInterface::class ); } diff --git a/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php b/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php index c4501665f5bf9..7ef08d151b1d4 100644 --- a/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php +++ b/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php @@ -60,20 +60,22 @@ class SwitchActionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')->getMock(); + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)->getMock(); $this->storeCookieManagerMock = - $this->getMockBuilder('Magento\Store\Api\StoreCookieManagerInterface')->getMock(); - $this->storeRepositoryMock = $this->getMockBuilder('Magento\Store\Api\StoreRepositoryInterface')->getMock(); - $this->httpContextMock = $this->getMockBuilder('Magento\Framework\App\Http\Context')->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')->getMock(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface') + $this->getMockBuilder(\Magento\Store\Api\StoreCookieManagerInterface::class)->getMock(); + $this->storeRepositoryMock = + $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class)->getMock(); + $this->httpContextMock = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class)->getMock(); + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock(); + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->disableOriginalConstructor() ->setMethods(['setRedirect']) ->getMockForAbstractClass(); - $this->redirectMock = $this->getMockBuilder('Magento\Framework\App\Response\RedirectInterface')->getMock(); + $this->redirectMock = + $this->getMockBuilder(\Magento\Framework\App\Response\RedirectInterface::class)->getMock(); $this->model = (new ObjectManager($this))->getObject( - 'Magento\Store\Controller\Store\SwitchAction', + \Magento\Store\Controller\Store\SwitchAction::class, [ 'storeCookieManager' => $this->storeCookieManagerMock, 'httpContext' => $this->httpContextMock, @@ -91,9 +93,9 @@ public function testExecuteSuccessWithoutUseStoreInUrl() $storeToSwitchToCode = 'sv2'; $defaultStoreViewCode = 'default'; $expectedRedirectUrl = "magento.com/{$storeToSwitchToCode}"; - $currentActiveStoreMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface')->getMock(); - $defaultStoreViewMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface')->getMock(); - $storeToSwitchToMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface') + $currentActiveStoreMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMock(); + $defaultStoreViewMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMock(); + $storeToSwitchToMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) ->disableOriginalConstructor() ->setMethods(['isUseStoreInUrl']) ->getMockForAbstractClass(); @@ -124,12 +126,12 @@ public function testExecuteSuccessWithUseStoreInUrl() $defaultStoreViewCode = 'default'; $originalRedirectUrl = "magento.com/{$currentActiveStoreCode}/test-page/test-sub-page"; $expectedRedirectUrl = "magento.com/{$storeToSwitchToCode}/test-page/test-sub-page"; - $currentActiveStoreMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface') + $currentActiveStoreMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) ->disableOriginalConstructor() ->setMethods(['isUseStoreInUrl', 'getBaseUrl']) ->getMockForAbstractClass(); - $defaultStoreViewMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface')->getMock(); - $storeToSwitchToMock = $this->getMockBuilder('Magento\Store\Api\Data\StoreInterface') + $defaultStoreViewMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMock(); + $storeToSwitchToMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) ->disableOriginalConstructor() ->setMethods(['isUseStoreInUrl', 'getBaseUrl']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Store/Test/Unit/Model/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/StoreTest.php index 3d3c4152d4826..5b2691d2e4b40 100644 --- a/app/code/Magento/Store/Test/Unit/Model/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/StoreTest.php @@ -69,7 +69,7 @@ protected function setUp() ['filesystem' => $this->filesystemMock] ); - $this->urlModifierMock = $this->getMock('Magento\Framework\Url\ModifierInterface'); + $this->urlModifierMock = $this->getMock(\Magento\Framework\Url\ModifierInterface::class); $this->urlModifierMock->expects($this->any()) ->method('execute') ->willReturnArgument(0); diff --git a/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php b/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php index 3021b64ee55e2..5c0818cb7eb58 100644 --- a/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php @@ -88,7 +88,7 @@ protected function setUp() true ); - $this->connectionMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->setMethods(['quoteInto']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Swatches/Test/Unit/Plugin/Catalog/CacheInvalidateTest.php b/app/code/Magento/Swatches/Test/Unit/Plugin/Catalog/CacheInvalidateTest.php index 7f59f97a12725..cdbb1d72d3f53 100644 --- a/app/code/Magento/Swatches/Test/Unit/Plugin/Catalog/CacheInvalidateTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Plugin/Catalog/CacheInvalidateTest.php @@ -30,21 +30,21 @@ class CacheInvalidateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->typeList = $this->getMock( - '\Magento\Framework\App\Cache\TypeListInterface', + \Magento\Framework\App\Cache\TypeListInterface::class, [], [], '', false ); $this->swatchHelper = $this->getMock( - '\Magento\Swatches\Helper\Data', + \Magento\Swatches\Helper\Data::class, [], [], '', false ); $this->attribute = $this->getMock( - '\Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', @@ -53,7 +53,7 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->cacheInvalidate = $objectManager->getObject( - 'Magento\Swatches\Plugin\Catalog\CacheInvalidate', + \Magento\Swatches\Plugin\Catalog\CacheInvalidate::class, [ 'typeList' => $this->typeList, 'swatchHelper' => $this->swatchHelper diff --git a/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php b/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php index d7ef893374fea..472b8ea0a7024 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php @@ -214,7 +214,7 @@ public function testAfterSave( */ public function afterSaveDataProvider() { - $orderTaxDetailsApplied = $this->getMockBuilder('\Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface') + $orderTaxDetailsApplied = $this->getMockBuilder(\Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface::class) ->disableOriginalConstructor() ->setMethods(['getRates']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Translation/Test/Unit/Model/Inline/ParserTest.php b/app/code/Magento/Translation/Test/Unit/Model/Inline/ParserTest.php index ac2bb6daae324..f31990453c0de 100644 --- a/app/code/Magento/Translation/Test/Unit/Model/Inline/ParserTest.php +++ b/app/code/Magento/Translation/Test/Unit/Model/Inline/ParserTest.php @@ -78,17 +78,20 @@ class ParserTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->translateInlineMock = $this->getMockForAbstractClass('Magento\Framework\Translate\InlineInterface'); - $this->appCacheMock = $this->getMockForAbstractClass('Magento\Framework\App\Cache\TypeListInterface'); - $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); - $this->storeMock = $this->getMockForAbstractClass('Magento\Store\Api\Data\StoreInterface'); + $this->translateInlineMock = + $this->getMockForAbstractClass(\Magento\Framework\Translate\InlineInterface::class); + $this->appCacheMock = $this->getMockForAbstractClass(\Magento\Framework\App\Cache\TypeListInterface::class); + $this->storeManagerMock = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeMock = $this->getMockForAbstractClass(\Magento\Store\Api\Data\StoreInterface::class); $this->storeManagerMock->expects($this->any()) ->method('getStore') ->willReturn($this->storeMock); - $this->resourceFactoryMock = $this->getMockBuilder('Magento\Translation\Model\ResourceModel\StringUtilsFactory') + $this->resourceFactoryMock = $this->getMockBuilder( + \Magento\Translation\Model\ResourceModel\StringUtilsFactory::class + ) ->setMethods(['create']) ->getMock(); - $this->resourceMock = $this->getMockBuilder('Magento\Translation\Model\ResourceModel\StringUtils') + $this->resourceMock = $this->getMockBuilder(\Magento\Translation\Model\ResourceModel\StringUtils::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -98,12 +101,12 @@ protected function setUp() $this->resourceFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->resourceMock); - $this->cacheManagerMock = $this->getMockBuilder('Magento\Translation\Model\Inline\CacheManager') + $this->cacheManagerMock = $this->getMockBuilder(\Magento\Translation\Model\Inline\CacheManager::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Webapi/Test/Unit/Controller/Rest/RequestValidatorTest.php b/app/code/Magento/Webapi/Test/Unit/Controller/Rest/RequestValidatorTest.php index 4a342b283ca5f..59e215823e87c 100644 --- a/app/code/Magento/Webapi/Test/Unit/Controller/Rest/RequestValidatorTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Controller/Rest/RequestValidatorTest.php @@ -39,7 +39,7 @@ class RequestValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMockBuilder('Magento\Framework\Webapi\Rest\Request') + $this->requestMock = $this->getMockBuilder(\Magento\Framework\Webapi\Rest\Request::class) ->setMethods( [ 'isSecure', @@ -55,16 +55,16 @@ protected function setUp() $this->requestMock->expects($this->any()) ->method('getHttpHost') ->willReturn('testHostName.com'); - $routerMock = $this->getMockBuilder('Magento\Webapi\Controller\Rest\Router')->setMethods(['match']) + $routerMock = $this->getMockBuilder(\Magento\Webapi\Controller\Rest\Router::class)->setMethods(['match']) ->disableOriginalConstructor()->getMock(); - $this->routeMock = $this->getMockBuilder('Magento\Webapi\Controller\Rest\Router\Route') + $this->routeMock = $this->getMockBuilder(\Magento\Webapi\Controller\Rest\Router\Route::class) ->setMethods(['isSecure', 'getServiceMethod', 'getServiceClass', 'getAclResources', 'getParameters']) ->disableOriginalConstructor()->getMock(); - $this->authorizationMock = $this->getMockBuilder('Magento\Framework\Webapi\Authorization') + $this->authorizationMock = $this->getMockBuilder(\Magento\Framework\Webapi\Authorization::class) ->disableOriginalConstructor()->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->storeMock = $this->getMock('\Magento\Store\Api\Data\StoreInterface'); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->requestValidator = diff --git a/app/code/Magento/Widget/Test/Unit/Controller/Adminhtml/Widget/LoadOptionsTest.php b/app/code/Magento/Widget/Test/Unit/Controller/Adminhtml/Widget/LoadOptionsTest.php index 50946ed3f78dd..0d4f1b1e5d801 100644 --- a/app/code/Magento/Widget/Test/Unit/Controller/Adminhtml/Widget/LoadOptionsTest.php +++ b/app/code/Magento/Widget/Test/Unit/Controller/Adminhtml/Widget/LoadOptionsTest.php @@ -111,7 +111,7 @@ public function dtestExecuteWithException() $errorMessage = 'Some error'; /** @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject $jsonDataHelperMock */ - $jsonDataHelperMock = $this->getMockBuilder('Magento\Framework\Json\Helper\Data') + $jsonDataHelperMock = $this->getMockBuilder(\Magento\Framework\Json\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); $jsonDataHelperMock->expects($this->once()) @@ -124,7 +124,7 @@ public function dtestExecuteWithException() ->willThrowException(new LocalizedException(__($errorMessage))); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\Json\Helper\Data') + ->with(\Magento\Framework\Json\Helper\Data::class) ->willReturn($jsonDataHelperMock); $this->responseMock->expects($this->once()) ->method('representJson') @@ -164,7 +164,7 @@ public function testExecute() ]; /** @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject $jsonDataHelperMock */ - $jsonDataHelperMock = $this->getMockBuilder('Magento\Framework\Json\Helper\Data') + $jsonDataHelperMock = $this->getMockBuilder(\Magento\Framework\Json\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); $jsonDataHelperMock->expects($this->once()) @@ -180,7 +180,7 @@ public function testExecute() ->willReturn($widgetJsonParams); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\Json\Helper\Data') + ->with(\Magento\Framework\Json\Helper\Data::class) ->willReturn($jsonDataHelperMock); /** @var \Magento\Framework\View\Element\BlockInterface|\PHPUnit_Framework_MockObject_MockObject $blockMock */ diff --git a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php index 3ebb9c0724264..19b4e385e7908 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php +++ b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php @@ -64,7 +64,7 @@ private function getPriceRender() $priceRender = $this->getLayout()->getBlock('product.price.render.default'); if (!$priceRender) { $priceRender = $this->getLayout()->createBlock( - 'Magento\Framework\Pricing\Render', + \Magento\Framework\Pricing\Render::class, 'product.price.render.default', [ 'data' => [ diff --git a/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php b/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php index 9e8fc4edbf77e..08677043050fc 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php @@ -32,17 +32,17 @@ class SidebarTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->layout = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->getMockForAbstractClass(); - $this->productContext = $this->getMockBuilder('Magento\Catalog\Block\Product\Context') + $this->productContext = $this->getMockBuilder(\Magento\Catalog\Block\Product\Context::class) ->disableOriginalConstructor() ->getMock(); $this->productContext->expects($this->any()) ->method('getLayout') ->willReturn($this->layout); - $this->httpContext = $this->getMockBuilder('Magento\Framework\App\Http\Context') + $this->httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class) ->disableOriginalConstructor() ->getMock(); @@ -57,11 +57,11 @@ public function testGetProductPriceHtml() $priceType = 'wishlist_configured_price'; $expected = 'block content'; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $renderMock = $this->getMockBuilder('\Magento\Framework\Pricing\Render') + $renderMock = $this->getMockBuilder(\Magento\Framework\Pricing\Render::class) ->disableOriginalConstructor() ->getMock(); $renderMock->expects($this->once()) @@ -85,11 +85,11 @@ public function testGetProductPriceHtmlCreateBlock() $priceType = 'wishlist_configured_price'; $expected = 'block content'; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $renderMock = $this->getMockBuilder('\Magento\Framework\Pricing\Render') + $renderMock = $this->getMockBuilder(\Magento\Framework\Pricing\Render::class) ->disableOriginalConstructor() ->getMock(); $renderMock->expects($this->once()) @@ -104,7 +104,7 @@ public function testGetProductPriceHtmlCreateBlock() $this->layout->expects($this->once()) ->method('createBlock') ->with( - 'Magento\Framework\Pricing\Render', + \Magento\Framework\Pricing\Render::class, 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']] ) diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php index 32e5da02b89b1..068dea753399a 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php @@ -323,11 +323,11 @@ public function testGetProductPriceHtmlBlockDoesntExists() { $price = 10.; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $renderBlockMock = $this->getMockBuilder('Magento\Framework\Pricing\Render') + $renderBlockMock = $this->getMockBuilder(\Magento\Framework\Pricing\Render::class) ->disableOriginalConstructor() ->getMock(); $renderBlockMock->expects($this->once()) @@ -346,7 +346,7 @@ public function testGetProductPriceHtmlBlockDoesntExists() $this->layoutMock->expects($this->once()) ->method('createBlock') ->with( - 'Magento\Framework\Pricing\Render', + \Magento\Framework\Pricing\Render::class, 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']] ) @@ -359,11 +359,11 @@ public function testGetProductPriceHtmlBlockExists() { $price = 10.; - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); - $renderBlockMock = $this->getMockBuilder('Magento\Framework\Pricing\Render') + $renderBlockMock = $this->getMockBuilder(\Magento\Framework\Pricing\Render::class) ->disableOriginalConstructor() ->getMock(); $renderBlockMock->expects($this->once()) diff --git a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php index 4fa6ca0ac4c22..9e05a578080ef 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php @@ -40,10 +40,10 @@ class ConfigurableProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfoInterface') + $this->priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfoInterface::class) ->getMockForAbstractClass(); - $this->saleableItem = $this->getMockBuilder('Magento\Framework\Pricing\SaleableInterface') + $this->saleableItem = $this->getMockBuilder(\Magento\Framework\Pricing\SaleableInterface::class) ->setMethods([ 'getPriceInfo', 'getCustomOption', @@ -53,10 +53,10 @@ protected function setUp() ->method('getPriceInfo') ->willReturn($this->priceInfoMock); - $this->calculator = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\CalculatorInterface') + $this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class) ->getMockForAbstractClass(); - $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface') + $this->priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) ->getMockForAbstractClass(); $this->model = new ConfigurableProduct( @@ -71,13 +71,13 @@ public function testGetValue() { $priceValue = 10; - $priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) ->getMockForAbstractClass(); $priceMock->expects($this->once()) ->method('getValue') ->willReturn($priceValue); - $this->priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfo\Base') + $this->priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) ->disableOriginalConstructor() ->getMock(); $this->priceInfoMock->expects($this->once()) @@ -85,14 +85,14 @@ public function testGetValue() ->with(ConfigurableProduct::PRICE_CODE) ->willReturn($priceMock); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->getMock(); $productMock->expects($this->once()) ->method('getPriceInfo') ->willReturn($this->priceInfoMock); - $wishlistItemOptionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + $wishlistItemOptionMock = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) ->disableOriginalConstructor() ->getMock(); $wishlistItemOptionMock->expects($this->once()) diff --git a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/DownloadableTest.php b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/DownloadableTest.php index f8354393eea37..5c8bd7c09cc61 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/DownloadableTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/DownloadableTest.php @@ -41,10 +41,10 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceInfoMock = $this->getMockBuilder('Magento\Framework\Pricing\PriceInfoInterface') + $this->priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfoInterface::class) ->getMockForAbstractClass(); - $this->saleableItem = $this->getMockBuilder('Magento\Framework\Pricing\SaleableInterface') + $this->saleableItem = $this->getMockBuilder(\Magento\Framework\Pricing\SaleableInterface::class) ->setMethods([ 'getPriceInfo', 'getLinksPurchasedSeparately', @@ -56,10 +56,10 @@ protected function setUp() ->method('getPriceInfo') ->willReturn($this->priceInfoMock); - $this->calculator = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\CalculatorInterface') + $this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class) ->getMockForAbstractClass(); - $this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface') + $this->priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) ->getMockForAbstractClass(); $this->model = new Downloadable( @@ -74,21 +74,21 @@ public function testGetValue() { $priceValue = 10; - $wishlistItemOptionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + $wishlistItemOptionMock = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) ->disableOriginalConstructor() ->getMock(); $wishlistItemOptionMock->expects($this->once()) ->method('getValue') ->willReturn('1,2'); - $linkMock = $this->getMockBuilder('Magento\Downloadable\Model\Link') + $linkMock = $this->getMockBuilder(\Magento\Downloadable\Model\Link::class) ->disableOriginalConstructor() ->getMock(); $linkMock->expects($this->once()) ->method('getPrice') ->willReturn(10); - $productTypeMock = $this->getMockBuilder('Magento\Downloadable\Model\Product\Type') + $productTypeMock = $this->getMockBuilder(\Magento\Downloadable\Model\Product\Type::class) ->disableOriginalConstructor() ->getMock(); $productTypeMock->expects($this->once()) @@ -96,7 +96,7 @@ public function testGetValue() ->with($this->saleableItem) ->willReturn([1 => $linkMock]); - $priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) ->getMockForAbstractClass(); $priceMock->expects($this->once()) ->method('getValue') @@ -125,7 +125,7 @@ public function testGetValueNoLinksPurchasedSeparately() { $priceValue = 10; - $priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) ->getMockForAbstractClass(); $priceMock->expects($this->once()) ->method('getValue') @@ -147,7 +147,7 @@ public function testGetValueNoOptions() { $priceValue = 10; - $priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) ->getMockForAbstractClass(); $priceMock->expects($this->once()) ->method('getValue') @@ -158,14 +158,14 @@ public function testGetValueNoOptions() ->with(BasePrice::PRICE_CODE) ->willReturn($priceMock); - $wishlistItemOptionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + $wishlistItemOptionMock = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) ->disableOriginalConstructor() ->getMock(); $wishlistItemOptionMock->expects($this->once()) ->method('getValue') ->willReturn(null); - $productTypeMock = $this->getMockBuilder('Magento\Downloadable\Model\Product\Type') + $productTypeMock = $this->getMockBuilder(\Magento\Downloadable\Model\Product\Type::class) ->disableOriginalConstructor() ->getMock(); $productTypeMock->expects($this->once()) @@ -189,7 +189,7 @@ public function testGetValueNoOptions() public function testGetValueWithNoCustomOption() { - $priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) ->getMockForAbstractClass(); $priceMock->expects($this->once()) ->method('getValue') diff --git a/app/code/Magento/Wishlist/Test/Unit/Pricing/Render/ConfiguredPriceBoxTest.php b/app/code/Magento/Wishlist/Test/Unit/Pricing/Render/ConfiguredPriceBoxTest.php index 1a3af86cfdcf7..193119bb30425 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Pricing/Render/ConfiguredPriceBoxTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Pricing/Render/ConfiguredPriceBoxTest.php @@ -41,24 +41,22 @@ class ConfiguredPriceBoxTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->templateContext = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + $this->templateContext = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->saleableItem = $this->getMockBuilder('Magento\Framework\Pricing\SaleableInterface') + $this->saleableItem = $this->getMockBuilder(\Magento\Framework\Pricing\SaleableInterface::class) ->getMockForAbstractClass(); - $this->price = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface') - ->setMethods([ - 'setItem', - ]) + $this->price = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) + ->setMethods(['setItem']) ->getMockForAbstractClass(); - $this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool') + $this->rendererPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class) ->disableOriginalConstructor() ->getMock(); - $this->item = $this->getMockBuilder('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface') + $this->item = $this->getMockBuilder(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class) ->getMockForAbstractClass(); $this->model = new ConfiguredPriceBox( @@ -72,7 +70,7 @@ protected function setUp() public function testSetLayout() { - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->getMockForAbstractClass(); $this->price->expects($this->once()) @@ -81,7 +79,7 @@ public function testSetLayout() ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Wishlist\Pricing\Render\ConfiguredPriceBox', + \Magento\Wishlist\Pricing\Render\ConfiguredPriceBox::class, $this->model->setLayout($layoutMock) ); } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index baac301b5d3be..3a4438c44ade9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -160,7 +160,7 @@ public function tearDown() private function initSubscriber() { $this->subscriber = Bootstrap::getObjectManager()->create( - 'Magento\Newsletter\Model\Subscriber' + \Magento\Newsletter\Model\Subscriber::class ); } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index 5ed716b1f675b..e694b0264298e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -159,7 +159,7 @@ public function testInvalidCustomerUpdate() /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ //$customerTokenService = $this->objectManager->create(CustomerTokenServiceInterface::class); $customerTokenService = Bootstrap::getObjectManager()->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' + \Magento\Integration\Api\CustomerTokenServiceInterface::class ); $token = $customerTokenService->createCustomerAccessToken($firstCustomerData[Customer::EMAIL], 'test@123'); @@ -172,7 +172,7 @@ public function testInvalidCustomerUpdate() $this->dataObjectHelper->populateWithArray( $newCustomerDataObject, $customerData, - '\Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $serviceInfo = [ @@ -185,7 +185,7 @@ public function testInvalidCustomerUpdate() $newCustomerDataObject = $this->dataObjectProcessor->buildOutputDataArray( $newCustomerDataObject, - 'Magento\Customer\Api\Data\CustomerInterface' + \Magento\Customer\Api\Data\CustomerInterface::class ); $requestData = ['customer' => $newCustomerDataObject]; $this->_webApiCall($serviceInfo, $requestData); diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditMemoCreateRefundTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditMemoCreateRefundTest.php index f77c5512c4436..39c8a7bf8fe91 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditMemoCreateRefundTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditMemoCreateRefundTest.php @@ -36,7 +36,7 @@ protected function setUp() public function testInvoke() { /** @var \Magento\Sales\Model\Order $order */ - $orderCollection = $this->objectManager->get('Magento\Sales\Model\ResourceModel\Order\Collection'); + $orderCollection = $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Collection::class); $order = $orderCollection->getFirstItem(); $items = []; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/AddAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/AddAttribute.php index e1c44942c1b04..3ca9c392dad6d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/AddAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/AddAttribute.php @@ -37,7 +37,7 @@ class AddAttribute extends FormSections protected function getTemplateBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Template', + \Magento\Backend\Test\Block\Template::class, ['element' => $this->_rootElement->find($this->addAttributeBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/NewAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/NewAttribute.php index 4bedbb1e3152f..0be96a6273f87 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/NewAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Modal/NewAttribute.php @@ -30,7 +30,7 @@ class NewAttribute extends FormSections protected function getFormPageActionsBlock() { return $this->blockFactory->create( - 'Magento\Backend\Test\Block\FormPageActions', + \Magento\Backend\Test\Block\FormPageActions::class, ['element' => $this->_rootElement->find($this->newAttributeBlock, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/AddProductVideoTest.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/AddProductVideoTest.php index 6f26d25342c17..e0fff16f9cbd5 100644 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/AddProductVideoTest.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/AddProductVideoTest.php @@ -83,7 +83,7 @@ public function test( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); @@ -114,7 +114,7 @@ public function tearDown() { if ($this->configData) { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/DeleteProductVideoTest.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/DeleteProductVideoTest.php index 4228c01578480..63f3fa8f4f49a 100644 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/DeleteProductVideoTest.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/DeleteProductVideoTest.php @@ -85,7 +85,7 @@ public function test( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); @@ -121,7 +121,7 @@ public function tearDown() { if ($this->configData) { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateProductVideoTest.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateProductVideoTest.php index f3820b718c582..b6c4fdc25dc78 100644 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateProductVideoTest.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateProductVideoTest.php @@ -88,7 +88,7 @@ public function test( // Preconditions $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData] )->run(); @@ -124,7 +124,7 @@ public function tearDown() { if ($this->configData) { $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true] )->run(); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php index 762ae8f165035..8f967fb42a88e 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php @@ -219,7 +219,7 @@ public function assertSessionMessages( */ protected function getMessages( $messageType = null, - $messageManagerClass = 'Magento\Framework\Message\Manager' + $messageManagerClass = \Magento\Framework\Message\Manager::class ) { return array_merge( $this->getSessionMessages($messageType, $messageManagerClass), @@ -236,7 +236,7 @@ protected function getMessages( */ protected function getSessionMessages( $messageType = null, - $messageManagerClass = 'Magento\Framework\Message\Manager' + $messageManagerClass = \Magento\Framework\Message\Manager::class ) { /** @var $messageManager \Magento\Framework\Message\ManagerInterface */ $messageManager = $this->_objectManager->get($messageManagerClass); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php index eee9ae3bf50c6..fd4f1e15bf7b3 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php @@ -32,12 +32,12 @@ public function testAll() $block->setLayout($objectManager->get(\Magento\Framework\View\LayoutInterface::class)); $block->setTemplate('Magento_Catalog::product/list/items.phtml'); $block->setType('related'); - $block->addChild('addto', '\Magento\Catalog\Block\Product\ProductList\Item\Container'); + $block->addChild('addto', \Magento\Catalog\Block\Product\ProductList\Item\Container::class); $block->getChildBlock( 'addto' )->addChild( 'compare', - '\Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare', + \Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare::class, ['template' => 'Magento_Catalog::product/list/addto/compare.phtml'] ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/SkuTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/SkuTest.php index 2c1f4c292fef0..88390103a0f48 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/SkuTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/SkuTest.php @@ -45,7 +45,7 @@ public function testGenerateUniqueSkuNotExistingProduct($product) public function testGenerateUniqueLongSku() { $repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\ProductRepository' + \Magento\Catalog\Model\ProductRepository::class ); $product = $repository->get('simple'); $product->setSku('0123456789012345678901234567890123456789012345678901234567890123'); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php index fa0b2567ba87f..17a7aa9a6b1df 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php @@ -24,11 +24,11 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\ResourceModel\Product\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Collection::class ); $this->processor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Indexer\Product\Price\Processor' + \Magento\Catalog\Model\Indexer\Product\Price\Processor::class ); } @@ -42,7 +42,7 @@ public function testAddPriceDataOnSchedule() $this->processor->getIndexer()->setScheduled(true); $this->assertTrue($this->processor->getIndexer()->isScheduled()); $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Catalog\Api\ProductRepositoryInterface'); + ->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var \Magento\Catalog\Api\Data\ProductInterface $product */ $product = $productRepository->get('simple'); $this->assertEquals(10, $product->getPrice()); @@ -61,7 +61,7 @@ public function testAddPriceDataOnSchedule() $this->processor->getIndexer()->reindexList([1]); $this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\ResourceModel\Product\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Collection::class ); $this->collection->addPriceData(0, 1); $this->collection->load(); @@ -86,7 +86,7 @@ public function testAddPriceDataOnSave() $this->processor->getIndexer()->setScheduled(false); $this->assertFalse($this->processor->getIndexer()->isScheduled()); $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Catalog\Api\ProductRepositoryInterface'); + ->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var \Magento\Catalog\Api\Data\ProductInterface $product */ $product = $productRepository->get('simple'); $this->assertNotEquals(15, $product->getPrice()); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php index 7933bf9f89ac4..ed8f12020a977 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php @@ -106,13 +106,13 @@ public function testReindexMultiselectAttribute() ->create(ProductRepositoryInterface::class); /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attr **/ - $attr = Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config') + $attr = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class) ->getAttribute('catalog_product', 'multiselect_attribute'); $attr->setIsFilterable(1)->save(); /** @var $options \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */ $options = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection' + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class ); $options->setAttributeFilter($attr->getId()); $optionIds = $options->getAllIds(); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php b/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php index 7b78046a4e307..7658431c6f378 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php @@ -6,7 +6,7 @@ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Email\Model\Template $template */ -$template = $objectManager->create('Magento\Email\Model\Template'); +$template = $objectManager->create(\Magento\Email\Model\Template::class); $template->setId(1); $template->setOptions(['area' => 'test area', 'store' => 1]); $template->setData( diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php index 606a53acbfd72..97276c02574c9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php @@ -11,13 +11,13 @@ /** @var $installer \Magento\Catalog\Setup\CategorySetup */ $installer = $objectManager->create( - 'Magento\Catalog\Setup\CategorySetup', + \Magento\Catalog\Setup\CategorySetup::class, ['resourceName' => 'catalog_setup'] ); /** @var $selectAttribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ $dateAttribute = $objectManager->create( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); $dateAttribute->setData( [ @@ -35,7 +35,7 @@ $installer->addAttributeToGroup('catalog_product', 'Default', 'General', $dateAttribute->getId()); /** @var $product \Magento\Catalog\Model\Product */ -$product = $objectManager->create('Magento\Catalog\Model\Product'); +$product = $objectManager->create(\Magento\Catalog\Model\Product::class); $product ->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) ->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default')) @@ -49,7 +49,7 @@ ->setStockData(['use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1]) ->save(); -$objectManager->get('Magento\Catalog\Model\Product\Action') +$objectManager->get(\Magento\Catalog\Model\Product\Action::class) ->updateAttributes( [$product->getId()], [ diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute_rollback.php index 2f59c100ca3b1..a973a6649977a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute_rollback.php @@ -7,16 +7,16 @@ /* Create attribute */ /** @var $installer \Magento\Catalog\Setup\CategorySetup */ $installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Setup\CategorySetup', + \Magento\Catalog\Setup\CategorySetup::class, ['resourceName' => 'catalog_setup'] ); -$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); /** @var $product \Magento\Catalog\Model\Product */ -$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); $product = $product->loadByAttribute('sku', 'simple_product_with_date_attribute'); if ($product->getId()) { $product->delete(); @@ -24,7 +24,7 @@ /** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute' + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); $attribute->loadByCode($installer->getEntityTypeId('catalog_product'), 'date_attribute'); if ($attribute->getId()) { diff --git a/dev/tests/integration/testsuite/Magento/GroupedProduct/Pricing/Price/FinalPriceTest.php b/dev/tests/integration/testsuite/Magento/GroupedProduct/Pricing/Price/FinalPriceTest.php index 2b40b621c7180..7b44c2d88dc13 100644 --- a/dev/tests/integration/testsuite/Magento/GroupedProduct/Pricing/Price/FinalPriceTest.php +++ b/dev/tests/integration/testsuite/Magento/GroupedProduct/Pricing/Price/FinalPriceTest.php @@ -18,7 +18,7 @@ class FinalPriceTest extends \PHPUnit_Framework_TestCase public function testFinalPrice() { $productRepository = Bootstrap::getObjectManager() - ->get('\Magento\Catalog\Api\ProductRepositoryInterface'); + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var $product \Magento\Catalog\Model\Product */ $product = $productRepository->get('grouped-product'); @@ -32,7 +32,7 @@ public function testFinalPrice() public function testFinalPriceWithTearPrice() { $productRepository = Bootstrap::getObjectManager() - ->get('\Magento\Catalog\Api\ProductRepositoryInterface'); + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var ProductTierPriceInterface $tierPrice */ $tierPrice = Bootstrap::getObjectManager()->create(ProductTierPriceInterface::class); $tierPrice->setQty(1); @@ -58,7 +58,7 @@ public function testFinalPriceWithTearPrice() public function testFinalPriceWithSpecialPrice() { $productRepository = Bootstrap::getObjectManager() - ->get('\Magento\Catalog\Api\ProductRepositoryInterface'); + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var $simpleProduct \Magento\Catalog\Api\Data\ProductInterface */ $simpleProduct = $productRepository->get('simple'); diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php index 0dfc023c4de37..9200ca259e9e0 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php @@ -28,7 +28,7 @@ public function testEmailConfirmation() { $this->_model->subscribe('customer_confirm@example.com'); $transportBuilder = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\TestFramework\Mail\Template\TransportBuilderMock'); + ->get(\Magento\TestFramework\Mail\Template\TransportBuilderMock::class); // confirmationCode 'ysayquyajua23iq29gxwu2eax2qb6gvy' is taken from fixture $this->assertContains( '/newsletter/subscriber/confirm/id/' . $this->_model->getSubscriberId() diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php index 7315e1dddb6ff..2f6b4f00c61c4 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php @@ -37,7 +37,7 @@ /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ $subscriber = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Newsletter\Model\Subscriber'); + ->create(\Magento\Newsletter\Model\Subscriber::class); $subscriber->setStoreId($currentStore) ->setCustomerId(1) ->setSubscriberEmail('customer_confirm@example.com') diff --git a/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php b/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php index 1daee72615457..c1e92e9054ebc 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php @@ -20,13 +20,13 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Framework\App\AreaList') + $objectManager->get(\Magento\Framework\App\AreaList::class) ->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) ->load(\Magento\Framework\App\Area::PART_CONFIG); - $objectManager->get('Magento\Framework\App\State') + $objectManager->get(\Magento\Framework\App\State::class) ->setAreaCode(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); - $this->model = $objectManager->get('Magento\Theme\Model\Design\Config\Validator'); + $this->model = $objectManager->get(\Magento\Theme\Model\Design\Config\Validator::class); } /** @@ -42,15 +42,16 @@ public function testValidateHasRecursiveReference() 'field' => 'email_header_template' ]; - $designConfigMock = $this->getMockBuilder('Magento\Theme\Api\Data\DesignConfigInterface') + $designConfigMock = $this->getMockBuilder(\Magento\Theme\Api\Data\DesignConfigInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $designConfigExtensionMock = $this->getMockBuilder('Magento\Theme\Api\Data\DesignConfigExtensionInterface') + $designConfigExtensionMock = + $this->getMockBuilder(\Magento\Theme\Api\Data\DesignConfigExtensionInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $designElementMock = $this->getMockBuilder('Magento\Theme\Model\Data\Design\Config\Data') + $designElementMock = $this->getMockBuilder(\Magento\Theme\Model\Data\Design\Config\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -79,15 +80,16 @@ public function testValidateNoRecursiveReference() 'field' => 'email_footer_template' ]; - $designConfigMock = $this->getMockBuilder('Magento\Theme\Api\Data\DesignConfigInterface') + $designConfigMock = $this->getMockBuilder(\Magento\Theme\Api\Data\DesignConfigInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $designConfigExtensionMock = $this->getMockBuilder('Magento\Theme\Api\Data\DesignConfigExtensionInterface') + $designConfigExtensionMock = + $this->getMockBuilder(\Magento\Theme\Api\Data\DesignConfigExtensionInterface::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $designElementMock = $this->getMockBuilder('Magento\Theme\Model\Data\Design\Config\Data') + $designElementMock = $this->getMockBuilder(\Magento\Theme\Model\Data\Design\Config\Data::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php index ce078e9deafb1..fa655b7d987c9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php @@ -70,7 +70,7 @@ public function assertCommandListClassIsNotDirectlyConfigured($file) $xml = simplexml_load_file($file); foreach ($xml->xpath('//type') as $type) { $this->assertNotContains( - 'Magento\Framework\Console\CommandList', + \Magento\Framework\Console\CommandList::class, $type->attributes(), 'Use \Magento\Framework\Console\CommandListInterface instead of \Magento\Framework\Console\CommandList' ); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php index 8595b0924b0b8..6a7fac692f4d0 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php @@ -31,7 +31,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->typeProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\TypeProcessor') + $this->typeProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\TypeProcessor::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php index 94b6afe95b5bb..842802470454b 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php @@ -31,7 +31,7 @@ public function testGenerate() ], // Ensure type declaration is added to argument of setter 'complex_object_attribute_with_type_declaration' => [ - Converter::DATA_TYPE => '\Magento\Bundle\Api\Data\BundleOptionInterface', + Converter::DATA_TYPE => \Magento\Bundle\Api\Data\BundleOptionInterface::class, Converter::RESOURCE_PERMISSIONS => [], ], ], @@ -43,7 +43,7 @@ public function testGenerate() ], ] ); - $typeProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\TypeProcessor') + $typeProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\TypeProcessor::class) ->disableOriginalConstructor() ->setMethods(null) ->getMock(); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php index 59ec0721c9204..055fcfc2a9e66 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php @@ -19,11 +19,11 @@ class DocRootLocatorTest extends \PHPUnit_Framework_TestCase */ public function testIsPub($path, $isExist, $result) { - $request = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $request->expects($this->once())->method('getServer')->willReturn($path); - $reader = $this->getMock('\Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $reader = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $reader->expects($this->any())->method('isExist')->willReturn($isExist); - $readFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $readFactory = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false); $readFactory->expects($this->once())->method('create')->willReturn($reader); $model = new DocRootLocator($request, $readFactory); $this->assertSame($result, $model->isPub()); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php index 5d5f7178ed909..facf71854c575 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php @@ -28,10 +28,11 @@ class GeneratedFilesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); - $writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false); + $this->directoryList = + $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); + $writeFactory = $this->getMock(\Magento\Framework\Filesystem\Directory\WriteFactory::class, [], [], '', false); $this->writeInterface = $this->getMock( - '\Magento\Framework\Filesystem\Directory\WriteInterface', + \Magento\Framework\Filesystem\Directory\WriteInterface::class, [], [], '', diff --git a/lib/internal/Magento/Framework/EntityManager/Test/Unit/MapperTest.php b/lib/internal/Magento/Framework/EntityManager/Test/Unit/MapperTest.php index cf8e204b5f429..498dba3f26b40 100644 --- a/lib/internal/Magento/Framework/EntityManager/Test/Unit/MapperTest.php +++ b/lib/internal/Magento/Framework/EntityManager/Test/Unit/MapperTest.php @@ -15,8 +15,8 @@ class MapperTest extends \PHPUnit_Framework_TestCase public function setUp() { $config = [ - 'Magento\Customer\Api\Data\CustomerInterface' => ['entity_id' => 'id'], - 'Magento\Customer\Api\Data\AddressInterface' => ['parent_id' => 'customer_id', 'invalid' => ''] + \Magento\Customer\Api\Data\CustomerInterface::class => ['entity_id' => 'id'], + \Magento\Customer\Api\Data\AddressInterface::class => ['parent_id' => 'customer_id', 'invalid' => ''] ]; $this->mapper = new \Magento\Framework\EntityManager\Mapper($config); } @@ -32,7 +32,10 @@ public function testEntityToDatabase() $expectedOutput['entity_id'] = 123; unset($expectedOutput['id']); - $actualOutput = $this->mapper->entityToDatabase('Magento\Customer\Api\Data\CustomerInterface', $inputData); + $actualOutput = $this->mapper->entityToDatabase( + \Magento\Customer\Api\Data\CustomerInterface::class, + $inputData + ); $this->assertEquals($expectedOutput, $actualOutput); } @@ -47,7 +50,7 @@ public function testEntityToDatabaseException() 'group_id' => 1, 'extension_attributes' => ['extension_attribute' => ['value' => 'some value']], ]; - $this->mapper->entityToDatabase('Magento\Customer\Api\Data\AddressInterface', $inputData); + $this->mapper->entityToDatabase(\Magento\Customer\Api\Data\AddressInterface::class, $inputData); } public function testDatabaseToEntity() @@ -61,7 +64,10 @@ public function testDatabaseToEntity() $expectedOutput['id'] = 123; unset($expectedOutput['entity_id']); - $actualOutput = $this->mapper->databaseToEntity('Magento\Customer\Api\Data\CustomerInterface', $inputData); + $actualOutput = $this->mapper->databaseToEntity( + \Magento\Customer\Api\Data\CustomerInterface::class, + $inputData + ); $this->assertEquals($expectedOutput, $actualOutput); } @@ -77,6 +83,6 @@ public function testDatabaseToEntityException() 'extension_attributes' => ['extension_attribute' => ['value' => 'some value']], 'invalid' => 123 ]; - $this->mapper->databaseToEntity('Magento\Customer\Api\Data\AddressInterface', $inputData); + $this->mapper->databaseToEntity(\Magento\Customer\Api\Data\AddressInterface::class, $inputData); } } diff --git a/lib/internal/Magento/Framework/EntityManager/Test/Unit/TypeResolverTest.php b/lib/internal/Magento/Framework/EntityManager/Test/Unit/TypeResolverTest.php index 8f09409de7ec6..da84e4b8901c3 100644 --- a/lib/internal/Magento/Framework/EntityManager/Test/Unit/TypeResolverTest.php +++ b/lib/internal/Magento/Framework/EntityManager/Test/Unit/TypeResolverTest.php @@ -25,7 +25,8 @@ class TypeResolverTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->metadataPoolMock = $this->getMock('\Magento\Framework\EntityManager\MetadataPool', [], [], '', false); + $this->metadataPoolMock = + $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); $this->resolver = new \Magento\Framework\EntityManager\TypeResolver($this->metadataPoolMock); } diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php index 7e5569ffaa9f9..173892316cd46 100644 --- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php @@ -77,7 +77,7 @@ private function getNameFinder() { if ($this->nameFinder === null) { $this->nameFinder = \Magento\Framework\App\ObjectManager::getInstance() - ->get('\Magento\Framework\Reflection\NameFinder'); + ->get(\Magento\Framework\Reflection\NameFinder::class); } return $this->nameFinder; } diff --git a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php index 7bfbb7737e1e3..9e1d50ec7ed29 100644 --- a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php @@ -82,7 +82,7 @@ private function getNameFinder() { if ($this->nameFinder === null) { $this->nameFinder = \Magento\Framework\App\ObjectManager::getInstance() - ->get('\Magento\Framework\Reflection\NameFinder'); + ->get(\Magento\Framework\Reflection\NameFinder::class); } return $this->nameFinder; } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index fbaea89e7c256..0ebb6d9be4f3d 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -110,7 +110,7 @@ function () use ($objectManager) { ); /** @var \Magento\Framework\Reflection\NameFinder $nameFinder */ - $nameFinder = $objectManager->getObject('\Magento\Framework\Reflection\NameFinder'); + $nameFinder = $objectManager->getObject(\Magento\Framework\Reflection\NameFinder::class); $serviceInputProcessorReflection = new \ReflectionClass(get_class($this->serviceInputProcessor)); $typeResolverReflection = $serviceInputProcessorReflection->getProperty('nameFinder'); $typeResolverReflection->setAccessible(true); diff --git a/setup/src/Magento/Setup/Model/PackagesData.php b/setup/src/Magento/Setup/Model/PackagesData.php index 4d113728a8b7e..22cb3bc81ff61 100644 --- a/setup/src/Magento/Setup/Model/PackagesData.php +++ b/setup/src/Magento/Setup/Model/PackagesData.php @@ -387,7 +387,7 @@ private function getPackageAvailableVersions($package) ]; $applicationFactory = $this->objectManagerProvider->get() - ->get('Magento\Framework\Composer\MagentoComposerApplicationFactory'); + ->get(\Magento\Framework\Composer\MagentoComposerApplicationFactory::class); /** @var \Magento\Composer\MagentoComposerApplication $application */ $application = $applicationFactory->create(); diff --git a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php index 48f25e3105509..06e8b34471dad 100644 --- a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php +++ b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php @@ -202,8 +202,8 @@ public function checkMemoryLimit() $message = sprintf( 'Your current PHP memory limit is %s. Magento 2 requires it to be set to %s or more. - As a user with root privileges, edit your php.ini file to increase memory_limit. - (The command php --ini tells you where it is located.) + As a user with root privileges, edit your php.ini file to increase memory_limit. + (The command php --ini tells you where it is located.) After that, restart your web server and try again.', $currentMemoryLimit, $minimumRequiredMemoryLimit @@ -217,8 +217,8 @@ public function checkMemoryLimit() $message = sprintf( 'Your current PHP memory limit is %s. We recommend it to be set to %s or more to use Setup Wizard. - As a user with root privileges, edit your php.ini file to increase memory_limit. - (The command php --ini tells you where it is located.) + As a user with root privileges, edit your php.ini file to increase memory_limit. + (The command php --ini tells you where it is located.) After that, restart your web server and try again.', $currentMemoryLimit, $recommendedForUpgradeMemoryLimit 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 63f62a801b103..776dc8128c79c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php @@ -67,7 +67,7 @@ protected function setUp() $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); - $this->generatedFiles = $this->getMock('\Magento\Framework\Code\GeneratedFiles', [], [], '', false); + $this->generatedFiles = $this->getMock(\Magento\Framework\Code\GeneratedFiles::class, [], [], '', false); $objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php index 94cd20c355a7e..efc0d1c561c35 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php @@ -63,11 +63,11 @@ public function setUp() public function testFilePermissionsInstaller() { - $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); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php b/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php index ad63c3873bb56..a415cbe67384d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php @@ -32,14 +32,14 @@ class BasePackageInfoTest extends \PHPUnit_Framework_TestCase public function setup() { $this->readFactoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\ReadFactory', + \Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false ); $this->readerMock = $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/JobSetCacheTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php index af6836d72052b..e45071c845b0b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php @@ -21,20 +21,22 @@ class JobSetCacheTest extends \PHPUnit_Framework_TestCase */ public function testSetCache($commandClass, $arrayInput, $jobName, $params) { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); - $cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', 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); + $cache = $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false); $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); - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); - $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); + $status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); $command = $this->getMock($commandClass, [], [], '', false); $command->expects($this->once()) @@ -46,7 +48,7 @@ public function testSetCache($commandClass, $arrayInput, $jobName, $params) new InputArgument('command', InputArgument::REQUIRED), ]); - $inputDef = $this->getMock('\Symfony\Component\Console\Input\InputDefinition', [], [], '', false); + $inputDef = $this->getMock(\Symfony\Component\Console\Input\InputDefinition::class, [], [], '', false); $inputDef->expects($this->any())->method('hasArgument')->willReturn(true); $command->expects($this->any())->method('getDefinition')->willReturn($inputDef); $command->expects($this->any())->method('setDefinition')->with($definition); @@ -63,8 +65,18 @@ public function setCacheDataProvider() $cacheEnable = new ArrayInput(['command' => 'cache:enable', 'types' => ['cache1']]); $cacheDisable = new ArrayInput(['command' => 'cache:disable']); return [ - ['Magento\Backend\Console\Command\CacheEnableCommand', $cacheEnable, 'setup:cache:enable', ['cache1']], - ['Magento\Backend\Console\Command\CacheDisableCommand', $cacheDisable, 'setup:cache:disable', []], + [ + \Magento\Backend\Console\Command\CacheEnableCommand::class, + $cacheEnable, + 'setup:cache:enable', + ['cache1'] + ], + [ + \Magento\Backend\Console\Command\CacheDisableCommand::class, + $cacheDisable, + 'setup:cache:disable', + [] + ], ]; } } 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 b6503e3eef018..474127d84c342 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/StatusTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/StatusTest.php @@ -47,8 +47,9 @@ public function setUp() $this->filesystem->expects($this->once()) ->method('getDirectoryWrite') ->will($this->returnValue($this->varReaderWriter)); - $this->logger = $this->getMockForAbstractClass('\Psr\Log\LoggerInterface', [], '', false); - $this->setupLoggerFactory = $this->getMock('\Magento\Setup\Model\Cron\SetupLoggerFactory', [], [], '', false); + $this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class, [], '', false); + $this->setupLoggerFactory = + $this->getMock(\Magento\Setup\Model\Cron\SetupLoggerFactory::class, [], [], '', false); $this->setupLoggerFactory ->expects($this->once()) ->method('create') diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PackagesAuthTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PackagesAuthTest.php index 405262440a49f..c62d3a96a3f1b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PackagesAuthTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PackagesAuthTest.php @@ -30,7 +30,7 @@ class PackagesAuthTest extends \PHPUnit_Framework_TestCase public function setUp() { - $zendServiceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface', [], [], '', false); + $zendServiceLocator = $this->getMock(\Zend\ServiceManager\ServiceLocatorInterface::class, [], [], '', false); $zendServiceLocator ->expects($this->any()) ->method('get') @@ -40,8 +40,8 @@ public function setUp() 'check_credentials_url' => 'some_url' ] ]); - $this->curl = $this->getMock('Magento\Framework\HTTP\Client\Curl', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->curl = $this->getMock(\Magento\Framework\HTTP\Client\Curl::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->packagesAuth = new PackagesAuth($zendServiceLocator, $this->curl, $this->filesystem); } @@ -59,7 +59,7 @@ public function testCheckCredentials() $this->curl->expects($this->once())->method('setCredentials')->with('username', 'password'); $this->curl->expects($this->once())->method('getStatus')->willReturn(200); $this->curl->expects($this->once())->method('getBody')->willReturn("{'someJson'}"); - $directory = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $directory = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directory)); $directory->expects($this->once()) ->method('writeFile') @@ -84,8 +84,8 @@ public function testCheckCredentialsActionWithException() public function testRemoveCredentials() { - $directoryWrite = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); - $directoryRead = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $directoryWrite = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); + $directoryRead = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->filesystem->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($directoryRead)); $this->filesystem->expects($this->once()) ->method('getDirectoryWrite') @@ -104,7 +104,7 @@ public function testRemoveCredentials() public function testSaveAuthJson() { - $directoryWrite = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $directoryWrite = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->filesystem->expects($this->once()) ->method('getDirectoryWrite') ->will($this->returnValue($directoryWrite)); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php index 3c096fa1faf6f..ba4f2ffec9478 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php @@ -20,7 +20,8 @@ class PackagesDataTest extends \PHPUnit_Framework_TestCase public function setUp() { - $composerInformation = $this->getMock('\Magento\Framework\Composer\ComposerInformation', [], [], '', false); + $composerInformation = + $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, [], [], '', false); $composerInformation->expects($this->any())->method('getInstalledMagentoPackages')->willReturn( [ ['name' => 'magento/package-1', 'type' => 'magento2-module', 'version'=> '1.0.0'], @@ -30,33 +31,33 @@ public function setUp() $composerInformation->expects($this->any())->method('getRootRepositories')->willReturn(['repo1', 'repo2']); $composerInformation->expects($this->any())->method('getPackagesTypes')->willReturn(['magento2-module']); - $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); - $packagesAuth = $this->getMock('\Magento\Setup\Model\PackagesAuth', [], [], '', false); - $filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); - $objectManagerProvider = $this->getMock('\Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManagerInterface'); + $packagesAuth = $this->getMock(\Magento\Setup\Model\PackagesAuth::class, [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $applicationFactory = $this->getMock( - '\Magento\Framework\Composer\MagentoComposerApplicationFactory', + \Magento\Framework\Composer\MagentoComposerApplicationFactory::class, [], [], '', false ); - $application = $this->getMock('\Magento\Composer\MagentoComposerApplication', [], [], '', false); + $application = $this->getMock(\Magento\Composer\MagentoComposerApplication::class, [], [], '', false); $application->expects($this->any()) ->method('runComposerCommand') ->willReturn('versions: 2.0.1'); $applicationFactory->expects($this->any())->method('create')->willReturn($application); $objectManager->expects($this->any()) ->method('get') - ->with('Magento\Framework\Composer\MagentoComposerApplicationFactory') + ->with( \Magento\Framework\Composer\MagentoComposerApplicationFactory::class) ->willReturn($applicationFactory); $objectManagerProvider->expects($this->any())->method('get')->willReturn($objectManager); - $directoryWrite = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); - $directoryRead = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + $directoryWrite = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); + $directoryRead = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $filesystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($directoryRead)); $filesystem->expects($this->any()) ->method('getDirectoryWrite') diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php index cd749cc66a3e9..2b1d8529d7818 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php @@ -22,7 +22,7 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); + $this->fullModuleList = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); $this->model = new PayloadValidator($this->fullModuleList); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php index e4539b8883bca..95f3b7eb772cb 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php @@ -33,10 +33,11 @@ class UpdaterTaskCreatorTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false); - $this->objectManagerProvider = $this->getMock('\Magento\Setup\Model\ObjectManagerProvider', [], [], '', 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->objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->navigation = $this->getMock(\Magento\Setup\Model\Navigation::class, [], [], '', false); $this->model = new UpdaterTaskCreator( $this->filesystem, $this->navigation, @@ -59,11 +60,16 @@ public function setUp() */ public function testCreateUpdaterTasks($payload) { - $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'); - $cacheManager = $this->getMock('\Magento\Framework\App\Cache\Manager', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManagerInterface'); + $cacheManager = $this->getMock(\Magento\Framework\App\Cache\Manager::class, [], [], '', false); + $objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManager->expects($this->once())->method('get')->willReturn($cacheManager); $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); From e762e485da3adffd10ee743421391e4c327a5a18 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 19 Jul 2016 09:01:46 +0300 Subject: [PATCH 21/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Customer/Api/AccountManagementCustomAttributesTest.php | 2 +- .../Magento/Customer/Api/AccountManagementMeTest.php | 2 +- .../testsuite/Magento/Customer/Api/AccountManagementTest.php | 4 ++-- .../testsuite/Magento/Customer/Api/CustomerRepositoryTest.php | 2 +- .../testsuite/Magento/Integration/Model/IntegrationTest.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php index 3f897786232d9..f1fe32db175e5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php @@ -103,7 +103,7 @@ public function tearDown() $this->assertTrue($response); } } - unset($this->accountManagement); + $this->accountManagement = null; $mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA); $mediaDirectory->delete(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php index 0b6dd9d6b9ba3..5ae3d2837d18a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php @@ -94,7 +94,7 @@ public function setUp() */ public function tearDown() { - unset($this->customerRepository); + $this->customerRepository = null; /** @var \Magento\Framework\Registry $registry */ $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index 3a4438c44ade9..b426d9e2a1b4e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -154,8 +154,8 @@ public function tearDown() $this->configValue ); $this->config->save(); - unset($this->accountManagement); - unset($this->subscriber); + $this->accountManagement = null; + $this->subscriber = null; } private function initSubscriber() { diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index e694b0264298e..f74c3e565e010 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -139,7 +139,7 @@ public function tearDown() $this->assertTrue($response); } } - unset($this->customerRepository); + $this->customerRepository = null; } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php index 7585c704e37c0..8cd113e517ec2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php @@ -31,7 +31,7 @@ protected function setUp() protected function tearDown() { - unset($this->integration); + $this->integration = null; OauthHelper::clearApiAccessCredentials(); parent::tearDown(); } From e0b3a4fd8afcaef1b3d98eaf2bf8170c632e076f Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 19 Jul 2016 15:23:11 +0300 Subject: [PATCH 22/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Test/Unit/Controller/Block/EsiTest.php | 11 +++----- .../Test/Unit/Controller/Block/RenderTest.php | 23 +++++++--------- .../Payment/Test/Unit/Block/Info/CcTest.php | 6 ++--- .../Payment/Test/Unit/Block/InfoTest.php | 10 +++---- .../Test/Unit/Model/Method/FreeTest.php | 5 ++-- .../Paypal/Test/Unit/Model/Api/NvpTest.php | 22 ++++++++------- .../Test/TestCase/MassOrdersUpdateTest.php | 2 +- .../Framework/App/Cache/Frontend/Factory.php | 4 +-- .../Test/Unit/Tree/Node/CollectionTest.php | 2 +- .../Filter/Test/Unit/TemplateTest.php | 4 +-- .../Test/Unit/Code/InterfaceValidatorTest.php | 27 +++++++++++++------ .../Framework/Locale/TranslatedLists.php | 3 +-- .../Module/Setup/MigrationFactory.php | 6 +++-- .../Framework/Mview/Test/Unit/ViewTest.php | 2 +- .../Framework/Test/Unit/ObjectTest.php | 4 +-- .../Unit/Unit/Helper/ProxyTestingTest.php | 4 +-- .../Translate/Test/Unit/AdapterTest.php | 2 +- .../Framework/Webapi/ErrorProcessor.php | 2 +- 18 files changed, 72 insertions(+), 67 deletions(-) diff --git a/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php b/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php index b218237197955..294f91b8fa50b 100644 --- a/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php @@ -50,17 +50,15 @@ protected function setUp() ->disableOriginalConstructor()->getMock(); $contextMock = - $this->getMockBuilder( - \Magento\Framework\App\Action\Context::class)->disableOriginalConstructor()->getMock( - ); + $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) + ->disableOriginalConstructor()->getMock(); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class) ->disableOriginalConstructor()->getMock(); - $this->viewMock = $this->getMockBuilder( - \Magento\Framework\App\View::class)->disableOriginalConstructor()->getMock( - ); + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class) + ->disableOriginalConstructor()->getMock(); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); @@ -88,7 +86,6 @@ public function testExecute($blockClass, $shouldSetHeaders) $mapData = [['blocks', '', json_encode([$block])], ['handles', '', json_encode($handles)]]; $blockInstance1 = $this->getMock( - $blockClass, ['toHtml'], [], diff --git a/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php b/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php index c734851abbe1c..162c84ced9ae5 100644 --- a/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php @@ -46,24 +46,21 @@ class RenderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMockBuilder( + $this->layoutMock = $this->getMockBuilder( \Magento\Framework\View\Layout::class )->disableOriginalConstructor()->getMock(); - $contextMock = - $this->getMockBuilder( - \Magento\Framework\App\Action\Context::class)->disableOriginalConstructor()->getMock( - ); + $contextMock = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) + ->disableOriginalConstructor()->getMock(); - $this->requestMock = $this->getMockBuilder( + $this->requestMock = $this->getMockBuilder( \Magento\Framework\App\Request\Http::class )->disableOriginalConstructor()->getMock(); - $this->responseMock = $this->getMockBuilder( + $this->responseMock = $this->getMockBuilder( \Magento\Framework\App\Response\Http::class )->disableOriginalConstructor()->getMock(); - $this->viewMock = $this->getMockBuilder( - \Magento\Framework\App\View::class)->disableOriginalConstructor()->getMock( - ); + $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class) + ->disableOriginalConstructor()->getMock(); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); @@ -72,7 +69,7 @@ protected function setUp() $this->translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class); $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->action = $helperObjectManager->getObject( + $this->action = $helperObjectManager->getObject( \Magento\PageCache\Controller\Block\Render::class, ['context' => $contextMock, 'translateInline' => $this->translateInline] ); @@ -110,7 +107,7 @@ public function testExecute() $originalRequest = '{"route":"route","controller":"controller","action":"action","uri":"uri"}'; $expectedData = ['block1' => 'data1', 'block2' => 'data2']; - $blockInstance1 = $this->getMock( + $blockInstance1 = $this->getMock( \Magento\PageCache\Test\Unit\Block\Controller\StubBlock::class, ['toHtml'], [], @@ -119,7 +116,7 @@ public function testExecute() ); $blockInstance1->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block1'])); - $blockInstance2 = $this->getMock( + $blockInstance2 = $this->getMock( \Magento\PageCache\Test\Unit\Block\Controller\StubBlock::class, ['toHtml'], [], diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php index 08f667eec9657..3d75aaa39be34 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php @@ -93,8 +93,7 @@ public function testHasCcExpDate($ccExpMonth, $ccExpYear, $expected) { $paymentInfo = $this->getMock( \Magento\Payment\Model\Info::class, - ['getCcExpMonth', - 'getCcExpYear'], + ['getCcExpMonth', 'getCcExpYear'], [], '', false @@ -152,8 +151,7 @@ public function testGetCcExpDate($ccExpMonth, $ccExpYear) { $paymentInfo = $this->getMock( \Magento\Payment\Model\Info::class, - ['getCcExpMonth', - 'getCcExpYear'], + ['getCcExpMonth', 'getCcExpYear'], [], '', false diff --git a/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php b/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php index 61279d551d02f..6799e2156200f 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php @@ -73,9 +73,8 @@ public function testGetIsSecureMode($isSecureMode, $methodInstance, $store, $sto $this->_storeManager->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); } - $paymentInfo = $this->getMockBuilder( - \Magento\Payment\Model\Info::class - )->disableOriginalConstructor()->getMock(); + $paymentInfo = $this->getMockBuilder(\Magento\Payment\Model\Info::class) + ->disableOriginalConstructor()->getMock(); $paymentInfo->expects($this->any())->method('getMethodInstance')->will($this->returnValue($methodInstance)); $this->_object->setData('info', $paymentInfo); @@ -133,9 +132,8 @@ public function testGetInfoThrowException() public function testGetSpecificInformation() { - $paymentInfo = $this->getMockBuilder( - \Magento\Payment\Model\Info::class - )->disableOriginalConstructor()->getMock(); + $paymentInfo = $this->getMockBuilder(\Magento\Payment\Model\Info::class) + ->disableOriginalConstructor()->getMock(); $this->_object->setData('info', $paymentInfo); $this->_object->getSpecificInformation(); diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php index 4c9d6fd6fcdb1..2dc274aa089f9 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php @@ -32,9 +32,8 @@ protected function setUp() '', false ); - $this->currencyPrice = $this->getMockBuilder( - \Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock( - ); + $this->currencyPrice = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) + ->getMock(); $context = $this->getMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher'], [], '', false); $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php index b4eac27135c6f..12251ff32cef5 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php @@ -59,7 +59,7 @@ protected function setUp() $this->resolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); $this->regionFactory = $this->getMock(\Magento\Directory\Model\RegionFactory::class, [], [], '', false); $this->countryFactory = $this->getMock(\Magento\Directory\Model\CountryFactory::class, [], [], '', false); - $processableExceptionFactory = $this->getMock( + $processableExceptionFactory = $this->getMock( \Magento\Paypal\Model\Api\ProcessableExceptionFactory::class, ['create'], [], @@ -69,14 +69,14 @@ protected function setUp() $processableExceptionFactory->expects($this->any()) ->method('create') ->will($this->returnCallback(function ($arguments) { - $this->processableException = $this->getMock( + $this->processableException = $this->getMock( \Magento\Paypal\Model\Api\ProcessableException::class, null, [$arguments['phrase'], null, $arguments['code']] ); return $this->processableException; })); - $exceptionFactory = $this->getMock( + $exceptionFactory = $this->getMock( \Magento\Framework\Exception\LocalizedExceptionFactory::class, ['create'], [], @@ -86,7 +86,7 @@ protected function setUp() $exceptionFactory->expects($this->any()) ->method('create') ->will($this->returnCallback(function ($arguments) { - $this->exception = $this->getMock( + $this->exception = $this->getMock( \Magento\Framework\Exception\LocalizedException::class, null, [$arguments['phrase']] @@ -99,7 +99,7 @@ protected function setUp() $this->config = $this->getMock(\Magento\Paypal\Model\Config::class, [], [], '', false); $helper = new ObjectManagerHelper($this); - $this->model = $helper->getObject( + $this->model = $helper->getObject( \Magento\Paypal\Model\Api\Nvp::class, [ 'customerAddress' => $this->customerAddressHelper, @@ -158,26 +158,30 @@ public function callDataProvider() ['', [], null], [ "\r\n" . 'ACK=Failure&L_ERRORCODE0=10417&L_SHORTMESSAGE0=Message.&L_LONGMESSAGE0=Long%20Message.', - [], \Magento\Framework\Exception\LocalizedException::class, + [], + \Magento\Framework\Exception\LocalizedException::class, 'PayPal gateway has rejected request. Long Message (#10417: Message).', 0 ], [ "\r\n" . 'ACK=Failure&L_ERRORCODE0=10417&L_SHORTMESSAGE0=Message.&L_LONGMESSAGE0=Long%20Message.', - [10417, 10422], \Magento\Paypal\Model\Api\ProcessableException::class, + [10417, 10422], + \Magento\Paypal\Model\Api\ProcessableException::class, 'PayPal gateway has rejected request. Long Message (#10417: Message).', 10417 ], [ "\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10417' . '&L_SHORTMESSAGE0[8]=Message.&L_LONGMESSAGE0[15]=Long%20Message.', - [10417, 10422], \Magento\Paypal\Model\Api\ProcessableException::class, + [10417, 10422], + \Magento\Paypal\Model\Api\ProcessableException::class, 'PayPal gateway has rejected request. Long Message (#10417: Message).', 10417 ], [ "\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10417&L_SHORTMESSAGE0[8]=Message.', - [10417, 10422], \Magento\Paypal\Model\Api\ProcessableException::class, + [10417, 10422], + \Magento\Paypal\Model\Api\ProcessableException::class, 'PayPal gateway has rejected request. #10417: Message.', 10417 ], diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php index 2b1b3142901b7..5735c26625106 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php @@ -116,7 +116,7 @@ protected function processSteps(OrderInjectable $order, $steps) foreach ($steps as $step) { $action = str_replace(' ', '', ucwords($step)); $methodAction = (($action != 'OnHold') ? 'Create' : '') . $action . 'Step'; - $path = \Magento\Sales\Test\TestStep::class; + $path = 'Magento\Sales\Test\TestStep'; $processStep = $this->objectManager->create($path . '\\' . $methodAction, ['order' => $order]); $processStep->run(); } diff --git a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php index 54c2ed5c1708b..6a8b639f85364 100644 --- a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php +++ b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php @@ -244,7 +244,7 @@ protected function _getBackendOptions(array $cacheOptions) } break; case 'apc': - if (extension_loaded('apc') && ini_get(\apc.enabled::class)) { + if (extension_loaded('apc') && ini_get('apc.enabled')) { $enableTwoLevels = true; $backendType = 'Apc'; } @@ -257,7 +257,7 @@ protected function _getBackendOptions(array $cacheOptions) break; case 'eaccelerator': case 'varien_cache_backend_eaccelerator': - if (extension_loaded('eaccelerator') && ini_get(\eaccelerator.enable::class)) { + if (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) { $enableTwoLevels = true; $backendType = \Magento\Framework\Cache\Backend\Eaccelerator::class; } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php index 6303ceb334a40..5b87bef16422c 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Tree/Node/CollectionTest.php @@ -40,7 +40,7 @@ public function testOffsets() $this->assertSame($this->collection->offsetExists('node1'), true); $this->collection->offsetSet('node1', 'Hello'); $this->assertSame($this->collection->offsetExists('node1'), true); - $this->assertSame($this->collection->offsetget(\node1::class), 'Hello'); + $this->assertSame($this->collection->offsetget('node1'), 'Hello'); $this->collection->offsetUnset('node1'); $this->assertSame($this->collection->offsetExists('node1'), false); } diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php index 0bd5d176aa7c4..cd61e7ddf60ac 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php @@ -80,7 +80,7 @@ public function testAfterFilter() $expectedResult = 'TEST STRING'; // Build arbitrary object to pass into the addAfterFilterCallback method - $callbackObject = $this->getMockBuilder(\stdObject::class) + $callbackObject = $this->getMockBuilder('stdObject') ->setMethods(['afterFilterCallbackMethod']) ->getMock(); @@ -108,7 +108,7 @@ public function testAfterFilterCallbackReset() $expectedResult = 'TEST STRING'; // Build arbitrary object to pass into the addAfterFilterCallback method - $callbackObject = $this->getMockBuilder(\stdObject::class) + $callbackObject = $this->getMockBuilder('stdObject') ->setMethods(['afterFilterCallbackMethod']) ->getMock(); diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php index 8760f84b59212..fb9a63c5c09e7 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php @@ -25,7 +25,11 @@ class InterfaceValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->argumentsReaderMock = $this->getMock( - \Magento\Framework\Code\Reader\ArgumentsReader::class, [], [], '', false + \Magento\Framework\Code\Reader\ArgumentsReader::class, + [], + [], + '', + false ); $this->argumentsReaderMock->expects($this->any())->method('isCompatibleType') @@ -47,7 +51,8 @@ protected function setUp() public function testValidate() { $this->model->validate( - \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ValidPlugin::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ValidPlugin::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class ); } @@ -59,7 +64,8 @@ public function testValidate() public function testValidateIncorrectInterface() { $this->model->validate( - \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncompatibleInterface::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncompatibleInterface::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -71,7 +77,8 @@ public function testValidateIncorrectInterface() public function testValidateIncorrectSubjectType() { $this->model->validate( - \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncorrectSubject::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncorrectSubject::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -85,7 +92,8 @@ public function testValidateIncompatibleMethodArgumentsCount() { $this->model->validate( \Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class - . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsCount', \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class + . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsCount', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -99,7 +107,8 @@ public function testValidateIncompatibleMethodArgumentsType() { $this->model->validate( \Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class - . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsType', \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class + . '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsType', + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class ); } @@ -111,7 +120,8 @@ public function testValidateIncompatibleMethodArgumentsType() public function testValidateExtraParameters() { $this->model->validate( - \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ExtraParameters::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ExtraParameters::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } @@ -123,7 +133,8 @@ public function testValidateExtraParameters() public function testValidateInvalidProceed() { $this->model->validate( - \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\InvalidProceed::class, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\InvalidProceed::class, + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class ); } } diff --git a/lib/internal/Magento/Framework/Locale/TranslatedLists.php b/lib/internal/Magento/Framework/Locale/TranslatedLists.php index 17d2a1399a50b..a9724176f198e 100644 --- a/lib/internal/Magento/Framework/Locale/TranslatedLists.php +++ b/lib/internal/Magento/Framework/Locale/TranslatedLists.php @@ -125,8 +125,7 @@ public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false) $options = []; $days = (new DataBundle()) ->get($this->localeResolver->getLocale())['calendar']['gregorian']['dayNames']['format']['wide'] ?: []; - $englishDays = (new DataBundle())->get( - \en_US::class)['calendar']['gregorian']['dayNames']['format']['abbreviated']; + $englishDays = (new DataBundle())->get('en_US')['calendar']['gregorian']['dayNames']['format']['abbreviated']; foreach ($days as $code => $name) { $code = $preserveCodes ? $englishDays[$code] : $code; $options[] = ['label' => $name, 'value' => $ucFirstCode ? ucfirst($code) : $code]; diff --git a/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php b/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php index 4fd60a6654585..dd8067278728e 100644 --- a/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php +++ b/lib/internal/Magento/Framework/Module/Setup/MigrationFactory.php @@ -33,8 +33,10 @@ class MigrationFactory * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param string $instanceName */ - public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = \Magento\Framework\Module\Setup\Migration::class) - { + public function __construct( + \Magento\Framework\ObjectManagerInterface $objectManager, + $instanceName = \Magento\Framework\Module\Setup\Migration::class + ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; } diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php index b5eef1b5e1ba6..cf17286af0e9e 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php @@ -336,7 +336,7 @@ public function testUpdate() $this->returnValue($listId) ); - $actionMock = $this->getMock(\Magento\Framework\Mview\ActionInterface::class, ['execute'], [], '', false); + $actionMock = $this->getMock(\Magento\Framework\Mview\ActionInterface::class); $actionMock->expects($this->once())->method('execute')->with($listId)->will($this->returnSelf()); $this->actionFactoryMock->expects( $this->once() diff --git a/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php b/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php index c11eea303c2e5..c61b851356d55 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ObjectTest.php @@ -346,8 +346,8 @@ public function testOffset() $this->assertTrue($this->_object->offsetExists('key1')); $this->assertFalse($this->_object->offsetExists('key2')); - $this->assertEquals('value1', $this->_object->offsetget(\key1::class)); - $this->assertNull($this->_object->offsetget(\key2::class)); + $this->assertEquals('value1', $this->_object->offsetGet('key1')); + $this->assertNull($this->_object->offsetGet('key2')); $this->_object->offsetUnset('key1'); $this->assertFalse($this->_object->offsetExists('key1')); } diff --git a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php index 83cc52c3cf200..148aa72a94613 100644 --- a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php +++ b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ProxyTestingTest.php @@ -30,14 +30,14 @@ public function testInvokeWithExpectations( $expectedResult ) { // Create proxied object with $callProxiedMethod - $proxiedObject = $this->getMock(\stdClass::class, [$callProxiedMethod]); + $proxiedObject = $this->getMock('stdClass', [$callProxiedMethod]); // Create object, which reacts on called $method by calling $callProxiedMethod from proxied object $callProxy = function () use ($proxiedObject, $callProxiedMethod, $passProxiedParams) { return call_user_func_array([$proxiedObject, $callProxiedMethod], $passProxiedParams); }; - $object = $this->getMock(\stdClass::class, [$method]); + $object = $this->getMock('stdClass', [$method]); $builder = $object->expects($this->once())->method($method); call_user_func_array([$builder, 'with'], $params); $builder->will($this->returnCallback($callProxy)); diff --git a/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php b/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php index 992ee64f0d1ce..acfd8b5b324c2 100644 --- a/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php +++ b/lib/internal/Magento/Framework/Translate/Test/Unit/AdapterTest.php @@ -17,7 +17,7 @@ class AdapterTest extends \PHPUnit_Framework_TestCase */ public function testTranslate($method, $strToTranslate, $translatedStr) { - $translatorMock = $this->getMockBuilder(\stdClass::class)->setMethods(['translate'])->getMock(); + $translatorMock = $this->getMockBuilder('stdClass')->setMethods(['translate'])->getMock(); $translatorMock->expects( $this->once() )->method( diff --git a/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php b/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php index 14be2dbb313e3..b3e01634347d2 100644 --- a/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php @@ -306,7 +306,7 @@ public function apiShutdownFunction() */ protected function _saveFatalErrorReport($reportData) { - $this->directoryWrite->create(\report/api::class); + $this->directoryWrite->create('report/api'); $reportId = abs(intval(microtime(true) * rand(100, 1000))); $this->directoryWrite->writeFile('report/api/' . $reportId, serialize($reportData)); return $reportId; From f171da37327ed188e8384bca3749761781cf45a3 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Wed, 20 Jul 2016 16:37:41 +0300 Subject: [PATCH 23/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Backend/Test/Unit/Model/MenuTest.php | 10 ++--- .../Model/Product/Gallery/CreateHandler.php | 2 +- .../Controller/Adminhtml/Index/SaveTest.php | 6 +-- .../Db/VersionControl/AddressSnapshotTest.php | 4 +- .../Test/Unit/Block/Checkout/ShippingTest.php | 38 +++++++++---------- .../Block/Adminhtml/Template/Edit.php | 29 +++++++++----- ...ogProductCompareAddProductObserverTest.php | 3 +- .../CatalogProductViewObserverTest.php | 3 +- .../Observer/CustomerLoginObserverTest.php | 6 +-- .../Observer/CustomerLogoutObserverTest.php | 3 +- .../Block/Adminhtml/Order/Create/Form.php | 2 +- .../Shipment/AbstractShipment/PrintAction.php | 2 +- .../Magento/Sales/Model/AdminOrder/Create.php | 4 +- .../Magento/Sales/Model/Convert/Order.php | 2 +- .../Sales/Model/Order/CustomerManagement.php | 4 +- .../Model/Order/Pdf/Total/FactoryTest.php | 2 +- .../Adminhtml/Term/ExportSearchExcel.php | 2 +- app/code/Magento/Usps/Model/Carrier.php | 13 +++---- .../Vault/Model/PaymentTokenManagement.php | 2 +- .../Ui/Adminhtml/TokensConfigProvider.php | 2 +- .../Dependency/Parser/Config/XmlTest.php | 4 +- 21 files changed, 71 insertions(+), 72 deletions(-) diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php index 1255915f751c3..c985bec92074a 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php @@ -115,9 +115,9 @@ public function testGetRecursive() $this->_items['item3']->expects($this->any())->method('hasChildren')->will($this->returnValue(false)); $menu2->add($this->_items['item3']); - $this->assertEquals($this->_items['item1'], $this->_model->get(\item1::class)); - $this->assertEquals($this->_items['item2'], $this->_model->get(\item2::class)); - $this->assertEquals($this->_items['item3'], $this->_model->get(\item3::class)); + $this->assertEquals($this->_items['item1'], $this->_model->get('item1')); + $this->assertEquals($this->_items['item2'], $this->_model->get('item2')); + $this->assertEquals($this->_items['item3'], $this->_model->get('item3')); } public function testMove() @@ -170,11 +170,11 @@ public function testRemoveRemovesMenuItem() $this->_model->add($this->_items['item1']); $this->assertCount(1, $this->_model); - $this->assertEquals($this->_items['item1'], $this->_model->get(\item1::class)); + $this->assertEquals($this->_items['item1'], $this->_model->get('item1')); $this->_model->remove('item1'); $this->assertCount(0, $this->_model); - $this->assertNull($this->_model->get(\item1::class)); + $this->assertNull($this->_model->get('item1')); } public function testRemoveRemovesMenuItemRecursively() diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php index bf03eecbb6607..ada156f571b0e 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php @@ -194,7 +194,7 @@ public function getAttribute() { if (!$this->attribute) { $this->attribute = $this->attributeRepository->get( - \media_gallery::class + 'media_gallery' ); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php index dac67b7cf3b1c..8fb48fe9f87e7 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php @@ -161,8 +161,7 @@ protected function setUp() ->getMock(); $this->resultForwardFactoryMock = $this->getMockBuilder( \Magento\Backend\Model\View\Result\ForwardFactory::class - ) - ->disableOriginalConstructor() + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->resultForwardMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class) @@ -194,8 +193,7 @@ protected function setUp() ->getMock(); $this->customerDataFactoryMock = $this->getMockBuilder( \Magento\Customer\Api\Data\CustomerInterfaceFactory::class - ) - ->disableOriginalConstructor() + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php index 6ccce8857634d..e2de4e7e7d5c4 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php @@ -23,9 +23,7 @@ protected function setUp() { $this->metadataMock = $this->getMockBuilder( \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata::class - ) - ->disableOriginalConstructor() - ->getMock(); + )->disableOriginalConstructor()->getMock(); $this->model = new AddressSnapshot( $this->metadataMock diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php index 43b384a7484bc..72e6ebe356c4a 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/ShippingTest.php @@ -42,19 +42,19 @@ class ShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfigMock = $this->getMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - [], - [], - '', - false + $this->scopeConfigMock = $this->getMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + [], + [], + '', + false ); $this->multiShippingMock = $this->getMock(\Magento\Multishipping\Model\Checkout\Type\Multishipping::class, [], [], '', false); $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class, [], [], '', false); $this->taxHelperMock = $this->getMock(\Magento\Tax\Helper\Data::class, [], [], '', false); - $this->model = $objectManager->getObject( + $this->model = $objectManager->getObject( \Magento\Multishipping\Block\Checkout\Shipping::class, [ 'multishipping' => $this->multiShippingMock, @@ -76,7 +76,7 @@ public function testGetAddresses() public function testGetAddressShippingMethod() { - $addressMock = $this->getMock( + $addressMock = $this->getMock( \Magento\Quote\Model\Quote\Address::class, ['getShippingMethod', '__wakeup'], [], @@ -90,7 +90,7 @@ public function testGetAddressShippingMethod() public function testGetShippingRates() { - $addressMock = $this->getMock( + $addressMock = $this->getMock( \Magento\Quote\Model\Quote\Address::class, ['getGroupedAllShippingRates', '__wakeup'], [], @@ -107,11 +107,10 @@ public function testGetCarrierName() { $carrierCode = 'some carrier code'; $name = 'some name'; - $this->scopeConfigMock->expects($this->once())->method('getValue')->with('carriers/' . $carrierCode . '/title', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will($this->returnValue($name - ) - ); + $this->scopeConfigMock->expects($this->once())->method('getValue')->with( + 'carriers/' . $carrierCode . '/title', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will($this->returnValue($name)); $this->assertEquals($name, $this->model->getCarrierName($carrierCode)); } @@ -119,18 +118,17 @@ public function testGetCarrierName() public function testGetCarrierNameWithEmptyName() { $carrierCode = 'some carrier code'; - $this->scopeConfigMock->expects($this->once())->method('getValue')->with('carriers/' . $carrierCode . '/title', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will($this->returnValue(null - ) - ); + $this->scopeConfigMock->expects($this->once())->method('getValue')->with( + 'carriers/' . $carrierCode . '/title', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will($this->returnValue(null)); $this->assertEquals($carrierCode, $this->model->getCarrierName($carrierCode)); } public function testGetShippingPrice() { - $addressMock = $this->getMock( + $addressMock = $this->getMock( \Magento\Quote\Model\Quote\Address::class, ['getQuote', '__wakeup'], [], diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php index 5f0664f72866a..4e55d61f92ae5 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php @@ -72,7 +72,8 @@ protected function _prepareLayout() // } $this->getToolbar()->addChild( - 'back_button', \Magento\Backend\Block\Widget\Button::class, + 'back_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Back'), 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'", @@ -81,7 +82,8 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( - 'reset_button', \Magento\Backend\Block\Widget\Button::class, + 'reset_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Reset'), 'onclick' => 'window.location.href = window.location.href', @@ -91,7 +93,8 @@ protected function _prepareLayout() if (!$this->isTextType()) { $this->getToolbar()->addChild( - 'to_plain_button', \Magento\Backend\Block\Widget\Button::class, + 'to_plain_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Convert to Plain Text'), 'data_attribute' => [ @@ -103,7 +106,8 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( - 'to_html_button', \Magento\Backend\Block\Widget\Button::class, + 'to_html_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Return HTML Version'), 'data_attribute' => [ @@ -117,7 +121,8 @@ protected function _prepareLayout() } $this->getToolbar()->addChild( - 'preview_button', \Magento\Backend\Block\Widget\Button::class, + 'preview_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Preview Template'), 'data_attribute' => [ @@ -129,7 +134,8 @@ protected function _prepareLayout() if ($this->getEditMode()) { $this->getToolbar()->addChild( - 'delete_button', \Magento\Backend\Block\Widget\Button::class, + 'delete_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Delete Template'), 'data_attribute' => [ @@ -140,7 +146,8 @@ protected function _prepareLayout() ); $this->getToolbar()->addChild( - 'save_as_button', \Magento\Backend\Block\Widget\Button::class, + 'save_as_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save As'), 'data_attribute' => [ @@ -152,7 +159,8 @@ protected function _prepareLayout() } $this->getToolbar()->addChild( - 'save_button', \Magento\Backend\Block\Widget\Button::class, + 'save_button', + \Magento\Backend\Block\Widget\Button::class, [ 'label' => __('Save Template'), 'data_attribute' => [ @@ -200,8 +208,9 @@ public function getHeaderText() */ public function getForm() { - return $this->getLayout()->createBlock( - \Magento\Newsletter\Block\Adminhtml\Template\Edit\Form::class)->toHtml(); + return $this->getLayout()->createBlock( + \Magento\Newsletter\Block\Adminhtml\Template\Edit\Form::class + )->toHtml(); } /** diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php index d4c671b52a65c..ebac9e9daa6ca 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductCompareAddProductObserverTest.php @@ -86,8 +86,7 @@ protected function setUp() $this->productCompFactoryMock = $this->getMockBuilder( \Magento\Reports\Model\Product\Index\ComparedFactory::class - ) - ->disableOriginalConstructor() + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->productCompFactoryMock->expects($this->any()) diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php index 3a0ad161c9be0..452f0e570700e 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CatalogProductViewObserverTest.php @@ -118,8 +118,7 @@ protected function setUp() $this->productCompFactoryMock = $this->getMockBuilder( \Magento\Reports\Model\Product\Index\ComparedFactory::class - ) - ->disableOriginalConstructor() + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php index 4b8f57b4dc513..2392ea148121e 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLoginObserverTest.php @@ -64,8 +64,7 @@ protected function setUp() $this->productIndexFactoryMock = $this->getMockBuilder( \Magento\Reports\Model\Product\Index\ViewedFactory::class - ) - ->setMethods(['create']) + )->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->productIndexMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Viewed::class) ->disableOriginalConstructor()->getMock(); @@ -89,8 +88,7 @@ protected function setUp() $this->productCompFactoryMock = $this->getMockBuilder( \Magento\Reports\Model\Product\Index\ComparedFactory::class - ) - ->disableOriginalConstructor() + )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->productCompFactoryMock->expects($this->any()) diff --git a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php index ab59ff47b7466..92add4c3694af 100644 --- a/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Observer/CustomerLogoutObserverTest.php @@ -41,8 +41,7 @@ protected function setUp() $this->productIndexFactoryMock = $this->getMockBuilder( \Magento\Reports\Model\Product\Index\ViewedFactory::class - ) - ->setMethods(['create']) + )->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->productIndexMock = $this->getMockBuilder(\Magento\Reports\Model\Product\Index\Viewed::class) ->disableOriginalConstructor()->getMock(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php index 465039fd2916b..52dbfab429b83 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php @@ -169,7 +169,7 @@ public function getOrderDataJson() foreach ($addresses as $address) { $addressForm = $this->_customerFormFactory->create( - \customer_address::class, + 'customer_address', 'adminhtml_customer_address', $this->addressMapper->toFlatArray($address) ); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php index 8d8f0aa580a53..1ecfea11f3838 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/PrintAction.php @@ -64,7 +64,7 @@ public function execute() \Magento\Framework\Stdlib\DateTime\DateTime::class )->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( - \packingslip::class . $date . '.pdf', + 'packingslip' . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf' diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index e61b8977a2e37..d5557b295647e 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -565,7 +565,7 @@ protected function _initBillingAddressFromOrder(\Magento\Sales\Model\Order $orde { $this->getQuote()->getBillingAddress()->setCustomerAddressId(''); $this->_objectCopyService->copyFieldsetToTarget( - \sales_copy_order_billing_address::class, + 'sales_copy_order_billing_address', 'to_order', $order->getBillingAddress(), $this->getQuote()->getBillingAddress() @@ -587,7 +587,7 @@ protected function _initShippingAddressFromOrder(\Magento\Sales\Model\Order $ord $orderShippingAddress && $orderShippingAddress->getSameAsBilling() ); $this->_objectCopyService->copyFieldsetToTarget( - \sales_copy_order_shipping_address::class, + 'sales_copy_order_shipping_address', 'to_order', $orderShippingAddress, $quoteShippingAddress diff --git a/app/code/Magento/Sales/Model/Convert/Order.php b/app/code/Magento/Sales/Model/Convert/Order.php index ca1fd3382c063..359e73ad5e25e 100644 --- a/app/code/Magento/Sales/Model/Convert/Order.php +++ b/app/code/Magento/Sales/Model/Convert/Order.php @@ -123,7 +123,7 @@ public function itemToInvoiceItem(\Magento\Sales\Model\Order\Item $item) $invoiceItem->setOrderItem($item)->setProductId($item->getProductId()); $this->_objectCopyService->copyFieldsetToTarget( - \sales_convert_order_item::class, + 'sales_convert_order_item', 'to_invoice_item', $item, $invoiceItem diff --git a/app/code/Magento/Sales/Model/Order/CustomerManagement.php b/app/code/Magento/Sales/Model/Order/CustomerManagement.php index bc9ef51d9f618..ad87d5ddb552e 100644 --- a/app/code/Magento/Sales/Model/Order/CustomerManagement.php +++ b/app/code/Magento/Sales/Model/Order/CustomerManagement.php @@ -77,7 +77,7 @@ public function create($orderId) throw new AlreadyExistsException(__("This order already has associated customer account")); } $customerData = $this->objectCopyService->copyFieldsetToTarget( - \order_address::class, + 'order_address', 'to_customer', $order->getBillingAddress(), [] @@ -85,7 +85,7 @@ public function create($orderId) $addresses = $order->getAddresses(); foreach ($addresses as $address) { $addressData = $this->objectCopyService->copyFieldsetToTarget( - \order_address::class, + 'order_address', 'to_customer_address', $address, [] diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php index cfcffcc3b5df7..14f3cc9b31571 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Total/FactoryTest.php @@ -74,6 +74,6 @@ public static function createDataProvider() */ public function testCreateException() { - $this->_factory->create(\TEST::class); + $this->_factory->create('TEST'); } } diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchExcel.php b/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchExcel.php index ec66922e07e83..92246b37371c3 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchExcel.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchExcel.php @@ -40,6 +40,6 @@ public function execute() /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT); $content = $resultLayout->getLayout()->getChildBlock('adminhtml.report.search.grid', 'grid.export'); - return $this->fileFactory->create(\search.xml::class, $content->getExcelFile(), DirectoryList::VAR_DIR); + return $this->fileFactory->create('search.xml', $content->getExcelFile(), DirectoryList::VAR_DIR); } } diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index 192867cd8e23d..3040d18ad8041 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -492,8 +492,8 @@ protected function _getXmlQuotes() $client = $this->_httpClientFactory->create(); $client->setUri($url); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); - $client->setParameterget('API', $api); - $client->setParameterget('XML', $request); + $client->setParameterGet('API', $api); + $client->setParameterGet('XML', $request); $response = $client->request(); $responseBody = $response->getBody(); @@ -1008,7 +1008,6 @@ protected function _getXmlTracking($trackings) foreach ($trackings as $tracking) { $xml = $this->_xmlElFactory->create( - ['data' => ''] ); $xml->addAttribute('USERID', $r->getUserId()); @@ -1028,8 +1027,8 @@ protected function _getXmlTracking($trackings) $client = $this->_httpClientFactory->create(); $client->setUri($url); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); - $client->setParameterget('API', $api); - $client->setParameterget('XML', $request); + $client->setParameterGet('API', $api); + $client->setParameterGet('XML', $request); $response = $client->request(); $responseBody = $response->getBody(); $debugData['result'] = $responseBody; @@ -1888,8 +1887,8 @@ protected function _doShipmentRequest(\Magento\Framework\DataObject $request) $client = $this->_httpClientFactory->create(); $client->setUri($url); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); - $client->setParameterget('API', $api); - $client->setParameterget('XML', $requestXml); + $client->setParameterGet('API', $api); + $client->setParameterGet('XML', $requestXml); $response = $client->request()->getBody(); $response = $this->parseXml($response); diff --git a/app/code/Magento/Vault/Model/PaymentTokenManagement.php b/app/code/Magento/Vault/Model/PaymentTokenManagement.php index dfb5f1cc36e1f..510dc4cea3162 100644 --- a/app/code/Magento/Vault/Model/PaymentTokenManagement.php +++ b/app/code/Magento/Vault/Model/PaymentTokenManagement.php @@ -141,7 +141,7 @@ public function getVisibleAvailableTokens($customerId) ->setConditionType('gt') ->setValue( $this->dateTimeFactory->create( - \now::class, + 'now', new \DateTimeZone('UTC') )->format('Y-m-d 00:00:00') ) diff --git a/app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php b/app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php index 432470ce74c5f..81fb24d14bcbd 100644 --- a/app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php +++ b/app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php @@ -131,7 +131,7 @@ public function getTokensComponents($vaultPaymentCode) ->setConditionType('gt') ->setValue( $this->dateTimeFactory->create( - \now::class, + 'now', new \DateTimeZone('UTC') )->format('Y-m-d 00:00:00') ) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php index ade47f73840bb..10a1779829b09 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php @@ -27,7 +27,9 @@ protected function setUp() public function testParse() { - $expected = [\Magento\Module1::class, \Magento\Module2::class, + $expected = [ + 'Magento\Module1', + 'Magento\Module2', ]; $actual = $this->parser->parse( From e496d69c5439dcb6d339ccf72faadb2aadf7b6eb Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Wed, 20 Jul 2016 16:55:41 +0300 Subject: [PATCH 24/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Test/Unit/Model/Cron/ReportNewRelicCronTest.php | 2 +- app/code/Magento/Paypal/Test/Unit/Cron/FetchReportsTest.php | 4 ++-- .../Magento/ProductAlert/Test/Unit/Model/ObserverTest.php | 4 ++-- .../SalesRule/Model/Rule/Condition/Product/Combine.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php index d8574174ba956..785a80e849e1a 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php @@ -108,7 +108,7 @@ protected function setUp() $this->deploymentsFactory->expects($this->any()) ->method('create') ->willReturn($this->deploymentsModel); - $this->logger = $this->getMockForAbstractClass('Psr\Log\LoggerInterface'); + $this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class); $this->model = new ReportNewRelicCron( $this->config, diff --git a/app/code/Magento/Paypal/Test/Unit/Cron/FetchReportsTest.php b/app/code/Magento/Paypal/Test/Unit/Cron/FetchReportsTest.php index d3d3910cc4dbb..57d5eb6bbb135 100644 --- a/app/code/Magento/Paypal/Test/Unit/Cron/FetchReportsTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Cron/FetchReportsTest.php @@ -42,7 +42,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->logger = $this->getMockForAbstractClass('Psr\Log\LoggerInterface'); + $this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class); $this->objectManager = new ObjectManager($this); $this->fetchReports = $this->objectManager->getObject( @@ -64,7 +64,7 @@ public function testExecuteThrowsException() 'password' => ['test_password'], 'path' => ['test_path'] ]; - $settlementMock = $this->getMockBuilder('Magento\Paypal\Model\Report\Settlement') + $settlementMock = $this->getMockBuilder(\Magento\Paypal\Model\Report\Settlement::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/ProductAlert/Test/Unit/Model/ObserverTest.php b/app/code/Magento/ProductAlert/Test/Unit/Model/ObserverTest.php index b67568dc0d0d5..84aa800521b38 100644 --- a/app/code/Magento/ProductAlert/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/ProductAlert/Test/Unit/Model/ObserverTest.php @@ -151,7 +151,7 @@ protected function setUp() ->getMock(); $this->websiteMock = $this->getMock( - '\Magento\Store\Model\Website', + \Magento\Store\Model\Website::class, ['getDefaultGroup', 'getDefaultStore'], [], '', @@ -165,7 +165,7 @@ protected function setUp() ->getMock(); $this->productRepositoryMock = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class) ->getMock(); - $this->productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $this->productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods( [ diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php index 9c52baf55bf05..1ac904309a046 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php @@ -42,12 +42,12 @@ public function getNewChildSelectOptions() foreach ($productAttributes as $code => $label) { if (strpos($code, 'quote_item_') === 0) { $iAttributes[] = [ - 'value' => 'Magento\SalesRule\Model\Rule\Condition\Product' . $code, + 'value' => \Magento\SalesRule\Model\Rule\Condition\Product::class . $code, 'label' => $label, ]; } else { $pAttributes[] = [ - 'value' => 'Magento\SalesRule\Model\Rule\Condition\Product' . $code, + 'value' => \Magento\SalesRule\Model\Rule\Condition\Product::class . $code, 'label' => $label, ]; } From 66763b62a0cf2cbdb8e18dab72c9d3a0d30733a8 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 21 Jul 2016 17:36:21 +0300 Subject: [PATCH 25/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Test/Unit/Model/Session/QuoteTest.php | 1 - .../Product/Helper/Form/Gallery/Content.php | 5 +++-- .../Helper/Form/Gallery/ContentTest.php | 4 ++-- .../Catalog/Url/Rewrite/SuffixTest.php | 12 ++++++++--- .../Product/Form/Modifier/EavTest.php | 2 +- .../Test/Unit/Model/Stock/ItemTest.php | 4 ++-- .../Test/Unit/Model/StockTest.php | 20 +++++++++---------- .../Customer/Model/AccountManagement.php | 4 ++-- .../Customer/Model/Customer/DataProvider.php | 4 +++- .../Unit/Controller/Address/DeleteTest.php | 3 ++- .../Test/Unit/Model/AccountManagementTest.php | 4 ++-- .../Unit/Model/Plugin/CustomerPluginTest.php | 10 ++++++---- .../Adminhtml/Order/Status/Save.php | 4 ++-- .../Ui/Adminhtml/TokensConfigProviderTest.php | 1 - .../Webapi/Test/Unit/Controller/SoapTest.php | 2 +- .../Magento/TestFramework/Helper/Customer.php | 3 ++- .../Customer/Api/AccountManagementTest.php | 3 ++- .../Magento/Theme/Block/Html/FooterTest.php | 2 +- .../Magento/Framework/App/Request/Http.php | 2 -- .../Test/Unit/Model/BasePackageInfoTest.php | 4 ++-- .../Test/Unit/Model/PackagesDataTest.php | 2 +- 21 files changed, 53 insertions(+), 43 deletions(-) diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index fd80821a7e34b..39f5a89be8cc0 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -310,7 +310,6 @@ public function testGetQuoteWithoutQuoteId() ->method('getId') ->willReturn($quoteId); - $defaultGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class) ->getMock(); $defaultGroup->expects($this->any()) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php index fcf805f72ce90..a115c4fc6b716 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php @@ -139,7 +139,7 @@ public function getImagesJson() is_array($value['images']) && count($value['images']) ) { - $mediaDir = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA); + $mediaDir = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA); $images = $this->sortImagesByPosition($value['images']); foreach ($images as &$image) { $image['url'] = $this->_mediaConfig->getMediaUrl($image['file']); @@ -150,7 +150,8 @@ public function getImagesJson() $staticDir = $this->_filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW); $image['url'] = $this->getImageHelper()->getDefaultPlaceholderUrl('thumbnail'); $fileHandler = $staticDir->stat( - $this->getAssetRepo()->createAsset($this->getImageHelper()->getPlaceholder('thumbnail'))->getPath() + $this->getAssetRepo() + ->createAsset($this->getImageHelper()->getPlaceholder('thumbnail'))->getPath() ); $image['size'] = $fileHandler['size']; $this->_logger->warning($e); diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php index 26ffd9b053a78..853041df429bc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php @@ -243,7 +243,7 @@ public function testGetImagesJsonWithException() $sizePlaceholder, $this->throwException( new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test')) - ), + ), $sizePlaceholder ); $this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl); @@ -253,5 +253,5 @@ public function testGetImagesJsonWithException() $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode'); $this->assertSame(json_encode($imagesResult), $this->content->getImagesJson()); - } + } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php index 2bbdcb68c22ea..c793cc60098c5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php @@ -109,7 +109,9 @@ public function setUp() public function testAfterSaveCleanCache() { $this->suffixModel->setValue('new'); - $this->suffixModel->setPath(\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX); + $this->suffixModel->setPath( + \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX + ); $this->cacheTypeList->expects($this->exactly(2))->method('invalidate')->withConsecutive( [$this->equalTo([ \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER, @@ -123,7 +125,9 @@ public function testAfterSaveCleanCache() public function testAfterSaveWithoutChanges() { $this->suffixModel->setValue(''); - $this->suffixModel->setPath(\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX); + $this->suffixModel->setPath( + \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX + ); $this->cacheTypeList->expects($this->never())->method('invalidate'); $this->suffixModel->afterSave(); } @@ -131,7 +135,9 @@ public function testAfterSaveWithoutChanges() public function testAfterSaveProduct() { $this->suffixModel->setValue('new'); - $this->suffixModel->setPath(\Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX); + $this->suffixModel->setPath( + \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX + ); $this->cacheTypeList->expects($this->once())->method('invalidate')->with('config'); $this->suffixModel->afterSave(); } diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index feb8ddd75a803..10722de41c1d2 100755 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -31,7 +31,7 @@ use Magento\Catalog\Model\ResourceModel\Eav\Attribute; use Magento\Framework\Currency; use Magento\Framework\Locale\Currency as CurrencyLocale; -Use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** * Class EavTest diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index 11bb5cf82328a..e7ca99198fab8 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -472,7 +472,7 @@ public function getQtyIncrementsDataProvider() ]; } - /** + /** * We wan't to ensure that property $_eventPrefix used during event dispatching * * @param $eventName @@ -484,7 +484,7 @@ public function testDispatchEvents($eventName, $methodName) { $isCalledWithRightPrefix = 0; $this->eventDispatcher->expects($this->any())->method('dispatch')->with( - $this->callback(function($arg) use (&$isCalledWithRightPrefix, $eventName) { + $this->callback(function ($arg) use (&$isCalledWithRightPrefix, $eventName) { $isCalledWithRightPrefix |= ($arg === $eventName); return true; }), diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php index 369b9ec2b5269..2cefb6e8a8ee6 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php @@ -12,7 +12,7 @@ class StockTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Framework\Model\Context - */ + */ private $context; /** @@ -32,12 +32,12 @@ class StockTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Framework\Model\ResourceModel\AbstractResource - */ + */ private $resource; /** * @var \Magento\Framework\Data\Collection\AbstractDb - */ + */ private $resourceCollection; /** @@ -92,7 +92,7 @@ public function setUp() $this->customAttributeFactory, $this->resource, $this->resourceCollection - ); + ); } /** @@ -104,11 +104,11 @@ public function setUp() * @dataProvider eventsDataProvider */ public function testDispatchEvents($eventName, $methodName) - { + { $isCalledWithRightPrefix = 0; $this->eventDispatcher->expects($this->any())->method('dispatch')->with( - $this->callback(function($arg) use (&$isCalledWithRightPrefix, $eventName) { - $isCalledWithRightPrefix |= ($arg === $eventName); + $this->callback(function ($arg) use (&$isCalledWithRightPrefix, $eventName) { + $isCalledWithRightPrefix |= ($arg === $eventName); return true; }), $this->anything() @@ -116,8 +116,8 @@ public function testDispatchEvents($eventName, $methodName) $this->stockModel->$methodName(); $this->assertEquals( - 1, - (int) $isCalledWithRightPrefix, + 1, + (int) $isCalledWithRightPrefix, sprintf("Event %s doesn't dispatched", $eventName) ); } @@ -127,6 +127,6 @@ public function eventsDataProvider() return [ ['cataloginventory_stock_save_before', 'beforeSave'], ['cataloginventory_stock_save_after', 'afterSave'], - ]; + ]; } } diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php index 7a1c40fa61f42..cdbfc51361315 100644 --- a/app/code/Magento/Customer/Model/AccountManagement.php +++ b/app/code/Magento/Customer/Model/AccountManagement.php @@ -717,12 +717,12 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash } try { foreach ($customerAddresses as $address) { - if ($address->getId()) { + if ($address->getId()) { $newAddress = clone $address; $newAddress->setId(null); $newAddress->setCustomerId($customer->getId()); $this->addressRepository->save($newAddress); - } else { + } else { $address->setCustomerId($customer->getId()); $this->addressRepository->save($address); } diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index e4b4fdd0149db..615903c745c9f 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -342,7 +342,9 @@ private function overrideFileUploaderMetadata( if (isset($config['validation']['file_extensions'])) { $allowedExtensions = explode(',', $config['validation']['file_extensions']); - array_walk($allowedExtensions, function(&$value) { $value = strtolower(trim($value)); }); + array_walk($allowedExtensions, function (&$value) { + $value = strtolower(trim($value)); + }); } $allowedExtensions = implode(' ', $allowedExtensions); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php index 6dcc9c2f310a6..44227ab13af12 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php @@ -92,7 +92,8 @@ protected function setUp() ->getMock(); $objectManager = new ObjectManagerHelper($this); - $this->context = $objectManager->getObject(\Magento\Framework\App\Action\Context::class, + $this->context = $objectManager->getObject( + \Magento\Framework\App\Action\Context::class, [ 'request' => $this->request, 'messageManager' => $this->messageManager, diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php index 892598cf3e756..4d21cf4ebd008 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php @@ -1628,8 +1628,8 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses() ->expects($this->atLeastOnce()) ->method("save") ->withConsecutive( - array($this->logicalNot($this->identicalTo($existingAddress))), - array($this->identicalTo($nonExistingAddress)) + [$this->logicalNot($this->identicalTo($existingAddress))], + [$this->identicalTo($nonExistingAddress)] ); $existingAddress diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php index 581d128fc0df6..434c55360701f 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php @@ -69,7 +69,7 @@ public function testAroundSaveWithoutIsSubscribed() $customerId = 1; /** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */ $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); - $proceed = function(CustomerInterface $customer, $passwordHash = null) use($customer) { + $proceed = function (CustomerInterface $customer, $passwordHash = null) use ($customer) { return $customer; }; /** @var CustomerRepository | \PHPUnit_Framework_MockObject_MockObject $subject */ @@ -85,7 +85,8 @@ public function testAroundSaveWithoutIsSubscribed() /** * @return array */ - public function provideExtensionAttributeDataForAroundSave() { + public function provideExtensionAttributeDataForAroundSave() + { return [ [true, true] , [false, false] @@ -95,7 +96,8 @@ public function provideExtensionAttributeDataForAroundSave() { /** * @dataProvider provideExtensionAttributeDataForAroundSave */ - public function testAroundSaveWithIsSubscribed($isSubscribed, $subscribeIsCreated) { + public function testAroundSaveWithIsSubscribed($isSubscribed, $subscribeIsCreated) + { $passwordHash = null; $customerId = 1; /** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */ @@ -124,7 +126,7 @@ public function testAroundSaveWithIsSubscribed($isSubscribed, $subscribeIsCreate ->with($customerId); } - $proceed = function(CustomerInterface $customer, $passwordHash = null) use($customer) { + $proceed = function (CustomerInterface $customer, $passwordHash = null) use ($customer) { return $customer; }; /** @var CustomerRepository | \PHPUnit_Framework_MockObject_MockObject $subject */ diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php index a6cb7a62f6f71..56271282d196a 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php @@ -27,8 +27,8 @@ public function execute() $filterManager = $this->_objectManager->get(\Magento\Framework\Filter\FilterManager::class); if ($isNew) { $statusCode = $data['status'] = $filterManager->stripTags($data['status']); - } - $data['label'] = $filterManager->stripTags($data['label']); + } + $data['label'] = $filterManager->stripTags($data['label']); if (!isset($data['store_labels'])) { $data['store_labels'] = []; } diff --git a/app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php b/app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php index a97aa4dbee3a5..ab825de32c91e 100644 --- a/app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php +++ b/app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php @@ -263,7 +263,6 @@ public function testGetTokensComponentsGuestCustomer() ->method('getEntityId') ->willReturn(self::ENTITY_ID); - list($tokenUiComponent, $tokenUiComponentProvider) = $this->getTokenUiComponentProvider($token); $searchCriteria = $this->getSearchCriteria($customerId, self::ENTITY_ID, self::VAULT_PROVIDER_CODE); diff --git a/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php b/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php index fe97acf59ca37..6657b9e317ff0 100644 --- a/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php @@ -102,7 +102,7 @@ protected function setUp() ->method('getHeaders') ->will($this->returnValue(new \Zend\Http\Headers())); - $appconfig = $this->getMock(\Magento\Framework\App\Config::class, [], [], '' , false); + $appconfig = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false); $objectManagerHelper->setBackwardCompatibleProperty( $this->_requestMock, 'appConfig', diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php index cde2724bcccf2..615e8fd774be3 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php @@ -115,7 +115,8 @@ public function createSampleCustomer(array $additional = []) * @param int $customerId * @return array|bool|float|int|string */ - public function updateSampleCustomer(array $additional = [], $customerId) { + public function updateSampleCustomer(array $additional = [], $customerId) + { $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . "/" . $customerId, diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index b426d9e2a1b4e..a99ba1c3cd592 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -158,7 +158,8 @@ public function tearDown() $this->subscriber = null; } - private function initSubscriber() { + private function initSubscriber() + { $this->subscriber = Bootstrap::getObjectManager()->create( \Magento\Newsletter\Model\Subscriber::class ); diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php index 44e20f2bc0e96..fb7f1f0904f66 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php @@ -33,7 +33,7 @@ public function testGetCacheKeyInfo() ->createBlock(\Magento\Theme\Block\Html\Footer::class); $storeId = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId(); $this->assertEquals( - ['PAGE_FOOTER', $storeId, 0, $this->_theme->getId(), false, $block->getTemplateFile(),'template' => null], + ['PAGE_FOOTER', $storeId, 0, $this->_theme->getId(), false, $block->getTemplateFile(), 'template' => null], $block->getCacheKeyInfo() ); } diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php index f301aa0b52eb4..84154f7ac98e7 100644 --- a/lib/internal/Magento/Framework/App/Request/Http.php +++ b/lib/internal/Magento/Framework/App/Request/Http.php @@ -422,6 +422,4 @@ public function isSafeMethod() } return $this->isSafeMethod; } - - } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php b/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php index a415cbe67384d..10e7484ddae68 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php @@ -55,7 +55,7 @@ public function testBaseComposerJsonFileNotFound() $this->readerMock->expects($this->never())->method('isReadable'); $this->readerMock->expects($this->never())->method('readFile'); $this->setExpectedException( - 'Magento\Setup\Exception', + \Magento\Setup\Exception::class, sprintf('Could not locate %s file.', BasePackageInfo::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE) ); $this->basePackageInfo->getPaths(); @@ -68,7 +68,7 @@ public function testBaseComposerJsonFileNotReadable() $this->readerMock->expects($this->once())->method('isReadable')->willReturn(false); $this->readerMock->expects($this->never())->method('readFile'); $this->setExpectedException( - 'Magento\Setup\Exception', + \Magento\Setup\Exception::class, sprintf('Could not read %s file.', BasePackageInfo::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE) ); $this->basePackageInfo->getPaths(); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php index ba4f2ffec9478..55fabdae4ab2d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PackagesDataTest.php @@ -52,7 +52,7 @@ public function setUp() $applicationFactory->expects($this->any())->method('create')->willReturn($application); $objectManager->expects($this->any()) ->method('get') - ->with( \Magento\Framework\Composer\MagentoComposerApplicationFactory::class) + ->with(\Magento\Framework\Composer\MagentoComposerApplicationFactory::class) ->willReturn($applicationFactory); $objectManagerProvider->expects($this->any())->method('get')->willReturn($objectManager); From 248870a5f1d778865ad411e6f2c3ef217f78e2cb Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 21 Jul 2016 17:49:36 +0300 Subject: [PATCH 26/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php index 9c5a0f1fa8a8e..75de794c76241 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Handler/CatalogRule/Curl.php @@ -35,7 +35,7 @@ class Curl extends Conditions implements CatalogRuleInterface 'attribute' => 'category_ids', ], 'Attribute' => [ - 'type' => 'Magento\CatalogRule\Model\Rule\Condition\Product', + 'type' => \Magento\CatalogRule\Model\Rule\Condition\Product::class, 'attribute' => 'attribute_id', ], ]; From 17b81b5cb63348e3675a4ee87296279614ffa217 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 22 Jul 2016 11:45:12 +0300 Subject: [PATCH 27/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- app/code/Magento/Bundle/Setup/UpgradeData.php | 7 ++++++- .../Magento/Customer/Model/Customer/DataProvider.php | 2 ++ .../Test/Unit/Controller/Account/LogoutTest.php | 2 -- .../Customer/Test/Unit/Model/FileProcessorTest.php | 1 - .../Customer/Test/Unit/Model/FileUploaderTest.php | 1 - app/code/Magento/Deploy/Model/Deployer.php | 9 ++++++++- .../Test/Unit/Model/Plugin/CustomerPluginTest.php | 12 ++++++++++-- .../Ui/Test/Unit/Component/Filters/Type/DateTest.php | 1 - .../Magento/Webapi/Test/Unit/Controller/SoapTest.php | 4 +--- .../Magento/TestFramework/Helper/Customer.php | 2 +- .../Magento/Customer/Api/AccountManagementTest.php | 4 ++-- .../Model/ResourceModel/Product/CollectionTest.php | 1 - .../Setup/Test/Unit/Controller/InstallTest.php | 5 +++-- 13 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Bundle/Setup/UpgradeData.php b/app/code/Magento/Bundle/Setup/UpgradeData.php index 2b07d34ee6560..6da134ead88b0 100644 --- a/app/code/Magento/Bundle/Setup/UpgradeData.php +++ b/app/code/Magento/Bundle/Setup/UpgradeData.php @@ -41,7 +41,12 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $attributeSetId = $eavSetup->getDefaultAttributeSetId(ProductAttributeInterface::ENTITY_TYPE_CODE); - $eavSetup->addAttributeGroup(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeSetId, 'Bundle Items', 16); + $eavSetup->addAttributeGroup( + ProductAttributeInterface::ENTITY_TYPE_CODE, + $attributeSetId, + 'Bundle Items', + 16 + ); $this->upgradePriceType($eavSetup); $this->upgradeSkuType($eavSetup); diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 615903c745c9f..2c1f3bdb2388c 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -210,6 +210,7 @@ public function getData() * * @param Customer|Address $entity * @param array $entityData + * @return void */ private function overrideFileUploaderData($entity, array &$entityData) { @@ -325,6 +326,7 @@ protected function getAttributesMeta(Type $entityType) * @param Type $entityType * @param AbstractAttribute $attribute * @param array $config + * @return void */ private function overrideFileUploaderMetadata( Type $entityType, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php index 51df92317e05d..27d3895a2524d 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php @@ -87,8 +87,6 @@ protected function setUp() $cookieMetadataFactoryProperty = $refClass->getProperty('cookieMetadataFactory'); $cookieMetadataFactoryProperty->setAccessible(true); $cookieMetadataFactoryProperty->setValue($this->controller, $this->cookieMetadataFactory); - - } public function testExecute() diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php index 94cd992717881..69064dbc1a420 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php @@ -75,7 +75,6 @@ private function getModel($entityTypeCode, array $allowedExtensions = []) return $model; } - public function testGetStat() { $fileName = '/filename.ext1'; diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php index 610f059f23baa..8a415a8883334 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php @@ -179,7 +179,6 @@ public function testUpload() ->method('getValidationRules') ->willReturn([$validationRuleMock]); - $model = $this->getModel(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 'customer'); $this->assertEquals($expectedResult, $model->upload()); } diff --git a/app/code/Magento/Deploy/Model/Deployer.php b/app/code/Magento/Deploy/Model/Deployer.php index a7dd163c952d8..6d886d8e5f9b0 100644 --- a/app/code/Magento/Deploy/Model/Deployer.php +++ b/app/code/Magento/Deploy/Model/Deployer.php @@ -180,7 +180,14 @@ public function deploy(ObjectManagerFactory $omFactory, array $locales) $this->findAncestors($area . Theme::THEME_PATH_SEPARATOR . $themePath) )) ) { - $compiledFile = $this->deployFile($filePath, $area, $themePath, $locale, $module, $fullPath); + $compiledFile = $this->deployFile( + $filePath, + $area, + $themePath, + $locale, + $module, + $fullPath + ); if ($compiledFile !== '') { $this->deployFile($compiledFile, $area, $themePath, $locale, $module, $fullPath); } diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php index 434c55360701f..b4bc13043bf97 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php @@ -37,8 +37,16 @@ protected function setUp() ->setMethods(['create']) ->getMock(); $this->subscriber = $this->getMockBuilder(\Magento\Newsletter\Model\Subscriber::class) - ->setMethods(['loadByEmail', 'getId', 'delete', 'updateSubscription', 'subscribeCustomerById', 'unsubscribeCustomerById']) - ->disableOriginalConstructor() + ->setMethods( + [ + 'loadByEmail', + 'getId', + 'delete', + 'updateSubscription', + 'subscribeCustomerById', + 'unsubscribeCustomerById' + ] + )->disableOriginalConstructor() ->getMock(); $this->subscriberFactory->expects($this->any())->method('create')->willReturn($this->subscriber); diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php index a3302068f60da..41ca08d1686ff 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php @@ -39,7 +39,6 @@ class DateTest extends \PHPUnit_Framework_TestCase */ private $filterModifierMock; - /** * @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php b/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php index 6657b9e317ff0..22a72e84fa748 100644 --- a/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Controller/SoapTest.php @@ -52,8 +52,8 @@ class SoapTest extends \PHPUnit_Framework_TestCase */ protected $_appStateMock; - protected $_appconfig; + /** * Set up Controller object. */ @@ -109,8 +109,6 @@ protected function setUp() $appconfig ); - - $this->_soapServerMock->expects($this->any())->method('setWSDL')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setEncoding')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setReturnResponse')->will($this->returnSelf()); diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php index 615e8fd774be3..c59201da45fb3 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php @@ -115,7 +115,7 @@ public function createSampleCustomer(array $additional = []) * @param int $customerId * @return array|bool|float|int|string */ - public function updateSampleCustomer(array $additional = [], $customerId) + public function updateSampleCustomer($customerId, array $additional = []) { $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index a99ba1c3cd592..2be15b16cec2d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -824,11 +824,11 @@ public function testUnsubscribeCustomer() $this->assertEquals($customerData['id'], $this->subscriber->getCustomerId()); //Manage customer in order to unsubscribe $this->customerHelper->updateSampleCustomer( + $customerData["id"], array_merge( $customerData, ["extension_attributes" => ["is_subscribed" => false]] - ), - $customerData["id"] + ) ); $this->initSubscriber(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php index 17a7aa9a6b1df..f0a665d8be8b7 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php @@ -32,7 +32,6 @@ protected function setUp() ); } - /** * @magentoDataFixture Magento/Catalog/_files/products.php * @magentoAppIsolation enabled diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php index edd36c95527ea..3a0bbc5f550b4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php @@ -54,7 +54,8 @@ public function setUp() $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->progressFactory = + $this->getMock(\Magento\Setup\Model\Installer\ProgressFactory::class, [], [], '', false); $this->sampleDataState = $this->getMock(\Magento\Framework\Setup\SampleData\State::class, [], [], '', false); $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->requestDataConverter = $this->getMock(RequestDataConverter::class, [], [], '', false); @@ -100,7 +101,7 @@ public function testStartActionPriorInstallException() $this->installer->expects($this->never())->method('getInstallInfo'); $this->deploymentConfig->expects($this->once())->method('isAvailable')->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->assertArrayHasKey('messages', $variables); From bc29f115edb07ff641495d4f542cc4e5ee0b7f38 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 22 Jul 2016 17:13:44 +0300 Subject: [PATCH 28/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Block/Widget/Form/Element/Gallery.php | 11 ++-- .../Test/Unit/Model/Session/QuoteTest.php | 55 +++++-------------- .../Unit/Model/CategoryManagementTest.php | 3 - .../Test/Unit/Model/Entity/AttributeTest.php | 16 ++---- .../Catalog/Test/Unit/Model/ProductTest.php | 15 ++--- .../Api/Code/Generator/SearchResults.php | 6 ++ 6 files changed, 36 insertions(+), 70 deletions(-) diff --git a/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php b/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php index 7a77b854bbc20..5137407aa9c5b 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Backend\Block\Widget\Form\Element; use Magento\Framework\Data\Form\Element\AbstractElement; @@ -15,7 +13,8 @@ * * @author Magento Core Team */ -class Gallery extends \Magento\Backend\Block\Template implements \Magento\Framework\Data\Form\Element\Renderer\RendererInterface +class Gallery extends \Magento\Backend\Block\Template implements + \Magento\Framework\Data\Form\Element\Renderer\RendererInterface { /** * @var AbstractElement|null @@ -69,12 +68,14 @@ public function getValues() protected function _prepareLayout() { $this->addChild( - 'delete_button', \Magento\Backend\Block\Widget\Button::class, + 'delete_button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Delete'), 'onclick' => "deleteImage(#image#)", 'class' => 'delete'] ); $this->addChild( - 'add_button', \Magento\Backend\Block\Widget\Button::class, + 'add_button', + \Magento\Backend\Block\Widget\Button::class, ['label' => __('Add New Image'), 'onclick' => 'addNewImage()', 'class' => 'add'] ); return parent::_prepareLayout(); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index 39f5a89be8cc0..5db3c2e41c04a 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -243,13 +243,8 @@ public function testGetQuoteWithoutQuoteId() $storeId = 10; $customerId = 66; $customerGroupId = 77; - - $this->quote->expects($this->any()) - ->method('getQuoteId') - ->will($this->returnValue(null)); - $this->quote->expects($this->any()) - ->method('setQuoteId') - ->with($quoteId); + $this->quote->expects($this->any())->method('getQuoteId')->will($this->returnValue(null)); + $this->quote->expects($this->any())->method('setQuoteId')->with($quoteId); $cartInterfaceMock = $this->getMock( \Magento\Quote\Api\Data\CartInterface::class, [ @@ -297,27 +292,13 @@ public function testGetQuoteWithoutQuoteId() 'setCustomerGroupId' ] ); - $this->quoteFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($cartInterfaceMock); - $this->quote->expects($this->any()) - ->method('getStoreId') - ->will($this->returnValue($storeId)); - $this->quote->expects($this->any()) - ->method('getCustomerId') - ->will($this->returnValue($customerId)); - $cartInterfaceMock->expects($this->atLeastOnce()) - ->method('getId') - ->willReturn($quoteId); - - $defaultGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class) - ->getMock(); - $defaultGroup->expects($this->any()) - ->method('getId') - ->will($this->returnValue($customerGroupId)); - $this->groupManagementMock->expects($this->any()) - ->method('getDefaultGroup') - ->will($this->returnValue($defaultGroup)); + $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($cartInterfaceMock); + $this->quote->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId)); + $this->quote->expects($this->any())->method('getCustomerId')->will($this->returnValue($customerId)); + $cartInterfaceMock->expects($this->atLeastOnce())->method('getId')->willReturn($quoteId); + $defaultGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)->getMock(); + $defaultGroup->expects($this->any())->method('getId')->will($this->returnValue($customerGroupId)); + $this->groupManagementMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup); $dataCustomerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->disableOriginalConstructor() @@ -344,19 +325,11 @@ public function testGetQuoteWithoutQuoteId() ); $this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock); - $cartInterfaceMock->expects($this->once()) - ->method('setCustomerGroupId') - ->with($customerGroupId) - ->will($this->returnSelf()); - $quoteMock->expects($this->once()) - ->method('assignCustomer') - ->with($dataCustomerMock); - $quoteMock->expects($this->once()) - ->method('setIgnoreOldQty') - ->with(true); - $quoteMock->expects($this->once()) - ->method('setIsSuperMode') - ->with(true); + $cartInterfaceMock->expects($this->once())->method('setCustomerGroupId')->with($customerGroupId) + ->willReturnSelf(); + $quoteMock->expects($this->once())->method('assignCustomer')->with($dataCustomerMock); + $quoteMock->expects($this->once())->method('setIgnoreOldQty')->with(true); + $quoteMock->expects($this->once())->method('setIsSuperMode')->with(true); $this->assertEquals($quoteMock, $this->quote->getQuote()); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php index 8fe9bc7b3febb..45e3e51a6df20 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php @@ -135,10 +135,7 @@ public function testGetTreeWithNullArguments() */ public function testGetTreeForAllScope() { - - $rootCategoryId = null; $depth = null; - $category = null; $categoriesMock = $this->getMock( \Magento\Catalog\Model\ResourceModel\Category\Collection::class, [], diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php index aef1c66c335ea..49dd01d150a49 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php @@ -137,10 +137,9 @@ protected function setUp() ->getMock(); $this->metadataServiceMock = $this->getMockBuilder(\Magento\Framework\Api\MetadataServiceInterface::class) ->getMock(); - $this->extensionAttributesFactory = $this->getMockBuilder( - \Magento\Framework\Api\ExtensionAttributesFactory::class) - ->disableOriginalConstructor() - ->getMock(); + $this->extensionAttributesFactory = $this->getMockBuilder( + \Magento\Framework\Api\ExtensionAttributesFactory::class + )->disableOriginalConstructor()->getMock(); $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -172,10 +171,9 @@ protected function setUp() ->getMock(); $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getMock(); - $this->reservedAttributeListMock = $this->getMockBuilder( - \Magento\Catalog\Model\Product\ReservedAttributeList::class) - ->disableOriginalConstructor() - ->getMock(); + $this->reservedAttributeListMock = $this->getMockBuilder( + \Magento\Catalog\Model\Product\ReservedAttributeList::class + )->disableOriginalConstructor()->getMock(); $this->resolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); $this->lockValidatorMock = $this->getMockBuilder(\Magento\Catalog\Model\Attribute\LockValidatorInterface::class) @@ -189,7 +187,6 @@ protected function setUp() ->getMock(); $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->getMock(); - $this->contextMock ->expects($this->any()) ->method('getCacheManager') @@ -198,7 +195,6 @@ protected function setUp() ->expects($this->any()) ->method('getEventDispatcher') ->willReturn($this->eventDispatcher); - $attributeCacheMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\AttributeCache::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index 74557d8932277..2d6508c78b5c6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -667,18 +667,11 @@ public function testGetIdentities($expected, $origData, $data, $isDeleted = fals public function getIdentitiesProvider() { $extensionAttributesMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getStockItem']) - ->getMock(); + ->disableOriginalConstructor()->setMethods(['getStockItem'])->getMock(); $stockItemMock = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $extensionAttributesMock->expects($this->any()) - ->method('getStockItem') - ->willReturn($stockItemMock); - $stockItemMock->expects($this->any()) - ->method('getIsInStock') - ->willReturn(true); + ->disableOriginalConstructor()->getMock(); + $extensionAttributesMock->expects($this->any())->method('getStockItem')->willReturn($stockItemMock); + $stockItemMock->expects($this->any())->method('getIsInStock')->willReturn(true); return [ 'no changes' => [ diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php index 4e8ad74019919..8df53f197552a 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php @@ -20,6 +20,12 @@ class SearchResults extends EntityAbstract */ const ENTITY_TYPE = 'searchResults'; + /** + * Search result default class + * @deprecated + */ + const SEARCH_RESULT = '\\' . \Magento\Framework\Api\SearchResults::class; + /** * Retrieve class properties * From 0b7cf4ff3149fe1b435025d7a8924aba4ffc6a8b Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 28 Jul 2016 11:59:43 +0300 Subject: [PATCH 29/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Model/ResourceModel/Address/DeleteRelationTest.php | 4 ++-- .../Entity/Attribute/Frontend/DefaultFrontendTest.php | 8 ++++---- .../Test/TestCase/DeleteCatalogPriceRuleEntityTest.php | 2 +- .../Magento/Customer/Model/AccountManagementTest.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php index c371a5de42668..15e3958dd4974 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php @@ -19,7 +19,7 @@ class DeleteRelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->customerFactoryMock = $this->getMock( - 'Magento\Customer\Model\CustomerFactory', + \Magento\Customer\Model\CustomerFactory::class, ['create'], [], '', @@ -49,7 +49,7 @@ public function testDeleteRelation($addressId, $isDefaultBilling, $isDefaultShip ->getMock(); $addressResource = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], '', false, diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php index 805730d20c23b..80badeea2b2c4 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php @@ -21,7 +21,7 @@ class DefaultFrontendTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->booleanFactory = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory') + $this->booleanFactory = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -32,7 +32,7 @@ protected function setUp() public function testGetClassEmpty() { - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods([ 'getIsRequired', @@ -56,7 +56,7 @@ public function testGetClassEmpty() public function testGetClass() { - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods([ 'getIsRequired', @@ -89,7 +89,7 @@ public function testGetClass() public function testGetClassLength() { - $attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods([ 'getIsRequired', diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php index 0d11df021d972..89dd079aecdd5 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php @@ -85,7 +85,7 @@ public function test(CatalogRule $catalogPriceRule, $product) $this->catalogRuleNew->getFormPageActions()->delete(); $this->catalogRuleNew->getModalBlock()->acceptAlert(); $products = $this->objectManager->create( - '\Magento\Catalog\Test\TestStep\CreateProductsStep', + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, ['products' => $product] )->run(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php index 8d4917065a382..0fecd0476c2e8 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php @@ -908,7 +908,7 @@ public function testSaveNewAddressDefaults() $addressShippingExpected = $this->addressRepository->save($addressShipping); $addressBillingExpected = $this->addressRepository->save($addressBilling); /** @var \Magento\Customer\Model\CustomerRegistry $customerRegistry */ - $customerRegistry = $this->objectManager->get('Magento\Customer\Model\CustomerRegistry'); + $customerRegistry = $this->objectManager->get(\Magento\Customer\Model\CustomerRegistry::class); $customerRegistry->remove(1); // Call api under test $shippingResponse = $this->accountManagement->getDefaultShippingAddress($customerId); From 0cbca31879bc7969ada9b8c0173252063d6585e5 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 29 Jul 2016 15:37:21 +0300 Subject: [PATCH 30/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Catalog/Model/ResourceModel/Product.php | 2 +- .../ResourceModel/Product/CategoryLinkTest.php | 16 ++++++++-------- .../ResourceModel/Product/Website/LinkTest.php | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product.php b/app/code/Magento/Catalog/Model/ResourceModel/Product.php index 388dcdd93e018..a3be4a2f98acb 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product.php @@ -641,7 +641,7 @@ private function getProductCategoryLink() { if (null === $this->productCategoryLink) { $this->productCategoryLink = \Magento\Framework\App\ObjectManager::getInstance() - ->get('Magento\Catalog\Model\ResourceModel\Product\CategoryLink'); + ->get(\Magento\Catalog\Model\ResourceModel\Product\CategoryLink::class); } return $this->productCategoryLink; } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php index 1c1865d81463d..e6e4a92e75a75 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php @@ -37,10 +37,10 @@ class CategoryLinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\ResourceConnection') + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) ->disableOriginalConstructor() ->getMock(); - $this->metadataPoolMock = $this->getMockBuilder('Magento\Framework\EntityManager\MetadataPool') + $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); @@ -52,10 +52,10 @@ protected function setUp() private function prepareAdapter() { - $this->dbSelectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + $this->dbSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor() ->getMock(); - $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->getMockForAbstractClass(); $this->connectionMock->expects($this->any())->method('select')->willReturn($this->dbSelectMock); $this->resourceMock->expects($this->any()) @@ -65,10 +65,10 @@ private function prepareAdapter() private function prepareMetadata() { - $categoryLinkMetadata = $this->getMockBuilder('Magento\Framework\EntityManager\EntityMetadataInterface') + $categoryLinkMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class) ->getMockForAbstractClass(); $categoryLinkMetadata->expects($this->any())->method('getEntityTable')->willReturn('category_link_table'); - $categoryEntityMetadata = $this->getMockBuilder('Magento\Framework\EntityManager\EntityMetadataInterface') + $categoryEntityMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class) ->getMockForAbstractClass(); $categoryEntityMetadata->expects($this->any())->method('getEntityTable')->willReturn('category_entity_table'); $this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturnMap( @@ -83,7 +83,7 @@ public function testGetCategoryLinks() { $this->prepareAdapter(); $this->prepareMetadata(); - $product = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductInterface')->getMockForAbstractClass(); + $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)->getMockForAbstractClass(); $product->expects($this->any())->method('getId')->willReturn(1); $this->connectionMock->expects($this->once())->method('fetchAll')->with($this->dbSelectMock)->willReturn( [ @@ -111,7 +111,7 @@ public function testSaveCategoryLinks($newCategoryLinks, $dbCategoryLinks, $affe { $this->prepareAdapter(); $this->prepareMetadata(); - $product = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductInterface')->getMockForAbstractClass(); + $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)->getMockForAbstractClass(); $product->expects($this->any())->method('getId')->willReturn(1); $this->connectionMock->expects($this->once()) ->method('fetchAll') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php index 39d2ea4041958..bedeba40eefcf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php @@ -32,9 +32,9 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->connection = - $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class, [], [], '', false); $this->dbSelect = $this->getMockBuilder(\Magento\Framework\Db\Select::class) ->disableOriginalConstructor() ->getMock(); From f3b5b4b64ebc95bf201ea02d95d9c4a235d46978 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Sun, 31 Jul 2016 16:25:29 +0300 Subject: [PATCH 31/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php index 7a6e0429e50ba..dd94048d59d84 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php @@ -30,7 +30,7 @@ ], 'customCacheInstance' => [ 'shared' => true, - 'type' => 'Magento\Framework\App\Cache', + 'type' => \Magento\Framework\App\Cache::class, 'arguments' => [], ], 'customOverriddenInstance' => [ From a85841df71162c4ccd66dbd33ff376d432a3b023 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Sun, 31 Jul 2016 19:58:21 +0300 Subject: [PATCH 32/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Magento/Test/Integrity/_files/blacklist/reference.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index b7492fa0c0dc9..57acdf7e40654 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -112,3 +112,5 @@ DoubleColon \Magento\Framework\Model\Name \Magento\Test\Di\WrappedClass \Magento\Test\Di\WrappedClass\Logger +\Magento\TestModuleMessageQueueConfiguration\AsyncHandler +\Magento\TestModuleMessageQueueConfiguration\SyncHandler From 8066d518780f7c45317ea770f0b86c49374ccd08 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Sun, 31 Jul 2016 20:10:42 +0300 Subject: [PATCH 33/33] MAGETWO-51858: Convert literal class names to \Namespace\Classname::class --- .../Magento/Test/Integrity/_files/blacklist/reference.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 57acdf7e40654..836a928dc5a72 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -114,3 +114,4 @@ DoubleColon \Magento\Test\Di\WrappedClass\Logger \Magento\TestModuleMessageQueueConfiguration\AsyncHandler \Magento\TestModuleMessageQueueConfiguration\SyncHandler +\Magento\TestModuleAsyncAmqp\Model\AsyncTestData